[C#] Update auto-generated bindings
[ldk-java] / c_sharp / bindings.c
1 #define LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #define LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
4 #define CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
5
6 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
7 #define int64_t jlong
8 #include <lightning.h>
9 #include <string.h>
10 #include <stdatomic.h>
11 #include <stdlib.h>
12
13 #define LIKELY(v) __builtin_expect(!!(v), 1)
14 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
15
16 #include <stdio.h>
17 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
18 #define do_MALLOC(a, _b, _c) malloc(a)
19 #define MALLOC(a, _) malloc(a)
20 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
21 #define CHECK_ACCESS(p)
22 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
23 #define DO_ASSERT(a) (void)(a)
24 #define CHECK(a)
25
26
27 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
28 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
29 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
30 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
31
32 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
33
34 #define DECL_ARR_TYPE(ty, name) \
35         struct name##array { \
36                 uint64_t arr_len; /* uint32_t would suffice but we want to align uint64_ts as well */ \
37                 ty elems[]; \
38         }; \
39         typedef struct name##array * name##Array; \
40         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
41                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint64_t), #name" array init", lineno); \
42                 arr->arr_len = arr_len; \
43                 return arr; \
44         }
45
46 DECL_ARR_TYPE(int64_t, int64_t);
47 DECL_ARR_TYPE(uint64_t, uint64_t);
48 DECL_ARR_TYPE(int8_t, int8_t);
49 DECL_ARR_TYPE(int16_t, int16_t);
50 DECL_ARR_TYPE(uint32_t, uint32_t);
51 DECL_ARR_TYPE(void*, ptr);
52 DECL_ARR_TYPE(char, char);
53 typedef charArray jstring;
54
55 static inline jstring str_ref_to_cs(const char* chars, size_t len) {
56         charArray arr = init_charArray(len, __LINE__);
57         memcpy(arr->elems, chars, len);
58         return arr;
59 }
60 static inline LDKStr str_ref_to_owned_c(const jstring str) {
61         char* newchars = MALLOC(str->arr_len + 1, "String chars");
62         memcpy(newchars, str->elems, str->arr_len);
63         newchars[str->arr_len] = 0;
64         LDKStr res = {
65                 .chars = newchars,
66                 .len = str->arr_len,
67                 .chars_is_owned = true
68         };
69         return res;
70 }
71
72 typedef bool jboolean;
73
74 int64_t CS_LDK_allocate_buffer(int64_t len) {
75         return (int64_t)MALLOC(len, "C#-requested buffer");
76 }
77
78 void CS_LDK_free_buffer(int64_t buf) {
79         FREE((void*)buf);
80 }
81
82 jstring CS_LDK_get_ldk_c_bindings_version() {
83         return str_ref_to_cs(check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
84 }
85 jstring CS_LDK_get_ldk_version() {
86         return str_ref_to_cs(check_get_ldk_version(), strlen(check_get_ldk_version()));
87 }
88 #include "version.c"
89
90 typedef int64_t (*invoker_l_l)(int obj_ptr, int fn_id, int64_t a);
91 static invoker_l_l js_invoke_function_l_l;
92 int CS_LDK_register_l_l_invoker(invoker_l_l invoker) {
93         js_invoke_function_l_l = invoker;
94         return 0;
95 }
96
97 typedef int64_t (*invoker_l_ll)(int obj_ptr, int fn_id, int64_t a, int64_t b);
98 static invoker_l_ll js_invoke_function_l_ll;
99 int CS_LDK_register_l_ll_invoker(invoker_l_ll invoker) {
100         js_invoke_function_l_ll = invoker;
101         return 0;
102 }
103
104 typedef int64_t (*invoker_l_)(int obj_ptr, int fn_id);
105 static invoker_l_ js_invoke_function_l_;
106 int CS_LDK_register_l__invoker(invoker_l_ invoker) {
107         js_invoke_function_l_ = invoker;
108         return 0;
109 }
110
111 typedef void (*invoker_void_l)(int obj_ptr, int fn_id, int64_t a);
112 static invoker_void_l js_invoke_function_void_l;
113 int CS_LDK_register_void_l_invoker(invoker_void_l invoker) {
114         js_invoke_function_void_l = invoker;
115         return 0;
116 }
117
118 typedef int64_t (*invoker_l_llll)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c, int64_t d);
119 static invoker_l_llll js_invoke_function_l_llll;
120 int CS_LDK_register_l_llll_invoker(invoker_l_llll invoker) {
121         js_invoke_function_l_llll = invoker;
122         return 0;
123 }
124
125 typedef int64_t (*invoker_l_lllll)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c, int64_t d, int64_t e);
126 static invoker_l_lllll js_invoke_function_l_lllll;
127 int CS_LDK_register_l_lllll_invoker(invoker_l_lllll invoker) {
128         js_invoke_function_l_lllll = invoker;
129         return 0;
130 }
131
132 typedef int64_t (*invoker_l_lll)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c);
133 static invoker_l_lll js_invoke_function_l_lll;
134 int CS_LDK_register_l_lll_invoker(invoker_l_lll invoker) {
135         js_invoke_function_l_lll = invoker;
136         return 0;
137 }
138
139 typedef void (*invoker_void_ll)(int obj_ptr, int fn_id, int64_t a, int64_t b);
140 static invoker_void_ll js_invoke_function_void_ll;
141 int CS_LDK_register_void_ll_invoker(invoker_void_ll invoker) {
142         js_invoke_function_void_ll = invoker;
143         return 0;
144 }
145
146 typedef int32_t (*invoker_ChannelMonitorUpdateStatus_ll)(int obj_ptr, int fn_id, int64_t a, int64_t b);
147 static invoker_ChannelMonitorUpdateStatus_ll js_invoke_function_ChannelMonitorUpdateStatus_ll;
148 int CS_LDK_register_ChannelMonitorUpdateStatus_ll_invoker(invoker_ChannelMonitorUpdateStatus_ll invoker) {
149         js_invoke_function_ChannelMonitorUpdateStatus_ll = invoker;
150         return 0;
151 }
152
153 typedef int64_t (*invoker_l_Recipient)(int obj_ptr, int fn_id, int32_t a);
154 static invoker_l_Recipient js_invoke_function_l_Recipient;
155 int CS_LDK_register_l_Recipient_invoker(invoker_l_Recipient invoker) {
156         js_invoke_function_l_Recipient = invoker;
157         return 0;
158 }
159
160 typedef int64_t (*invoker_l_Recipientll)(int obj_ptr, int fn_id, int32_t a, int64_t b, int64_t c);
161 static invoker_l_Recipientll js_invoke_function_l_Recipientll;
162 int CS_LDK_register_l_Recipientll_invoker(invoker_l_Recipientll invoker) {
163         js_invoke_function_l_Recipientll = invoker;
164         return 0;
165 }
166
167 typedef int64_t (*invoker_l_llRecipient)(int obj_ptr, int fn_id, int64_t a, int64_t b, int32_t c);
168 static invoker_l_llRecipient js_invoke_function_l_llRecipient;
169 int CS_LDK_register_l_llRecipient_invoker(invoker_l_llRecipient invoker) {
170         js_invoke_function_l_llRecipient = invoker;
171         return 0;
172 }
173
174 typedef int64_t (*invoker_l_bll)(int obj_ptr, int fn_id, jboolean a, int64_t b, int64_t c);
175 static invoker_l_bll js_invoke_function_l_bll;
176 int CS_LDK_register_l_bll_invoker(invoker_l_bll invoker) {
177         js_invoke_function_l_bll = invoker;
178         return 0;
179 }
180
181 typedef int32_t (*invoker_i_ConfirmationTarget)(int obj_ptr, int fn_id, int32_t a);
182 static invoker_i_ConfirmationTarget js_invoke_function_i_ConfirmationTarget;
183 int CS_LDK_register_i_ConfirmationTarget_invoker(invoker_i_ConfirmationTarget invoker) {
184         js_invoke_function_i_ConfirmationTarget = invoker;
185         return 0;
186 }
187
188 typedef int64_t (*invoker_l_llllll)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c, int64_t d, int64_t e, int64_t f);
189 static invoker_l_llllll js_invoke_function_l_llllll;
190 int CS_LDK_register_l_llllll_invoker(invoker_l_llllll invoker) {
191         js_invoke_function_l_llllll = invoker;
192         return 0;
193 }
194
195 typedef int16_t (*invoker_s_)(int obj_ptr, int fn_id);
196 static invoker_s_ js_invoke_function_s_;
197 int CS_LDK_register_s__invoker(invoker_s_ invoker) {
198         js_invoke_function_s_ = invoker;
199         return 0;
200 }
201
202 typedef int64_t (*invoker_l_lllb)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c, jboolean d);
203 static invoker_l_lllb js_invoke_function_l_lllb;
204 int CS_LDK_register_l_lllb_invoker(invoker_l_lllb invoker) {
205         js_invoke_function_l_lllb = invoker;
206         return 0;
207 }
208
209 typedef int32_t (*invoker_ChannelMonitorUpdateStatus_lll)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c);
210 static invoker_ChannelMonitorUpdateStatus_lll js_invoke_function_ChannelMonitorUpdateStatus_lll;
211 int CS_LDK_register_ChannelMonitorUpdateStatus_lll_invoker(invoker_ChannelMonitorUpdateStatus_lll invoker) {
212         js_invoke_function_ChannelMonitorUpdateStatus_lll = invoker;
213         return 0;
214 }
215
216 typedef int32_t (*invoker_ChannelMonitorUpdateStatus_llll)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c, int64_t d);
217 static invoker_ChannelMonitorUpdateStatus_llll js_invoke_function_ChannelMonitorUpdateStatus_llll;
218 int CS_LDK_register_ChannelMonitorUpdateStatus_llll_invoker(invoker_ChannelMonitorUpdateStatus_llll invoker) {
219         js_invoke_function_ChannelMonitorUpdateStatus_llll = invoker;
220         return 0;
221 }
222
223 typedef void (*invoker_void_)(int obj_ptr, int fn_id);
224 static invoker_void_ js_invoke_function_void_;
225 int CS_LDK_register_void__invoker(invoker_void_ invoker) {
226         js_invoke_function_void_ = invoker;
227         return 0;
228 }
229
230 typedef void (*invoker_void_lli)(int obj_ptr, int fn_id, int64_t a, int64_t b, int32_t c);
231 static invoker_void_lli js_invoke_function_void_lli;
232 int CS_LDK_register_void_lli_invoker(invoker_void_lli invoker) {
233         js_invoke_function_void_lli = invoker;
234         return 0;
235 }
236
237 typedef void (*invoker_void_li)(int obj_ptr, int fn_id, int64_t a, int32_t b);
238 static invoker_void_li js_invoke_function_void_li;
239 int CS_LDK_register_void_li_invoker(invoker_void_li invoker) {
240         js_invoke_function_void_li = invoker;
241         return 0;
242 }
243
244 typedef int64_t (*invoker_l_llb)(int obj_ptr, int fn_id, int64_t a, int64_t b, jboolean c);
245 static invoker_l_llb js_invoke_function_l_llb;
246 int CS_LDK_register_l_llb_invoker(invoker_l_llb invoker) {
247         js_invoke_function_l_llb = invoker;
248         return 0;
249 }
250
251 typedef jboolean (*invoker_b_)(int obj_ptr, int fn_id);
252 static invoker_b_ js_invoke_function_b_;
253 int CS_LDK_register_b__invoker(invoker_b_ invoker) {
254         js_invoke_function_b_ = invoker;
255         return 0;
256 }
257
258 typedef int64_t (*invoker_l_sl)(int obj_ptr, int fn_id, int16_t a, int64_t b);
259 static invoker_l_sl js_invoke_function_l_sl;
260 int CS_LDK_register_l_sl_invoker(invoker_l_sl invoker) {
261         js_invoke_function_l_sl = invoker;
262         return 0;
263 }
264
265 typedef int64_t (*invoker_l_lb)(int obj_ptr, int fn_id, int64_t a, jboolean b);
266 static invoker_l_lb js_invoke_function_l_lb;
267 int CS_LDK_register_l_lb_invoker(invoker_l_lb invoker) {
268         js_invoke_function_l_lb = invoker;
269         return 0;
270 }
271
272 typedef jboolean (*invoker_b_l)(int obj_ptr, int fn_id, int64_t a);
273 static invoker_b_l js_invoke_function_b_l;
274 int CS_LDK_register_b_l_invoker(invoker_b_l invoker) {
275         js_invoke_function_b_l = invoker;
276         return 0;
277 }
278
279 typedef int64_t (*invoker_l_llli)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c, int32_t d);
280 static invoker_l_llli js_invoke_function_l_llli;
281 int CS_LDK_register_l_llli_invoker(invoker_l_llli invoker) {
282         js_invoke_function_l_llli = invoker;
283         return 0;
284 }
285 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
286
287 static inline void* untag_ptr(uint64_t ptr) {
288         if (ptr < 4096) return (void*)ptr;
289         if (sizeof(void*) == 4) {
290                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
291                 return (void*)(uintptr_t)ptr;
292         } else {
293                 // For 64-bit systems, assume the top byte is used for tagging, then
294                 // use bit 9 ^ bit 10.
295                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
296                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
297 #ifdef LDK_DEBUG_BUILD
298                 // On debug builds we also use the 11th bit as a debug flag
299                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
300                 CHECK(tenth_bit != eleventh_bit);
301                 p ^= 1ULL << 53;
302 #endif
303                 return (void*)p;
304         }
305 }
306 static inline bool ptr_is_owned(uint64_t ptr) {
307         if(ptr < 4096) return true;
308         if (sizeof(void*) == 4) {
309                 return ptr & (1ULL << 32);
310         } else {
311                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
312                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
313 #ifdef LDK_DEBUG_BUILD
314                 // On debug builds we also use the 11th bit as a debug flag
315                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
316                 CHECK(tenth_bit != eleventh_bit);
317 #endif
318                 return (ninth_bit ^ tenth_bit) ? true : false;
319         }
320 }
321 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
322         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
323         if (sizeof(void*) == 4) {
324                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
325         } else {
326                 CHECK(sizeof(uintptr_t) == 8);
327                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
328                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
329 #ifdef LDK_DEBUG_BUILD
330                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
331                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
332                 CHECK(ninth_bit == tenth_bit);
333                 CHECK(ninth_bit == eleventh_bit);
334                 t ^= 1ULL << 53;
335 #endif
336                 CHECK(ptr_is_owned(t) == is_owned);
337                 CHECK(untag_ptr(t) == ptr);
338                 return t;
339         }
340 }
341
342 static inline LDKBolt11SemanticError LDKBolt11SemanticError_from_cs(int32_t ord) {
343         switch (ord) {
344                 case 0: return LDKBolt11SemanticError_NoPaymentHash;
345                 case 1: return LDKBolt11SemanticError_MultiplePaymentHashes;
346                 case 2: return LDKBolt11SemanticError_NoDescription;
347                 case 3: return LDKBolt11SemanticError_MultipleDescriptions;
348                 case 4: return LDKBolt11SemanticError_NoPaymentSecret;
349                 case 5: return LDKBolt11SemanticError_MultiplePaymentSecrets;
350                 case 6: return LDKBolt11SemanticError_InvalidFeatures;
351                 case 7: return LDKBolt11SemanticError_InvalidRecoveryId;
352                 case 8: return LDKBolt11SemanticError_InvalidSignature;
353                 case 9: return LDKBolt11SemanticError_ImpreciseAmount;
354                 default: abort();
355         }
356 }
357 static inline int32_t LDKBolt11SemanticError_to_cs(LDKBolt11SemanticError val) {
358         switch (val) {
359                 case LDKBolt11SemanticError_NoPaymentHash: return 0;
360                 case LDKBolt11SemanticError_MultiplePaymentHashes: return 1;
361                 case LDKBolt11SemanticError_NoDescription: return 2;
362                 case LDKBolt11SemanticError_MultipleDescriptions: return 3;
363                 case LDKBolt11SemanticError_NoPaymentSecret: return 4;
364                 case LDKBolt11SemanticError_MultiplePaymentSecrets: return 5;
365                 case LDKBolt11SemanticError_InvalidFeatures: return 6;
366                 case LDKBolt11SemanticError_InvalidRecoveryId: return 7;
367                 case LDKBolt11SemanticError_InvalidSignature: return 8;
368                 case LDKBolt11SemanticError_ImpreciseAmount: return 9;
369                 default: abort();
370         }
371 }
372 static inline LDKBolt12SemanticError LDKBolt12SemanticError_from_cs(int32_t ord) {
373         switch (ord) {
374                 case 0: return LDKBolt12SemanticError_AlreadyExpired;
375                 case 1: return LDKBolt12SemanticError_UnsupportedChain;
376                 case 2: return LDKBolt12SemanticError_UnexpectedChain;
377                 case 3: return LDKBolt12SemanticError_MissingAmount;
378                 case 4: return LDKBolt12SemanticError_InvalidAmount;
379                 case 5: return LDKBolt12SemanticError_InsufficientAmount;
380                 case 6: return LDKBolt12SemanticError_UnexpectedAmount;
381                 case 7: return LDKBolt12SemanticError_UnsupportedCurrency;
382                 case 8: return LDKBolt12SemanticError_UnknownRequiredFeatures;
383                 case 9: return LDKBolt12SemanticError_UnexpectedFeatures;
384                 case 10: return LDKBolt12SemanticError_MissingDescription;
385                 case 11: return LDKBolt12SemanticError_MissingSigningPubkey;
386                 case 12: return LDKBolt12SemanticError_InvalidSigningPubkey;
387                 case 13: return LDKBolt12SemanticError_UnexpectedSigningPubkey;
388                 case 14: return LDKBolt12SemanticError_MissingQuantity;
389                 case 15: return LDKBolt12SemanticError_InvalidQuantity;
390                 case 16: return LDKBolt12SemanticError_UnexpectedQuantity;
391                 case 17: return LDKBolt12SemanticError_InvalidMetadata;
392                 case 18: return LDKBolt12SemanticError_UnexpectedMetadata;
393                 case 19: return LDKBolt12SemanticError_MissingPayerMetadata;
394                 case 20: return LDKBolt12SemanticError_MissingPayerId;
395                 case 21: return LDKBolt12SemanticError_DuplicatePaymentId;
396                 case 22: return LDKBolt12SemanticError_MissingPaths;
397                 case 23: return LDKBolt12SemanticError_InvalidPayInfo;
398                 case 24: return LDKBolt12SemanticError_MissingCreationTime;
399                 case 25: return LDKBolt12SemanticError_MissingPaymentHash;
400                 case 26: return LDKBolt12SemanticError_MissingSignature;
401                 default: abort();
402         }
403 }
404 static inline int32_t LDKBolt12SemanticError_to_cs(LDKBolt12SemanticError val) {
405         switch (val) {
406                 case LDKBolt12SemanticError_AlreadyExpired: return 0;
407                 case LDKBolt12SemanticError_UnsupportedChain: return 1;
408                 case LDKBolt12SemanticError_UnexpectedChain: return 2;
409                 case LDKBolt12SemanticError_MissingAmount: return 3;
410                 case LDKBolt12SemanticError_InvalidAmount: return 4;
411                 case LDKBolt12SemanticError_InsufficientAmount: return 5;
412                 case LDKBolt12SemanticError_UnexpectedAmount: return 6;
413                 case LDKBolt12SemanticError_UnsupportedCurrency: return 7;
414                 case LDKBolt12SemanticError_UnknownRequiredFeatures: return 8;
415                 case LDKBolt12SemanticError_UnexpectedFeatures: return 9;
416                 case LDKBolt12SemanticError_MissingDescription: return 10;
417                 case LDKBolt12SemanticError_MissingSigningPubkey: return 11;
418                 case LDKBolt12SemanticError_InvalidSigningPubkey: return 12;
419                 case LDKBolt12SemanticError_UnexpectedSigningPubkey: return 13;
420                 case LDKBolt12SemanticError_MissingQuantity: return 14;
421                 case LDKBolt12SemanticError_InvalidQuantity: return 15;
422                 case LDKBolt12SemanticError_UnexpectedQuantity: return 16;
423                 case LDKBolt12SemanticError_InvalidMetadata: return 17;
424                 case LDKBolt12SemanticError_UnexpectedMetadata: return 18;
425                 case LDKBolt12SemanticError_MissingPayerMetadata: return 19;
426                 case LDKBolt12SemanticError_MissingPayerId: return 20;
427                 case LDKBolt12SemanticError_DuplicatePaymentId: return 21;
428                 case LDKBolt12SemanticError_MissingPaths: return 22;
429                 case LDKBolt12SemanticError_InvalidPayInfo: return 23;
430                 case LDKBolt12SemanticError_MissingCreationTime: return 24;
431                 case LDKBolt12SemanticError_MissingPaymentHash: return 25;
432                 case LDKBolt12SemanticError_MissingSignature: return 26;
433                 default: abort();
434         }
435 }
436 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_cs(int32_t ord) {
437         switch (ord) {
438                 case 0: return LDKCOption_NoneZ_Some;
439                 case 1: return LDKCOption_NoneZ_None;
440                 default: abort();
441         }
442 }
443 static inline int32_t LDKCOption_NoneZ_to_cs(LDKCOption_NoneZ val) {
444         switch (val) {
445                 case LDKCOption_NoneZ_Some: return 0;
446                 case LDKCOption_NoneZ_None: return 1;
447                 default: abort();
448         }
449 }
450 static inline LDKChannelMonitorUpdateStatus LDKChannelMonitorUpdateStatus_from_cs(int32_t ord) {
451         switch (ord) {
452                 case 0: return LDKChannelMonitorUpdateStatus_Completed;
453                 case 1: return LDKChannelMonitorUpdateStatus_InProgress;
454                 case 2: return LDKChannelMonitorUpdateStatus_UnrecoverableError;
455                 default: abort();
456         }
457 }
458 static inline int32_t LDKChannelMonitorUpdateStatus_to_cs(LDKChannelMonitorUpdateStatus val) {
459         switch (val) {
460                 case LDKChannelMonitorUpdateStatus_Completed: return 0;
461                 case LDKChannelMonitorUpdateStatus_InProgress: return 1;
462                 case LDKChannelMonitorUpdateStatus_UnrecoverableError: return 2;
463                 default: abort();
464         }
465 }
466 static inline LDKChannelShutdownState LDKChannelShutdownState_from_cs(int32_t ord) {
467         switch (ord) {
468                 case 0: return LDKChannelShutdownState_NotShuttingDown;
469                 case 1: return LDKChannelShutdownState_ShutdownInitiated;
470                 case 2: return LDKChannelShutdownState_ResolvingHTLCs;
471                 case 3: return LDKChannelShutdownState_NegotiatingClosingFee;
472                 case 4: return LDKChannelShutdownState_ShutdownComplete;
473                 default: abort();
474         }
475 }
476 static inline int32_t LDKChannelShutdownState_to_cs(LDKChannelShutdownState val) {
477         switch (val) {
478                 case LDKChannelShutdownState_NotShuttingDown: return 0;
479                 case LDKChannelShutdownState_ShutdownInitiated: return 1;
480                 case LDKChannelShutdownState_ResolvingHTLCs: return 2;
481                 case LDKChannelShutdownState_NegotiatingClosingFee: return 3;
482                 case LDKChannelShutdownState_ShutdownComplete: return 4;
483                 default: abort();
484         }
485 }
486 static inline LDKConfirmationTarget LDKConfirmationTarget_from_cs(int32_t ord) {
487         switch (ord) {
488                 case 0: return LDKConfirmationTarget_OnChainSweep;
489                 case 1: return LDKConfirmationTarget_MaxAllowedNonAnchorChannelRemoteFee;
490                 case 2: return LDKConfirmationTarget_MinAllowedAnchorChannelRemoteFee;
491                 case 3: return LDKConfirmationTarget_MinAllowedNonAnchorChannelRemoteFee;
492                 case 4: return LDKConfirmationTarget_AnchorChannelFee;
493                 case 5: return LDKConfirmationTarget_NonAnchorChannelFee;
494                 case 6: return LDKConfirmationTarget_ChannelCloseMinimum;
495                 default: abort();
496         }
497 }
498 static inline int32_t LDKConfirmationTarget_to_cs(LDKConfirmationTarget val) {
499         switch (val) {
500                 case LDKConfirmationTarget_OnChainSweep: return 0;
501                 case LDKConfirmationTarget_MaxAllowedNonAnchorChannelRemoteFee: return 1;
502                 case LDKConfirmationTarget_MinAllowedAnchorChannelRemoteFee: return 2;
503                 case LDKConfirmationTarget_MinAllowedNonAnchorChannelRemoteFee: return 3;
504                 case LDKConfirmationTarget_AnchorChannelFee: return 4;
505                 case LDKConfirmationTarget_NonAnchorChannelFee: return 5;
506                 case LDKConfirmationTarget_ChannelCloseMinimum: return 6;
507                 default: abort();
508         }
509 }
510 static inline LDKCreationError LDKCreationError_from_cs(int32_t ord) {
511         switch (ord) {
512                 case 0: return LDKCreationError_DescriptionTooLong;
513                 case 1: return LDKCreationError_RouteTooLong;
514                 case 2: return LDKCreationError_TimestampOutOfBounds;
515                 case 3: return LDKCreationError_InvalidAmount;
516                 case 4: return LDKCreationError_MissingRouteHints;
517                 case 5: return LDKCreationError_MinFinalCltvExpiryDeltaTooShort;
518                 default: abort();
519         }
520 }
521 static inline int32_t LDKCreationError_to_cs(LDKCreationError val) {
522         switch (val) {
523                 case LDKCreationError_DescriptionTooLong: return 0;
524                 case LDKCreationError_RouteTooLong: return 1;
525                 case LDKCreationError_TimestampOutOfBounds: return 2;
526                 case LDKCreationError_InvalidAmount: return 3;
527                 case LDKCreationError_MissingRouteHints: return 4;
528                 case LDKCreationError_MinFinalCltvExpiryDeltaTooShort: return 5;
529                 default: abort();
530         }
531 }
532 static inline LDKCurrency LDKCurrency_from_cs(int32_t ord) {
533         switch (ord) {
534                 case 0: return LDKCurrency_Bitcoin;
535                 case 1: return LDKCurrency_BitcoinTestnet;
536                 case 2: return LDKCurrency_Regtest;
537                 case 3: return LDKCurrency_Simnet;
538                 case 4: return LDKCurrency_Signet;
539                 default: abort();
540         }
541 }
542 static inline int32_t LDKCurrency_to_cs(LDKCurrency val) {
543         switch (val) {
544                 case LDKCurrency_Bitcoin: return 0;
545                 case LDKCurrency_BitcoinTestnet: return 1;
546                 case LDKCurrency_Regtest: return 2;
547                 case LDKCurrency_Simnet: return 3;
548                 case LDKCurrency_Signet: return 4;
549                 default: abort();
550         }
551 }
552 static inline LDKHTLCClaim LDKHTLCClaim_from_cs(int32_t ord) {
553         switch (ord) {
554                 case 0: return LDKHTLCClaim_OfferedTimeout;
555                 case 1: return LDKHTLCClaim_OfferedPreimage;
556                 case 2: return LDKHTLCClaim_AcceptedTimeout;
557                 case 3: return LDKHTLCClaim_AcceptedPreimage;
558                 case 4: return LDKHTLCClaim_Revocation;
559                 default: abort();
560         }
561 }
562 static inline int32_t LDKHTLCClaim_to_cs(LDKHTLCClaim val) {
563         switch (val) {
564                 case LDKHTLCClaim_OfferedTimeout: return 0;
565                 case LDKHTLCClaim_OfferedPreimage: return 1;
566                 case LDKHTLCClaim_AcceptedTimeout: return 2;
567                 case LDKHTLCClaim_AcceptedPreimage: return 3;
568                 case LDKHTLCClaim_Revocation: return 4;
569                 default: abort();
570         }
571 }
572 static inline LDKIOError LDKIOError_from_cs(int32_t ord) {
573         switch (ord) {
574                 case 0: return LDKIOError_NotFound;
575                 case 1: return LDKIOError_PermissionDenied;
576                 case 2: return LDKIOError_ConnectionRefused;
577                 case 3: return LDKIOError_ConnectionReset;
578                 case 4: return LDKIOError_ConnectionAborted;
579                 case 5: return LDKIOError_NotConnected;
580                 case 6: return LDKIOError_AddrInUse;
581                 case 7: return LDKIOError_AddrNotAvailable;
582                 case 8: return LDKIOError_BrokenPipe;
583                 case 9: return LDKIOError_AlreadyExists;
584                 case 10: return LDKIOError_WouldBlock;
585                 case 11: return LDKIOError_InvalidInput;
586                 case 12: return LDKIOError_InvalidData;
587                 case 13: return LDKIOError_TimedOut;
588                 case 14: return LDKIOError_WriteZero;
589                 case 15: return LDKIOError_Interrupted;
590                 case 16: return LDKIOError_Other;
591                 case 17: return LDKIOError_UnexpectedEof;
592                 default: abort();
593         }
594 }
595 static inline int32_t LDKIOError_to_cs(LDKIOError val) {
596         switch (val) {
597                 case LDKIOError_NotFound: return 0;
598                 case LDKIOError_PermissionDenied: return 1;
599                 case LDKIOError_ConnectionRefused: return 2;
600                 case LDKIOError_ConnectionReset: return 3;
601                 case LDKIOError_ConnectionAborted: return 4;
602                 case LDKIOError_NotConnected: return 5;
603                 case LDKIOError_AddrInUse: return 6;
604                 case LDKIOError_AddrNotAvailable: return 7;
605                 case LDKIOError_BrokenPipe: return 8;
606                 case LDKIOError_AlreadyExists: return 9;
607                 case LDKIOError_WouldBlock: return 10;
608                 case LDKIOError_InvalidInput: return 11;
609                 case LDKIOError_InvalidData: return 12;
610                 case LDKIOError_TimedOut: return 13;
611                 case LDKIOError_WriteZero: return 14;
612                 case LDKIOError_Interrupted: return 15;
613                 case LDKIOError_Other: return 16;
614                 case LDKIOError_UnexpectedEof: return 17;
615                 default: abort();
616         }
617 }
618 static inline LDKLevel LDKLevel_from_cs(int32_t ord) {
619         switch (ord) {
620                 case 0: return LDKLevel_Gossip;
621                 case 1: return LDKLevel_Trace;
622                 case 2: return LDKLevel_Debug;
623                 case 3: return LDKLevel_Info;
624                 case 4: return LDKLevel_Warn;
625                 case 5: return LDKLevel_Error;
626                 default: abort();
627         }
628 }
629 static inline int32_t LDKLevel_to_cs(LDKLevel val) {
630         switch (val) {
631                 case LDKLevel_Gossip: return 0;
632                 case LDKLevel_Trace: return 1;
633                 case LDKLevel_Debug: return 2;
634                 case LDKLevel_Info: return 3;
635                 case LDKLevel_Warn: return 4;
636                 case LDKLevel_Error: return 5;
637                 default: abort();
638         }
639 }
640 static inline LDKNetwork LDKNetwork_from_cs(int32_t ord) {
641         switch (ord) {
642                 case 0: return LDKNetwork_Bitcoin;
643                 case 1: return LDKNetwork_Testnet;
644                 case 2: return LDKNetwork_Regtest;
645                 case 3: return LDKNetwork_Signet;
646                 default: abort();
647         }
648 }
649 static inline int32_t LDKNetwork_to_cs(LDKNetwork val) {
650         switch (val) {
651                 case LDKNetwork_Bitcoin: return 0;
652                 case LDKNetwork_Testnet: return 1;
653                 case LDKNetwork_Regtest: return 2;
654                 case LDKNetwork_Signet: return 3;
655                 default: abort();
656         }
657 }
658 static inline LDKPaymentFailureReason LDKPaymentFailureReason_from_cs(int32_t ord) {
659         switch (ord) {
660                 case 0: return LDKPaymentFailureReason_RecipientRejected;
661                 case 1: return LDKPaymentFailureReason_UserAbandoned;
662                 case 2: return LDKPaymentFailureReason_RetriesExhausted;
663                 case 3: return LDKPaymentFailureReason_PaymentExpired;
664                 case 4: return LDKPaymentFailureReason_RouteNotFound;
665                 case 5: return LDKPaymentFailureReason_UnexpectedError;
666                 default: abort();
667         }
668 }
669 static inline int32_t LDKPaymentFailureReason_to_cs(LDKPaymentFailureReason val) {
670         switch (val) {
671                 case LDKPaymentFailureReason_RecipientRejected: return 0;
672                 case LDKPaymentFailureReason_UserAbandoned: return 1;
673                 case LDKPaymentFailureReason_RetriesExhausted: return 2;
674                 case LDKPaymentFailureReason_PaymentExpired: return 3;
675                 case LDKPaymentFailureReason_RouteNotFound: return 4;
676                 case LDKPaymentFailureReason_UnexpectedError: return 5;
677                 default: abort();
678         }
679 }
680 static inline LDKRecipient LDKRecipient_from_cs(int32_t ord) {
681         switch (ord) {
682                 case 0: return LDKRecipient_Node;
683                 case 1: return LDKRecipient_PhantomNode;
684                 default: abort();
685         }
686 }
687 static inline int32_t LDKRecipient_to_cs(LDKRecipient val) {
688         switch (val) {
689                 case LDKRecipient_Node: return 0;
690                 case LDKRecipient_PhantomNode: return 1;
691                 default: abort();
692         }
693 }
694 static inline LDKRetryableSendFailure LDKRetryableSendFailure_from_cs(int32_t ord) {
695         switch (ord) {
696                 case 0: return LDKRetryableSendFailure_PaymentExpired;
697                 case 1: return LDKRetryableSendFailure_RouteNotFound;
698                 case 2: return LDKRetryableSendFailure_DuplicatePayment;
699                 default: abort();
700         }
701 }
702 static inline int32_t LDKRetryableSendFailure_to_cs(LDKRetryableSendFailure val) {
703         switch (val) {
704                 case LDKRetryableSendFailure_PaymentExpired: return 0;
705                 case LDKRetryableSendFailure_RouteNotFound: return 1;
706                 case LDKRetryableSendFailure_DuplicatePayment: return 2;
707                 default: abort();
708         }
709 }
710 static inline LDKSecp256k1Error LDKSecp256k1Error_from_cs(int32_t ord) {
711         switch (ord) {
712                 case 0: return LDKSecp256k1Error_IncorrectSignature;
713                 case 1: return LDKSecp256k1Error_InvalidMessage;
714                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
715                 case 3: return LDKSecp256k1Error_InvalidSignature;
716                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
717                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
718                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
719                 case 7: return LDKSecp256k1Error_InvalidTweak;
720                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
721                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
722                 case 10: return LDKSecp256k1Error_InvalidParityValue;
723                 default: abort();
724         }
725 }
726 static inline int32_t LDKSecp256k1Error_to_cs(LDKSecp256k1Error val) {
727         switch (val) {
728                 case LDKSecp256k1Error_IncorrectSignature: return 0;
729                 case LDKSecp256k1Error_InvalidMessage: return 1;
730                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
731                 case LDKSecp256k1Error_InvalidSignature: return 3;
732                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
733                 case LDKSecp256k1Error_InvalidSharedSecret: return 5;
734                 case LDKSecp256k1Error_InvalidRecoveryId: return 6;
735                 case LDKSecp256k1Error_InvalidTweak: return 7;
736                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
737                 case LDKSecp256k1Error_InvalidPublicKeySum: return 9;
738                 case LDKSecp256k1Error_InvalidParityValue: return 10;
739                 default: abort();
740         }
741 }
742 static inline LDKSiPrefix LDKSiPrefix_from_cs(int32_t ord) {
743         switch (ord) {
744                 case 0: return LDKSiPrefix_Milli;
745                 case 1: return LDKSiPrefix_Micro;
746                 case 2: return LDKSiPrefix_Nano;
747                 case 3: return LDKSiPrefix_Pico;
748                 default: abort();
749         }
750 }
751 static inline int32_t LDKSiPrefix_to_cs(LDKSiPrefix val) {
752         switch (val) {
753                 case LDKSiPrefix_Milli: return 0;
754                 case LDKSiPrefix_Micro: return 1;
755                 case LDKSiPrefix_Nano: return 2;
756                 case LDKSiPrefix_Pico: return 3;
757                 default: abort();
758         }
759 }
760 static inline LDKSocketAddressParseError LDKSocketAddressParseError_from_cs(int32_t ord) {
761         switch (ord) {
762                 case 0: return LDKSocketAddressParseError_SocketAddrParse;
763                 case 1: return LDKSocketAddressParseError_InvalidInput;
764                 case 2: return LDKSocketAddressParseError_InvalidPort;
765                 case 3: return LDKSocketAddressParseError_InvalidOnionV3;
766                 default: abort();
767         }
768 }
769 static inline int32_t LDKSocketAddressParseError_to_cs(LDKSocketAddressParseError val) {
770         switch (val) {
771                 case LDKSocketAddressParseError_SocketAddrParse: return 0;
772                 case LDKSocketAddressParseError_InvalidInput: return 1;
773                 case LDKSocketAddressParseError_InvalidPort: return 2;
774                 case LDKSocketAddressParseError_InvalidOnionV3: return 3;
775                 default: abort();
776         }
777 }
778 static inline LDKUtxoLookupError LDKUtxoLookupError_from_cs(int32_t ord) {
779         switch (ord) {
780                 case 0: return LDKUtxoLookupError_UnknownChain;
781                 case 1: return LDKUtxoLookupError_UnknownTx;
782                 default: abort();
783         }
784 }
785 static inline int32_t LDKUtxoLookupError_to_cs(LDKUtxoLookupError val) {
786         switch (val) {
787                 case LDKUtxoLookupError_UnknownChain: return 0;
788                 case LDKUtxoLookupError_UnknownTx: return 1;
789                 default: abort();
790         }
791 }
792 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
793         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
794         return ret;
795 }
796 int8_tArray  CS_LDK_BigEndianScalar_get_bytes(int64_t thing) {
797         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
798         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
799         memcpy(ret_arr->elems, BigEndianScalar_get_bytes(thing_conv).data, 32);
800         return ret_arr;
801 }
802
803 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
804 void  CS_LDK_BigEndianScalar_free(int64_t thing) {
805         if (!ptr_is_owned(thing)) return;
806         void* thing_ptr = untag_ptr(thing);
807         CHECK_ACCESS(thing_ptr);
808         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
809         FREE(untag_ptr(thing));
810         BigEndianScalar_free(thing_conv);
811 }
812
813 uint32_t CS_LDK_LDKBech32Error_ty_from_ptr(int64_t ptr) {
814         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
815         switch(obj->tag) {
816                 case LDKBech32Error_MissingSeparator: return 0;
817                 case LDKBech32Error_InvalidChecksum: return 1;
818                 case LDKBech32Error_InvalidLength: return 2;
819                 case LDKBech32Error_InvalidChar: return 3;
820                 case LDKBech32Error_InvalidData: return 4;
821                 case LDKBech32Error_InvalidPadding: return 5;
822                 case LDKBech32Error_MixedCase: return 6;
823                 default: abort();
824         }
825 }
826 int32_t CS_LDK_LDKBech32Error_InvalidChar_get_invalid_char(int64_t ptr) {
827         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
828         CHECK(obj->tag == LDKBech32Error_InvalidChar);
829         int32_t invalid_char_conv = obj->invalid_char;
830         return invalid_char_conv;
831 }
832 int8_t CS_LDK_LDKBech32Error_InvalidData_get_invalid_data(int64_t ptr) {
833         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
834         CHECK(obj->tag == LDKBech32Error_InvalidData);
835         int8_t invalid_data_conv = obj->invalid_data;
836         return invalid_data_conv;
837 }
838 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
839         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
840         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
841         return ret;
842 }
843 struct LDKWitness TxIn_get_witness (struct LDKTxIn* thing) {    return Witness_clone(&thing->witness);}int8_tArray  CS_LDK_TxIn_get_witness(int64_t thing) {
844         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
845         LDKWitness ret_var = TxIn_get_witness(thing_conv);
846         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
847         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
848         Witness_free(ret_var);
849         return ret_arr;
850 }
851
852 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) {
853         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
854         LDKCVec_u8Z ret_var = TxIn_get_script_sig(thing_conv);
855         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
856         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
857         CVec_u8Z_free(ret_var);
858         return ret_arr;
859 }
860
861 LDKThirtyTwoBytes TxIn_get_previous_txid (struct LDKTxIn* thing) {      return thing->previous_txid;}int8_tArray  CS_LDK_TxIn_get_previous_txid(int64_t thing) {
862         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
863         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
864         memcpy(ret_arr->elems, TxIn_get_previous_txid(thing_conv).data, 32);
865         return ret_arr;
866 }
867
868 uint32_t TxIn_get_previous_vout (struct LDKTxIn* thing) {       return thing->previous_vout;}int32_t  CS_LDK_TxIn_get_previous_vout(int64_t thing) {
869         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
870         int32_t ret_conv = TxIn_get_previous_vout(thing_conv);
871         return ret_conv;
872 }
873
874 uint32_t TxIn_get_sequence (struct LDKTxIn* thing) {    return thing->sequence;}int32_t  CS_LDK_TxIn_get_sequence(int64_t thing) {
875         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
876         int32_t ret_conv = TxIn_get_sequence(thing_conv);
877         return ret_conv;
878 }
879
880 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) {
881         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
882         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
883         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
884         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
885         CVec_u8Z_free(ret_var);
886         return ret_arr;
887 }
888
889 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  CS_LDK_TxOut_get_value(int64_t thing) {
890         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
891         int64_t ret_conv = TxOut_get_value(thing_conv);
892         return ret_conv;
893 }
894
895 uint32_t CS_LDK_LDKCOption_u64Z_ty_from_ptr(int64_t ptr) {
896         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
897         switch(obj->tag) {
898                 case LDKCOption_u64Z_Some: return 0;
899                 case LDKCOption_u64Z_None: return 1;
900                 default: abort();
901         }
902 }
903 int64_t CS_LDK_LDKCOption_u64Z_Some_get_some(int64_t ptr) {
904         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
905         CHECK(obj->tag == LDKCOption_u64Z_Some);
906         int64_t some_conv = obj->some;
907         return some_conv;
908 }
909 static inline LDKCVec_BlindedPathZ CVec_BlindedPathZ_clone(const LDKCVec_BlindedPathZ *orig) {
910         LDKCVec_BlindedPathZ ret = { .data = MALLOC(sizeof(LDKBlindedPath) * orig->datalen, "LDKCVec_BlindedPathZ clone bytes"), .datalen = orig->datalen };
911         for (size_t i = 0; i < ret.datalen; i++) {
912                 ret.data[i] = BlindedPath_clone(&orig->data[i]);
913         }
914         return ret;
915 }
916 static inline struct LDKRefund CResult_RefundBolt12ParseErrorZ_get_ok(LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR owner){
917         LDKRefund ret = *owner->contents.result;
918         ret.is_owned = false;
919         return ret;
920 }
921 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_get_ok(int64_t owner) {
922         LDKCResult_RefundBolt12ParseErrorZ* owner_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(owner);
923         LDKRefund ret_var = CResult_RefundBolt12ParseErrorZ_get_ok(owner_conv);
924         int64_t ret_ref = 0;
925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
926         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
927         return ret_ref;
928 }
929
930 static inline struct LDKBolt12ParseError CResult_RefundBolt12ParseErrorZ_get_err(LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR owner){
931         LDKBolt12ParseError ret = *owner->contents.err;
932         ret.is_owned = false;
933         return ret;
934 }
935 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_get_err(int64_t owner) {
936         LDKCResult_RefundBolt12ParseErrorZ* owner_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(owner);
937         LDKBolt12ParseError ret_var = CResult_RefundBolt12ParseErrorZ_get_err(owner_conv);
938         int64_t ret_ref = 0;
939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
941         return ret_ref;
942 }
943
944 uint32_t CS_LDK_LDKRetry_ty_from_ptr(int64_t ptr) {
945         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
946         switch(obj->tag) {
947                 case LDKRetry_Attempts: return 0;
948                 case LDKRetry_Timeout: return 1;
949                 default: abort();
950         }
951 }
952 int32_t CS_LDK_LDKRetry_Attempts_get_attempts(int64_t ptr) {
953         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
954         CHECK(obj->tag == LDKRetry_Attempts);
955         int32_t attempts_conv = obj->attempts;
956         return attempts_conv;
957 }
958 int64_t CS_LDK_LDKRetry_Timeout_get_timeout(int64_t ptr) {
959         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
960         CHECK(obj->tag == LDKRetry_Timeout);
961         int64_t timeout_conv = obj->timeout;
962         return timeout_conv;
963 }
964 uint32_t CS_LDK_LDKDecodeError_ty_from_ptr(int64_t ptr) {
965         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
966         switch(obj->tag) {
967                 case LDKDecodeError_UnknownVersion: return 0;
968                 case LDKDecodeError_UnknownRequiredFeature: return 1;
969                 case LDKDecodeError_InvalidValue: return 2;
970                 case LDKDecodeError_ShortRead: return 3;
971                 case LDKDecodeError_BadLengthDescriptor: return 4;
972                 case LDKDecodeError_Io: return 5;
973                 case LDKDecodeError_UnsupportedCompression: return 6;
974                 default: abort();
975         }
976 }
977 int32_t CS_LDK_LDKDecodeError_Io_get_io(int64_t ptr) {
978         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
979         CHECK(obj->tag == LDKDecodeError_Io);
980         int32_t io_conv = LDKIOError_to_cs(obj->io);
981         return io_conv;
982 }
983 static inline struct LDKRetry CResult_RetryDecodeErrorZ_get_ok(LDKCResult_RetryDecodeErrorZ *NONNULL_PTR owner){
984 CHECK(owner->result_ok);
985         return Retry_clone(&*owner->contents.result);
986 }
987 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_get_ok(int64_t owner) {
988         LDKCResult_RetryDecodeErrorZ* owner_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(owner);
989         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
990         *ret_copy = CResult_RetryDecodeErrorZ_get_ok(owner_conv);
991         int64_t ret_ref = tag_ptr(ret_copy, true);
992         return ret_ref;
993 }
994
995 static inline struct LDKDecodeError CResult_RetryDecodeErrorZ_get_err(LDKCResult_RetryDecodeErrorZ *NONNULL_PTR owner){
996 CHECK(!owner->result_ok);
997         return DecodeError_clone(&*owner->contents.err);
998 }
999 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_get_err(int64_t owner) {
1000         LDKCResult_RetryDecodeErrorZ* owner_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(owner);
1001         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1002         *ret_copy = CResult_RetryDecodeErrorZ_get_err(owner_conv);
1003         int64_t ret_ref = tag_ptr(ret_copy, true);
1004         return ret_ref;
1005 }
1006
1007 uint32_t CS_LDK_LDKAPIError_ty_from_ptr(int64_t ptr) {
1008         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1009         switch(obj->tag) {
1010                 case LDKAPIError_APIMisuseError: return 0;
1011                 case LDKAPIError_FeeRateTooHigh: return 1;
1012                 case LDKAPIError_InvalidRoute: return 2;
1013                 case LDKAPIError_ChannelUnavailable: return 3;
1014                 case LDKAPIError_MonitorUpdateInProgress: return 4;
1015                 case LDKAPIError_IncompatibleShutdownScript: return 5;
1016                 default: abort();
1017         }
1018 }
1019 jstring CS_LDK_LDKAPIError_APIMisuseError_get_err(int64_t ptr) {
1020         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1021         CHECK(obj->tag == LDKAPIError_APIMisuseError);
1022         LDKStr err_str = obj->api_misuse_error.err;
1023                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
1024         return err_conv;
1025 }
1026 jstring CS_LDK_LDKAPIError_FeeRateTooHigh_get_err(int64_t ptr) {
1027         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1028         CHECK(obj->tag == LDKAPIError_FeeRateTooHigh);
1029         LDKStr err_str = obj->fee_rate_too_high.err;
1030                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
1031         return err_conv;
1032 }
1033 int32_t CS_LDK_LDKAPIError_FeeRateTooHigh_get_feerate(int64_t ptr) {
1034         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1035         CHECK(obj->tag == LDKAPIError_FeeRateTooHigh);
1036         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
1037         return feerate_conv;
1038 }
1039 jstring CS_LDK_LDKAPIError_InvalidRoute_get_err(int64_t ptr) {
1040         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1041         CHECK(obj->tag == LDKAPIError_InvalidRoute);
1042         LDKStr err_str = obj->invalid_route.err;
1043                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
1044         return err_conv;
1045 }
1046 jstring CS_LDK_LDKAPIError_ChannelUnavailable_get_err(int64_t ptr) {
1047         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1048         CHECK(obj->tag == LDKAPIError_ChannelUnavailable);
1049         LDKStr err_str = obj->channel_unavailable.err;
1050                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
1051         return err_conv;
1052 }
1053 int64_t CS_LDK_LDKAPIError_IncompatibleShutdownScript_get_script(int64_t ptr) {
1054         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1055         CHECK(obj->tag == LDKAPIError_IncompatibleShutdownScript);
1056         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
1057                         int64_t script_ref = 0;
1058                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
1059                         script_ref = tag_ptr(script_var.inner, false);
1060         return script_ref;
1061 }
1062 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1063 CHECK(owner->result_ok);
1064         return *owner->contents.result;
1065 }
1066 void  CS_LDK_CResult_NoneAPIErrorZ_get_ok(int64_t owner) {
1067         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1068         CResult_NoneAPIErrorZ_get_ok(owner_conv);
1069 }
1070
1071 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1072 CHECK(!owner->result_ok);
1073         return APIError_clone(&*owner->contents.err);
1074 }
1075 int64_t  CS_LDK_CResult_NoneAPIErrorZ_get_err(int64_t owner) {
1076         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1077         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
1078         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
1079         int64_t ret_ref = tag_ptr(ret_copy, true);
1080         return ret_ref;
1081 }
1082
1083 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
1084         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
1085         for (size_t i = 0; i < ret.datalen; i++) {
1086                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
1087         }
1088         return ret;
1089 }
1090 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
1091         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
1092         for (size_t i = 0; i < ret.datalen; i++) {
1093                 ret.data[i] = APIError_clone(&orig->data[i]);
1094         }
1095         return ret;
1096 }
1097 uint32_t CS_LDK_LDKCOption_ThirtyTwoBytesZ_ty_from_ptr(int64_t ptr) {
1098         LDKCOption_ThirtyTwoBytesZ *obj = (LDKCOption_ThirtyTwoBytesZ*)untag_ptr(ptr);
1099         switch(obj->tag) {
1100                 case LDKCOption_ThirtyTwoBytesZ_Some: return 0;
1101                 case LDKCOption_ThirtyTwoBytesZ_None: return 1;
1102                 default: abort();
1103         }
1104 }
1105 int8_tArray CS_LDK_LDKCOption_ThirtyTwoBytesZ_Some_get_some(int64_t ptr) {
1106         LDKCOption_ThirtyTwoBytesZ *obj = (LDKCOption_ThirtyTwoBytesZ*)untag_ptr(ptr);
1107         CHECK(obj->tag == LDKCOption_ThirtyTwoBytesZ_Some);
1108         int8_tArray some_arr = init_int8_tArray(32, __LINE__);
1109         memcpy(some_arr->elems, obj->some.data, 32);
1110         return some_arr;
1111 }
1112 uint32_t CS_LDK_LDKCOption_CVec_u8ZZ_ty_from_ptr(int64_t ptr) {
1113         LDKCOption_CVec_u8ZZ *obj = (LDKCOption_CVec_u8ZZ*)untag_ptr(ptr);
1114         switch(obj->tag) {
1115                 case LDKCOption_CVec_u8ZZ_Some: return 0;
1116                 case LDKCOption_CVec_u8ZZ_None: return 1;
1117                 default: abort();
1118         }
1119 }
1120 int8_tArray CS_LDK_LDKCOption_CVec_u8ZZ_Some_get_some(int64_t ptr) {
1121         LDKCOption_CVec_u8ZZ *obj = (LDKCOption_CVec_u8ZZ*)untag_ptr(ptr);
1122         CHECK(obj->tag == LDKCOption_CVec_u8ZZ_Some);
1123         LDKCVec_u8Z some_var = obj->some;
1124                         int8_tArray some_arr = init_int8_tArray(some_var.datalen, __LINE__);
1125                         memcpy(some_arr->elems, some_var.data, some_var.datalen);
1126         return some_arr;
1127 }
1128 static inline struct LDKRecipientOnionFields CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR owner){
1129         LDKRecipientOnionFields ret = *owner->contents.result;
1130         ret.is_owned = false;
1131         return ret;
1132 }
1133 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(int64_t owner) {
1134         LDKCResult_RecipientOnionFieldsDecodeErrorZ* owner_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(owner);
1135         LDKRecipientOnionFields ret_var = CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(owner_conv);
1136         int64_t ret_ref = 0;
1137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1138         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1139         return ret_ref;
1140 }
1141
1142 static inline struct LDKDecodeError CResult_RecipientOnionFieldsDecodeErrorZ_get_err(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR owner){
1143 CHECK(!owner->result_ok);
1144         return DecodeError_clone(&*owner->contents.err);
1145 }
1146 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_get_err(int64_t owner) {
1147         LDKCResult_RecipientOnionFieldsDecodeErrorZ* owner_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(owner);
1148         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1149         *ret_copy = CResult_RecipientOnionFieldsDecodeErrorZ_get_err(owner_conv);
1150         int64_t ret_ref = tag_ptr(ret_copy, true);
1151         return ret_ref;
1152 }
1153
1154 static inline uint64_t C2Tuple_u64CVec_u8ZZ_get_a(LDKC2Tuple_u64CVec_u8ZZ *NONNULL_PTR owner){
1155         return owner->a;
1156 }
1157 int64_t  CS_LDK_C2Tuple_u64CVec_u8ZZ_get_a(int64_t owner) {
1158         LDKC2Tuple_u64CVec_u8ZZ* owner_conv = (LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(owner);
1159         int64_t ret_conv = C2Tuple_u64CVec_u8ZZ_get_a(owner_conv);
1160         return ret_conv;
1161 }
1162
1163 static inline struct LDKCVec_u8Z C2Tuple_u64CVec_u8ZZ_get_b(LDKC2Tuple_u64CVec_u8ZZ *NONNULL_PTR owner){
1164         return CVec_u8Z_clone(&owner->b);
1165 }
1166 int8_tArray  CS_LDK_C2Tuple_u64CVec_u8ZZ_get_b(int64_t owner) {
1167         LDKC2Tuple_u64CVec_u8ZZ* owner_conv = (LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(owner);
1168         LDKCVec_u8Z ret_var = C2Tuple_u64CVec_u8ZZ_get_b(owner_conv);
1169         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1170         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1171         CVec_u8Z_free(ret_var);
1172         return ret_arr;
1173 }
1174
1175 static inline LDKCVec_C2Tuple_u64CVec_u8ZZZ CVec_C2Tuple_u64CVec_u8ZZZ_clone(const LDKCVec_C2Tuple_u64CVec_u8ZZZ *orig) {
1176         LDKCVec_C2Tuple_u64CVec_u8ZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ) * orig->datalen, "LDKCVec_C2Tuple_u64CVec_u8ZZZ clone bytes"), .datalen = orig->datalen };
1177         for (size_t i = 0; i < ret.datalen; i++) {
1178                 ret.data[i] = C2Tuple_u64CVec_u8ZZ_clone(&orig->data[i]);
1179         }
1180         return ret;
1181 }
1182 static inline struct LDKRecipientOnionFields CResult_RecipientOnionFieldsNoneZ_get_ok(LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR owner){
1183         LDKRecipientOnionFields ret = *owner->contents.result;
1184         ret.is_owned = false;
1185         return ret;
1186 }
1187 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_get_ok(int64_t owner) {
1188         LDKCResult_RecipientOnionFieldsNoneZ* owner_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(owner);
1189         LDKRecipientOnionFields ret_var = CResult_RecipientOnionFieldsNoneZ_get_ok(owner_conv);
1190         int64_t ret_ref = 0;
1191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1192         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1193         return ret_ref;
1194 }
1195
1196 static inline void CResult_RecipientOnionFieldsNoneZ_get_err(LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR owner){
1197 CHECK(!owner->result_ok);
1198         return *owner->contents.err;
1199 }
1200 void  CS_LDK_CResult_RecipientOnionFieldsNoneZ_get_err(int64_t owner) {
1201         LDKCResult_RecipientOnionFieldsNoneZ* owner_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(owner);
1202         CResult_RecipientOnionFieldsNoneZ_get_err(owner_conv);
1203 }
1204
1205 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
1206         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
1207         for (size_t i = 0; i < ret.datalen; i++) {
1208                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1209         }
1210         return ret;
1211 }
1212 uint32_t CS_LDK_LDKCOption_CVec_ThirtyTwoBytesZZ_ty_from_ptr(int64_t ptr) {
1213         LDKCOption_CVec_ThirtyTwoBytesZZ *obj = (LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(ptr);
1214         switch(obj->tag) {
1215                 case LDKCOption_CVec_ThirtyTwoBytesZZ_Some: return 0;
1216                 case LDKCOption_CVec_ThirtyTwoBytesZZ_None: return 1;
1217                 default: abort();
1218         }
1219 }
1220 ptrArray CS_LDK_LDKCOption_CVec_ThirtyTwoBytesZZ_Some_get_some(int64_t ptr) {
1221         LDKCOption_CVec_ThirtyTwoBytesZZ *obj = (LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(ptr);
1222         CHECK(obj->tag == LDKCOption_CVec_ThirtyTwoBytesZZ_Some);
1223         LDKCVec_ThirtyTwoBytesZ some_var = obj->some;
1224                         ptrArray some_arr = NULL;
1225                         some_arr = init_ptrArray(some_var.datalen, __LINE__);
1226                         int8_tArray *some_arr_ptr = (int8_tArray*)(((uint8_t*)some_arr) + 8);
1227                         for (size_t i = 0; i < some_var.datalen; i++) {
1228                                 int8_tArray some_conv_8_arr = init_int8_tArray(32, __LINE__);
1229                                 memcpy(some_conv_8_arr->elems, some_var.data[i].data, 32);
1230                                 some_arr_ptr[i] = some_conv_8_arr;
1231                         }
1232                         
1233         return some_arr;
1234 }
1235 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesNoneZ_get_ok(LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR owner){
1236 CHECK(owner->result_ok);
1237         return ThirtyTwoBytes_clone(&*owner->contents.result);
1238 }
1239 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesNoneZ_get_ok(int64_t owner) {
1240         LDKCResult_ThirtyTwoBytesNoneZ* owner_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(owner);
1241         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1242         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesNoneZ_get_ok(owner_conv).data, 32);
1243         return ret_arr;
1244 }
1245
1246 static inline void CResult_ThirtyTwoBytesNoneZ_get_err(LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR owner){
1247 CHECK(!owner->result_ok);
1248         return *owner->contents.err;
1249 }
1250 void  CS_LDK_CResult_ThirtyTwoBytesNoneZ_get_err(int64_t owner) {
1251         LDKCResult_ThirtyTwoBytesNoneZ* owner_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(owner);
1252         CResult_ThirtyTwoBytesNoneZ_get_err(owner_conv);
1253 }
1254
1255 static inline struct LDKBlindedPayInfo CResult_BlindedPayInfoDecodeErrorZ_get_ok(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR owner){
1256         LDKBlindedPayInfo ret = *owner->contents.result;
1257         ret.is_owned = false;
1258         return ret;
1259 }
1260 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_get_ok(int64_t owner) {
1261         LDKCResult_BlindedPayInfoDecodeErrorZ* owner_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(owner);
1262         LDKBlindedPayInfo ret_var = CResult_BlindedPayInfoDecodeErrorZ_get_ok(owner_conv);
1263         int64_t ret_ref = 0;
1264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1266         return ret_ref;
1267 }
1268
1269 static inline struct LDKDecodeError CResult_BlindedPayInfoDecodeErrorZ_get_err(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR owner){
1270 CHECK(!owner->result_ok);
1271         return DecodeError_clone(&*owner->contents.err);
1272 }
1273 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_get_err(int64_t owner) {
1274         LDKCResult_BlindedPayInfoDecodeErrorZ* owner_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(owner);
1275         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1276         *ret_copy = CResult_BlindedPayInfoDecodeErrorZ_get_err(owner_conv);
1277         int64_t ret_ref = tag_ptr(ret_copy, true);
1278         return ret_ref;
1279 }
1280
1281 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1282         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
1283         ret.is_owned = false;
1284         return ret;
1285 }
1286 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(int64_t owner) {
1287         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1288         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
1289         int64_t ret_ref = 0;
1290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1292         return ret_ref;
1293 }
1294
1295 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1296 CHECK(!owner->result_ok);
1297         return DecodeError_clone(&*owner->contents.err);
1298 }
1299 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(int64_t owner) {
1300         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1301         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1302         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
1303         int64_t ret_ref = tag_ptr(ret_copy, true);
1304         return ret_ref;
1305 }
1306
1307 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1308         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
1309         ret.is_owned = false;
1310         return ret;
1311 }
1312 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(int64_t owner) {
1313         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1314         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
1315         int64_t ret_ref = 0;
1316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1318         return ret_ref;
1319 }
1320
1321 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1322 CHECK(!owner->result_ok);
1323         return DecodeError_clone(&*owner->contents.err);
1324 }
1325 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(int64_t owner) {
1326         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1327         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1328         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
1329         int64_t ret_ref = tag_ptr(ret_copy, true);
1330         return ret_ref;
1331 }
1332
1333 uint32_t CS_LDK_LDKSpendableOutputDescriptor_ty_from_ptr(int64_t ptr) {
1334         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1335         switch(obj->tag) {
1336                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1337                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1338                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1339                 default: abort();
1340         }
1341 }
1342 int64_t CS_LDK_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(int64_t ptr) {
1343         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1344         CHECK(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1345         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1346                         int64_t outpoint_ref = 0;
1347                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1348                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
1349         return outpoint_ref;
1350 }
1351 int64_t CS_LDK_LDKSpendableOutputDescriptor_StaticOutput_get_output(int64_t ptr) {
1352         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1353         CHECK(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1354         LDKTxOut* output_ref = &obj->static_output.output;
1355         return tag_ptr(output_ref, false);
1356 }
1357 int64_t CS_LDK_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(int64_t ptr) {
1358         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1359         CHECK(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1360         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1361                         int64_t delayed_payment_output_ref = 0;
1362                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1363                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
1364         return delayed_payment_output_ref;
1365 }
1366 int64_t CS_LDK_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(int64_t ptr) {
1367         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1368         CHECK(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1369         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1370                         int64_t static_payment_output_ref = 0;
1371                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1372                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
1373         return static_payment_output_ref;
1374 }
1375 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1376 CHECK(owner->result_ok);
1377         return SpendableOutputDescriptor_clone(&*owner->contents.result);
1378 }
1379 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(int64_t owner) {
1380         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1381         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
1382         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
1383         int64_t ret_ref = tag_ptr(ret_copy, true);
1384         return ret_ref;
1385 }
1386
1387 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1388 CHECK(!owner->result_ok);
1389         return DecodeError_clone(&*owner->contents.err);
1390 }
1391 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(int64_t owner) {
1392         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1393         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1394         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
1395         int64_t ret_ref = tag_ptr(ret_copy, true);
1396         return ret_ref;
1397 }
1398
1399 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1400         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1401         for (size_t i = 0; i < ret.datalen; i++) {
1402                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1403         }
1404         return ret;
1405 }
1406 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
1407         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
1408         for (size_t i = 0; i < ret.datalen; i++) {
1409                 ret.data[i] = TxOut_clone(&orig->data[i]);
1410         }
1411         return ret;
1412 }
1413 uint32_t CS_LDK_LDKCOption_u32Z_ty_from_ptr(int64_t ptr) {
1414         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1415         switch(obj->tag) {
1416                 case LDKCOption_u32Z_Some: return 0;
1417                 case LDKCOption_u32Z_None: return 1;
1418                 default: abort();
1419         }
1420 }
1421 int32_t CS_LDK_LDKCOption_u32Z_Some_get_some(int64_t ptr) {
1422         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1423         CHECK(obj->tag == LDKCOption_u32Z_Some);
1424         int32_t some_conv = obj->some;
1425         return some_conv;
1426 }
1427 static inline struct LDKCVec_u8Z C2Tuple_CVec_u8ZusizeZ_get_a(LDKC2Tuple_CVec_u8ZusizeZ *NONNULL_PTR owner){
1428         return CVec_u8Z_clone(&owner->a);
1429 }
1430 int8_tArray  CS_LDK_C2Tuple_CVec_u8ZusizeZ_get_a(int64_t owner) {
1431         LDKC2Tuple_CVec_u8ZusizeZ* owner_conv = (LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(owner);
1432         LDKCVec_u8Z ret_var = C2Tuple_CVec_u8ZusizeZ_get_a(owner_conv);
1433         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1434         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1435         CVec_u8Z_free(ret_var);
1436         return ret_arr;
1437 }
1438
1439 static inline uintptr_t C2Tuple_CVec_u8ZusizeZ_get_b(LDKC2Tuple_CVec_u8ZusizeZ *NONNULL_PTR owner){
1440         return owner->b;
1441 }
1442 int64_t  CS_LDK_C2Tuple_CVec_u8ZusizeZ_get_b(int64_t owner) {
1443         LDKC2Tuple_CVec_u8ZusizeZ* owner_conv = (LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(owner);
1444         int64_t ret_conv = C2Tuple_CVec_u8ZusizeZ_get_b(owner_conv);
1445         return ret_conv;
1446 }
1447
1448 static inline struct LDKC2Tuple_CVec_u8ZusizeZ CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_ok(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ *NONNULL_PTR owner){
1449 CHECK(owner->result_ok);
1450         return C2Tuple_CVec_u8ZusizeZ_clone(&*owner->contents.result);
1451 }
1452 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_ok(int64_t owner) {
1453         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* owner_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(owner);
1454         LDKC2Tuple_CVec_u8ZusizeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_CVec_u8ZusizeZ), "LDKC2Tuple_CVec_u8ZusizeZ");
1455         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_ok(owner_conv);
1456         return tag_ptr(ret_conv, true);
1457 }
1458
1459 static inline void CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_err(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ *NONNULL_PTR owner){
1460 CHECK(!owner->result_ok);
1461         return *owner->contents.err;
1462 }
1463 void  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_err(int64_t owner) {
1464         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* owner_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(owner);
1465         CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_err(owner_conv);
1466 }
1467
1468 static inline struct LDKChannelDerivationParameters CResult_ChannelDerivationParametersDecodeErrorZ_get_ok(LDKCResult_ChannelDerivationParametersDecodeErrorZ *NONNULL_PTR owner){
1469         LDKChannelDerivationParameters ret = *owner->contents.result;
1470         ret.is_owned = false;
1471         return ret;
1472 }
1473 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_get_ok(int64_t owner) {
1474         LDKCResult_ChannelDerivationParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(owner);
1475         LDKChannelDerivationParameters ret_var = CResult_ChannelDerivationParametersDecodeErrorZ_get_ok(owner_conv);
1476         int64_t ret_ref = 0;
1477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1479         return ret_ref;
1480 }
1481
1482 static inline struct LDKDecodeError CResult_ChannelDerivationParametersDecodeErrorZ_get_err(LDKCResult_ChannelDerivationParametersDecodeErrorZ *NONNULL_PTR owner){
1483 CHECK(!owner->result_ok);
1484         return DecodeError_clone(&*owner->contents.err);
1485 }
1486 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_get_err(int64_t owner) {
1487         LDKCResult_ChannelDerivationParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(owner);
1488         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1489         *ret_copy = CResult_ChannelDerivationParametersDecodeErrorZ_get_err(owner_conv);
1490         int64_t ret_ref = tag_ptr(ret_copy, true);
1491         return ret_ref;
1492 }
1493
1494 static inline struct LDKHTLCDescriptor CResult_HTLCDescriptorDecodeErrorZ_get_ok(LDKCResult_HTLCDescriptorDecodeErrorZ *NONNULL_PTR owner){
1495         LDKHTLCDescriptor ret = *owner->contents.result;
1496         ret.is_owned = false;
1497         return ret;
1498 }
1499 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_get_ok(int64_t owner) {
1500         LDKCResult_HTLCDescriptorDecodeErrorZ* owner_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(owner);
1501         LDKHTLCDescriptor ret_var = CResult_HTLCDescriptorDecodeErrorZ_get_ok(owner_conv);
1502         int64_t ret_ref = 0;
1503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1505         return ret_ref;
1506 }
1507
1508 static inline struct LDKDecodeError CResult_HTLCDescriptorDecodeErrorZ_get_err(LDKCResult_HTLCDescriptorDecodeErrorZ *NONNULL_PTR owner){
1509 CHECK(!owner->result_ok);
1510         return DecodeError_clone(&*owner->contents.err);
1511 }
1512 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_get_err(int64_t owner) {
1513         LDKCResult_HTLCDescriptorDecodeErrorZ* owner_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(owner);
1514         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1515         *ret_copy = CResult_HTLCDescriptorDecodeErrorZ_get_err(owner_conv);
1516         int64_t ret_ref = tag_ptr(ret_copy, true);
1517         return ret_ref;
1518 }
1519
1520 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1521 CHECK(owner->result_ok);
1522         return *owner->contents.result;
1523 }
1524 void  CS_LDK_CResult_NoneNoneZ_get_ok(int64_t owner) {
1525         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1526         CResult_NoneNoneZ_get_ok(owner_conv);
1527 }
1528
1529 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1530 CHECK(!owner->result_ok);
1531         return *owner->contents.err;
1532 }
1533 void  CS_LDK_CResult_NoneNoneZ_get_err(int64_t owner) {
1534         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1535         CResult_NoneNoneZ_get_err(owner_conv);
1536 }
1537
1538 static inline struct LDKECDSASignature C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_a(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ *NONNULL_PTR owner){
1539         return owner->a;
1540 }
1541 int8_tArray  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_a(int64_t owner) {
1542         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* owner_conv = (LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(owner);
1543         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1544         memcpy(ret_arr->elems, C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_a(owner_conv).compact_form, 64);
1545         return ret_arr;
1546 }
1547
1548 static inline struct LDKCVec_ECDSASignatureZ C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_b(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ *NONNULL_PTR owner){
1549         return owner->b;
1550 }
1551 ptrArray  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_b(int64_t owner) {
1552         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* owner_conv = (LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(owner);
1553         LDKCVec_ECDSASignatureZ ret_var = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_b(owner_conv);
1554         ptrArray ret_arr = NULL;
1555         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
1556         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
1557         for (size_t i = 0; i < ret_var.datalen; i++) {
1558                 int8_tArray ret_conv_8_arr = init_int8_tArray(64, __LINE__);
1559                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compact_form, 64);
1560                 ret_arr_ptr[i] = ret_conv_8_arr;
1561         }
1562         
1563         return ret_arr;
1564 }
1565
1566 static inline struct LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ *NONNULL_PTR owner){
1567 CHECK(owner->result_ok);
1568         return C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(&*owner->contents.result);
1569 }
1570 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_ok(int64_t owner) {
1571         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(owner);
1572         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ), "LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ");
1573         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_ok(owner_conv);
1574         return tag_ptr(ret_conv, true);
1575 }
1576
1577 static inline void CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_err(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ *NONNULL_PTR owner){
1578 CHECK(!owner->result_ok);
1579         return *owner->contents.err;
1580 }
1581 void  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_err(int64_t owner) {
1582         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(owner);
1583         CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_err(owner_conv);
1584 }
1585
1586 static inline struct LDKECDSASignature CResult_ECDSASignatureNoneZ_get_ok(LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR owner){
1587 CHECK(owner->result_ok);
1588         return *owner->contents.result;
1589 }
1590 int8_tArray  CS_LDK_CResult_ECDSASignatureNoneZ_get_ok(int64_t owner) {
1591         LDKCResult_ECDSASignatureNoneZ* owner_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(owner);
1592         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1593         memcpy(ret_arr->elems, CResult_ECDSASignatureNoneZ_get_ok(owner_conv).compact_form, 64);
1594         return ret_arr;
1595 }
1596
1597 static inline void CResult_ECDSASignatureNoneZ_get_err(LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR owner){
1598 CHECK(!owner->result_ok);
1599         return *owner->contents.err;
1600 }
1601 void  CS_LDK_CResult_ECDSASignatureNoneZ_get_err(int64_t owner) {
1602         LDKCResult_ECDSASignatureNoneZ* owner_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(owner);
1603         CResult_ECDSASignatureNoneZ_get_err(owner_conv);
1604 }
1605
1606 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
1607 CHECK(owner->result_ok);
1608         return *owner->contents.result;
1609 }
1610 int8_tArray  CS_LDK_CResult_PublicKeyNoneZ_get_ok(int64_t owner) {
1611         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
1612         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
1613         memcpy(ret_arr->elems, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form, 33);
1614         return ret_arr;
1615 }
1616
1617 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
1618 CHECK(!owner->result_ok);
1619         return *owner->contents.err;
1620 }
1621 void  CS_LDK_CResult_PublicKeyNoneZ_get_err(int64_t owner) {
1622         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
1623         CResult_PublicKeyNoneZ_get_err(owner_conv);
1624 }
1625
1626 uint32_t CS_LDK_LDKCOption_BigEndianScalarZ_ty_from_ptr(int64_t ptr) {
1627         LDKCOption_BigEndianScalarZ *obj = (LDKCOption_BigEndianScalarZ*)untag_ptr(ptr);
1628         switch(obj->tag) {
1629                 case LDKCOption_BigEndianScalarZ_Some: return 0;
1630                 case LDKCOption_BigEndianScalarZ_None: return 1;
1631                 default: abort();
1632         }
1633 }
1634 int64_t CS_LDK_LDKCOption_BigEndianScalarZ_Some_get_some(int64_t ptr) {
1635         LDKCOption_BigEndianScalarZ *obj = (LDKCOption_BigEndianScalarZ*)untag_ptr(ptr);
1636         CHECK(obj->tag == LDKCOption_BigEndianScalarZ_Some);
1637         LDKBigEndianScalar* some_ref = &obj->some;
1638         return tag_ptr(some_ref, false);
1639 }
1640 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
1641 CHECK(owner->result_ok);
1642         return *owner->contents.result;
1643 }
1644 int8_tArray  CS_LDK_CResult_RecoverableSignatureNoneZ_get_ok(int64_t owner) {
1645         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
1646         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
1647         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
1648         return ret_arr;
1649 }
1650
1651 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
1652 CHECK(!owner->result_ok);
1653         return *owner->contents.err;
1654 }
1655 void  CS_LDK_CResult_RecoverableSignatureNoneZ_get_err(int64_t owner) {
1656         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
1657         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
1658 }
1659
1660 static inline struct LDKSchnorrSignature CResult_SchnorrSignatureNoneZ_get_ok(LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR owner){
1661 CHECK(owner->result_ok);
1662         return *owner->contents.result;
1663 }
1664 int8_tArray  CS_LDK_CResult_SchnorrSignatureNoneZ_get_ok(int64_t owner) {
1665         LDKCResult_SchnorrSignatureNoneZ* owner_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(owner);
1666         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1667         memcpy(ret_arr->elems, CResult_SchnorrSignatureNoneZ_get_ok(owner_conv).compact_form, 64);
1668         return ret_arr;
1669 }
1670
1671 static inline void CResult_SchnorrSignatureNoneZ_get_err(LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR owner){
1672 CHECK(!owner->result_ok);
1673         return *owner->contents.err;
1674 }
1675 void  CS_LDK_CResult_SchnorrSignatureNoneZ_get_err(int64_t owner) {
1676         LDKCResult_SchnorrSignatureNoneZ* owner_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(owner);
1677         CResult_SchnorrSignatureNoneZ_get_err(owner_conv);
1678 }
1679
1680 typedef struct LDKChannelSigner_JCalls {
1681         atomic_size_t refcnt;
1682         uint32_t instance_ptr;
1683 } LDKChannelSigner_JCalls;
1684 static void LDKChannelSigner_JCalls_free(void* this_arg) {
1685         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1686         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1687                 FREE(j_calls);
1688         }
1689 }
1690 LDKPublicKey get_per_commitment_point_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
1691         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1692         int64_t idx_conv = idx;
1693         int8_tArray ret = (int8_tArray)js_invoke_function_l_l(j_calls->instance_ptr, 0, idx_conv);
1694         LDKPublicKey ret_ref;
1695         CHECK(ret->arr_len == 33);
1696         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
1697         return ret_ref;
1698 }
1699 LDKThirtyTwoBytes release_commitment_secret_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
1700         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1701         int64_t idx_conv = idx;
1702         int8_tArray ret = (int8_tArray)js_invoke_function_l_l(j_calls->instance_ptr, 1, idx_conv);
1703         LDKThirtyTwoBytes ret_ref;
1704         CHECK(ret->arr_len == 32);
1705         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
1706         return ret_ref;
1707 }
1708 LDKCResult_NoneNoneZ validate_holder_commitment_LDKChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_ThirtyTwoBytesZ preimages) {
1709         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1710         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1711         int64_t holder_tx_ref = 0;
1712         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
1713         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
1714         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
1715         LDKCVec_ThirtyTwoBytesZ preimages_var = preimages;
1716         ptrArray preimages_arr = NULL;
1717         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
1718         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
1719         for (size_t i = 0; i < preimages_var.datalen; i++) {
1720                 int8_tArray preimages_conv_8_arr = init_int8_tArray(32, __LINE__);
1721                 memcpy(preimages_conv_8_arr->elems, preimages_var.data[i].data, 32);
1722                 preimages_arr_ptr[i] = preimages_conv_8_arr;
1723         }
1724         
1725         FREE(preimages_var.data);
1726         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 2, holder_tx_ref, (int64_t)preimages_arr);
1727         void* ret_ptr = untag_ptr(ret);
1728         CHECK_ACCESS(ret_ptr);
1729         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1730         FREE(untag_ptr(ret));
1731         return ret_conv;
1732 }
1733 LDKThirtyTwoBytes channel_keys_id_LDKChannelSigner_jcall(const void* this_arg) {
1734         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1735         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 3);
1736         LDKThirtyTwoBytes ret_ref;
1737         CHECK(ret->arr_len == 32);
1738         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
1739         return ret_ref;
1740 }
1741 void provide_channel_parameters_LDKChannelSigner_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1742         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1743         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1744         int64_t channel_parameters_ref = 0;
1745         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
1746         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
1747         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
1748         js_invoke_function_void_l(j_calls->instance_ptr, 4, channel_parameters_ref);
1749 }
1750 static void LDKChannelSigner_JCalls_cloned(LDKChannelSigner* new_obj) {
1751         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) new_obj->this_arg;
1752         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1753 }
1754 static inline LDKChannelSigner LDKChannelSigner_init (int64_t o, int64_t pubkeys) {
1755         LDKChannelSigner_JCalls *calls = MALLOC(sizeof(LDKChannelSigner_JCalls), "LDKChannelSigner_JCalls");
1756         atomic_init(&calls->refcnt, 1);
1757         calls->instance_ptr = o;
1758
1759         LDKChannelPublicKeys pubkeys_conv;
1760         pubkeys_conv.inner = untag_ptr(pubkeys);
1761         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
1762         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
1763
1764         LDKChannelSigner ret = {
1765                 .this_arg = (void*) calls,
1766                 .get_per_commitment_point = get_per_commitment_point_LDKChannelSigner_jcall,
1767                 .release_commitment_secret = release_commitment_secret_LDKChannelSigner_jcall,
1768                 .validate_holder_commitment = validate_holder_commitment_LDKChannelSigner_jcall,
1769                 .channel_keys_id = channel_keys_id_LDKChannelSigner_jcall,
1770                 .provide_channel_parameters = provide_channel_parameters_LDKChannelSigner_jcall,
1771                 .free = LDKChannelSigner_JCalls_free,
1772                 .pubkeys = pubkeys_conv,
1773                 .set_pubkeys = NULL,
1774         };
1775         return ret;
1776 }
1777 uint64_t  CS_LDK_LDKChannelSigner_new(int32_t o, int64_t pubkeys) {
1778         LDKChannelSigner *res_ptr = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
1779         *res_ptr = LDKChannelSigner_init(o, pubkeys);
1780         return tag_ptr(res_ptr, true);
1781 }
1782 int8_tArray  CS_LDK_ChannelSigner_get_per_commitment_point(int64_t this_arg, int64_t idx) {
1783         void* this_arg_ptr = untag_ptr(this_arg);
1784         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1785         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1786         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
1787         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1788         return ret_arr;
1789 }
1790
1791 int8_tArray  CS_LDK_ChannelSigner_release_commitment_secret(int64_t this_arg, int64_t idx) {
1792         void* this_arg_ptr = untag_ptr(this_arg);
1793         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1794         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1795         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1796         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1797         return ret_arr;
1798 }
1799
1800 int64_t  CS_LDK_ChannelSigner_validate_holder_commitment(int64_t this_arg, int64_t holder_tx, ptrArray preimages) {
1801         void* this_arg_ptr = untag_ptr(this_arg);
1802         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1803         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1804         LDKHolderCommitmentTransaction holder_tx_conv;
1805         holder_tx_conv.inner = untag_ptr(holder_tx);
1806         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
1807         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
1808         holder_tx_conv.is_owned = false;
1809         LDKCVec_ThirtyTwoBytesZ preimages_constr;
1810         preimages_constr.datalen = preimages->arr_len;
1811         if (preimages_constr.datalen > 0)
1812                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
1813         else
1814                 preimages_constr.data = NULL;
1815         int8_tArray* preimages_vals = (void*) preimages->elems;
1816         for (size_t i = 0; i < preimages_constr.datalen; i++) {
1817                 int8_tArray preimages_conv_8 = preimages_vals[i];
1818                 LDKThirtyTwoBytes preimages_conv_8_ref;
1819                 CHECK(preimages_conv_8->arr_len == 32);
1820                 memcpy(preimages_conv_8_ref.data, preimages_conv_8->elems, 32); FREE(preimages_conv_8);
1821                 preimages_constr.data[i] = preimages_conv_8_ref;
1822         }
1823         FREE(preimages);
1824         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
1825         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
1826         return tag_ptr(ret_conv, true);
1827 }
1828
1829 int8_tArray  CS_LDK_ChannelSigner_channel_keys_id(int64_t this_arg) {
1830         void* this_arg_ptr = untag_ptr(this_arg);
1831         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1832         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1833         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1834         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1835         return ret_arr;
1836 }
1837
1838 void  CS_LDK_ChannelSigner_provide_channel_parameters(int64_t this_arg, int64_t channel_parameters) {
1839         void* this_arg_ptr = untag_ptr(this_arg);
1840         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1841         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1842         LDKChannelTransactionParameters channel_parameters_conv;
1843         channel_parameters_conv.inner = untag_ptr(channel_parameters);
1844         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
1845         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
1846         channel_parameters_conv.is_owned = false;
1847         (this_arg_conv->provide_channel_parameters)(this_arg_conv->this_arg, &channel_parameters_conv);
1848 }
1849
1850 LDKChannelPublicKeys LDKChannelSigner_set_get_pubkeys(LDKChannelSigner* this_arg) {
1851         if (this_arg->set_pubkeys != NULL)
1852                 this_arg->set_pubkeys(this_arg);
1853         return this_arg->pubkeys;
1854 }
1855 int64_t  CS_LDK_ChannelSigner_get_pubkeys(int64_t this_arg) {
1856         void* this_arg_ptr = untag_ptr(this_arg);
1857         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1858         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1859         LDKChannelPublicKeys ret_var = LDKChannelSigner_set_get_pubkeys(this_arg_conv);
1860         int64_t ret_ref = 0;
1861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1862         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1863         return ret_ref;
1864 }
1865
1866 typedef struct LDKEcdsaChannelSigner_JCalls {
1867         atomic_size_t refcnt;
1868         uint32_t instance_ptr;
1869         LDKChannelSigner_JCalls* ChannelSigner;
1870 } LDKEcdsaChannelSigner_JCalls;
1871 static void LDKEcdsaChannelSigner_JCalls_free(void* this_arg) {
1872         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1873         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1874                 FREE(j_calls);
1875         }
1876 }
1877 LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_ThirtyTwoBytesZ preimages) {
1878         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1879         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1880         int64_t commitment_tx_ref = 0;
1881         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
1882         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1883         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
1884         LDKCVec_ThirtyTwoBytesZ preimages_var = preimages;
1885         ptrArray preimages_arr = NULL;
1886         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
1887         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
1888         for (size_t i = 0; i < preimages_var.datalen; i++) {
1889                 int8_tArray preimages_conv_8_arr = init_int8_tArray(32, __LINE__);
1890                 memcpy(preimages_conv_8_arr->elems, preimages_var.data[i].data, 32);
1891                 preimages_arr_ptr[i] = preimages_conv_8_arr;
1892         }
1893         
1894         FREE(preimages_var.data);
1895         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 5, commitment_tx_ref, (int64_t)preimages_arr);
1896         void* ret_ptr = untag_ptr(ret);
1897         CHECK_ACCESS(ret_ptr);
1898         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)(ret_ptr);
1899         FREE(untag_ptr(ret));
1900         return ret_conv;
1901 }
1902 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
1903         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1904         int64_t idx_conv = idx;
1905         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
1906         memcpy(secret_arr->elems, *secret, 32);
1907         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 6, idx_conv, (int64_t)secret_arr);
1908         void* ret_ptr = untag_ptr(ret);
1909         CHECK_ACCESS(ret_ptr);
1910         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1911         FREE(untag_ptr(ret));
1912         return ret_conv;
1913 }
1914 LDKCResult_ECDSASignatureNoneZ sign_holder_commitment_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1915         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1916         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1917         int64_t commitment_tx_ref = 0;
1918         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
1919         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1920         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
1921         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 7, commitment_tx_ref);
1922         void* ret_ptr = untag_ptr(ret);
1923         CHECK_ACCESS(ret_ptr);
1924         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
1925         FREE(untag_ptr(ret));
1926         return ret_conv;
1927 }
1928 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]) {
1929         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1930         LDKTransaction justice_tx_var = justice_tx;
1931         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
1932         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
1933         Transaction_free(justice_tx_var);
1934         int64_t input_conv = input;
1935         int64_t amount_conv = amount;
1936         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
1937         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
1938         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);
1939         void* ret_ptr = untag_ptr(ret);
1940         CHECK_ACCESS(ret_ptr);
1941         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
1942         FREE(untag_ptr(ret));
1943         return ret_conv;
1944 }
1945 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) {
1946         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1947         LDKTransaction justice_tx_var = justice_tx;
1948         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
1949         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
1950         Transaction_free(justice_tx_var);
1951         int64_t input_conv = input;
1952         int64_t amount_conv = amount;
1953         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
1954         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
1955         LDKHTLCOutputInCommitment htlc_var = *htlc;
1956         int64_t htlc_ref = 0;
1957         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
1958         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
1959         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
1960         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);
1961         void* ret_ptr = untag_ptr(ret);
1962         CHECK_ACCESS(ret_ptr);
1963         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
1964         FREE(untag_ptr(ret));
1965         return ret_conv;
1966 }
1967 LDKCResult_ECDSASignatureNoneZ sign_holder_htlc_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, const LDKHTLCDescriptor * htlc_descriptor) {
1968         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1969         LDKTransaction htlc_tx_var = htlc_tx;
1970         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
1971         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
1972         Transaction_free(htlc_tx_var);
1973         int64_t input_conv = input;
1974         LDKHTLCDescriptor htlc_descriptor_var = *htlc_descriptor;
1975         int64_t htlc_descriptor_ref = 0;
1976         htlc_descriptor_var = HTLCDescriptor_clone(&htlc_descriptor_var);
1977         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_descriptor_var);
1978         htlc_descriptor_ref = tag_ptr(htlc_descriptor_var.inner, htlc_descriptor_var.is_owned);
1979         uint64_t ret = js_invoke_function_l_lll(j_calls->instance_ptr, 10, (int64_t)htlc_tx_arr, input_conv, htlc_descriptor_ref);
1980         void* ret_ptr = untag_ptr(ret);
1981         CHECK_ACCESS(ret_ptr);
1982         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
1983         FREE(untag_ptr(ret));
1984         return ret_conv;
1985 }
1986 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) {
1987         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1988         LDKTransaction htlc_tx_var = htlc_tx;
1989         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
1990         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
1991         Transaction_free(htlc_tx_var);
1992         int64_t input_conv = input;
1993         int64_t amount_conv = amount;
1994         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
1995         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
1996         LDKHTLCOutputInCommitment htlc_var = *htlc;
1997         int64_t htlc_ref = 0;
1998         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
1999         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2000         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
2001         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);
2002         void* ret_ptr = untag_ptr(ret);
2003         CHECK_ACCESS(ret_ptr);
2004         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
2005         FREE(untag_ptr(ret));
2006         return ret_conv;
2007 }
2008 LDKCResult_ECDSASignatureNoneZ sign_closing_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2009         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
2010         LDKClosingTransaction closing_tx_var = *closing_tx;
2011         int64_t closing_tx_ref = 0;
2012         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
2013         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
2014         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
2015         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 12, closing_tx_ref);
2016         void* ret_ptr = untag_ptr(ret);
2017         CHECK_ACCESS(ret_ptr);
2018         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
2019         FREE(untag_ptr(ret));
2020         return ret_conv;
2021 }
2022 LDKCResult_ECDSASignatureNoneZ sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
2023         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
2024         LDKTransaction anchor_tx_var = anchor_tx;
2025         int8_tArray anchor_tx_arr = init_int8_tArray(anchor_tx_var.datalen, __LINE__);
2026         memcpy(anchor_tx_arr->elems, anchor_tx_var.data, anchor_tx_var.datalen);
2027         Transaction_free(anchor_tx_var);
2028         int64_t input_conv = input;
2029         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 13, (int64_t)anchor_tx_arr, input_conv);
2030         void* ret_ptr = untag_ptr(ret);
2031         CHECK_ACCESS(ret_ptr);
2032         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
2033         FREE(untag_ptr(ret));
2034         return ret_conv;
2035 }
2036 LDKCResult_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2037         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
2038         LDKUnsignedChannelAnnouncement msg_var = *msg;
2039         int64_t msg_ref = 0;
2040         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
2041         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2042         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
2043         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 14, msg_ref);
2044         void* ret_ptr = untag_ptr(ret);
2045         CHECK_ACCESS(ret_ptr);
2046         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
2047         FREE(untag_ptr(ret));
2048         return ret_conv;
2049 }
2050 static void LDKEcdsaChannelSigner_JCalls_cloned(LDKEcdsaChannelSigner* new_obj) {
2051         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) new_obj->this_arg;
2052         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2053         atomic_fetch_add_explicit(&j_calls->ChannelSigner->refcnt, 1, memory_order_release);
2054 }
2055 static inline LDKEcdsaChannelSigner LDKEcdsaChannelSigner_init (int64_t o, int64_t ChannelSigner, int64_t pubkeys) {
2056         LDKEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKEcdsaChannelSigner_JCalls), "LDKEcdsaChannelSigner_JCalls");
2057         atomic_init(&calls->refcnt, 1);
2058         calls->instance_ptr = o;
2059
2060         LDKChannelPublicKeys pubkeys_conv;
2061         pubkeys_conv.inner = untag_ptr(pubkeys);
2062         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
2063         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2064
2065         LDKEcdsaChannelSigner ret = {
2066                 .this_arg = (void*) calls,
2067                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall,
2068                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall,
2069                 .sign_holder_commitment = sign_holder_commitment_LDKEcdsaChannelSigner_jcall,
2070                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKEcdsaChannelSigner_jcall,
2071                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKEcdsaChannelSigner_jcall,
2072                 .sign_holder_htlc_transaction = sign_holder_htlc_transaction_LDKEcdsaChannelSigner_jcall,
2073                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKEcdsaChannelSigner_jcall,
2074                 .sign_closing_transaction = sign_closing_transaction_LDKEcdsaChannelSigner_jcall,
2075                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall,
2076                 .sign_channel_announcement_with_funding_key = sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall,
2077                 .free = LDKEcdsaChannelSigner_JCalls_free,
2078                 .ChannelSigner = LDKChannelSigner_init(ChannelSigner, pubkeys),
2079         };
2080         calls->ChannelSigner = ret.ChannelSigner.this_arg;
2081         return ret;
2082 }
2083 uint64_t  CS_LDK_LDKEcdsaChannelSigner_new(int32_t o, int32_t ChannelSigner, int64_t pubkeys) {
2084         LDKEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
2085         *res_ptr = LDKEcdsaChannelSigner_init(o, ChannelSigner, pubkeys);
2086         return tag_ptr(res_ptr, true);
2087 }
2088 int64_t  CS_LDK_EcdsaChannelSigner_sign_counterparty_commitment(int64_t this_arg, int64_t commitment_tx, ptrArray preimages) {
2089         void* this_arg_ptr = untag_ptr(this_arg);
2090         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2091         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2092         LDKCommitmentTransaction commitment_tx_conv;
2093         commitment_tx_conv.inner = untag_ptr(commitment_tx);
2094         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
2095         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2096         commitment_tx_conv.is_owned = false;
2097         LDKCVec_ThirtyTwoBytesZ preimages_constr;
2098         preimages_constr.datalen = preimages->arr_len;
2099         if (preimages_constr.datalen > 0)
2100                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
2101         else
2102                 preimages_constr.data = NULL;
2103         int8_tArray* preimages_vals = (void*) preimages->elems;
2104         for (size_t i = 0; i < preimages_constr.datalen; i++) {
2105                 int8_tArray preimages_conv_8 = preimages_vals[i];
2106                 LDKThirtyTwoBytes preimages_conv_8_ref;
2107                 CHECK(preimages_conv_8->arr_len == 32);
2108                 memcpy(preimages_conv_8_ref.data, preimages_conv_8->elems, 32); FREE(preimages_conv_8);
2109                 preimages_constr.data[i] = preimages_conv_8_ref;
2110         }
2111         FREE(preimages);
2112         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
2113         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
2114         return tag_ptr(ret_conv, true);
2115 }
2116
2117 int64_t  CS_LDK_EcdsaChannelSigner_validate_counterparty_revocation(int64_t this_arg, int64_t idx, int8_tArray secret) {
2118         void* this_arg_ptr = untag_ptr(this_arg);
2119         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2120         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2121         uint8_t secret_arr[32];
2122         CHECK(secret->arr_len == 32);
2123         memcpy(secret_arr, secret->elems, 32); FREE(secret);
2124         uint8_t (*secret_ref)[32] = &secret_arr;
2125         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2126         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2127         return tag_ptr(ret_conv, true);
2128 }
2129
2130 int64_t  CS_LDK_EcdsaChannelSigner_sign_holder_commitment(int64_t this_arg, int64_t commitment_tx) {
2131         void* this_arg_ptr = untag_ptr(this_arg);
2132         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2133         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2134         LDKHolderCommitmentTransaction commitment_tx_conv;
2135         commitment_tx_conv.inner = untag_ptr(commitment_tx);
2136         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
2137         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2138         commitment_tx_conv.is_owned = false;
2139         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2140         *ret_conv = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2141         return tag_ptr(ret_conv, true);
2142 }
2143
2144 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) {
2145         void* this_arg_ptr = untag_ptr(this_arg);
2146         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2147         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2148         LDKTransaction justice_tx_ref;
2149         justice_tx_ref.datalen = justice_tx->arr_len;
2150         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2151         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
2152         justice_tx_ref.data_is_owned = true;
2153         uint8_t per_commitment_key_arr[32];
2154         CHECK(per_commitment_key->arr_len == 32);
2155         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
2156         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2157         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2158         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2159         return tag_ptr(ret_conv, true);
2160 }
2161
2162 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) {
2163         void* this_arg_ptr = untag_ptr(this_arg);
2164         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2165         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2166         LDKTransaction justice_tx_ref;
2167         justice_tx_ref.datalen = justice_tx->arr_len;
2168         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2169         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
2170         justice_tx_ref.data_is_owned = true;
2171         uint8_t per_commitment_key_arr[32];
2172         CHECK(per_commitment_key->arr_len == 32);
2173         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
2174         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2175         LDKHTLCOutputInCommitment htlc_conv;
2176         htlc_conv.inner = untag_ptr(htlc);
2177         htlc_conv.is_owned = ptr_is_owned(htlc);
2178         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2179         htlc_conv.is_owned = false;
2180         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2181         *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);
2182         return tag_ptr(ret_conv, true);
2183 }
2184
2185 int64_t  CS_LDK_EcdsaChannelSigner_sign_holder_htlc_transaction(int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t htlc_descriptor) {
2186         void* this_arg_ptr = untag_ptr(this_arg);
2187         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2188         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2189         LDKTransaction htlc_tx_ref;
2190         htlc_tx_ref.datalen = htlc_tx->arr_len;
2191         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2192         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
2193         htlc_tx_ref.data_is_owned = true;
2194         LDKHTLCDescriptor htlc_descriptor_conv;
2195         htlc_descriptor_conv.inner = untag_ptr(htlc_descriptor);
2196         htlc_descriptor_conv.is_owned = ptr_is_owned(htlc_descriptor);
2197         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_descriptor_conv);
2198         htlc_descriptor_conv.is_owned = false;
2199         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2200         *ret_conv = (this_arg_conv->sign_holder_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_ref, input, &htlc_descriptor_conv);
2201         return tag_ptr(ret_conv, true);
2202 }
2203
2204 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) {
2205         void* this_arg_ptr = untag_ptr(this_arg);
2206         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2207         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2208         LDKTransaction htlc_tx_ref;
2209         htlc_tx_ref.datalen = htlc_tx->arr_len;
2210         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2211         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
2212         htlc_tx_ref.data_is_owned = true;
2213         LDKPublicKey per_commitment_point_ref;
2214         CHECK(per_commitment_point->arr_len == 33);
2215         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
2216         LDKHTLCOutputInCommitment htlc_conv;
2217         htlc_conv.inner = untag_ptr(htlc);
2218         htlc_conv.is_owned = ptr_is_owned(htlc);
2219         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2220         htlc_conv.is_owned = false;
2221         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2222         *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);
2223         return tag_ptr(ret_conv, true);
2224 }
2225
2226 int64_t  CS_LDK_EcdsaChannelSigner_sign_closing_transaction(int64_t this_arg, int64_t closing_tx) {
2227         void* this_arg_ptr = untag_ptr(this_arg);
2228         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2229         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2230         LDKClosingTransaction closing_tx_conv;
2231         closing_tx_conv.inner = untag_ptr(closing_tx);
2232         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
2233         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
2234         closing_tx_conv.is_owned = false;
2235         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2236         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2237         return tag_ptr(ret_conv, true);
2238 }
2239
2240 int64_t  CS_LDK_EcdsaChannelSigner_sign_holder_anchor_input(int64_t this_arg, int8_tArray anchor_tx, int64_t input) {
2241         void* this_arg_ptr = untag_ptr(this_arg);
2242         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2243         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2244         LDKTransaction anchor_tx_ref;
2245         anchor_tx_ref.datalen = anchor_tx->arr_len;
2246         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
2247         memcpy(anchor_tx_ref.data, anchor_tx->elems, anchor_tx_ref.datalen); FREE(anchor_tx);
2248         anchor_tx_ref.data_is_owned = true;
2249         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2250         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
2251         return tag_ptr(ret_conv, true);
2252 }
2253
2254 int64_t  CS_LDK_EcdsaChannelSigner_sign_channel_announcement_with_funding_key(int64_t this_arg, int64_t msg) {
2255         void* this_arg_ptr = untag_ptr(this_arg);
2256         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2257         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2258         LDKUnsignedChannelAnnouncement msg_conv;
2259         msg_conv.inner = untag_ptr(msg);
2260         msg_conv.is_owned = ptr_is_owned(msg);
2261         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
2262         msg_conv.is_owned = false;
2263         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2264         *ret_conv = (this_arg_conv->sign_channel_announcement_with_funding_key)(this_arg_conv->this_arg, &msg_conv);
2265         return tag_ptr(ret_conv, true);
2266 }
2267
2268 typedef struct LDKWriteableEcdsaChannelSigner_JCalls {
2269         atomic_size_t refcnt;
2270         uint32_t instance_ptr;
2271         LDKEcdsaChannelSigner_JCalls* EcdsaChannelSigner;
2272         LDKChannelSigner_JCalls* ChannelSigner;
2273 } LDKWriteableEcdsaChannelSigner_JCalls;
2274 static void LDKWriteableEcdsaChannelSigner_JCalls_free(void* this_arg) {
2275         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
2276         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2277                 FREE(j_calls);
2278         }
2279 }
2280 LDKCVec_u8Z write_LDKWriteableEcdsaChannelSigner_jcall(const void* this_arg) {
2281         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
2282         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 15);
2283         LDKCVec_u8Z ret_ref;
2284         ret_ref.datalen = ret->arr_len;
2285         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2286         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
2287         return ret_ref;
2288 }
2289 static void LDKWriteableEcdsaChannelSigner_JCalls_cloned(LDKWriteableEcdsaChannelSigner* new_obj) {
2290         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) new_obj->this_arg;
2291         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2292         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->refcnt, 1, memory_order_release);
2293         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->ChannelSigner->refcnt, 1, memory_order_release);
2294 }
2295 static inline LDKWriteableEcdsaChannelSigner LDKWriteableEcdsaChannelSigner_init (int64_t o, int64_t EcdsaChannelSigner, int64_t ChannelSigner, int64_t pubkeys) {
2296         LDKWriteableEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner_JCalls), "LDKWriteableEcdsaChannelSigner_JCalls");
2297         atomic_init(&calls->refcnt, 1);
2298         calls->instance_ptr = o;
2299
2300         LDKChannelPublicKeys pubkeys_conv;
2301         pubkeys_conv.inner = untag_ptr(pubkeys);
2302         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
2303         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2304
2305         LDKWriteableEcdsaChannelSigner ret = {
2306                 .this_arg = (void*) calls,
2307                 .write = write_LDKWriteableEcdsaChannelSigner_jcall,
2308                 .cloned = LDKWriteableEcdsaChannelSigner_JCalls_cloned,
2309                 .free = LDKWriteableEcdsaChannelSigner_JCalls_free,
2310                 .EcdsaChannelSigner = LDKEcdsaChannelSigner_init(EcdsaChannelSigner, ChannelSigner, pubkeys),
2311         };
2312         calls->EcdsaChannelSigner = ret.EcdsaChannelSigner.this_arg;
2313         calls->ChannelSigner = ret.EcdsaChannelSigner.ChannelSigner.this_arg;
2314         return ret;
2315 }
2316 uint64_t  CS_LDK_LDKWriteableEcdsaChannelSigner_new(int32_t o, int32_t EcdsaChannelSigner, int32_t ChannelSigner, int64_t pubkeys) {
2317         LDKWriteableEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
2318         *res_ptr = LDKWriteableEcdsaChannelSigner_init(o, EcdsaChannelSigner, ChannelSigner, pubkeys);
2319         return tag_ptr(res_ptr, true);
2320 }
2321 int8_tArray  CS_LDK_WriteableEcdsaChannelSigner_write(int64_t this_arg) {
2322         void* this_arg_ptr = untag_ptr(this_arg);
2323         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2324         LDKWriteableEcdsaChannelSigner* this_arg_conv = (LDKWriteableEcdsaChannelSigner*)this_arg_ptr;
2325         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2326         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2327         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2328         CVec_u8Z_free(ret_var);
2329         return ret_arr;
2330 }
2331
2332 static inline struct LDKWriteableEcdsaChannelSigner CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
2333 CHECK(owner->result_ok);
2334         return WriteableEcdsaChannelSigner_clone(&*owner->contents.result);
2335 }
2336 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(int64_t owner) {
2337         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
2338         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
2339         *ret_ret = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(owner_conv);
2340         return tag_ptr(ret_ret, true);
2341 }
2342
2343 static inline struct LDKDecodeError CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
2344 CHECK(!owner->result_ok);
2345         return DecodeError_clone(&*owner->contents.err);
2346 }
2347 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(int64_t owner) {
2348         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
2349         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2350         *ret_copy = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(owner_conv);
2351         int64_t ret_ref = tag_ptr(ret_copy, true);
2352         return ret_ref;
2353 }
2354
2355 static inline struct LDKCVec_u8Z CResult_CVec_u8ZNoneZ_get_ok(LDKCResult_CVec_u8ZNoneZ *NONNULL_PTR owner){
2356 CHECK(owner->result_ok);
2357         return CVec_u8Z_clone(&*owner->contents.result);
2358 }
2359 int8_tArray  CS_LDK_CResult_CVec_u8ZNoneZ_get_ok(int64_t owner) {
2360         LDKCResult_CVec_u8ZNoneZ* owner_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(owner);
2361         LDKCVec_u8Z ret_var = CResult_CVec_u8ZNoneZ_get_ok(owner_conv);
2362         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2363         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2364         CVec_u8Z_free(ret_var);
2365         return ret_arr;
2366 }
2367
2368 static inline void CResult_CVec_u8ZNoneZ_get_err(LDKCResult_CVec_u8ZNoneZ *NONNULL_PTR owner){
2369 CHECK(!owner->result_ok);
2370         return *owner->contents.err;
2371 }
2372 void  CS_LDK_CResult_CVec_u8ZNoneZ_get_err(int64_t owner) {
2373         LDKCResult_CVec_u8ZNoneZ* owner_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(owner);
2374         CResult_CVec_u8ZNoneZ_get_err(owner_conv);
2375 }
2376
2377 static inline struct LDKShutdownScript CResult_ShutdownScriptNoneZ_get_ok(LDKCResult_ShutdownScriptNoneZ *NONNULL_PTR owner){
2378         LDKShutdownScript ret = *owner->contents.result;
2379         ret.is_owned = false;
2380         return ret;
2381 }
2382 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_get_ok(int64_t owner) {
2383         LDKCResult_ShutdownScriptNoneZ* owner_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(owner);
2384         LDKShutdownScript ret_var = CResult_ShutdownScriptNoneZ_get_ok(owner_conv);
2385         int64_t ret_ref = 0;
2386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2388         return ret_ref;
2389 }
2390
2391 static inline void CResult_ShutdownScriptNoneZ_get_err(LDKCResult_ShutdownScriptNoneZ *NONNULL_PTR owner){
2392 CHECK(!owner->result_ok);
2393         return *owner->contents.err;
2394 }
2395 void  CS_LDK_CResult_ShutdownScriptNoneZ_get_err(int64_t owner) {
2396         LDKCResult_ShutdownScriptNoneZ* owner_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(owner);
2397         CResult_ShutdownScriptNoneZ_get_err(owner_conv);
2398 }
2399
2400 uint32_t CS_LDK_LDKCOption_u16Z_ty_from_ptr(int64_t ptr) {
2401         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
2402         switch(obj->tag) {
2403                 case LDKCOption_u16Z_Some: return 0;
2404                 case LDKCOption_u16Z_None: return 1;
2405                 default: abort();
2406         }
2407 }
2408 int16_t CS_LDK_LDKCOption_u16Z_Some_get_some(int64_t ptr) {
2409         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
2410         CHECK(obj->tag == LDKCOption_u16Z_Some);
2411         int16_t some_conv = obj->some;
2412         return some_conv;
2413 }
2414 uint32_t CS_LDK_LDKCOption_boolZ_ty_from_ptr(int64_t ptr) {
2415         LDKCOption_boolZ *obj = (LDKCOption_boolZ*)untag_ptr(ptr);
2416         switch(obj->tag) {
2417                 case LDKCOption_boolZ_Some: return 0;
2418                 case LDKCOption_boolZ_None: return 1;
2419                 default: abort();
2420         }
2421 }
2422 jboolean CS_LDK_LDKCOption_boolZ_Some_get_some(int64_t ptr) {
2423         LDKCOption_boolZ *obj = (LDKCOption_boolZ*)untag_ptr(ptr);
2424         CHECK(obj->tag == LDKCOption_boolZ_Some);
2425         jboolean some_conv = obj->some;
2426         return some_conv;
2427 }
2428 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2429         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2430         for (size_t i = 0; i < ret.datalen; i++) {
2431                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2432         }
2433         return ret;
2434 }
2435 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
2436 CHECK(owner->result_ok);
2437         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
2438 }
2439 ptrArray  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_get_ok(int64_t owner) {
2440         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
2441         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
2442         ptrArray ret_arr = NULL;
2443         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2444         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
2445         for (size_t i = 0; i < ret_var.datalen; i++) {
2446                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
2447                 int8_tArray ret_conv_8_arr = init_int8_tArray(ret_conv_8_var.datalen, __LINE__);
2448                 memcpy(ret_conv_8_arr->elems, ret_conv_8_var.data, ret_conv_8_var.datalen);
2449                 CVec_u8Z_free(ret_conv_8_var);
2450                 ret_arr_ptr[i] = ret_conv_8_arr;
2451         }
2452         
2453         FREE(ret_var.data);
2454         return ret_arr;
2455 }
2456
2457 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
2458 CHECK(!owner->result_ok);
2459         return *owner->contents.err;
2460 }
2461 void  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_get_err(int64_t owner) {
2462         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
2463         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
2464 }
2465
2466 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
2467         LDKInMemorySigner ret = *owner->contents.result;
2468         ret.is_owned = false;
2469         return ret;
2470 }
2471 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_get_ok(int64_t owner) {
2472         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
2473         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
2474         int64_t ret_ref = 0;
2475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2477         return ret_ref;
2478 }
2479
2480 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
2481 CHECK(!owner->result_ok);
2482         return DecodeError_clone(&*owner->contents.err);
2483 }
2484 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_get_err(int64_t owner) {
2485         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
2486         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2487         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
2488         int64_t ret_ref = tag_ptr(ret_copy, true);
2489         return ret_ref;
2490 }
2491
2492 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
2493 CHECK(owner->result_ok);
2494         return *owner->contents.result;
2495 }
2496 int8_tArray  CS_LDK_CResult_TransactionNoneZ_get_ok(int64_t owner) {
2497         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
2498         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
2499         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2500         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2501         return ret_arr;
2502 }
2503
2504 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
2505 CHECK(!owner->result_ok);
2506         return *owner->contents.err;
2507 }
2508 void  CS_LDK_CResult_TransactionNoneZ_get_err(int64_t owner) {
2509         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
2510         CResult_TransactionNoneZ_get_err(owner_conv);
2511 }
2512
2513 typedef struct LDKScoreLookUp_JCalls {
2514         atomic_size_t refcnt;
2515         uint32_t instance_ptr;
2516 } LDKScoreLookUp_JCalls;
2517 static void LDKScoreLookUp_JCalls_free(void* this_arg) {
2518         LDKScoreLookUp_JCalls *j_calls = (LDKScoreLookUp_JCalls*) this_arg;
2519         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2520                 FREE(j_calls);
2521         }
2522 }
2523 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) {
2524         LDKScoreLookUp_JCalls *j_calls = (LDKScoreLookUp_JCalls*) this_arg;
2525         int64_t short_channel_id_conv = short_channel_id;
2526         LDKNodeId source_var = *source;
2527         int64_t source_ref = 0;
2528         source_var = NodeId_clone(&source_var);
2529         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
2530         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
2531         LDKNodeId target_var = *target;
2532         int64_t target_ref = 0;
2533         target_var = NodeId_clone(&target_var);
2534         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
2535         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
2536         LDKChannelUsage usage_var = usage;
2537         int64_t usage_ref = 0;
2538         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
2539         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
2540         LDKProbabilisticScoringFeeParameters score_params_var = *score_params;
2541         int64_t score_params_ref = 0;
2542         score_params_var = ProbabilisticScoringFeeParameters_clone(&score_params_var);
2543         CHECK_INNER_FIELD_ACCESS_OR_NULL(score_params_var);
2544         score_params_ref = tag_ptr(score_params_var.inner, score_params_var.is_owned);
2545         return js_invoke_function_l_lllll(j_calls->instance_ptr, 16, short_channel_id_conv, source_ref, target_ref, usage_ref, score_params_ref);
2546 }
2547 static void LDKScoreLookUp_JCalls_cloned(LDKScoreLookUp* new_obj) {
2548         LDKScoreLookUp_JCalls *j_calls = (LDKScoreLookUp_JCalls*) new_obj->this_arg;
2549         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2550 }
2551 static inline LDKScoreLookUp LDKScoreLookUp_init (int64_t o) {
2552         LDKScoreLookUp_JCalls *calls = MALLOC(sizeof(LDKScoreLookUp_JCalls), "LDKScoreLookUp_JCalls");
2553         atomic_init(&calls->refcnt, 1);
2554         calls->instance_ptr = o;
2555
2556         LDKScoreLookUp ret = {
2557                 .this_arg = (void*) calls,
2558                 .channel_penalty_msat = channel_penalty_msat_LDKScoreLookUp_jcall,
2559                 .free = LDKScoreLookUp_JCalls_free,
2560         };
2561         return ret;
2562 }
2563 uint64_t  CS_LDK_LDKScoreLookUp_new(int32_t o) {
2564         LDKScoreLookUp *res_ptr = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
2565         *res_ptr = LDKScoreLookUp_init(o);
2566         return tag_ptr(res_ptr, true);
2567 }
2568 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) {
2569         void* this_arg_ptr = untag_ptr(this_arg);
2570         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2571         LDKScoreLookUp* this_arg_conv = (LDKScoreLookUp*)this_arg_ptr;
2572         LDKNodeId source_conv;
2573         source_conv.inner = untag_ptr(source);
2574         source_conv.is_owned = ptr_is_owned(source);
2575         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
2576         source_conv.is_owned = false;
2577         LDKNodeId target_conv;
2578         target_conv.inner = untag_ptr(target);
2579         target_conv.is_owned = ptr_is_owned(target);
2580         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
2581         target_conv.is_owned = false;
2582         LDKChannelUsage usage_conv;
2583         usage_conv.inner = untag_ptr(usage);
2584         usage_conv.is_owned = ptr_is_owned(usage);
2585         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
2586         usage_conv = ChannelUsage_clone(&usage_conv);
2587         LDKProbabilisticScoringFeeParameters score_params_conv;
2588         score_params_conv.inner = untag_ptr(score_params);
2589         score_params_conv.is_owned = ptr_is_owned(score_params);
2590         CHECK_INNER_FIELD_ACCESS_OR_NULL(score_params_conv);
2591         score_params_conv.is_owned = false;
2592         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);
2593         return ret_conv;
2594 }
2595
2596 typedef struct LDKScoreUpdate_JCalls {
2597         atomic_size_t refcnt;
2598         uint32_t instance_ptr;
2599 } LDKScoreUpdate_JCalls;
2600 static void LDKScoreUpdate_JCalls_free(void* this_arg) {
2601         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2602         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2603                 FREE(j_calls);
2604         }
2605 }
2606 void payment_path_failed_LDKScoreUpdate_jcall(void* this_arg, const LDKPath * path, uint64_t short_channel_id) {
2607         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2608         LDKPath path_var = *path;
2609         int64_t path_ref = 0;
2610         path_var = Path_clone(&path_var);
2611         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2612         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2613         int64_t short_channel_id_conv = short_channel_id;
2614         js_invoke_function_void_ll(j_calls->instance_ptr, 17, path_ref, short_channel_id_conv);
2615 }
2616 void payment_path_successful_LDKScoreUpdate_jcall(void* this_arg, const LDKPath * path) {
2617         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2618         LDKPath path_var = *path;
2619         int64_t path_ref = 0;
2620         path_var = Path_clone(&path_var);
2621         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2622         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2623         js_invoke_function_void_l(j_calls->instance_ptr, 18, path_ref);
2624 }
2625 void probe_failed_LDKScoreUpdate_jcall(void* this_arg, const LDKPath * path, uint64_t short_channel_id) {
2626         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2627         LDKPath path_var = *path;
2628         int64_t path_ref = 0;
2629         path_var = Path_clone(&path_var);
2630         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2631         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2632         int64_t short_channel_id_conv = short_channel_id;
2633         js_invoke_function_void_ll(j_calls->instance_ptr, 19, path_ref, short_channel_id_conv);
2634 }
2635 void probe_successful_LDKScoreUpdate_jcall(void* this_arg, const LDKPath * path) {
2636         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2637         LDKPath path_var = *path;
2638         int64_t path_ref = 0;
2639         path_var = Path_clone(&path_var);
2640         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2641         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2642         js_invoke_function_void_l(j_calls->instance_ptr, 20, path_ref);
2643 }
2644 static void LDKScoreUpdate_JCalls_cloned(LDKScoreUpdate* new_obj) {
2645         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) new_obj->this_arg;
2646         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2647 }
2648 static inline LDKScoreUpdate LDKScoreUpdate_init (int64_t o) {
2649         LDKScoreUpdate_JCalls *calls = MALLOC(sizeof(LDKScoreUpdate_JCalls), "LDKScoreUpdate_JCalls");
2650         atomic_init(&calls->refcnt, 1);
2651         calls->instance_ptr = o;
2652
2653         LDKScoreUpdate ret = {
2654                 .this_arg = (void*) calls,
2655                 .payment_path_failed = payment_path_failed_LDKScoreUpdate_jcall,
2656                 .payment_path_successful = payment_path_successful_LDKScoreUpdate_jcall,
2657                 .probe_failed = probe_failed_LDKScoreUpdate_jcall,
2658                 .probe_successful = probe_successful_LDKScoreUpdate_jcall,
2659                 .free = LDKScoreUpdate_JCalls_free,
2660         };
2661         return ret;
2662 }
2663 uint64_t  CS_LDK_LDKScoreUpdate_new(int32_t o) {
2664         LDKScoreUpdate *res_ptr = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
2665         *res_ptr = LDKScoreUpdate_init(o);
2666         return tag_ptr(res_ptr, true);
2667 }
2668 void  CS_LDK_ScoreUpdate_payment_path_failed(int64_t this_arg, int64_t path, int64_t short_channel_id) {
2669         void* this_arg_ptr = untag_ptr(this_arg);
2670         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2671         LDKScoreUpdate* this_arg_conv = (LDKScoreUpdate*)this_arg_ptr;
2672         LDKPath path_conv;
2673         path_conv.inner = untag_ptr(path);
2674         path_conv.is_owned = ptr_is_owned(path);
2675         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2676         path_conv.is_owned = false;
2677         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, &path_conv, short_channel_id);
2678 }
2679
2680 void  CS_LDK_ScoreUpdate_payment_path_successful(int64_t this_arg, int64_t path) {
2681         void* this_arg_ptr = untag_ptr(this_arg);
2682         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2683         LDKScoreUpdate* this_arg_conv = (LDKScoreUpdate*)this_arg_ptr;
2684         LDKPath path_conv;
2685         path_conv.inner = untag_ptr(path);
2686         path_conv.is_owned = ptr_is_owned(path);
2687         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2688         path_conv.is_owned = false;
2689         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, &path_conv);
2690 }
2691
2692 void  CS_LDK_ScoreUpdate_probe_failed(int64_t this_arg, int64_t path, int64_t short_channel_id) {
2693         void* this_arg_ptr = untag_ptr(this_arg);
2694         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2695         LDKScoreUpdate* this_arg_conv = (LDKScoreUpdate*)this_arg_ptr;
2696         LDKPath path_conv;
2697         path_conv.inner = untag_ptr(path);
2698         path_conv.is_owned = ptr_is_owned(path);
2699         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2700         path_conv.is_owned = false;
2701         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, &path_conv, short_channel_id);
2702 }
2703
2704 void  CS_LDK_ScoreUpdate_probe_successful(int64_t this_arg, int64_t path) {
2705         void* this_arg_ptr = untag_ptr(this_arg);
2706         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2707         LDKScoreUpdate* this_arg_conv = (LDKScoreUpdate*)this_arg_ptr;
2708         LDKPath path_conv;
2709         path_conv.inner = untag_ptr(path);
2710         path_conv.is_owned = ptr_is_owned(path);
2711         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2712         path_conv.is_owned = false;
2713         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, &path_conv);
2714 }
2715
2716 typedef struct LDKLockableScore_JCalls {
2717         atomic_size_t refcnt;
2718         uint32_t instance_ptr;
2719 } LDKLockableScore_JCalls;
2720 static void LDKLockableScore_JCalls_free(void* this_arg) {
2721         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2722         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2723                 FREE(j_calls);
2724         }
2725 }
2726 LDKScoreLookUp read_lock_LDKLockableScore_jcall(const void* this_arg) {
2727         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2728         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 21);
2729         void* ret_ptr = untag_ptr(ret);
2730         CHECK_ACCESS(ret_ptr);
2731         LDKScoreLookUp ret_conv = *(LDKScoreLookUp*)(ret_ptr);
2732         if (ret_conv.free == LDKScoreLookUp_JCalls_free) {
2733                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2734                 LDKScoreLookUp_JCalls_cloned(&ret_conv);
2735         }// WARNING: we may need a move here but no clone is available for LDKScoreLookUp
2736         
2737         return ret_conv;
2738 }
2739 LDKScoreUpdate write_lock_LDKLockableScore_jcall(const void* this_arg) {
2740         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2741         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 22);
2742         void* ret_ptr = untag_ptr(ret);
2743         CHECK_ACCESS(ret_ptr);
2744         LDKScoreUpdate ret_conv = *(LDKScoreUpdate*)(ret_ptr);
2745         if (ret_conv.free == LDKScoreUpdate_JCalls_free) {
2746                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2747                 LDKScoreUpdate_JCalls_cloned(&ret_conv);
2748         }// WARNING: we may need a move here but no clone is available for LDKScoreUpdate
2749         
2750         return ret_conv;
2751 }
2752 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2753         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2754         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2755 }
2756 static inline LDKLockableScore LDKLockableScore_init (int64_t o) {
2757         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2758         atomic_init(&calls->refcnt, 1);
2759         calls->instance_ptr = o;
2760
2761         LDKLockableScore ret = {
2762                 .this_arg = (void*) calls,
2763                 .read_lock = read_lock_LDKLockableScore_jcall,
2764                 .write_lock = write_lock_LDKLockableScore_jcall,
2765                 .free = LDKLockableScore_JCalls_free,
2766         };
2767         return ret;
2768 }
2769 uint64_t  CS_LDK_LDKLockableScore_new(int32_t o) {
2770         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2771         *res_ptr = LDKLockableScore_init(o);
2772         return tag_ptr(res_ptr, true);
2773 }
2774 int64_t  CS_LDK_LockableScore_read_lock(int64_t this_arg) {
2775         void* this_arg_ptr = untag_ptr(this_arg);
2776         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2777         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2778         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
2779         *ret_ret = (this_arg_conv->read_lock)(this_arg_conv->this_arg);
2780         return tag_ptr(ret_ret, true);
2781 }
2782
2783 int64_t  CS_LDK_LockableScore_write_lock(int64_t this_arg) {
2784         void* this_arg_ptr = untag_ptr(this_arg);
2785         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2786         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2787         LDKScoreUpdate* ret_ret = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
2788         *ret_ret = (this_arg_conv->write_lock)(this_arg_conv->this_arg);
2789         return tag_ptr(ret_ret, true);
2790 }
2791
2792 typedef struct LDKWriteableScore_JCalls {
2793         atomic_size_t refcnt;
2794         uint32_t instance_ptr;
2795         LDKLockableScore_JCalls* LockableScore;
2796 } LDKWriteableScore_JCalls;
2797 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2798         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2799         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2800                 FREE(j_calls);
2801         }
2802 }
2803 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2804         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2805         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 23);
2806         LDKCVec_u8Z ret_ref;
2807         ret_ref.datalen = ret->arr_len;
2808         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2809         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
2810         return ret_ref;
2811 }
2812 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2813         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2814         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2815         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2816 }
2817 static inline LDKWriteableScore LDKWriteableScore_init (int64_t o, int64_t LockableScore) {
2818         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2819         atomic_init(&calls->refcnt, 1);
2820         calls->instance_ptr = o;
2821
2822         LDKWriteableScore ret = {
2823                 .this_arg = (void*) calls,
2824                 .write = write_LDKWriteableScore_jcall,
2825                 .free = LDKWriteableScore_JCalls_free,
2826                 .LockableScore = LDKLockableScore_init(LockableScore),
2827         };
2828         calls->LockableScore = ret.LockableScore.this_arg;
2829         return ret;
2830 }
2831 uint64_t  CS_LDK_LDKWriteableScore_new(int32_t o, int32_t LockableScore) {
2832         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2833         *res_ptr = LDKWriteableScore_init(o, LockableScore);
2834         return tag_ptr(res_ptr, true);
2835 }
2836 int8_tArray  CS_LDK_WriteableScore_write(int64_t this_arg) {
2837         void* this_arg_ptr = untag_ptr(this_arg);
2838         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2839         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2840         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2841         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2842         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2843         CVec_u8Z_free(ret_var);
2844         return ret_arr;
2845 }
2846
2847 uint32_t CS_LDK_LDKCOption_WriteableScoreZ_ty_from_ptr(int64_t ptr) {
2848         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2849         switch(obj->tag) {
2850                 case LDKCOption_WriteableScoreZ_Some: return 0;
2851                 case LDKCOption_WriteableScoreZ_None: return 1;
2852                 default: abort();
2853         }
2854 }
2855 int64_t CS_LDK_LDKCOption_WriteableScoreZ_Some_get_some(int64_t ptr) {
2856         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2857         CHECK(obj->tag == LDKCOption_WriteableScoreZ_Some);
2858         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2859         *some_ret = obj->some;
2860                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2861                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2862                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2863                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2864                         }
2865         return tag_ptr(some_ret, true);
2866 }
2867 static inline void CResult_NoneIOErrorZ_get_ok(LDKCResult_NoneIOErrorZ *NONNULL_PTR owner){
2868 CHECK(owner->result_ok);
2869         return *owner->contents.result;
2870 }
2871 void  CS_LDK_CResult_NoneIOErrorZ_get_ok(int64_t owner) {
2872         LDKCResult_NoneIOErrorZ* owner_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(owner);
2873         CResult_NoneIOErrorZ_get_ok(owner_conv);
2874 }
2875
2876 static inline enum LDKIOError CResult_NoneIOErrorZ_get_err(LDKCResult_NoneIOErrorZ *NONNULL_PTR owner){
2877 CHECK(!owner->result_ok);
2878         return *owner->contents.err;
2879 }
2880 int32_t  CS_LDK_CResult_NoneIOErrorZ_get_err(int64_t owner) {
2881         LDKCResult_NoneIOErrorZ* owner_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(owner);
2882         int32_t ret_conv = LDKIOError_to_cs(CResult_NoneIOErrorZ_get_err(owner_conv));
2883         return ret_conv;
2884 }
2885
2886 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2887         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2888         for (size_t i = 0; i < ret.datalen; i++) {
2889                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2890         }
2891         return ret;
2892 }
2893 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2894         LDKRoute ret = *owner->contents.result;
2895         ret.is_owned = false;
2896         return ret;
2897 }
2898 int64_t  CS_LDK_CResult_RouteLightningErrorZ_get_ok(int64_t owner) {
2899         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2900         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2901         int64_t ret_ref = 0;
2902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2903         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2904         return ret_ref;
2905 }
2906
2907 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2908         LDKLightningError ret = *owner->contents.err;
2909         ret.is_owned = false;
2910         return ret;
2911 }
2912 int64_t  CS_LDK_CResult_RouteLightningErrorZ_get_err(int64_t owner) {
2913         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2914         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2915         int64_t ret_ref = 0;
2916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2918         return ret_ref;
2919 }
2920
2921 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2922         LDKInFlightHtlcs ret = *owner->contents.result;
2923         ret.is_owned = false;
2924         return ret;
2925 }
2926 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_get_ok(int64_t owner) {
2927         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2928         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
2929         int64_t ret_ref = 0;
2930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2932         return ret_ref;
2933 }
2934
2935 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2936 CHECK(!owner->result_ok);
2937         return DecodeError_clone(&*owner->contents.err);
2938 }
2939 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_get_err(int64_t owner) {
2940         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2941         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2942         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
2943         int64_t ret_ref = tag_ptr(ret_copy, true);
2944         return ret_ref;
2945 }
2946
2947 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2948         LDKRouteHop ret = *owner->contents.result;
2949         ret.is_owned = false;
2950         return ret;
2951 }
2952 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_get_ok(int64_t owner) {
2953         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2954         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2955         int64_t ret_ref = 0;
2956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2957         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2958         return ret_ref;
2959 }
2960
2961 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2962 CHECK(!owner->result_ok);
2963         return DecodeError_clone(&*owner->contents.err);
2964 }
2965 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_get_err(int64_t owner) {
2966         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2967         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2968         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2969         int64_t ret_ref = tag_ptr(ret_copy, true);
2970         return ret_ref;
2971 }
2972
2973 static inline LDKCVec_BlindedHopZ CVec_BlindedHopZ_clone(const LDKCVec_BlindedHopZ *orig) {
2974         LDKCVec_BlindedHopZ ret = { .data = MALLOC(sizeof(LDKBlindedHop) * orig->datalen, "LDKCVec_BlindedHopZ clone bytes"), .datalen = orig->datalen };
2975         for (size_t i = 0; i < ret.datalen; i++) {
2976                 ret.data[i] = BlindedHop_clone(&orig->data[i]);
2977         }
2978         return ret;
2979 }
2980 static inline struct LDKBlindedTail CResult_BlindedTailDecodeErrorZ_get_ok(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR owner){
2981         LDKBlindedTail ret = *owner->contents.result;
2982         ret.is_owned = false;
2983         return ret;
2984 }
2985 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_get_ok(int64_t owner) {
2986         LDKCResult_BlindedTailDecodeErrorZ* owner_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(owner);
2987         LDKBlindedTail ret_var = CResult_BlindedTailDecodeErrorZ_get_ok(owner_conv);
2988         int64_t ret_ref = 0;
2989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2991         return ret_ref;
2992 }
2993
2994 static inline struct LDKDecodeError CResult_BlindedTailDecodeErrorZ_get_err(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR owner){
2995 CHECK(!owner->result_ok);
2996         return DecodeError_clone(&*owner->contents.err);
2997 }
2998 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_get_err(int64_t owner) {
2999         LDKCResult_BlindedTailDecodeErrorZ* owner_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(owner);
3000         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3001         *ret_copy = CResult_BlindedTailDecodeErrorZ_get_err(owner_conv);
3002         int64_t ret_ref = tag_ptr(ret_copy, true);
3003         return ret_ref;
3004 }
3005
3006 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
3007         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
3008         for (size_t i = 0; i < ret.datalen; i++) {
3009                 ret.data[i] = RouteHop_clone(&orig->data[i]);
3010         }
3011         return ret;
3012 }
3013 static inline LDKCVec_PathZ CVec_PathZ_clone(const LDKCVec_PathZ *orig) {
3014         LDKCVec_PathZ ret = { .data = MALLOC(sizeof(LDKPath) * orig->datalen, "LDKCVec_PathZ clone bytes"), .datalen = orig->datalen };
3015         for (size_t i = 0; i < ret.datalen; i++) {
3016                 ret.data[i] = Path_clone(&orig->data[i]);
3017         }
3018         return ret;
3019 }
3020 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
3021         LDKRoute ret = *owner->contents.result;
3022         ret.is_owned = false;
3023         return ret;
3024 }
3025 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_get_ok(int64_t owner) {
3026         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
3027         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
3028         int64_t ret_ref = 0;
3029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3030         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3031         return ret_ref;
3032 }
3033
3034 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
3035 CHECK(!owner->result_ok);
3036         return DecodeError_clone(&*owner->contents.err);
3037 }
3038 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_get_err(int64_t owner) {
3039         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
3040         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3041         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
3042         int64_t ret_ref = tag_ptr(ret_copy, true);
3043         return ret_ref;
3044 }
3045
3046 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
3047         LDKRouteParameters ret = *owner->contents.result;
3048         ret.is_owned = false;
3049         return ret;
3050 }
3051 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_get_ok(int64_t owner) {
3052         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
3053         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
3054         int64_t ret_ref = 0;
3055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3057         return ret_ref;
3058 }
3059
3060 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
3061 CHECK(!owner->result_ok);
3062         return DecodeError_clone(&*owner->contents.err);
3063 }
3064 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_get_err(int64_t owner) {
3065         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
3066         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3067         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
3068         int64_t ret_ref = tag_ptr(ret_copy, true);
3069         return ret_ref;
3070 }
3071
3072 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3073         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3074         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3075         return ret;
3076 }
3077 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
3078         LDKPaymentParameters ret = *owner->contents.result;
3079         ret.is_owned = false;
3080         return ret;
3081 }
3082 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_get_ok(int64_t owner) {
3083         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
3084         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
3085         int64_t ret_ref = 0;
3086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3087         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3088         return ret_ref;
3089 }
3090
3091 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
3092 CHECK(!owner->result_ok);
3093         return DecodeError_clone(&*owner->contents.err);
3094 }
3095 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_get_err(int64_t owner) {
3096         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
3097         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3098         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
3099         int64_t ret_ref = tag_ptr(ret_copy, true);
3100         return ret_ref;
3101 }
3102
3103 static inline struct LDKBlindedPayInfo C2Tuple_BlindedPayInfoBlindedPathZ_get_a(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR owner){
3104         LDKBlindedPayInfo ret = owner->a;
3105         ret.is_owned = false;
3106         return ret;
3107 }
3108 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_get_a(int64_t owner) {
3109         LDKC2Tuple_BlindedPayInfoBlindedPathZ* owner_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(owner);
3110         LDKBlindedPayInfo ret_var = C2Tuple_BlindedPayInfoBlindedPathZ_get_a(owner_conv);
3111         int64_t ret_ref = 0;
3112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3114         return ret_ref;
3115 }
3116
3117 static inline struct LDKBlindedPath C2Tuple_BlindedPayInfoBlindedPathZ_get_b(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR owner){
3118         LDKBlindedPath ret = owner->b;
3119         ret.is_owned = false;
3120         return ret;
3121 }
3122 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_get_b(int64_t owner) {
3123         LDKC2Tuple_BlindedPayInfoBlindedPathZ* owner_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(owner);
3124         LDKBlindedPath ret_var = C2Tuple_BlindedPayInfoBlindedPathZ_get_b(owner_conv);
3125         int64_t ret_ref = 0;
3126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3128         return ret_ref;
3129 }
3130
3131 static inline LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_clone(const LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ *orig) {
3132         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ) * orig->datalen, "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ clone bytes"), .datalen = orig->datalen };
3133         for (size_t i = 0; i < ret.datalen; i++) {
3134                 ret.data[i] = C2Tuple_BlindedPayInfoBlindedPathZ_clone(&orig->data[i]);
3135         }
3136         return ret;
3137 }
3138 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
3139         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
3140         for (size_t i = 0; i < ret.datalen; i++) {
3141                 ret.data[i] = RouteHint_clone(&orig->data[i]);
3142         }
3143         return ret;
3144 }
3145 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
3146         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
3147         for (size_t i = 0; i < ret.datalen; i++) {
3148                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
3149         }
3150         return ret;
3151 }
3152 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
3153         LDKRouteHint ret = *owner->contents.result;
3154         ret.is_owned = false;
3155         return ret;
3156 }
3157 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_get_ok(int64_t owner) {
3158         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
3159         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
3160         int64_t ret_ref = 0;
3161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3162         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3163         return ret_ref;
3164 }
3165
3166 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
3167 CHECK(!owner->result_ok);
3168         return DecodeError_clone(&*owner->contents.err);
3169 }
3170 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_get_err(int64_t owner) {
3171         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
3172         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3173         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
3174         int64_t ret_ref = tag_ptr(ret_copy, true);
3175         return ret_ref;
3176 }
3177
3178 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
3179         LDKRouteHintHop ret = *owner->contents.result;
3180         ret.is_owned = false;
3181         return ret;
3182 }
3183 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_get_ok(int64_t owner) {
3184         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
3185         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
3186         int64_t ret_ref = 0;
3187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3189         return ret_ref;
3190 }
3191
3192 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
3193 CHECK(!owner->result_ok);
3194         return DecodeError_clone(&*owner->contents.err);
3195 }
3196 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_get_err(int64_t owner) {
3197         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
3198         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3199         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
3200         int64_t ret_ref = tag_ptr(ret_copy, true);
3201         return ret_ref;
3202 }
3203
3204 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3205         LDKFixedPenaltyScorer ret = *owner->contents.result;
3206         ret.is_owned = false;
3207         return ret;
3208 }
3209 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(int64_t owner) {
3210         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3211         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3212         int64_t ret_ref = 0;
3213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3215         return ret_ref;
3216 }
3217
3218 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3219 CHECK(!owner->result_ok);
3220         return DecodeError_clone(&*owner->contents.err);
3221 }
3222 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(int64_t owner) {
3223         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3224         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3225         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3226         int64_t ret_ref = tag_ptr(ret_copy, true);
3227         return ret_ref;
3228 }
3229
3230 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3231         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3232         for (size_t i = 0; i < ret.datalen; i++) {
3233                 ret.data[i] = NodeId_clone(&orig->data[i]);
3234         }
3235         return ret;
3236 }
3237 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3238         return owner->a;
3239 }
3240 int64_t  CS_LDK_C2Tuple_u64u64Z_get_a(int64_t owner) {
3241         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3242         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3243         return ret_conv;
3244 }
3245
3246 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3247         return owner->b;
3248 }
3249 int64_t  CS_LDK_C2Tuple_u64u64Z_get_b(int64_t owner) {
3250         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3251         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3252         return ret_conv;
3253 }
3254
3255 uint32_t CS_LDK_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr(int64_t ptr) {
3256         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
3257         switch(obj->tag) {
3258                 case LDKCOption_C2Tuple_u64u64ZZ_Some: return 0;
3259                 case LDKCOption_C2Tuple_u64u64ZZ_None: return 1;
3260                 default: abort();
3261         }
3262 }
3263 int64_t CS_LDK_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some(int64_t ptr) {
3264         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
3265         CHECK(obj->tag == LDKCOption_C2Tuple_u64u64ZZ_Some);
3266         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3267         *some_conv = obj->some;
3268                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3269         return tag_ptr(some_conv, true);
3270 }
3271 static inline struct LDKThirtyTwoU16s C2Tuple_Z_get_a(LDKC2Tuple_Z *NONNULL_PTR owner){
3272         return owner->a;
3273 }
3274 int16_tArray  CS_LDK_C2Tuple_Z_get_a(int64_t owner) {
3275         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
3276         int16_tArray ret_arr = init_int16_tArray(32, __LINE__);
3277         memcpy(ret_arr->elems, C2Tuple_Z_get_a(owner_conv).data, 32 * 2);
3278         return ret_arr;
3279 }
3280
3281 static inline struct LDKThirtyTwoU16s C2Tuple_Z_get_b(LDKC2Tuple_Z *NONNULL_PTR owner){
3282         return owner->b;
3283 }
3284 int16_tArray  CS_LDK_C2Tuple_Z_get_b(int64_t owner) {
3285         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
3286         int16_tArray ret_arr = init_int16_tArray(32, __LINE__);
3287         memcpy(ret_arr->elems, C2Tuple_Z_get_b(owner_conv).data, 32 * 2);
3288         return ret_arr;
3289 }
3290
3291 static inline struct LDKThirtyTwoU16s C2Tuple__u1632_u1632Z_get_a(LDKC2Tuple__u1632_u1632Z *NONNULL_PTR owner){
3292         return owner->a;
3293 }
3294 int16_tArray  CS_LDK_C2Tuple__u1632_u1632Z_get_a(int64_t owner) {
3295         LDKC2Tuple__u1632_u1632Z* owner_conv = (LDKC2Tuple__u1632_u1632Z*)untag_ptr(owner);
3296         int16_tArray ret_arr = init_int16_tArray(32, __LINE__);
3297         memcpy(ret_arr->elems, C2Tuple__u1632_u1632Z_get_a(owner_conv).data, 32 * 2);
3298         return ret_arr;
3299 }
3300
3301 static inline struct LDKThirtyTwoU16s C2Tuple__u1632_u1632Z_get_b(LDKC2Tuple__u1632_u1632Z *NONNULL_PTR owner){
3302         return owner->b;
3303 }
3304 int16_tArray  CS_LDK_C2Tuple__u1632_u1632Z_get_b(int64_t owner) {
3305         LDKC2Tuple__u1632_u1632Z* owner_conv = (LDKC2Tuple__u1632_u1632Z*)untag_ptr(owner);
3306         int16_tArray ret_arr = init_int16_tArray(32, __LINE__);
3307         memcpy(ret_arr->elems, C2Tuple__u1632_u1632Z_get_b(owner_conv).data, 32 * 2);
3308         return ret_arr;
3309 }
3310
3311 uint32_t CS_LDK_LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_ty_from_ptr(int64_t ptr) {
3312         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *obj = (LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ*)untag_ptr(ptr);
3313         switch(obj->tag) {
3314                 case LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_Some: return 0;
3315                 case LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_None: return 1;
3316                 default: abort();
3317         }
3318 }
3319 int64_t CS_LDK_LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_Some_get_some(int64_t ptr) {
3320         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *obj = (LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ*)untag_ptr(ptr);
3321         CHECK(obj->tag == LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_Some);
3322         LDKC2Tuple__u1632_u1632Z* some_conv = &obj->some;
3323                         // WARNING: we really need to clone here, but no clone is available for LDKC2Tuple__u1632_u1632Z
3324         return tag_ptr(some_conv, false);
3325 }
3326 uint32_t CS_LDK_LDKCOption_f64Z_ty_from_ptr(int64_t ptr) {
3327         LDKCOption_f64Z *obj = (LDKCOption_f64Z*)untag_ptr(ptr);
3328         switch(obj->tag) {
3329                 case LDKCOption_f64Z_Some: return 0;
3330                 case LDKCOption_f64Z_None: return 1;
3331                 default: abort();
3332         }
3333 }
3334 double CS_LDK_LDKCOption_f64Z_Some_get_some(int64_t ptr) {
3335         LDKCOption_f64Z *obj = (LDKCOption_f64Z*)untag_ptr(ptr);
3336         CHECK(obj->tag == LDKCOption_f64Z_Some);
3337         double some_conv = obj->some;
3338         return some_conv;
3339 }
3340 typedef struct LDKLogger_JCalls {
3341         atomic_size_t refcnt;
3342         uint32_t instance_ptr;
3343 } LDKLogger_JCalls;
3344 static void LDKLogger_JCalls_free(void* this_arg) {
3345         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3346         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3347                 FREE(j_calls);
3348         }
3349 }
3350 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3351         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3352         LDKRecord record_var = *record;
3353         int64_t record_ref = 0;
3354         record_var = Record_clone(&record_var);
3355         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3356         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
3357         js_invoke_function_void_l(j_calls->instance_ptr, 24, record_ref);
3358 }
3359 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3360         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3361         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3362 }
3363 static inline LDKLogger LDKLogger_init (int64_t o) {
3364         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3365         atomic_init(&calls->refcnt, 1);
3366         calls->instance_ptr = o;
3367
3368         LDKLogger ret = {
3369                 .this_arg = (void*) calls,
3370                 .log = log_LDKLogger_jcall,
3371                 .free = LDKLogger_JCalls_free,
3372         };
3373         return ret;
3374 }
3375 uint64_t  CS_LDK_LDKLogger_new(int32_t o) {
3376         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3377         *res_ptr = LDKLogger_init(o);
3378         return tag_ptr(res_ptr, true);
3379 }
3380 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3381         LDKProbabilisticScorer ret = *owner->contents.result;
3382         ret.is_owned = false;
3383         return ret;
3384 }
3385 int64_t  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(int64_t owner) {
3386         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3387         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3388         int64_t ret_ref = 0;
3389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3390         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3391         return ret_ref;
3392 }
3393
3394 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3395 CHECK(!owner->result_ok);
3396         return DecodeError_clone(&*owner->contents.err);
3397 }
3398 int64_t  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_get_err(int64_t owner) {
3399         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3400         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3401         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3402         int64_t ret_ref = tag_ptr(ret_copy, true);
3403         return ret_ref;
3404 }
3405
3406 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3407         return owner->a;
3408 }
3409 int64_t  CS_LDK_C2Tuple_usizeTransactionZ_get_a(int64_t owner) {
3410         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3411         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3412         return ret_conv;
3413 }
3414
3415 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3416         return owner->b;
3417 }
3418 int8_tArray  CS_LDK_C2Tuple_usizeTransactionZ_get_b(int64_t owner) {
3419         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3420         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3421         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3422         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3423         return ret_arr;
3424 }
3425
3426 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3427         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3428         for (size_t i = 0; i < ret.datalen; i++) {
3429                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3430         }
3431         return ret;
3432 }
3433 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_a(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ *NONNULL_PTR owner){
3434         return ThirtyTwoBytes_clone(&owner->a);
3435 }
3436 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_a(int64_t owner) {
3437         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)untag_ptr(owner);
3438         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3439         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_a(owner_conv).data, 32);
3440         return ret_arr;
3441 }
3442
3443 static inline struct LDKCOption_ThirtyTwoBytesZ C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_b(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ *NONNULL_PTR owner){
3444         return COption_ThirtyTwoBytesZ_clone(&owner->b);
3445 }
3446 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_b(int64_t owner) {
3447         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)untag_ptr(owner);
3448         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
3449         *ret_copy = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_b(owner_conv);
3450         int64_t ret_ref = tag_ptr(ret_copy, true);
3451         return ret_ref;
3452 }
3453
3454 static inline LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ CVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ *orig) {
3455         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ clone bytes"), .datalen = orig->datalen };
3456         for (size_t i = 0; i < ret.datalen; i++) {
3457                 ret.data[i] = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone(&orig->data[i]);
3458         }
3459         return ret;
3460 }
3461 static inline enum LDKChannelMonitorUpdateStatus CResult_ChannelMonitorUpdateStatusNoneZ_get_ok(LDKCResult_ChannelMonitorUpdateStatusNoneZ *NONNULL_PTR owner){
3462 CHECK(owner->result_ok);
3463         return ChannelMonitorUpdateStatus_clone(&*owner->contents.result);
3464 }
3465 int32_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_get_ok(int64_t owner) {
3466         LDKCResult_ChannelMonitorUpdateStatusNoneZ* owner_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(owner);
3467         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(CResult_ChannelMonitorUpdateStatusNoneZ_get_ok(owner_conv));
3468         return ret_conv;
3469 }
3470
3471 static inline void CResult_ChannelMonitorUpdateStatusNoneZ_get_err(LDKCResult_ChannelMonitorUpdateStatusNoneZ *NONNULL_PTR owner){
3472 CHECK(!owner->result_ok);
3473         return *owner->contents.err;
3474 }
3475 void  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_get_err(int64_t owner) {
3476         LDKCResult_ChannelMonitorUpdateStatusNoneZ* owner_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(owner);
3477         CResult_ChannelMonitorUpdateStatusNoneZ_get_err(owner_conv);
3478 }
3479
3480 uint32_t CS_LDK_LDKMonitorEvent_ty_from_ptr(int64_t ptr) {
3481         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3482         switch(obj->tag) {
3483                 case LDKMonitorEvent_HTLCEvent: return 0;
3484                 case LDKMonitorEvent_HolderForceClosed: return 1;
3485                 case LDKMonitorEvent_Completed: return 2;
3486                 default: abort();
3487         }
3488 }
3489 int64_t CS_LDK_LDKMonitorEvent_HTLCEvent_get_htlc_event(int64_t ptr) {
3490         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3491         CHECK(obj->tag == LDKMonitorEvent_HTLCEvent);
3492         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3493                         int64_t htlc_event_ref = 0;
3494                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3495                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
3496         return htlc_event_ref;
3497 }
3498 int64_t CS_LDK_LDKMonitorEvent_HolderForceClosed_get_holder_force_closed(int64_t ptr) {
3499         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3500         CHECK(obj->tag == LDKMonitorEvent_HolderForceClosed);
3501         LDKOutPoint holder_force_closed_var = obj->holder_force_closed;
3502                         int64_t holder_force_closed_ref = 0;
3503                         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_force_closed_var);
3504                         holder_force_closed_ref = tag_ptr(holder_force_closed_var.inner, false);
3505         return holder_force_closed_ref;
3506 }
3507 int64_t CS_LDK_LDKMonitorEvent_Completed_get_funding_txo(int64_t ptr) {
3508         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3509         CHECK(obj->tag == LDKMonitorEvent_Completed);
3510         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
3511                         int64_t funding_txo_ref = 0;
3512                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3513                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
3514         return funding_txo_ref;
3515 }
3516 int64_t CS_LDK_LDKMonitorEvent_Completed_get_monitor_update_id(int64_t ptr) {
3517         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3518         CHECK(obj->tag == LDKMonitorEvent_Completed);
3519         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
3520         return monitor_update_id_conv;
3521 }
3522 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3523         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3524         for (size_t i = 0; i < ret.datalen; i++) {
3525                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3526         }
3527         return ret;
3528 }
3529 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3530         LDKOutPoint ret = owner->a;
3531         ret.is_owned = false;
3532         return ret;
3533 }
3534 int64_t  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(int64_t owner) {
3535         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3536         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3537         int64_t ret_ref = 0;
3538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3539         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3540         return ret_ref;
3541 }
3542
3543 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3544         return CVec_MonitorEventZ_clone(&owner->b);
3545 }
3546 int64_tArray  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(int64_t owner) {
3547         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3548         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3549         int64_tArray ret_arr = NULL;
3550         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
3551         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
3552         for (size_t o = 0; o < ret_var.datalen; o++) {
3553                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3554                 *ret_conv_14_copy = ret_var.data[o];
3555                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
3556                 ret_arr_ptr[o] = ret_conv_14_ref;
3557         }
3558         
3559         FREE(ret_var.data);
3560         return ret_arr;
3561 }
3562
3563 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3564         return owner->c;
3565 }
3566 int8_tArray  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(int64_t owner) {
3567         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3568         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3569         memcpy(ret_arr->elems, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form, 33);
3570         return ret_arr;
3571 }
3572
3573 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3574         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3575         for (size_t i = 0; i < ret.datalen; i++) {
3576                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3577         }
3578         return ret;
3579 }
3580 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3581         LDKInitFeatures ret = *owner->contents.result;
3582         ret.is_owned = false;
3583         return ret;
3584 }
3585 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3586         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3587         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3588         int64_t ret_ref = 0;
3589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3591         return ret_ref;
3592 }
3593
3594 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3595 CHECK(!owner->result_ok);
3596         return DecodeError_clone(&*owner->contents.err);
3597 }
3598 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_get_err(int64_t owner) {
3599         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3600         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3601         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3602         int64_t ret_ref = tag_ptr(ret_copy, true);
3603         return ret_ref;
3604 }
3605
3606 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3607         LDKChannelFeatures ret = *owner->contents.result;
3608         ret.is_owned = false;
3609         return ret;
3610 }
3611 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3612         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3613         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3614         int64_t ret_ref = 0;
3615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3616         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3617         return ret_ref;
3618 }
3619
3620 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3621 CHECK(!owner->result_ok);
3622         return DecodeError_clone(&*owner->contents.err);
3623 }
3624 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_get_err(int64_t owner) {
3625         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3626         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3627         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3628         int64_t ret_ref = tag_ptr(ret_copy, true);
3629         return ret_ref;
3630 }
3631
3632 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3633         LDKNodeFeatures ret = *owner->contents.result;
3634         ret.is_owned = false;
3635         return ret;
3636 }
3637 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3638         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3639         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3640         int64_t ret_ref = 0;
3641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3642         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3643         return ret_ref;
3644 }
3645
3646 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3647 CHECK(!owner->result_ok);
3648         return DecodeError_clone(&*owner->contents.err);
3649 }
3650 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_get_err(int64_t owner) {
3651         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3652         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3653         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3654         int64_t ret_ref = tag_ptr(ret_copy, true);
3655         return ret_ref;
3656 }
3657
3658 static inline struct LDKBolt11InvoiceFeatures CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3659         LDKBolt11InvoiceFeatures ret = *owner->contents.result;
3660         ret.is_owned = false;
3661         return ret;
3662 }
3663 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3664         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3665         LDKBolt11InvoiceFeatures ret_var = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3666         int64_t ret_ref = 0;
3667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3668         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3669         return ret_ref;
3670 }
3671
3672 static inline struct LDKDecodeError CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3673 CHECK(!owner->result_ok);
3674         return DecodeError_clone(&*owner->contents.err);
3675 }
3676 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_err(int64_t owner) {
3677         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3678         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3679         *ret_copy = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3680         int64_t ret_ref = tag_ptr(ret_copy, true);
3681         return ret_ref;
3682 }
3683
3684 static inline struct LDKBolt12InvoiceFeatures CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3685         LDKBolt12InvoiceFeatures ret = *owner->contents.result;
3686         ret.is_owned = false;
3687         return ret;
3688 }
3689 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3690         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3691         LDKBolt12InvoiceFeatures ret_var = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3692         int64_t ret_ref = 0;
3693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3694         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3695         return ret_ref;
3696 }
3697
3698 static inline struct LDKDecodeError CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3699 CHECK(!owner->result_ok);
3700         return DecodeError_clone(&*owner->contents.err);
3701 }
3702 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_err(int64_t owner) {
3703         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3704         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3705         *ret_copy = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3706         int64_t ret_ref = tag_ptr(ret_copy, true);
3707         return ret_ref;
3708 }
3709
3710 static inline struct LDKBlindedHopFeatures CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
3711         LDKBlindedHopFeatures ret = *owner->contents.result;
3712         ret.is_owned = false;
3713         return ret;
3714 }
3715 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3716         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
3717         LDKBlindedHopFeatures ret_var = CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(owner_conv);
3718         int64_t ret_ref = 0;
3719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3720         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3721         return ret_ref;
3722 }
3723
3724 static inline struct LDKDecodeError CResult_BlindedHopFeaturesDecodeErrorZ_get_err(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
3725 CHECK(!owner->result_ok);
3726         return DecodeError_clone(&*owner->contents.err);
3727 }
3728 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_get_err(int64_t owner) {
3729         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
3730         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3731         *ret_copy = CResult_BlindedHopFeaturesDecodeErrorZ_get_err(owner_conv);
3732         int64_t ret_ref = tag_ptr(ret_copy, true);
3733         return ret_ref;
3734 }
3735
3736 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3737         LDKChannelTypeFeatures ret = *owner->contents.result;
3738         ret.is_owned = false;
3739         return ret;
3740 }
3741 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3742         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3743         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3744         int64_t ret_ref = 0;
3745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3747         return ret_ref;
3748 }
3749
3750 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3751 CHECK(!owner->result_ok);
3752         return DecodeError_clone(&*owner->contents.err);
3753 }
3754 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(int64_t owner) {
3755         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3756         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3757         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3758         int64_t ret_ref = tag_ptr(ret_copy, true);
3759         return ret_ref;
3760 }
3761
3762 static inline struct LDKOffer CResult_OfferBolt12ParseErrorZ_get_ok(LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR owner){
3763         LDKOffer ret = *owner->contents.result;
3764         ret.is_owned = false;
3765         return ret;
3766 }
3767 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_get_ok(int64_t owner) {
3768         LDKCResult_OfferBolt12ParseErrorZ* owner_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(owner);
3769         LDKOffer ret_var = CResult_OfferBolt12ParseErrorZ_get_ok(owner_conv);
3770         int64_t ret_ref = 0;
3771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3772         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3773         return ret_ref;
3774 }
3775
3776 static inline struct LDKBolt12ParseError CResult_OfferBolt12ParseErrorZ_get_err(LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR owner){
3777         LDKBolt12ParseError ret = *owner->contents.err;
3778         ret.is_owned = false;
3779         return ret;
3780 }
3781 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_get_err(int64_t owner) {
3782         LDKCResult_OfferBolt12ParseErrorZ* owner_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(owner);
3783         LDKBolt12ParseError ret_var = CResult_OfferBolt12ParseErrorZ_get_err(owner_conv);
3784         int64_t ret_ref = 0;
3785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3787         return ret_ref;
3788 }
3789
3790 static inline struct LDKPublicKey CResult_PublicKeySecp256k1ErrorZ_get_ok(LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR owner){
3791 CHECK(owner->result_ok);
3792         return *owner->contents.result;
3793 }
3794 int8_tArray  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_get_ok(int64_t owner) {
3795         LDKCResult_PublicKeySecp256k1ErrorZ* owner_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(owner);
3796         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3797         memcpy(ret_arr->elems, CResult_PublicKeySecp256k1ErrorZ_get_ok(owner_conv).compressed_form, 33);
3798         return ret_arr;
3799 }
3800
3801 static inline enum LDKSecp256k1Error CResult_PublicKeySecp256k1ErrorZ_get_err(LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR owner){
3802 CHECK(!owner->result_ok);
3803         return *owner->contents.err;
3804 }
3805 int32_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_get_err(int64_t owner) {
3806         LDKCResult_PublicKeySecp256k1ErrorZ* owner_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(owner);
3807         int32_t ret_conv = LDKSecp256k1Error_to_cs(CResult_PublicKeySecp256k1ErrorZ_get_err(owner_conv));
3808         return ret_conv;
3809 }
3810
3811 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3812         LDKNodeId ret = *owner->contents.result;
3813         ret.is_owned = false;
3814         return ret;
3815 }
3816 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_get_ok(int64_t owner) {
3817         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
3818         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3819         int64_t ret_ref = 0;
3820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3821         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3822         return ret_ref;
3823 }
3824
3825 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3826 CHECK(!owner->result_ok);
3827         return DecodeError_clone(&*owner->contents.err);
3828 }
3829 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_get_err(int64_t owner) {
3830         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
3831         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3832         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3833         int64_t ret_ref = tag_ptr(ret_copy, true);
3834         return ret_ref;
3835 }
3836
3837 uint32_t CS_LDK_LDKNetworkUpdate_ty_from_ptr(int64_t ptr) {
3838         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3839         switch(obj->tag) {
3840                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
3841                 case LDKNetworkUpdate_ChannelFailure: return 1;
3842                 case LDKNetworkUpdate_NodeFailure: return 2;
3843                 default: abort();
3844         }
3845 }
3846 int64_t CS_LDK_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(int64_t ptr) {
3847         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3848         CHECK(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
3849         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
3850                         int64_t msg_ref = 0;
3851                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3852                         msg_ref = tag_ptr(msg_var.inner, false);
3853         return msg_ref;
3854 }
3855 int64_t CS_LDK_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(int64_t ptr) {
3856         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3857         CHECK(obj->tag == LDKNetworkUpdate_ChannelFailure);
3858         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
3859         return short_channel_id_conv;
3860 }
3861 jboolean CS_LDK_LDKNetworkUpdate_ChannelFailure_get_is_permanent(int64_t ptr) {
3862         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3863         CHECK(obj->tag == LDKNetworkUpdate_ChannelFailure);
3864         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
3865         return is_permanent_conv;
3866 }
3867 int8_tArray CS_LDK_LDKNetworkUpdate_NodeFailure_get_node_id(int64_t ptr) {
3868         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3869         CHECK(obj->tag == LDKNetworkUpdate_NodeFailure);
3870         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3871         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
3872         return node_id_arr;
3873 }
3874 jboolean CS_LDK_LDKNetworkUpdate_NodeFailure_get_is_permanent(int64_t ptr) {
3875         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3876         CHECK(obj->tag == LDKNetworkUpdate_NodeFailure);
3877         jboolean is_permanent_conv = obj->node_failure.is_permanent;
3878         return is_permanent_conv;
3879 }
3880 uint32_t CS_LDK_LDKCOption_NetworkUpdateZ_ty_from_ptr(int64_t ptr) {
3881         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
3882         switch(obj->tag) {
3883                 case LDKCOption_NetworkUpdateZ_Some: return 0;
3884                 case LDKCOption_NetworkUpdateZ_None: return 1;
3885                 default: abort();
3886         }
3887 }
3888 int64_t CS_LDK_LDKCOption_NetworkUpdateZ_Some_get_some(int64_t ptr) {
3889         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
3890         CHECK(obj->tag == LDKCOption_NetworkUpdateZ_Some);
3891         int64_t some_ref = tag_ptr(&obj->some, false);
3892         return some_ref;
3893 }
3894 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3895 CHECK(owner->result_ok);
3896         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3897 }
3898 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(int64_t owner) {
3899         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
3900         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3901         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3902         int64_t ret_ref = tag_ptr(ret_copy, true);
3903         return ret_ref;
3904 }
3905
3906 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3907 CHECK(!owner->result_ok);
3908         return DecodeError_clone(&*owner->contents.err);
3909 }
3910 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(int64_t owner) {
3911         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
3912         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3913         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3914         int64_t ret_ref = tag_ptr(ret_copy, true);
3915         return ret_ref;
3916 }
3917
3918 static inline struct LDKTxOut CResult_TxOutUtxoLookupErrorZ_get_ok(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
3919 CHECK(owner->result_ok);
3920         return TxOut_clone(&*owner->contents.result);
3921 }
3922 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_get_ok(int64_t owner) {
3923         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
3924         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3925         *ret_ref = CResult_TxOutUtxoLookupErrorZ_get_ok(owner_conv);
3926         return tag_ptr(ret_ref, true);
3927 }
3928
3929 static inline enum LDKUtxoLookupError CResult_TxOutUtxoLookupErrorZ_get_err(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
3930 CHECK(!owner->result_ok);
3931         return UtxoLookupError_clone(&*owner->contents.err);
3932 }
3933 int32_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_get_err(int64_t owner) {
3934         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
3935         int32_t ret_conv = LDKUtxoLookupError_to_cs(CResult_TxOutUtxoLookupErrorZ_get_err(owner_conv));
3936         return ret_conv;
3937 }
3938
3939 uint32_t CS_LDK_LDKUtxoResult_ty_from_ptr(int64_t ptr) {
3940         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
3941         switch(obj->tag) {
3942                 case LDKUtxoResult_Sync: return 0;
3943                 case LDKUtxoResult_Async: return 1;
3944                 default: abort();
3945         }
3946 }
3947 int64_t CS_LDK_LDKUtxoResult_Sync_get_sync(int64_t ptr) {
3948         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
3949         CHECK(obj->tag == LDKUtxoResult_Sync);
3950         LDKCResult_TxOutUtxoLookupErrorZ* sync_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
3951         *sync_conv = obj->sync;
3952                         *sync_conv = CResult_TxOutUtxoLookupErrorZ_clone(sync_conv);
3953         return tag_ptr(sync_conv, true);
3954 }
3955 int64_t CS_LDK_LDKUtxoResult_Async_get_async(int64_t ptr) {
3956         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
3957         CHECK(obj->tag == LDKUtxoResult_Async);
3958         LDKUtxoFuture async_var = obj->async;
3959                         int64_t async_ref = 0;
3960                         CHECK_INNER_FIELD_ACCESS_OR_NULL(async_var);
3961                         async_ref = tag_ptr(async_var.inner, false);
3962         return async_ref;
3963 }
3964 typedef struct LDKUtxoLookup_JCalls {
3965         atomic_size_t refcnt;
3966         uint32_t instance_ptr;
3967 } LDKUtxoLookup_JCalls;
3968 static void LDKUtxoLookup_JCalls_free(void* this_arg) {
3969         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
3970         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3971                 FREE(j_calls);
3972         }
3973 }
3974 LDKUtxoResult get_utxo_LDKUtxoLookup_jcall(const void* this_arg, const uint8_t (* chain_hash)[32], uint64_t short_channel_id) {
3975         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
3976         int8_tArray chain_hash_arr = init_int8_tArray(32, __LINE__);
3977         memcpy(chain_hash_arr->elems, *chain_hash, 32);
3978         int64_t short_channel_id_conv = short_channel_id;
3979         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 25, (int64_t)chain_hash_arr, short_channel_id_conv);
3980         void* ret_ptr = untag_ptr(ret);
3981         CHECK_ACCESS(ret_ptr);
3982         LDKUtxoResult ret_conv = *(LDKUtxoResult*)(ret_ptr);
3983         FREE(untag_ptr(ret));
3984         return ret_conv;
3985 }
3986 static void LDKUtxoLookup_JCalls_cloned(LDKUtxoLookup* new_obj) {
3987         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) new_obj->this_arg;
3988         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3989 }
3990 static inline LDKUtxoLookup LDKUtxoLookup_init (int64_t o) {
3991         LDKUtxoLookup_JCalls *calls = MALLOC(sizeof(LDKUtxoLookup_JCalls), "LDKUtxoLookup_JCalls");
3992         atomic_init(&calls->refcnt, 1);
3993         calls->instance_ptr = o;
3994
3995         LDKUtxoLookup ret = {
3996                 .this_arg = (void*) calls,
3997                 .get_utxo = get_utxo_LDKUtxoLookup_jcall,
3998                 .free = LDKUtxoLookup_JCalls_free,
3999         };
4000         return ret;
4001 }
4002 uint64_t  CS_LDK_LDKUtxoLookup_new(int32_t o) {
4003         LDKUtxoLookup *res_ptr = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
4004         *res_ptr = LDKUtxoLookup_init(o);
4005         return tag_ptr(res_ptr, true);
4006 }
4007 int64_t  CS_LDK_UtxoLookup_get_utxo(int64_t this_arg, int8_tArray chain_hash, int64_t short_channel_id) {
4008         void* this_arg_ptr = untag_ptr(this_arg);
4009         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4010         LDKUtxoLookup* this_arg_conv = (LDKUtxoLookup*)this_arg_ptr;
4011         uint8_t chain_hash_arr[32];
4012         CHECK(chain_hash->arr_len == 32);
4013         memcpy(chain_hash_arr, chain_hash->elems, 32); FREE(chain_hash);
4014         uint8_t (*chain_hash_ref)[32] = &chain_hash_arr;
4015         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
4016         *ret_copy = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, chain_hash_ref, short_channel_id);
4017         int64_t ret_ref = tag_ptr(ret_copy, true);
4018         return ret_ref;
4019 }
4020
4021 uint32_t CS_LDK_LDKCOption_UtxoLookupZ_ty_from_ptr(int64_t ptr) {
4022         LDKCOption_UtxoLookupZ *obj = (LDKCOption_UtxoLookupZ*)untag_ptr(ptr);
4023         switch(obj->tag) {
4024                 case LDKCOption_UtxoLookupZ_Some: return 0;
4025                 case LDKCOption_UtxoLookupZ_None: return 1;
4026                 default: abort();
4027         }
4028 }
4029 int64_t CS_LDK_LDKCOption_UtxoLookupZ_Some_get_some(int64_t ptr) {
4030         LDKCOption_UtxoLookupZ *obj = (LDKCOption_UtxoLookupZ*)untag_ptr(ptr);
4031         CHECK(obj->tag == LDKCOption_UtxoLookupZ_Some);
4032         LDKUtxoLookup* some_ret = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
4033         *some_ret = obj->some;
4034                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4035                         if ((*some_ret).free == LDKUtxoLookup_JCalls_free) {
4036                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4037                                 LDKUtxoLookup_JCalls_cloned(&(*some_ret));
4038                         }
4039         return tag_ptr(some_ret, true);
4040 }
4041 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4042 CHECK(owner->result_ok);
4043         return *owner->contents.result;
4044 }
4045 void  CS_LDK_CResult_NoneLightningErrorZ_get_ok(int64_t owner) {
4046         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4047         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4048 }
4049
4050 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4051         LDKLightningError ret = *owner->contents.err;
4052         ret.is_owned = false;
4053         return ret;
4054 }
4055 int64_t  CS_LDK_CResult_NoneLightningErrorZ_get_err(int64_t owner) {
4056         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4057         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4058         int64_t ret_ref = 0;
4059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4060         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4061         return ret_ref;
4062 }
4063
4064 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4065 CHECK(owner->result_ok);
4066         return *owner->contents.result;
4067 }
4068 jboolean  CS_LDK_CResult_boolLightningErrorZ_get_ok(int64_t owner) {
4069         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4070         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4071         return ret_conv;
4072 }
4073
4074 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4075         LDKLightningError ret = *owner->contents.err;
4076         ret.is_owned = false;
4077         return ret;
4078 }
4079 int64_t  CS_LDK_CResult_boolLightningErrorZ_get_err(int64_t owner) {
4080         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4081         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4082         int64_t ret_ref = 0;
4083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4084         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4085         return ret_ref;
4086 }
4087
4088 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4089         LDKChannelAnnouncement ret = owner->a;
4090         ret.is_owned = false;
4091         return ret;
4092 }
4093 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(int64_t owner) {
4094         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4095         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4096         int64_t ret_ref = 0;
4097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4099         return ret_ref;
4100 }
4101
4102 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4103         LDKChannelUpdate ret = owner->b;
4104         ret.is_owned = false;
4105         return ret;
4106 }
4107 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(int64_t owner) {
4108         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4109         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4110         int64_t ret_ref = 0;
4111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4113         return ret_ref;
4114 }
4115
4116 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4117         LDKChannelUpdate ret = owner->c;
4118         ret.is_owned = false;
4119         return ret;
4120 }
4121 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(int64_t owner) {
4122         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4123         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4124         int64_t ret_ref = 0;
4125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4127         return ret_ref;
4128 }
4129
4130 uint32_t CS_LDK_LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_ty_from_ptr(int64_t ptr) {
4131         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4132         switch(obj->tag) {
4133                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: return 0;
4134                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: return 1;
4135                 default: abort();
4136         }
4137 }
4138 int64_t CS_LDK_LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_get_some(int64_t ptr) {
4139         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4140         CHECK(obj->tag == LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some);
4141         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4142         *some_conv = obj->some;
4143                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
4144         return tag_ptr(some_conv, true);
4145 }
4146 uint32_t CS_LDK_LDKErrorAction_ty_from_ptr(int64_t ptr) {
4147         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4148         switch(obj->tag) {
4149                 case LDKErrorAction_DisconnectPeer: return 0;
4150                 case LDKErrorAction_DisconnectPeerWithWarning: return 1;
4151                 case LDKErrorAction_IgnoreError: return 2;
4152                 case LDKErrorAction_IgnoreAndLog: return 3;
4153                 case LDKErrorAction_IgnoreDuplicateGossip: return 4;
4154                 case LDKErrorAction_SendErrorMessage: return 5;
4155                 case LDKErrorAction_SendWarningMessage: return 6;
4156                 default: abort();
4157         }
4158 }
4159 int64_t CS_LDK_LDKErrorAction_DisconnectPeer_get_msg(int64_t ptr) {
4160         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4161         CHECK(obj->tag == LDKErrorAction_DisconnectPeer);
4162         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
4163                         int64_t msg_ref = 0;
4164                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4165                         msg_ref = tag_ptr(msg_var.inner, false);
4166         return msg_ref;
4167 }
4168 int64_t CS_LDK_LDKErrorAction_DisconnectPeerWithWarning_get_msg(int64_t ptr) {
4169         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4170         CHECK(obj->tag == LDKErrorAction_DisconnectPeerWithWarning);
4171         LDKWarningMessage msg_var = obj->disconnect_peer_with_warning.msg;
4172                         int64_t msg_ref = 0;
4173                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4174                         msg_ref = tag_ptr(msg_var.inner, false);
4175         return msg_ref;
4176 }
4177 int32_t CS_LDK_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(int64_t ptr) {
4178         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4179         CHECK(obj->tag == LDKErrorAction_IgnoreAndLog);
4180         int32_t ignore_and_log_conv = LDKLevel_to_cs(obj->ignore_and_log);
4181         return ignore_and_log_conv;
4182 }
4183 int64_t CS_LDK_LDKErrorAction_SendErrorMessage_get_msg(int64_t ptr) {
4184         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4185         CHECK(obj->tag == LDKErrorAction_SendErrorMessage);
4186         LDKErrorMessage msg_var = obj->send_error_message.msg;
4187                         int64_t msg_ref = 0;
4188                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4189                         msg_ref = tag_ptr(msg_var.inner, false);
4190         return msg_ref;
4191 }
4192 int64_t CS_LDK_LDKErrorAction_SendWarningMessage_get_msg(int64_t ptr) {
4193         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4194         CHECK(obj->tag == LDKErrorAction_SendWarningMessage);
4195         LDKWarningMessage msg_var = obj->send_warning_message.msg;
4196                         int64_t msg_ref = 0;
4197                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4198                         msg_ref = tag_ptr(msg_var.inner, false);
4199         return msg_ref;
4200 }
4201 int32_t CS_LDK_LDKErrorAction_SendWarningMessage_get_log_level(int64_t ptr) {
4202         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4203         CHECK(obj->tag == LDKErrorAction_SendWarningMessage);
4204         int32_t log_level_conv = LDKLevel_to_cs(obj->send_warning_message.log_level);
4205         return log_level_conv;
4206 }
4207 uint32_t CS_LDK_LDKMessageSendEvent_ty_from_ptr(int64_t ptr) {
4208         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4209         switch(obj->tag) {
4210                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
4211                 case LDKMessageSendEvent_SendAcceptChannelV2: return 1;
4212                 case LDKMessageSendEvent_SendOpenChannel: return 2;
4213                 case LDKMessageSendEvent_SendOpenChannelV2: return 3;
4214                 case LDKMessageSendEvent_SendFundingCreated: return 4;
4215                 case LDKMessageSendEvent_SendFundingSigned: return 5;
4216                 case LDKMessageSendEvent_SendTxAddInput: return 6;
4217                 case LDKMessageSendEvent_SendTxAddOutput: return 7;
4218                 case LDKMessageSendEvent_SendTxRemoveInput: return 8;
4219                 case LDKMessageSendEvent_SendTxRemoveOutput: return 9;
4220                 case LDKMessageSendEvent_SendTxComplete: return 10;
4221                 case LDKMessageSendEvent_SendTxSignatures: return 11;
4222                 case LDKMessageSendEvent_SendTxInitRbf: return 12;
4223                 case LDKMessageSendEvent_SendTxAckRbf: return 13;
4224                 case LDKMessageSendEvent_SendTxAbort: return 14;
4225                 case LDKMessageSendEvent_SendChannelReady: return 15;
4226                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 16;
4227                 case LDKMessageSendEvent_UpdateHTLCs: return 17;
4228                 case LDKMessageSendEvent_SendRevokeAndACK: return 18;
4229                 case LDKMessageSendEvent_SendClosingSigned: return 19;
4230                 case LDKMessageSendEvent_SendShutdown: return 20;
4231                 case LDKMessageSendEvent_SendChannelReestablish: return 21;
4232                 case LDKMessageSendEvent_SendChannelAnnouncement: return 22;
4233                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 23;
4234                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 24;
4235                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 25;
4236                 case LDKMessageSendEvent_SendChannelUpdate: return 26;
4237                 case LDKMessageSendEvent_HandleError: return 27;
4238                 case LDKMessageSendEvent_SendChannelRangeQuery: return 28;
4239                 case LDKMessageSendEvent_SendShortIdsQuery: return 29;
4240                 case LDKMessageSendEvent_SendReplyChannelRange: return 30;
4241                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 31;
4242                 default: abort();
4243         }
4244 }
4245 int8_tArray CS_LDK_LDKMessageSendEvent_SendAcceptChannel_get_node_id(int64_t ptr) {
4246         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4247         CHECK(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
4248         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4249         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
4250         return node_id_arr;
4251 }
4252 int64_t CS_LDK_LDKMessageSendEvent_SendAcceptChannel_get_msg(int64_t ptr) {
4253         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4254         CHECK(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
4255         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
4256                         int64_t msg_ref = 0;
4257                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4258                         msg_ref = tag_ptr(msg_var.inner, false);
4259         return msg_ref;
4260 }
4261 int8_tArray CS_LDK_LDKMessageSendEvent_SendAcceptChannelV2_get_node_id(int64_t ptr) {
4262         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4263         CHECK(obj->tag == LDKMessageSendEvent_SendAcceptChannelV2);
4264         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4265         memcpy(node_id_arr->elems, obj->send_accept_channel_v2.node_id.compressed_form, 33);
4266         return node_id_arr;
4267 }
4268 int64_t CS_LDK_LDKMessageSendEvent_SendAcceptChannelV2_get_msg(int64_t ptr) {
4269         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4270         CHECK(obj->tag == LDKMessageSendEvent_SendAcceptChannelV2);
4271         LDKAcceptChannelV2 msg_var = obj->send_accept_channel_v2.msg;
4272                         int64_t msg_ref = 0;
4273                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4274                         msg_ref = tag_ptr(msg_var.inner, false);
4275         return msg_ref;
4276 }
4277 int8_tArray CS_LDK_LDKMessageSendEvent_SendOpenChannel_get_node_id(int64_t ptr) {
4278         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4279         CHECK(obj->tag == LDKMessageSendEvent_SendOpenChannel);
4280         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4281         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
4282         return node_id_arr;
4283 }
4284 int64_t CS_LDK_LDKMessageSendEvent_SendOpenChannel_get_msg(int64_t ptr) {
4285         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4286         CHECK(obj->tag == LDKMessageSendEvent_SendOpenChannel);
4287         LDKOpenChannel msg_var = obj->send_open_channel.msg;
4288                         int64_t msg_ref = 0;
4289                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4290                         msg_ref = tag_ptr(msg_var.inner, false);
4291         return msg_ref;
4292 }
4293 int8_tArray CS_LDK_LDKMessageSendEvent_SendOpenChannelV2_get_node_id(int64_t ptr) {
4294         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4295         CHECK(obj->tag == LDKMessageSendEvent_SendOpenChannelV2);
4296         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4297         memcpy(node_id_arr->elems, obj->send_open_channel_v2.node_id.compressed_form, 33);
4298         return node_id_arr;
4299 }
4300 int64_t CS_LDK_LDKMessageSendEvent_SendOpenChannelV2_get_msg(int64_t ptr) {
4301         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4302         CHECK(obj->tag == LDKMessageSendEvent_SendOpenChannelV2);
4303         LDKOpenChannelV2 msg_var = obj->send_open_channel_v2.msg;
4304                         int64_t msg_ref = 0;
4305                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4306                         msg_ref = tag_ptr(msg_var.inner, false);
4307         return msg_ref;
4308 }
4309 int8_tArray CS_LDK_LDKMessageSendEvent_SendFundingCreated_get_node_id(int64_t ptr) {
4310         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4311         CHECK(obj->tag == LDKMessageSendEvent_SendFundingCreated);
4312         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4313         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
4314         return node_id_arr;
4315 }
4316 int64_t CS_LDK_LDKMessageSendEvent_SendFundingCreated_get_msg(int64_t ptr) {
4317         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4318         CHECK(obj->tag == LDKMessageSendEvent_SendFundingCreated);
4319         LDKFundingCreated msg_var = obj->send_funding_created.msg;
4320                         int64_t msg_ref = 0;
4321                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4322                         msg_ref = tag_ptr(msg_var.inner, false);
4323         return msg_ref;
4324 }
4325 int8_tArray CS_LDK_LDKMessageSendEvent_SendFundingSigned_get_node_id(int64_t ptr) {
4326         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4327         CHECK(obj->tag == LDKMessageSendEvent_SendFundingSigned);
4328         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4329         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
4330         return node_id_arr;
4331 }
4332 int64_t CS_LDK_LDKMessageSendEvent_SendFundingSigned_get_msg(int64_t ptr) {
4333         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4334         CHECK(obj->tag == LDKMessageSendEvent_SendFundingSigned);
4335         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
4336                         int64_t msg_ref = 0;
4337                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4338                         msg_ref = tag_ptr(msg_var.inner, false);
4339         return msg_ref;
4340 }
4341 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxAddInput_get_node_id(int64_t ptr) {
4342         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4343         CHECK(obj->tag == LDKMessageSendEvent_SendTxAddInput);
4344         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4345         memcpy(node_id_arr->elems, obj->send_tx_add_input.node_id.compressed_form, 33);
4346         return node_id_arr;
4347 }
4348 int64_t CS_LDK_LDKMessageSendEvent_SendTxAddInput_get_msg(int64_t ptr) {
4349         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4350         CHECK(obj->tag == LDKMessageSendEvent_SendTxAddInput);
4351         LDKTxAddInput msg_var = obj->send_tx_add_input.msg;
4352                         int64_t msg_ref = 0;
4353                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4354                         msg_ref = tag_ptr(msg_var.inner, false);
4355         return msg_ref;
4356 }
4357 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxAddOutput_get_node_id(int64_t ptr) {
4358         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4359         CHECK(obj->tag == LDKMessageSendEvent_SendTxAddOutput);
4360         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4361         memcpy(node_id_arr->elems, obj->send_tx_add_output.node_id.compressed_form, 33);
4362         return node_id_arr;
4363 }
4364 int64_t CS_LDK_LDKMessageSendEvent_SendTxAddOutput_get_msg(int64_t ptr) {
4365         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4366         CHECK(obj->tag == LDKMessageSendEvent_SendTxAddOutput);
4367         LDKTxAddOutput msg_var = obj->send_tx_add_output.msg;
4368                         int64_t msg_ref = 0;
4369                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4370                         msg_ref = tag_ptr(msg_var.inner, false);
4371         return msg_ref;
4372 }
4373 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxRemoveInput_get_node_id(int64_t ptr) {
4374         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4375         CHECK(obj->tag == LDKMessageSendEvent_SendTxRemoveInput);
4376         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4377         memcpy(node_id_arr->elems, obj->send_tx_remove_input.node_id.compressed_form, 33);
4378         return node_id_arr;
4379 }
4380 int64_t CS_LDK_LDKMessageSendEvent_SendTxRemoveInput_get_msg(int64_t ptr) {
4381         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4382         CHECK(obj->tag == LDKMessageSendEvent_SendTxRemoveInput);
4383         LDKTxRemoveInput msg_var = obj->send_tx_remove_input.msg;
4384                         int64_t msg_ref = 0;
4385                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4386                         msg_ref = tag_ptr(msg_var.inner, false);
4387         return msg_ref;
4388 }
4389 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxRemoveOutput_get_node_id(int64_t ptr) {
4390         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4391         CHECK(obj->tag == LDKMessageSendEvent_SendTxRemoveOutput);
4392         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4393         memcpy(node_id_arr->elems, obj->send_tx_remove_output.node_id.compressed_form, 33);
4394         return node_id_arr;
4395 }
4396 int64_t CS_LDK_LDKMessageSendEvent_SendTxRemoveOutput_get_msg(int64_t ptr) {
4397         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4398         CHECK(obj->tag == LDKMessageSendEvent_SendTxRemoveOutput);
4399         LDKTxRemoveOutput msg_var = obj->send_tx_remove_output.msg;
4400                         int64_t msg_ref = 0;
4401                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4402                         msg_ref = tag_ptr(msg_var.inner, false);
4403         return msg_ref;
4404 }
4405 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxComplete_get_node_id(int64_t ptr) {
4406         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4407         CHECK(obj->tag == LDKMessageSendEvent_SendTxComplete);
4408         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4409         memcpy(node_id_arr->elems, obj->send_tx_complete.node_id.compressed_form, 33);
4410         return node_id_arr;
4411 }
4412 int64_t CS_LDK_LDKMessageSendEvent_SendTxComplete_get_msg(int64_t ptr) {
4413         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4414         CHECK(obj->tag == LDKMessageSendEvent_SendTxComplete);
4415         LDKTxComplete msg_var = obj->send_tx_complete.msg;
4416                         int64_t msg_ref = 0;
4417                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4418                         msg_ref = tag_ptr(msg_var.inner, false);
4419         return msg_ref;
4420 }
4421 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxSignatures_get_node_id(int64_t ptr) {
4422         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4423         CHECK(obj->tag == LDKMessageSendEvent_SendTxSignatures);
4424         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4425         memcpy(node_id_arr->elems, obj->send_tx_signatures.node_id.compressed_form, 33);
4426         return node_id_arr;
4427 }
4428 int64_t CS_LDK_LDKMessageSendEvent_SendTxSignatures_get_msg(int64_t ptr) {
4429         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4430         CHECK(obj->tag == LDKMessageSendEvent_SendTxSignatures);
4431         LDKTxSignatures msg_var = obj->send_tx_signatures.msg;
4432                         int64_t msg_ref = 0;
4433                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4434                         msg_ref = tag_ptr(msg_var.inner, false);
4435         return msg_ref;
4436 }
4437 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxInitRbf_get_node_id(int64_t ptr) {
4438         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4439         CHECK(obj->tag == LDKMessageSendEvent_SendTxInitRbf);
4440         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4441         memcpy(node_id_arr->elems, obj->send_tx_init_rbf.node_id.compressed_form, 33);
4442         return node_id_arr;
4443 }
4444 int64_t CS_LDK_LDKMessageSendEvent_SendTxInitRbf_get_msg(int64_t ptr) {
4445         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4446         CHECK(obj->tag == LDKMessageSendEvent_SendTxInitRbf);
4447         LDKTxInitRbf msg_var = obj->send_tx_init_rbf.msg;
4448                         int64_t msg_ref = 0;
4449                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4450                         msg_ref = tag_ptr(msg_var.inner, false);
4451         return msg_ref;
4452 }
4453 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxAckRbf_get_node_id(int64_t ptr) {
4454         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4455         CHECK(obj->tag == LDKMessageSendEvent_SendTxAckRbf);
4456         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4457         memcpy(node_id_arr->elems, obj->send_tx_ack_rbf.node_id.compressed_form, 33);
4458         return node_id_arr;
4459 }
4460 int64_t CS_LDK_LDKMessageSendEvent_SendTxAckRbf_get_msg(int64_t ptr) {
4461         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4462         CHECK(obj->tag == LDKMessageSendEvent_SendTxAckRbf);
4463         LDKTxAckRbf msg_var = obj->send_tx_ack_rbf.msg;
4464                         int64_t msg_ref = 0;
4465                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4466                         msg_ref = tag_ptr(msg_var.inner, false);
4467         return msg_ref;
4468 }
4469 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxAbort_get_node_id(int64_t ptr) {
4470         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4471         CHECK(obj->tag == LDKMessageSendEvent_SendTxAbort);
4472         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4473         memcpy(node_id_arr->elems, obj->send_tx_abort.node_id.compressed_form, 33);
4474         return node_id_arr;
4475 }
4476 int64_t CS_LDK_LDKMessageSendEvent_SendTxAbort_get_msg(int64_t ptr) {
4477         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4478         CHECK(obj->tag == LDKMessageSendEvent_SendTxAbort);
4479         LDKTxAbort msg_var = obj->send_tx_abort.msg;
4480                         int64_t msg_ref = 0;
4481                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4482                         msg_ref = tag_ptr(msg_var.inner, false);
4483         return msg_ref;
4484 }
4485 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelReady_get_node_id(int64_t ptr) {
4486         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4487         CHECK(obj->tag == LDKMessageSendEvent_SendChannelReady);
4488         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4489         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
4490         return node_id_arr;
4491 }
4492 int64_t CS_LDK_LDKMessageSendEvent_SendChannelReady_get_msg(int64_t ptr) {
4493         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4494         CHECK(obj->tag == LDKMessageSendEvent_SendChannelReady);
4495         LDKChannelReady msg_var = obj->send_channel_ready.msg;
4496                         int64_t msg_ref = 0;
4497                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4498                         msg_ref = tag_ptr(msg_var.inner, false);
4499         return msg_ref;
4500 }
4501 int8_tArray CS_LDK_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(int64_t ptr) {
4502         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4503         CHECK(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
4504         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4505         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
4506         return node_id_arr;
4507 }
4508 int64_t CS_LDK_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(int64_t ptr) {
4509         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4510         CHECK(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
4511         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
4512                         int64_t msg_ref = 0;
4513                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4514                         msg_ref = tag_ptr(msg_var.inner, false);
4515         return msg_ref;
4516 }
4517 int8_tArray CS_LDK_LDKMessageSendEvent_UpdateHTLCs_get_node_id(int64_t ptr) {
4518         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4519         CHECK(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
4520         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4521         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
4522         return node_id_arr;
4523 }
4524 int64_t CS_LDK_LDKMessageSendEvent_UpdateHTLCs_get_updates(int64_t ptr) {
4525         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4526         CHECK(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
4527         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
4528                         int64_t updates_ref = 0;
4529                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
4530                         updates_ref = tag_ptr(updates_var.inner, false);
4531         return updates_ref;
4532 }
4533 int8_tArray CS_LDK_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(int64_t ptr) {
4534         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4535         CHECK(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
4536         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4537         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
4538         return node_id_arr;
4539 }
4540 int64_t CS_LDK_LDKMessageSendEvent_SendRevokeAndACK_get_msg(int64_t ptr) {
4541         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4542         CHECK(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
4543         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
4544                         int64_t msg_ref = 0;
4545                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4546                         msg_ref = tag_ptr(msg_var.inner, false);
4547         return msg_ref;
4548 }
4549 int8_tArray CS_LDK_LDKMessageSendEvent_SendClosingSigned_get_node_id(int64_t ptr) {
4550         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4551         CHECK(obj->tag == LDKMessageSendEvent_SendClosingSigned);
4552         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4553         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
4554         return node_id_arr;
4555 }
4556 int64_t CS_LDK_LDKMessageSendEvent_SendClosingSigned_get_msg(int64_t ptr) {
4557         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4558         CHECK(obj->tag == LDKMessageSendEvent_SendClosingSigned);
4559         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
4560                         int64_t msg_ref = 0;
4561                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4562                         msg_ref = tag_ptr(msg_var.inner, false);
4563         return msg_ref;
4564 }
4565 int8_tArray CS_LDK_LDKMessageSendEvent_SendShutdown_get_node_id(int64_t ptr) {
4566         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4567         CHECK(obj->tag == LDKMessageSendEvent_SendShutdown);
4568         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4569         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
4570         return node_id_arr;
4571 }
4572 int64_t CS_LDK_LDKMessageSendEvent_SendShutdown_get_msg(int64_t ptr) {
4573         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4574         CHECK(obj->tag == LDKMessageSendEvent_SendShutdown);
4575         LDKShutdown msg_var = obj->send_shutdown.msg;
4576                         int64_t msg_ref = 0;
4577                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4578                         msg_ref = tag_ptr(msg_var.inner, false);
4579         return msg_ref;
4580 }
4581 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelReestablish_get_node_id(int64_t ptr) {
4582         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4583         CHECK(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
4584         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4585         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
4586         return node_id_arr;
4587 }
4588 int64_t CS_LDK_LDKMessageSendEvent_SendChannelReestablish_get_msg(int64_t ptr) {
4589         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4590         CHECK(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
4591         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
4592                         int64_t msg_ref = 0;
4593                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4594                         msg_ref = tag_ptr(msg_var.inner, false);
4595         return msg_ref;
4596 }
4597 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelAnnouncement_get_node_id(int64_t ptr) {
4598         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4599         CHECK(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
4600         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4601         memcpy(node_id_arr->elems, obj->send_channel_announcement.node_id.compressed_form, 33);
4602         return node_id_arr;
4603 }
4604 int64_t CS_LDK_LDKMessageSendEvent_SendChannelAnnouncement_get_msg(int64_t ptr) {
4605         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4606         CHECK(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
4607         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
4608                         int64_t msg_ref = 0;
4609                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4610                         msg_ref = tag_ptr(msg_var.inner, false);
4611         return msg_ref;
4612 }
4613 int64_t CS_LDK_LDKMessageSendEvent_SendChannelAnnouncement_get_update_msg(int64_t ptr) {
4614         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4615         CHECK(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
4616         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
4617                         int64_t update_msg_ref = 0;
4618                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4619                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4620         return update_msg_ref;
4621 }
4622 int64_t CS_LDK_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(int64_t ptr) {
4623         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4624         CHECK(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
4625         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
4626                         int64_t msg_ref = 0;
4627                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4628                         msg_ref = tag_ptr(msg_var.inner, false);
4629         return msg_ref;
4630 }
4631 int64_t CS_LDK_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(int64_t ptr) {
4632         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4633         CHECK(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
4634         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
4635                         int64_t update_msg_ref = 0;
4636                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4637                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4638         return update_msg_ref;
4639 }
4640 int64_t CS_LDK_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(int64_t ptr) {
4641         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4642         CHECK(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
4643         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
4644                         int64_t msg_ref = 0;
4645                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4646                         msg_ref = tag_ptr(msg_var.inner, false);
4647         return msg_ref;
4648 }
4649 int64_t CS_LDK_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(int64_t ptr) {
4650         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4651         CHECK(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
4652         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
4653                         int64_t msg_ref = 0;
4654                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4655                         msg_ref = tag_ptr(msg_var.inner, false);
4656         return msg_ref;
4657 }
4658 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelUpdate_get_node_id(int64_t ptr) {
4659         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4660         CHECK(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
4661         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4662         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
4663         return node_id_arr;
4664 }
4665 int64_t CS_LDK_LDKMessageSendEvent_SendChannelUpdate_get_msg(int64_t ptr) {
4666         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4667         CHECK(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
4668         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
4669                         int64_t msg_ref = 0;
4670                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4671                         msg_ref = tag_ptr(msg_var.inner, false);
4672         return msg_ref;
4673 }
4674 int8_tArray CS_LDK_LDKMessageSendEvent_HandleError_get_node_id(int64_t ptr) {
4675         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4676         CHECK(obj->tag == LDKMessageSendEvent_HandleError);
4677         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4678         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
4679         return node_id_arr;
4680 }
4681 int64_t CS_LDK_LDKMessageSendEvent_HandleError_get_action(int64_t ptr) {
4682         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4683         CHECK(obj->tag == LDKMessageSendEvent_HandleError);
4684         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
4685         return action_ref;
4686 }
4687 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(int64_t ptr) {
4688         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4689         CHECK(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
4690         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4691         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
4692         return node_id_arr;
4693 }
4694 int64_t CS_LDK_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(int64_t ptr) {
4695         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4696         CHECK(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
4697         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
4698                         int64_t msg_ref = 0;
4699                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4700                         msg_ref = tag_ptr(msg_var.inner, false);
4701         return msg_ref;
4702 }
4703 int8_tArray CS_LDK_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(int64_t ptr) {
4704         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4705         CHECK(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
4706         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4707         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
4708         return node_id_arr;
4709 }
4710 int64_t CS_LDK_LDKMessageSendEvent_SendShortIdsQuery_get_msg(int64_t ptr) {
4711         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4712         CHECK(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
4713         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
4714                         int64_t msg_ref = 0;
4715                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4716                         msg_ref = tag_ptr(msg_var.inner, false);
4717         return msg_ref;
4718 }
4719 int8_tArray CS_LDK_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(int64_t ptr) {
4720         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4721         CHECK(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
4722         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4723         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
4724         return node_id_arr;
4725 }
4726 int64_t CS_LDK_LDKMessageSendEvent_SendReplyChannelRange_get_msg(int64_t ptr) {
4727         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4728         CHECK(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
4729         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
4730                         int64_t msg_ref = 0;
4731                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4732                         msg_ref = tag_ptr(msg_var.inner, false);
4733         return msg_ref;
4734 }
4735 int8_tArray CS_LDK_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(int64_t ptr) {
4736         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4737         CHECK(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
4738         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4739         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
4740         return node_id_arr;
4741 }
4742 int64_t CS_LDK_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(int64_t ptr) {
4743         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4744         CHECK(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
4745         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
4746                         int64_t msg_ref = 0;
4747                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4748                         msg_ref = tag_ptr(msg_var.inner, false);
4749         return msg_ref;
4750 }
4751 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
4752         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
4753         for (size_t i = 0; i < ret.datalen; i++) {
4754                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
4755         }
4756         return ret;
4757 }
4758 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4759         LDKChannelUpdateInfo ret = *owner->contents.result;
4760         ret.is_owned = false;
4761         return ret;
4762 }
4763 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(int64_t owner) {
4764         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4765         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4766         int64_t ret_ref = 0;
4767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4768         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4769         return ret_ref;
4770 }
4771
4772 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4773 CHECK(!owner->result_ok);
4774         return DecodeError_clone(&*owner->contents.err);
4775 }
4776 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(int64_t owner) {
4777         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4778         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4779         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4780         int64_t ret_ref = tag_ptr(ret_copy, true);
4781         return ret_ref;
4782 }
4783
4784 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4785         LDKChannelInfo ret = *owner->contents.result;
4786         ret.is_owned = false;
4787         return ret;
4788 }
4789 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_get_ok(int64_t owner) {
4790         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4791         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4792         int64_t ret_ref = 0;
4793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4794         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4795         return ret_ref;
4796 }
4797
4798 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4799 CHECK(!owner->result_ok);
4800         return DecodeError_clone(&*owner->contents.err);
4801 }
4802 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_get_err(int64_t owner) {
4803         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4804         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4805         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4806         int64_t ret_ref = tag_ptr(ret_copy, true);
4807         return ret_ref;
4808 }
4809
4810 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4811         LDKRoutingFees ret = *owner->contents.result;
4812         ret.is_owned = false;
4813         return ret;
4814 }
4815 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_get_ok(int64_t owner) {
4816         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4817         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4818         int64_t ret_ref = 0;
4819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4820         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4821         return ret_ref;
4822 }
4823
4824 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4825 CHECK(!owner->result_ok);
4826         return DecodeError_clone(&*owner->contents.err);
4827 }
4828 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_get_err(int64_t owner) {
4829         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4830         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4831         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4832         int64_t ret_ref = tag_ptr(ret_copy, true);
4833         return ret_ref;
4834 }
4835
4836 uint32_t CS_LDK_LDKSocketAddress_ty_from_ptr(int64_t ptr) {
4837         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4838         switch(obj->tag) {
4839                 case LDKSocketAddress_TcpIpV4: return 0;
4840                 case LDKSocketAddress_TcpIpV6: return 1;
4841                 case LDKSocketAddress_OnionV2: return 2;
4842                 case LDKSocketAddress_OnionV3: return 3;
4843                 case LDKSocketAddress_Hostname: return 4;
4844                 default: abort();
4845         }
4846 }
4847 int8_tArray CS_LDK_LDKSocketAddress_TcpIpV4_get_addr(int64_t ptr) {
4848         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4849         CHECK(obj->tag == LDKSocketAddress_TcpIpV4);
4850         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
4851         memcpy(addr_arr->elems, obj->tcp_ip_v4.addr.data, 4);
4852         return addr_arr;
4853 }
4854 int16_t CS_LDK_LDKSocketAddress_TcpIpV4_get_port(int64_t ptr) {
4855         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4856         CHECK(obj->tag == LDKSocketAddress_TcpIpV4);
4857         int16_t port_conv = obj->tcp_ip_v4.port;
4858         return port_conv;
4859 }
4860 int8_tArray CS_LDK_LDKSocketAddress_TcpIpV6_get_addr(int64_t ptr) {
4861         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4862         CHECK(obj->tag == LDKSocketAddress_TcpIpV6);
4863         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
4864         memcpy(addr_arr->elems, obj->tcp_ip_v6.addr.data, 16);
4865         return addr_arr;
4866 }
4867 int16_t CS_LDK_LDKSocketAddress_TcpIpV6_get_port(int64_t ptr) {
4868         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4869         CHECK(obj->tag == LDKSocketAddress_TcpIpV6);
4870         int16_t port_conv = obj->tcp_ip_v6.port;
4871         return port_conv;
4872 }
4873 int8_tArray CS_LDK_LDKSocketAddress_OnionV2_get_onion_v2(int64_t ptr) {
4874         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4875         CHECK(obj->tag == LDKSocketAddress_OnionV2);
4876         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
4877         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
4878         return onion_v2_arr;
4879 }
4880 int8_tArray CS_LDK_LDKSocketAddress_OnionV3_get_ed25519_pubkey(int64_t ptr) {
4881         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4882         CHECK(obj->tag == LDKSocketAddress_OnionV3);
4883         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
4884         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
4885         return ed25519_pubkey_arr;
4886 }
4887 int16_t CS_LDK_LDKSocketAddress_OnionV3_get_checksum(int64_t ptr) {
4888         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4889         CHECK(obj->tag == LDKSocketAddress_OnionV3);
4890         int16_t checksum_conv = obj->onion_v3.checksum;
4891         return checksum_conv;
4892 }
4893 int8_t CS_LDK_LDKSocketAddress_OnionV3_get_version(int64_t ptr) {
4894         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4895         CHECK(obj->tag == LDKSocketAddress_OnionV3);
4896         int8_t version_conv = obj->onion_v3.version;
4897         return version_conv;
4898 }
4899 int16_t CS_LDK_LDKSocketAddress_OnionV3_get_port(int64_t ptr) {
4900         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4901         CHECK(obj->tag == LDKSocketAddress_OnionV3);
4902         int16_t port_conv = obj->onion_v3.port;
4903         return port_conv;
4904 }
4905 int64_t CS_LDK_LDKSocketAddress_Hostname_get_hostname(int64_t ptr) {
4906         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4907         CHECK(obj->tag == LDKSocketAddress_Hostname);
4908         LDKHostname hostname_var = obj->hostname.hostname;
4909                         int64_t hostname_ref = 0;
4910                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4911                         hostname_ref = tag_ptr(hostname_var.inner, false);
4912         return hostname_ref;
4913 }
4914 int16_t CS_LDK_LDKSocketAddress_Hostname_get_port(int64_t ptr) {
4915         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4916         CHECK(obj->tag == LDKSocketAddress_Hostname);
4917         int16_t port_conv = obj->hostname.port;
4918         return port_conv;
4919 }
4920 static inline LDKCVec_SocketAddressZ CVec_SocketAddressZ_clone(const LDKCVec_SocketAddressZ *orig) {
4921         LDKCVec_SocketAddressZ ret = { .data = MALLOC(sizeof(LDKSocketAddress) * orig->datalen, "LDKCVec_SocketAddressZ clone bytes"), .datalen = orig->datalen };
4922         for (size_t i = 0; i < ret.datalen; i++) {
4923                 ret.data[i] = SocketAddress_clone(&orig->data[i]);
4924         }
4925         return ret;
4926 }
4927 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4928         LDKNodeAnnouncementInfo ret = *owner->contents.result;
4929         ret.is_owned = false;
4930         return ret;
4931 }
4932 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(int64_t owner) {
4933         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4934         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4935         int64_t ret_ref = 0;
4936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4938         return ret_ref;
4939 }
4940
4941 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4942 CHECK(!owner->result_ok);
4943         return DecodeError_clone(&*owner->contents.err);
4944 }
4945 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(int64_t owner) {
4946         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4947         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4948         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4949         int64_t ret_ref = tag_ptr(ret_copy, true);
4950         return ret_ref;
4951 }
4952
4953 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4954         LDKNodeAlias ret = *owner->contents.result;
4955         ret.is_owned = false;
4956         return ret;
4957 }
4958 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_get_ok(int64_t owner) {
4959         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4960         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4961         int64_t ret_ref = 0;
4962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4964         return ret_ref;
4965 }
4966
4967 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4968 CHECK(!owner->result_ok);
4969         return DecodeError_clone(&*owner->contents.err);
4970 }
4971 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_get_err(int64_t owner) {
4972         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4973         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4974         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4975         int64_t ret_ref = tag_ptr(ret_copy, true);
4976         return ret_ref;
4977 }
4978
4979 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4980         LDKNodeInfo ret = *owner->contents.result;
4981         ret.is_owned = false;
4982         return ret;
4983 }
4984 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_get_ok(int64_t owner) {
4985         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4986         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4987         int64_t ret_ref = 0;
4988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4989         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4990         return ret_ref;
4991 }
4992
4993 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4994 CHECK(!owner->result_ok);
4995         return DecodeError_clone(&*owner->contents.err);
4996 }
4997 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_get_err(int64_t owner) {
4998         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4999         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5000         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
5001         int64_t ret_ref = tag_ptr(ret_copy, true);
5002         return ret_ref;
5003 }
5004
5005 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5006         LDKNetworkGraph ret = *owner->contents.result;
5007         ret.is_owned = false;
5008         return ret;
5009 }
5010 int64_t  CS_LDK_CResult_NetworkGraphDecodeErrorZ_get_ok(int64_t owner) {
5011         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5012         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
5013         int64_t ret_ref = 0;
5014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5015         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5016         return ret_ref;
5017 }
5018
5019 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5020 CHECK(!owner->result_ok);
5021         return DecodeError_clone(&*owner->contents.err);
5022 }
5023 int64_t  CS_LDK_CResult_NetworkGraphDecodeErrorZ_get_err(int64_t owner) {
5024         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5025         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5026         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
5027         int64_t ret_ref = tag_ptr(ret_copy, true);
5028         return ret_ref;
5029 }
5030
5031 uint32_t CS_LDK_LDKCOption_CVec_SocketAddressZZ_ty_from_ptr(int64_t ptr) {
5032         LDKCOption_CVec_SocketAddressZZ *obj = (LDKCOption_CVec_SocketAddressZZ*)untag_ptr(ptr);
5033         switch(obj->tag) {
5034                 case LDKCOption_CVec_SocketAddressZZ_Some: return 0;
5035                 case LDKCOption_CVec_SocketAddressZZ_None: return 1;
5036                 default: abort();
5037         }
5038 }
5039 int64_tArray CS_LDK_LDKCOption_CVec_SocketAddressZZ_Some_get_some(int64_t ptr) {
5040         LDKCOption_CVec_SocketAddressZZ *obj = (LDKCOption_CVec_SocketAddressZZ*)untag_ptr(ptr);
5041         CHECK(obj->tag == LDKCOption_CVec_SocketAddressZZ_Some);
5042         LDKCVec_SocketAddressZ some_var = obj->some;
5043                         int64_tArray some_arr = NULL;
5044                         some_arr = init_int64_tArray(some_var.datalen, __LINE__);
5045                         int64_t *some_arr_ptr = (int64_t*)(((uint8_t*)some_arr) + 8);
5046                         for (size_t p = 0; p < some_var.datalen; p++) {
5047                                 int64_t some_conv_15_ref = tag_ptr(&some_var.data[p], false);
5048                                 some_arr_ptr[p] = some_conv_15_ref;
5049                         }
5050                         
5051         return some_arr;
5052 }
5053 static inline LDKCVec_HTLCOutputInCommitmentZ CVec_HTLCOutputInCommitmentZ_clone(const LDKCVec_HTLCOutputInCommitmentZ *orig) {
5054         LDKCVec_HTLCOutputInCommitmentZ ret = { .data = MALLOC(sizeof(LDKHTLCOutputInCommitment) * orig->datalen, "LDKCVec_HTLCOutputInCommitmentZ clone bytes"), .datalen = orig->datalen };
5055         for (size_t i = 0; i < ret.datalen; i++) {
5056                 ret.data[i] = HTLCOutputInCommitment_clone(&orig->data[i]);
5057         }
5058         return ret;
5059 }
5060 static inline LDKCVec_HTLCDescriptorZ CVec_HTLCDescriptorZ_clone(const LDKCVec_HTLCDescriptorZ *orig) {
5061         LDKCVec_HTLCDescriptorZ ret = { .data = MALLOC(sizeof(LDKHTLCDescriptor) * orig->datalen, "LDKCVec_HTLCDescriptorZ clone bytes"), .datalen = orig->datalen };
5062         for (size_t i = 0; i < ret.datalen; i++) {
5063                 ret.data[i] = HTLCDescriptor_clone(&orig->data[i]);
5064         }
5065         return ret;
5066 }
5067 static inline LDKCVec_UtxoZ CVec_UtxoZ_clone(const LDKCVec_UtxoZ *orig) {
5068         LDKCVec_UtxoZ ret = { .data = MALLOC(sizeof(LDKUtxo) * orig->datalen, "LDKCVec_UtxoZ clone bytes"), .datalen = orig->datalen };
5069         for (size_t i = 0; i < ret.datalen; i++) {
5070                 ret.data[i] = Utxo_clone(&orig->data[i]);
5071         }
5072         return ret;
5073 }
5074 uint32_t CS_LDK_LDKCOption_TxOutZ_ty_from_ptr(int64_t ptr) {
5075         LDKCOption_TxOutZ *obj = (LDKCOption_TxOutZ*)untag_ptr(ptr);
5076         switch(obj->tag) {
5077                 case LDKCOption_TxOutZ_Some: return 0;
5078                 case LDKCOption_TxOutZ_None: return 1;
5079                 default: abort();
5080         }
5081 }
5082 int64_t CS_LDK_LDKCOption_TxOutZ_Some_get_some(int64_t ptr) {
5083         LDKCOption_TxOutZ *obj = (LDKCOption_TxOutZ*)untag_ptr(ptr);
5084         CHECK(obj->tag == LDKCOption_TxOutZ_Some);
5085         LDKTxOut* some_ref = &obj->some;
5086         return tag_ptr(some_ref, false);
5087 }
5088 static inline LDKCVec_InputZ CVec_InputZ_clone(const LDKCVec_InputZ *orig) {
5089         LDKCVec_InputZ ret = { .data = MALLOC(sizeof(LDKInput) * orig->datalen, "LDKCVec_InputZ clone bytes"), .datalen = orig->datalen };
5090         for (size_t i = 0; i < ret.datalen; i++) {
5091                 ret.data[i] = Input_clone(&orig->data[i]);
5092         }
5093         return ret;
5094 }
5095 static inline struct LDKCoinSelection CResult_CoinSelectionNoneZ_get_ok(LDKCResult_CoinSelectionNoneZ *NONNULL_PTR owner){
5096         LDKCoinSelection ret = *owner->contents.result;
5097         ret.is_owned = false;
5098         return ret;
5099 }
5100 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_get_ok(int64_t owner) {
5101         LDKCResult_CoinSelectionNoneZ* owner_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(owner);
5102         LDKCoinSelection ret_var = CResult_CoinSelectionNoneZ_get_ok(owner_conv);
5103         int64_t ret_ref = 0;
5104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5106         return ret_ref;
5107 }
5108
5109 static inline void CResult_CoinSelectionNoneZ_get_err(LDKCResult_CoinSelectionNoneZ *NONNULL_PTR owner){
5110 CHECK(!owner->result_ok);
5111         return *owner->contents.err;
5112 }
5113 void  CS_LDK_CResult_CoinSelectionNoneZ_get_err(int64_t owner) {
5114         LDKCResult_CoinSelectionNoneZ* owner_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(owner);
5115         CResult_CoinSelectionNoneZ_get_err(owner_conv);
5116 }
5117
5118 static inline struct LDKCVec_UtxoZ CResult_CVec_UtxoZNoneZ_get_ok(LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR owner){
5119 CHECK(owner->result_ok);
5120         return CVec_UtxoZ_clone(&*owner->contents.result);
5121 }
5122 int64_tArray  CS_LDK_CResult_CVec_UtxoZNoneZ_get_ok(int64_t owner) {
5123         LDKCResult_CVec_UtxoZNoneZ* owner_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(owner);
5124         LDKCVec_UtxoZ ret_var = CResult_CVec_UtxoZNoneZ_get_ok(owner_conv);
5125         int64_tArray ret_arr = NULL;
5126         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
5127         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
5128         for (size_t g = 0; g < ret_var.datalen; g++) {
5129                 LDKUtxo ret_conv_6_var = ret_var.data[g];
5130                 int64_t ret_conv_6_ref = 0;
5131                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
5132                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
5133                 ret_arr_ptr[g] = ret_conv_6_ref;
5134         }
5135         
5136         FREE(ret_var.data);
5137         return ret_arr;
5138 }
5139
5140 static inline void CResult_CVec_UtxoZNoneZ_get_err(LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR owner){
5141 CHECK(!owner->result_ok);
5142         return *owner->contents.err;
5143 }
5144 void  CS_LDK_CResult_CVec_UtxoZNoneZ_get_err(int64_t owner) {
5145         LDKCResult_CVec_UtxoZNoneZ* owner_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(owner);
5146         CResult_CVec_UtxoZNoneZ_get_err(owner_conv);
5147 }
5148
5149 static inline uint64_t C2Tuple_u64u16Z_get_a(LDKC2Tuple_u64u16Z *NONNULL_PTR owner){
5150         return owner->a;
5151 }
5152 int64_t  CS_LDK_C2Tuple_u64u16Z_get_a(int64_t owner) {
5153         LDKC2Tuple_u64u16Z* owner_conv = (LDKC2Tuple_u64u16Z*)untag_ptr(owner);
5154         int64_t ret_conv = C2Tuple_u64u16Z_get_a(owner_conv);
5155         return ret_conv;
5156 }
5157
5158 static inline uint16_t C2Tuple_u64u16Z_get_b(LDKC2Tuple_u64u16Z *NONNULL_PTR owner){
5159         return owner->b;
5160 }
5161 int16_t  CS_LDK_C2Tuple_u64u16Z_get_b(int64_t owner) {
5162         LDKC2Tuple_u64u16Z* owner_conv = (LDKC2Tuple_u64u16Z*)untag_ptr(owner);
5163         int16_t ret_conv = C2Tuple_u64u16Z_get_b(owner_conv);
5164         return ret_conv;
5165 }
5166
5167 uint32_t CS_LDK_LDKCOption_C2Tuple_u64u16ZZ_ty_from_ptr(int64_t ptr) {
5168         LDKCOption_C2Tuple_u64u16ZZ *obj = (LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(ptr);
5169         switch(obj->tag) {
5170                 case LDKCOption_C2Tuple_u64u16ZZ_Some: return 0;
5171                 case LDKCOption_C2Tuple_u64u16ZZ_None: return 1;
5172                 default: abort();
5173         }
5174 }
5175 int64_t CS_LDK_LDKCOption_C2Tuple_u64u16ZZ_Some_get_some(int64_t ptr) {
5176         LDKCOption_C2Tuple_u64u16ZZ *obj = (LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(ptr);
5177         CHECK(obj->tag == LDKCOption_C2Tuple_u64u16ZZ_Some);
5178         LDKC2Tuple_u64u16Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u16Z), "LDKC2Tuple_u64u16Z");
5179         *some_conv = obj->some;
5180                         *some_conv = C2Tuple_u64u16Z_clone(some_conv);
5181         return tag_ptr(some_conv, true);
5182 }
5183 uint32_t CS_LDK_LDKCOption_ChannelShutdownStateZ_ty_from_ptr(int64_t ptr) {
5184         LDKCOption_ChannelShutdownStateZ *obj = (LDKCOption_ChannelShutdownStateZ*)untag_ptr(ptr);
5185         switch(obj->tag) {
5186                 case LDKCOption_ChannelShutdownStateZ_Some: return 0;
5187                 case LDKCOption_ChannelShutdownStateZ_None: return 1;
5188                 default: abort();
5189         }
5190 }
5191 int32_t CS_LDK_LDKCOption_ChannelShutdownStateZ_Some_get_some(int64_t ptr) {
5192         LDKCOption_ChannelShutdownStateZ *obj = (LDKCOption_ChannelShutdownStateZ*)untag_ptr(ptr);
5193         CHECK(obj->tag == LDKCOption_ChannelShutdownStateZ_Some);
5194         int32_t some_conv = LDKChannelShutdownState_to_cs(obj->some);
5195         return some_conv;
5196 }
5197 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesAPIErrorZ_get_ok(LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR owner){
5198 CHECK(owner->result_ok);
5199         return ThirtyTwoBytes_clone(&*owner->contents.result);
5200 }
5201 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_get_ok(int64_t owner) {
5202         LDKCResult_ThirtyTwoBytesAPIErrorZ* owner_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(owner);
5203         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5204         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesAPIErrorZ_get_ok(owner_conv).data, 32);
5205         return ret_arr;
5206 }
5207
5208 static inline struct LDKAPIError CResult_ThirtyTwoBytesAPIErrorZ_get_err(LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR owner){
5209 CHECK(!owner->result_ok);
5210         return APIError_clone(&*owner->contents.err);
5211 }
5212 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_get_err(int64_t owner) {
5213         LDKCResult_ThirtyTwoBytesAPIErrorZ* owner_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(owner);
5214         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5215         *ret_copy = CResult_ThirtyTwoBytesAPIErrorZ_get_err(owner_conv);
5216         int64_t ret_ref = tag_ptr(ret_copy, true);
5217         return ret_ref;
5218 }
5219
5220 uint32_t CS_LDK_LDKRecentPaymentDetails_ty_from_ptr(int64_t ptr) {
5221         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5222         switch(obj->tag) {
5223                 case LDKRecentPaymentDetails_AwaitingInvoice: return 0;
5224                 case LDKRecentPaymentDetails_Pending: return 1;
5225                 case LDKRecentPaymentDetails_Fulfilled: return 2;
5226                 case LDKRecentPaymentDetails_Abandoned: return 3;
5227                 default: abort();
5228         }
5229 }
5230 int8_tArray CS_LDK_LDKRecentPaymentDetails_AwaitingInvoice_get_payment_id(int64_t ptr) {
5231         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5232         CHECK(obj->tag == LDKRecentPaymentDetails_AwaitingInvoice);
5233         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5234         memcpy(payment_id_arr->elems, obj->awaiting_invoice.payment_id.data, 32);
5235         return payment_id_arr;
5236 }
5237 int8_tArray CS_LDK_LDKRecentPaymentDetails_Pending_get_payment_id(int64_t ptr) {
5238         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5239         CHECK(obj->tag == LDKRecentPaymentDetails_Pending);
5240         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5241         memcpy(payment_id_arr->elems, obj->pending.payment_id.data, 32);
5242         return payment_id_arr;
5243 }
5244 int8_tArray CS_LDK_LDKRecentPaymentDetails_Pending_get_payment_hash(int64_t ptr) {
5245         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5246         CHECK(obj->tag == LDKRecentPaymentDetails_Pending);
5247         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
5248         memcpy(payment_hash_arr->elems, obj->pending.payment_hash.data, 32);
5249         return payment_hash_arr;
5250 }
5251 int64_t CS_LDK_LDKRecentPaymentDetails_Pending_get_total_msat(int64_t ptr) {
5252         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5253         CHECK(obj->tag == LDKRecentPaymentDetails_Pending);
5254         int64_t total_msat_conv = obj->pending.total_msat;
5255         return total_msat_conv;
5256 }
5257 int8_tArray CS_LDK_LDKRecentPaymentDetails_Fulfilled_get_payment_id(int64_t ptr) {
5258         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5259         CHECK(obj->tag == LDKRecentPaymentDetails_Fulfilled);
5260         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5261         memcpy(payment_id_arr->elems, obj->fulfilled.payment_id.data, 32);
5262         return payment_id_arr;
5263 }
5264 int64_t CS_LDK_LDKRecentPaymentDetails_Fulfilled_get_payment_hash(int64_t ptr) {
5265         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5266         CHECK(obj->tag == LDKRecentPaymentDetails_Fulfilled);
5267         int64_t payment_hash_ref = tag_ptr(&obj->fulfilled.payment_hash, false);
5268         return payment_hash_ref;
5269 }
5270 int8_tArray CS_LDK_LDKRecentPaymentDetails_Abandoned_get_payment_id(int64_t ptr) {
5271         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5272         CHECK(obj->tag == LDKRecentPaymentDetails_Abandoned);
5273         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5274         memcpy(payment_id_arr->elems, obj->abandoned.payment_id.data, 32);
5275         return payment_id_arr;
5276 }
5277 int8_tArray CS_LDK_LDKRecentPaymentDetails_Abandoned_get_payment_hash(int64_t ptr) {
5278         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5279         CHECK(obj->tag == LDKRecentPaymentDetails_Abandoned);
5280         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
5281         memcpy(payment_hash_arr->elems, obj->abandoned.payment_hash.data, 32);
5282         return payment_hash_arr;
5283 }
5284 static inline LDKCVec_RecentPaymentDetailsZ CVec_RecentPaymentDetailsZ_clone(const LDKCVec_RecentPaymentDetailsZ *orig) {
5285         LDKCVec_RecentPaymentDetailsZ ret = { .data = MALLOC(sizeof(LDKRecentPaymentDetails) * orig->datalen, "LDKCVec_RecentPaymentDetailsZ clone bytes"), .datalen = orig->datalen };
5286         for (size_t i = 0; i < ret.datalen; i++) {
5287                 ret.data[i] = RecentPaymentDetails_clone(&orig->data[i]);
5288         }
5289         return ret;
5290 }
5291 uint32_t CS_LDK_LDKPaymentSendFailure_ty_from_ptr(int64_t ptr) {
5292         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5293         switch(obj->tag) {
5294                 case LDKPaymentSendFailure_ParameterError: return 0;
5295                 case LDKPaymentSendFailure_PathParameterError: return 1;
5296                 case LDKPaymentSendFailure_AllFailedResendSafe: return 2;
5297                 case LDKPaymentSendFailure_DuplicatePayment: return 3;
5298                 case LDKPaymentSendFailure_PartialFailure: return 4;
5299                 default: abort();
5300         }
5301 }
5302 int64_t CS_LDK_LDKPaymentSendFailure_ParameterError_get_parameter_error(int64_t ptr) {
5303         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5304         CHECK(obj->tag == LDKPaymentSendFailure_ParameterError);
5305         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
5306         return parameter_error_ref;
5307 }
5308 int64_tArray CS_LDK_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(int64_t ptr) {
5309         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5310         CHECK(obj->tag == LDKPaymentSendFailure_PathParameterError);
5311         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5312                         int64_tArray path_parameter_error_arr = NULL;
5313                         path_parameter_error_arr = init_int64_tArray(path_parameter_error_var.datalen, __LINE__);
5314                         int64_t *path_parameter_error_arr_ptr = (int64_t*)(((uint8_t*)path_parameter_error_arr) + 8);
5315                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5316                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5317                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5318                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5319                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
5320                         }
5321                         
5322         return path_parameter_error_arr;
5323 }
5324 int64_tArray CS_LDK_LDKPaymentSendFailure_AllFailedResendSafe_get_all_failed_resend_safe(int64_t ptr) {
5325         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5326         CHECK(obj->tag == LDKPaymentSendFailure_AllFailedResendSafe);
5327         LDKCVec_APIErrorZ all_failed_resend_safe_var = obj->all_failed_resend_safe;
5328                         int64_tArray all_failed_resend_safe_arr = NULL;
5329                         all_failed_resend_safe_arr = init_int64_tArray(all_failed_resend_safe_var.datalen, __LINE__);
5330                         int64_t *all_failed_resend_safe_arr_ptr = (int64_t*)(((uint8_t*)all_failed_resend_safe_arr) + 8);
5331                         for (size_t k = 0; k < all_failed_resend_safe_var.datalen; k++) {
5332                                 int64_t all_failed_resend_safe_conv_10_ref = tag_ptr(&all_failed_resend_safe_var.data[k], false);
5333                                 all_failed_resend_safe_arr_ptr[k] = all_failed_resend_safe_conv_10_ref;
5334                         }
5335                         
5336         return all_failed_resend_safe_arr;
5337 }
5338 int64_tArray CS_LDK_LDKPaymentSendFailure_PartialFailure_get_results(int64_t ptr) {
5339         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5340         CHECK(obj->tag == LDKPaymentSendFailure_PartialFailure);
5341         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5342                         int64_tArray results_arr = NULL;
5343                         results_arr = init_int64_tArray(results_var.datalen, __LINE__);
5344                         int64_t *results_arr_ptr = (int64_t*)(((uint8_t*)results_arr) + 8);
5345                         for (size_t w = 0; w < results_var.datalen; w++) {
5346                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5347                                 *results_conv_22_conv = results_var.data[w];
5348                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5349                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
5350                         }
5351                         
5352         return results_arr;
5353 }
5354 int64_t CS_LDK_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(int64_t ptr) {
5355         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5356         CHECK(obj->tag == LDKPaymentSendFailure_PartialFailure);
5357         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5358                         int64_t failed_paths_retry_ref = 0;
5359                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5360                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
5361         return failed_paths_retry_ref;
5362 }
5363 int8_tArray CS_LDK_LDKPaymentSendFailure_PartialFailure_get_payment_id(int64_t ptr) {
5364         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5365         CHECK(obj->tag == LDKPaymentSendFailure_PartialFailure);
5366         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5367         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
5368         return payment_id_arr;
5369 }
5370 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5371 CHECK(owner->result_ok);
5372         return *owner->contents.result;
5373 }
5374 void  CS_LDK_CResult_NonePaymentSendFailureZ_get_ok(int64_t owner) {
5375         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
5376         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5377 }
5378
5379 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5380 CHECK(!owner->result_ok);
5381         return PaymentSendFailure_clone(&*owner->contents.err);
5382 }
5383 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_get_err(int64_t owner) {
5384         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
5385         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5386         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5387         int64_t ret_ref = tag_ptr(ret_copy, true);
5388         return ret_ref;
5389 }
5390
5391 static inline void CResult_NoneRetryableSendFailureZ_get_ok(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
5392 CHECK(owner->result_ok);
5393         return *owner->contents.result;
5394 }
5395 void  CS_LDK_CResult_NoneRetryableSendFailureZ_get_ok(int64_t owner) {
5396         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
5397         CResult_NoneRetryableSendFailureZ_get_ok(owner_conv);
5398 }
5399
5400 static inline enum LDKRetryableSendFailure CResult_NoneRetryableSendFailureZ_get_err(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
5401 CHECK(!owner->result_ok);
5402         return RetryableSendFailure_clone(&*owner->contents.err);
5403 }
5404 int32_t  CS_LDK_CResult_NoneRetryableSendFailureZ_get_err(int64_t owner) {
5405         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
5406         int32_t ret_conv = LDKRetryableSendFailure_to_cs(CResult_NoneRetryableSendFailureZ_get_err(owner_conv));
5407         return ret_conv;
5408 }
5409
5410 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesPaymentSendFailureZ_get_ok(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ *NONNULL_PTR owner){
5411 CHECK(owner->result_ok);
5412         return ThirtyTwoBytes_clone(&*owner->contents.result);
5413 }
5414 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_get_ok(int64_t owner) {
5415         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* owner_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(owner);
5416         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5417         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesPaymentSendFailureZ_get_ok(owner_conv).data, 32);
5418         return ret_arr;
5419 }
5420
5421 static inline struct LDKPaymentSendFailure CResult_ThirtyTwoBytesPaymentSendFailureZ_get_err(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ *NONNULL_PTR owner){
5422 CHECK(!owner->result_ok);
5423         return PaymentSendFailure_clone(&*owner->contents.err);
5424 }
5425 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_get_err(int64_t owner) {
5426         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* owner_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(owner);
5427         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5428         *ret_copy = CResult_ThirtyTwoBytesPaymentSendFailureZ_get_err(owner_conv);
5429         int64_t ret_ref = tag_ptr(ret_copy, true);
5430         return ret_ref;
5431 }
5432
5433 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesRetryableSendFailureZ_get_ok(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ *NONNULL_PTR owner){
5434 CHECK(owner->result_ok);
5435         return ThirtyTwoBytes_clone(&*owner->contents.result);
5436 }
5437 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_get_ok(int64_t owner) {
5438         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* owner_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(owner);
5439         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5440         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesRetryableSendFailureZ_get_ok(owner_conv).data, 32);
5441         return ret_arr;
5442 }
5443
5444 static inline enum LDKRetryableSendFailure CResult_ThirtyTwoBytesRetryableSendFailureZ_get_err(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ *NONNULL_PTR owner){
5445 CHECK(!owner->result_ok);
5446         return RetryableSendFailure_clone(&*owner->contents.err);
5447 }
5448 int32_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_get_err(int64_t owner) {
5449         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* owner_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(owner);
5450         int32_t ret_conv = LDKRetryableSendFailure_to_cs(CResult_ThirtyTwoBytesRetryableSendFailureZ_get_err(owner_conv));
5451         return ret_conv;
5452 }
5453
5454 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_a(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ *NONNULL_PTR owner){
5455         return ThirtyTwoBytes_clone(&owner->a);
5456 }
5457 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_a(int64_t owner) {
5458         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(owner);
5459         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5460         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_a(owner_conv).data, 32);
5461         return ret_arr;
5462 }
5463
5464 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_b(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ *NONNULL_PTR owner){
5465         return ThirtyTwoBytes_clone(&owner->b);
5466 }
5467 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_b(int64_t owner) {
5468         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(owner);
5469         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5470         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_b(owner_conv).data, 32);
5471         return ret_arr;
5472 }
5473
5474 static inline struct LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ *NONNULL_PTR owner){
5475 CHECK(owner->result_ok);
5476         return C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(&*owner->contents.result);
5477 }
5478 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_ok(int64_t owner) {
5479         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(owner);
5480         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
5481         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_ok(owner_conv);
5482         return tag_ptr(ret_conv, true);
5483 }
5484
5485 static inline struct LDKPaymentSendFailure CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ *NONNULL_PTR owner){
5486 CHECK(!owner->result_ok);
5487         return PaymentSendFailure_clone(&*owner->contents.err);
5488 }
5489 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_err(int64_t owner) {
5490         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(owner);
5491         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5492         *ret_copy = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_err(owner_conv);
5493         int64_t ret_ref = tag_ptr(ret_copy, true);
5494         return ret_ref;
5495 }
5496
5497 static inline LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ *orig) {
5498         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ clone bytes"), .datalen = orig->datalen };
5499         for (size_t i = 0; i < ret.datalen; i++) {
5500                 ret.data[i] = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(&orig->data[i]);
5501         }
5502         return ret;
5503 }
5504 uint32_t CS_LDK_LDKProbeSendFailure_ty_from_ptr(int64_t ptr) {
5505         LDKProbeSendFailure *obj = (LDKProbeSendFailure*)untag_ptr(ptr);
5506         switch(obj->tag) {
5507                 case LDKProbeSendFailure_RouteNotFound: return 0;
5508                 case LDKProbeSendFailure_SendingFailed: return 1;
5509                 default: abort();
5510         }
5511 }
5512 int64_t CS_LDK_LDKProbeSendFailure_SendingFailed_get_sending_failed(int64_t ptr) {
5513         LDKProbeSendFailure *obj = (LDKProbeSendFailure*)untag_ptr(ptr);
5514         CHECK(obj->tag == LDKProbeSendFailure_SendingFailed);
5515         int64_t sending_failed_ref = tag_ptr(&obj->sending_failed, false);
5516         return sending_failed_ref;
5517 }
5518 static inline struct LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_ok(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ *NONNULL_PTR owner){
5519 CHECK(owner->result_ok);
5520         return CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_clone(&*owner->contents.result);
5521 }
5522 int64_tArray  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_ok(int64_t owner) {
5523         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(owner);
5524         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ ret_var = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_ok(owner_conv);
5525         int64_tArray ret_arr = NULL;
5526         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
5527         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
5528         for (size_t o = 0; o < ret_var.datalen; o++) {
5529                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
5530                 *ret_conv_40_conv = ret_var.data[o];
5531                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
5532         }
5533         
5534         FREE(ret_var.data);
5535         return ret_arr;
5536 }
5537
5538 static inline struct LDKProbeSendFailure CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_err(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ *NONNULL_PTR owner){
5539 CHECK(!owner->result_ok);
5540         return ProbeSendFailure_clone(&*owner->contents.err);
5541 }
5542 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_err(int64_t owner) {
5543         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(owner);
5544         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
5545         *ret_copy = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_err(owner_conv);
5546         int64_t ret_ref = tag_ptr(ret_copy, true);
5547         return ret_ref;
5548 }
5549
5550 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesPublicKeyZ_get_a(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ *NONNULL_PTR owner){
5551         return ThirtyTwoBytes_clone(&owner->a);
5552 }
5553 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_get_a(int64_t owner) {
5554         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(owner);
5555         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5556         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesPublicKeyZ_get_a(owner_conv).data, 32);
5557         return ret_arr;
5558 }
5559
5560 static inline struct LDKPublicKey C2Tuple_ThirtyTwoBytesPublicKeyZ_get_b(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ *NONNULL_PTR owner){
5561         return owner->b;
5562 }
5563 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_get_b(int64_t owner) {
5564         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(owner);
5565         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
5566         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesPublicKeyZ_get_b(owner_conv).compressed_form, 33);
5567         return ret_arr;
5568 }
5569
5570 static inline LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ *orig) {
5571         LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ clone bytes"), .datalen = orig->datalen };
5572         for (size_t i = 0; i < ret.datalen; i++) {
5573                 ret.data[i] = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(&orig->data[i]);
5574         }
5575         return ret;
5576 }
5577 uint32_t CS_LDK_LDKCOption_StrZ_ty_from_ptr(int64_t ptr) {
5578         LDKCOption_StrZ *obj = (LDKCOption_StrZ*)untag_ptr(ptr);
5579         switch(obj->tag) {
5580                 case LDKCOption_StrZ_Some: return 0;
5581                 case LDKCOption_StrZ_None: return 1;
5582                 default: abort();
5583         }
5584 }
5585 jstring CS_LDK_LDKCOption_StrZ_Some_get_some(int64_t ptr) {
5586         LDKCOption_StrZ *obj = (LDKCOption_StrZ*)untag_ptr(ptr);
5587         CHECK(obj->tag == LDKCOption_StrZ_Some);
5588         LDKStr some_str = obj->some;
5589                         jstring some_conv = str_ref_to_cs(some_str.chars, some_str.len);
5590         return some_conv;
5591 }
5592 static inline void CResult_NoneBolt12SemanticErrorZ_get_ok(LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR owner){
5593 CHECK(owner->result_ok);
5594         return *owner->contents.result;
5595 }
5596 void  CS_LDK_CResult_NoneBolt12SemanticErrorZ_get_ok(int64_t owner) {
5597         LDKCResult_NoneBolt12SemanticErrorZ* owner_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(owner);
5598         CResult_NoneBolt12SemanticErrorZ_get_ok(owner_conv);
5599 }
5600
5601 static inline enum LDKBolt12SemanticError CResult_NoneBolt12SemanticErrorZ_get_err(LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR owner){
5602 CHECK(!owner->result_ok);
5603         return Bolt12SemanticError_clone(&*owner->contents.err);
5604 }
5605 int32_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_get_err(int64_t owner) {
5606         LDKCResult_NoneBolt12SemanticErrorZ* owner_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(owner);
5607         int32_t ret_conv = LDKBolt12SemanticError_to_cs(CResult_NoneBolt12SemanticErrorZ_get_err(owner_conv));
5608         return ret_conv;
5609 }
5610
5611 static inline struct LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR owner){
5612 CHECK(owner->result_ok);
5613         return C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(&*owner->contents.result);
5614 }
5615 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_ok(int64_t owner) {
5616         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(owner);
5617         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
5618         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_ok(owner_conv);
5619         return tag_ptr(ret_conv, true);
5620 }
5621
5622 static inline void CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR owner){
5623 CHECK(!owner->result_ok);
5624         return *owner->contents.err;
5625 }
5626 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_err(int64_t owner) {
5627         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(owner);
5628         CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_err(owner_conv);
5629 }
5630
5631 uint32_t CS_LDK_LDKOffersMessage_ty_from_ptr(int64_t ptr) {
5632         LDKOffersMessage *obj = (LDKOffersMessage*)untag_ptr(ptr);
5633         switch(obj->tag) {
5634                 case LDKOffersMessage_InvoiceRequest: return 0;
5635                 case LDKOffersMessage_Invoice: return 1;
5636                 case LDKOffersMessage_InvoiceError: return 2;
5637                 default: abort();
5638         }
5639 }
5640 int64_t CS_LDK_LDKOffersMessage_InvoiceRequest_get_invoice_request(int64_t ptr) {
5641         LDKOffersMessage *obj = (LDKOffersMessage*)untag_ptr(ptr);
5642         CHECK(obj->tag == LDKOffersMessage_InvoiceRequest);
5643         LDKInvoiceRequest invoice_request_var = obj->invoice_request;
5644                         int64_t invoice_request_ref = 0;
5645                         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_request_var);
5646                         invoice_request_ref = tag_ptr(invoice_request_var.inner, false);
5647         return invoice_request_ref;
5648 }
5649 int64_t CS_LDK_LDKOffersMessage_Invoice_get_invoice(int64_t ptr) {
5650         LDKOffersMessage *obj = (LDKOffersMessage*)untag_ptr(ptr);
5651         CHECK(obj->tag == LDKOffersMessage_Invoice);
5652         LDKBolt12Invoice invoice_var = obj->invoice;
5653                         int64_t invoice_ref = 0;
5654                         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_var);
5655                         invoice_ref = tag_ptr(invoice_var.inner, false);
5656         return invoice_ref;
5657 }
5658 int64_t CS_LDK_LDKOffersMessage_InvoiceError_get_invoice_error(int64_t ptr) {
5659         LDKOffersMessage *obj = (LDKOffersMessage*)untag_ptr(ptr);
5660         CHECK(obj->tag == LDKOffersMessage_InvoiceError);
5661         LDKInvoiceError invoice_error_var = obj->invoice_error;
5662                         int64_t invoice_error_ref = 0;
5663                         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_error_var);
5664                         invoice_error_ref = tag_ptr(invoice_error_var.inner, false);
5665         return invoice_error_ref;
5666 }
5667 uint32_t CS_LDK_LDKCOption_OffersMessageZ_ty_from_ptr(int64_t ptr) {
5668         LDKCOption_OffersMessageZ *obj = (LDKCOption_OffersMessageZ*)untag_ptr(ptr);
5669         switch(obj->tag) {
5670                 case LDKCOption_OffersMessageZ_Some: return 0;
5671                 case LDKCOption_OffersMessageZ_None: return 1;
5672                 default: abort();
5673         }
5674 }
5675 int64_t CS_LDK_LDKCOption_OffersMessageZ_Some_get_some(int64_t ptr) {
5676         LDKCOption_OffersMessageZ *obj = (LDKCOption_OffersMessageZ*)untag_ptr(ptr);
5677         CHECK(obj->tag == LDKCOption_OffersMessageZ_Some);
5678         int64_t some_ref = tag_ptr(&obj->some, false);
5679         return some_ref;
5680 }
5681 uint32_t CS_LDK_LDKDestination_ty_from_ptr(int64_t ptr) {
5682         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
5683         switch(obj->tag) {
5684                 case LDKDestination_Node: return 0;
5685                 case LDKDestination_BlindedPath: return 1;
5686                 default: abort();
5687         }
5688 }
5689 int8_tArray CS_LDK_LDKDestination_Node_get_node(int64_t ptr) {
5690         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
5691         CHECK(obj->tag == LDKDestination_Node);
5692         int8_tArray node_arr = init_int8_tArray(33, __LINE__);
5693         memcpy(node_arr->elems, obj->node.compressed_form, 33);
5694         return node_arr;
5695 }
5696 int64_t CS_LDK_LDKDestination_BlindedPath_get_blinded_path(int64_t ptr) {
5697         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
5698         CHECK(obj->tag == LDKDestination_BlindedPath);
5699         LDKBlindedPath blinded_path_var = obj->blinded_path;
5700                         int64_t blinded_path_ref = 0;
5701                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_path_var);
5702                         blinded_path_ref = tag_ptr(blinded_path_var.inner, false);
5703         return blinded_path_ref;
5704 }
5705 static inline struct LDKOffersMessage C3Tuple_OffersMessageDestinationBlindedPathZ_get_a(LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR owner){
5706         return OffersMessage_clone(&owner->a);
5707 }
5708 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_get_a(int64_t owner) {
5709         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(owner);
5710         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
5711         *ret_copy = C3Tuple_OffersMessageDestinationBlindedPathZ_get_a(owner_conv);
5712         int64_t ret_ref = tag_ptr(ret_copy, true);
5713         return ret_ref;
5714 }
5715
5716 static inline struct LDKDestination C3Tuple_OffersMessageDestinationBlindedPathZ_get_b(LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR owner){
5717         return Destination_clone(&owner->b);
5718 }
5719 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_get_b(int64_t owner) {
5720         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(owner);
5721         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
5722         *ret_copy = C3Tuple_OffersMessageDestinationBlindedPathZ_get_b(owner_conv);
5723         int64_t ret_ref = tag_ptr(ret_copy, true);
5724         return ret_ref;
5725 }
5726
5727 static inline struct LDKBlindedPath C3Tuple_OffersMessageDestinationBlindedPathZ_get_c(LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR owner){
5728         LDKBlindedPath ret = owner->c;
5729         ret.is_owned = false;
5730         return ret;
5731 }
5732 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_get_c(int64_t owner) {
5733         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(owner);
5734         LDKBlindedPath ret_var = C3Tuple_OffersMessageDestinationBlindedPathZ_get_c(owner_conv);
5735         int64_t ret_ref = 0;
5736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5738         return ret_ref;
5739 }
5740
5741 static inline LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_clone(const LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ *orig) {
5742         LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ) * orig->datalen, "LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ clone bytes"), .datalen = orig->datalen };
5743         for (size_t i = 0; i < ret.datalen; i++) {
5744                 ret.data[i] = C3Tuple_OffersMessageDestinationBlindedPathZ_clone(&orig->data[i]);
5745         }
5746         return ret;
5747 }
5748 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5749         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
5750         ret.is_owned = false;
5751         return ret;
5752 }
5753 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(int64_t owner) {
5754         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
5755         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5756         int64_t ret_ref = 0;
5757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5759         return ret_ref;
5760 }
5761
5762 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5763 CHECK(!owner->result_ok);
5764         return DecodeError_clone(&*owner->contents.err);
5765 }
5766 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(int64_t owner) {
5767         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
5768         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5769         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5770         int64_t ret_ref = tag_ptr(ret_copy, true);
5771         return ret_ref;
5772 }
5773
5774 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5775         LDKChannelCounterparty ret = *owner->contents.result;
5776         ret.is_owned = false;
5777         return ret;
5778 }
5779 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(int64_t owner) {
5780         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
5781         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5782         int64_t ret_ref = 0;
5783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5785         return ret_ref;
5786 }
5787
5788 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5789 CHECK(!owner->result_ok);
5790         return DecodeError_clone(&*owner->contents.err);
5791 }
5792 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_get_err(int64_t owner) {
5793         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
5794         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5795         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5796         int64_t ret_ref = tag_ptr(ret_copy, true);
5797         return ret_ref;
5798 }
5799
5800 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5801         LDKChannelDetails ret = *owner->contents.result;
5802         ret.is_owned = false;
5803         return ret;
5804 }
5805 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_get_ok(int64_t owner) {
5806         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
5807         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5808         int64_t ret_ref = 0;
5809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5811         return ret_ref;
5812 }
5813
5814 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5815 CHECK(!owner->result_ok);
5816         return DecodeError_clone(&*owner->contents.err);
5817 }
5818 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_get_err(int64_t owner) {
5819         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
5820         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5821         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5822         int64_t ret_ref = tag_ptr(ret_copy, true);
5823         return ret_ref;
5824 }
5825
5826 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5827         LDKPhantomRouteHints ret = *owner->contents.result;
5828         ret.is_owned = false;
5829         return ret;
5830 }
5831 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(int64_t owner) {
5832         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
5833         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5834         int64_t ret_ref = 0;
5835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5837         return ret_ref;
5838 }
5839
5840 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5841 CHECK(!owner->result_ok);
5842         return DecodeError_clone(&*owner->contents.err);
5843 }
5844 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_get_err(int64_t owner) {
5845         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
5846         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5847         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5848         int64_t ret_ref = tag_ptr(ret_copy, true);
5849         return ret_ref;
5850 }
5851
5852 static inline enum LDKChannelShutdownState CResult_ChannelShutdownStateDecodeErrorZ_get_ok(LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR owner){
5853 CHECK(owner->result_ok);
5854         return ChannelShutdownState_clone(&*owner->contents.result);
5855 }
5856 int32_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_get_ok(int64_t owner) {
5857         LDKCResult_ChannelShutdownStateDecodeErrorZ* owner_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(owner);
5858         int32_t ret_conv = LDKChannelShutdownState_to_cs(CResult_ChannelShutdownStateDecodeErrorZ_get_ok(owner_conv));
5859         return ret_conv;
5860 }
5861
5862 static inline struct LDKDecodeError CResult_ChannelShutdownStateDecodeErrorZ_get_err(LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR owner){
5863 CHECK(!owner->result_ok);
5864         return DecodeError_clone(&*owner->contents.err);
5865 }
5866 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_get_err(int64_t owner) {
5867         LDKCResult_ChannelShutdownStateDecodeErrorZ* owner_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(owner);
5868         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5869         *ret_copy = CResult_ChannelShutdownStateDecodeErrorZ_get_err(owner_conv);
5870         int64_t ret_ref = tag_ptr(ret_copy, true);
5871         return ret_ref;
5872 }
5873
5874 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5875         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5876         for (size_t i = 0; i < ret.datalen; i++) {
5877                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5878         }
5879         return ret;
5880 }
5881 typedef struct LDKWatch_JCalls {
5882         atomic_size_t refcnt;
5883         uint32_t instance_ptr;
5884 } LDKWatch_JCalls;
5885 static void LDKWatch_JCalls_free(void* this_arg) {
5886         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5887         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5888                 FREE(j_calls);
5889         }
5890 }
5891 LDKCResult_ChannelMonitorUpdateStatusNoneZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5892         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5893         LDKOutPoint funding_txo_var = funding_txo;
5894         int64_t funding_txo_ref = 0;
5895         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5896         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
5897         LDKChannelMonitor monitor_var = monitor;
5898         int64_t monitor_ref = 0;
5899         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5900         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
5901         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 26, funding_txo_ref, monitor_ref);
5902         void* ret_ptr = untag_ptr(ret);
5903         CHECK_ACCESS(ret_ptr);
5904         LDKCResult_ChannelMonitorUpdateStatusNoneZ ret_conv = *(LDKCResult_ChannelMonitorUpdateStatusNoneZ*)(ret_ptr);
5905         FREE(untag_ptr(ret));
5906         return ret_conv;
5907 }
5908 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, const LDKChannelMonitorUpdate * update) {
5909         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5910         LDKOutPoint funding_txo_var = funding_txo;
5911         int64_t funding_txo_ref = 0;
5912         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5913         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
5914         LDKChannelMonitorUpdate update_var = *update;
5915         int64_t update_ref = 0;
5916         update_var = ChannelMonitorUpdate_clone(&update_var);
5917         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5918         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
5919         uint64_t ret = js_invoke_function_ChannelMonitorUpdateStatus_ll(j_calls->instance_ptr, 27, funding_txo_ref, update_ref);
5920         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_cs(ret);
5921         return ret_conv;
5922 }
5923 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5924         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5925         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 28);
5926         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
5927         ret_constr.datalen = ret->arr_len;
5928         if (ret_constr.datalen > 0)
5929                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
5930         else
5931                 ret_constr.data = NULL;
5932         int64_t* ret_vals = ret->elems;
5933         for (size_t x = 0; x < ret_constr.datalen; x++) {
5934                 int64_t ret_conv_49 = ret_vals[x];
5935                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
5936                 CHECK_ACCESS(ret_conv_49_ptr);
5937                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
5938                 FREE(untag_ptr(ret_conv_49));
5939                 ret_constr.data[x] = ret_conv_49_conv;
5940         }
5941         FREE(ret);
5942         return ret_constr;
5943 }
5944 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5945         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5946         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5947 }
5948 static inline LDKWatch LDKWatch_init (int64_t o) {
5949         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5950         atomic_init(&calls->refcnt, 1);
5951         calls->instance_ptr = o;
5952
5953         LDKWatch ret = {
5954                 .this_arg = (void*) calls,
5955                 .watch_channel = watch_channel_LDKWatch_jcall,
5956                 .update_channel = update_channel_LDKWatch_jcall,
5957                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5958                 .free = LDKWatch_JCalls_free,
5959         };
5960         return ret;
5961 }
5962 uint64_t  CS_LDK_LDKWatch_new(int32_t o) {
5963         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5964         *res_ptr = LDKWatch_init(o);
5965         return tag_ptr(res_ptr, true);
5966 }
5967 int64_t  CS_LDK_Watch_watch_channel(int64_t this_arg, int64_t funding_txo, int64_t monitor) {
5968         void* this_arg_ptr = untag_ptr(this_arg);
5969         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5970         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5971         LDKOutPoint funding_txo_conv;
5972         funding_txo_conv.inner = untag_ptr(funding_txo);
5973         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
5974         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5975         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5976         LDKChannelMonitor monitor_conv;
5977         monitor_conv.inner = untag_ptr(monitor);
5978         monitor_conv.is_owned = ptr_is_owned(monitor);
5979         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5980         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5981         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
5982         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5983         return tag_ptr(ret_conv, true);
5984 }
5985
5986 int32_t  CS_LDK_Watch_update_channel(int64_t this_arg, int64_t funding_txo, int64_t update) {
5987         void* this_arg_ptr = untag_ptr(this_arg);
5988         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5989         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5990         LDKOutPoint funding_txo_conv;
5991         funding_txo_conv.inner = untag_ptr(funding_txo);
5992         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
5993         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5994         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5995         LDKChannelMonitorUpdate update_conv;
5996         update_conv.inner = untag_ptr(update);
5997         update_conv.is_owned = ptr_is_owned(update);
5998         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5999         update_conv.is_owned = false;
6000         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs((this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, &update_conv));
6001         return ret_conv;
6002 }
6003
6004 int64_tArray  CS_LDK_Watch_release_pending_monitor_events(int64_t this_arg) {
6005         void* this_arg_ptr = untag_ptr(this_arg);
6006         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6007         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6008         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6009         int64_tArray ret_arr = NULL;
6010         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
6011         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
6012         for (size_t x = 0; x < ret_var.datalen; x++) {
6013                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
6014                 *ret_conv_49_conv = ret_var.data[x];
6015                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
6016         }
6017         
6018         FREE(ret_var.data);
6019         return ret_arr;
6020 }
6021
6022 typedef struct LDKBroadcasterInterface_JCalls {
6023         atomic_size_t refcnt;
6024         uint32_t instance_ptr;
6025 } LDKBroadcasterInterface_JCalls;
6026 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6027         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6028         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6029                 FREE(j_calls);
6030         }
6031 }
6032 void broadcast_transactions_LDKBroadcasterInterface_jcall(const void* this_arg, LDKCVec_TransactionZ txs) {
6033         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6034         LDKCVec_TransactionZ txs_var = txs;
6035         ptrArray txs_arr = NULL;
6036         txs_arr = init_ptrArray(txs_var.datalen, __LINE__);
6037         int8_tArray *txs_arr_ptr = (int8_tArray*)(((uint8_t*)txs_arr) + 8);
6038         for (size_t i = 0; i < txs_var.datalen; i++) {
6039                 LDKTransaction txs_conv_8_var = txs_var.data[i];
6040                 int8_tArray txs_conv_8_arr = init_int8_tArray(txs_conv_8_var.datalen, __LINE__);
6041                 memcpy(txs_conv_8_arr->elems, txs_conv_8_var.data, txs_conv_8_var.datalen);
6042                 Transaction_free(txs_conv_8_var);
6043                 txs_arr_ptr[i] = txs_conv_8_arr;
6044         }
6045         
6046         FREE(txs_var.data);
6047         js_invoke_function_void_l(j_calls->instance_ptr, 29, (int64_t)txs_arr);
6048 }
6049 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6050         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6051         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6052 }
6053 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (int64_t o) {
6054         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6055         atomic_init(&calls->refcnt, 1);
6056         calls->instance_ptr = o;
6057
6058         LDKBroadcasterInterface ret = {
6059                 .this_arg = (void*) calls,
6060                 .broadcast_transactions = broadcast_transactions_LDKBroadcasterInterface_jcall,
6061                 .free = LDKBroadcasterInterface_JCalls_free,
6062         };
6063         return ret;
6064 }
6065 uint64_t  CS_LDK_LDKBroadcasterInterface_new(int32_t o) {
6066         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6067         *res_ptr = LDKBroadcasterInterface_init(o);
6068         return tag_ptr(res_ptr, true);
6069 }
6070 void  CS_LDK_BroadcasterInterface_broadcast_transactions(int64_t this_arg, ptrArray txs) {
6071         void* this_arg_ptr = untag_ptr(this_arg);
6072         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6073         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6074         LDKCVec_TransactionZ txs_constr;
6075         txs_constr.datalen = txs->arr_len;
6076         if (txs_constr.datalen > 0)
6077                 txs_constr.data = MALLOC(txs_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
6078         else
6079                 txs_constr.data = NULL;
6080         int8_tArray* txs_vals = (void*) txs->elems;
6081         for (size_t i = 0; i < txs_constr.datalen; i++) {
6082                 int8_tArray txs_conv_8 = txs_vals[i];
6083                 LDKTransaction txs_conv_8_ref;
6084                 txs_conv_8_ref.datalen = txs_conv_8->arr_len;
6085                 txs_conv_8_ref.data = MALLOC(txs_conv_8_ref.datalen, "LDKTransaction Bytes");
6086                 memcpy(txs_conv_8_ref.data, txs_conv_8->elems, txs_conv_8_ref.datalen); FREE(txs_conv_8);
6087                 txs_conv_8_ref.data_is_owned = true;
6088                 txs_constr.data[i] = txs_conv_8_ref;
6089         }
6090         FREE(txs);
6091         (this_arg_conv->broadcast_transactions)(this_arg_conv->this_arg, txs_constr);
6092 }
6093
6094 typedef struct LDKEntropySource_JCalls {
6095         atomic_size_t refcnt;
6096         uint32_t instance_ptr;
6097 } LDKEntropySource_JCalls;
6098 static void LDKEntropySource_JCalls_free(void* this_arg) {
6099         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
6100         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6101                 FREE(j_calls);
6102         }
6103 }
6104 LDKThirtyTwoBytes get_secure_random_bytes_LDKEntropySource_jcall(const void* this_arg) {
6105         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
6106         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 30);
6107         LDKThirtyTwoBytes ret_ref;
6108         CHECK(ret->arr_len == 32);
6109         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6110         return ret_ref;
6111 }
6112 static void LDKEntropySource_JCalls_cloned(LDKEntropySource* new_obj) {
6113         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) new_obj->this_arg;
6114         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6115 }
6116 static inline LDKEntropySource LDKEntropySource_init (int64_t o) {
6117         LDKEntropySource_JCalls *calls = MALLOC(sizeof(LDKEntropySource_JCalls), "LDKEntropySource_JCalls");
6118         atomic_init(&calls->refcnt, 1);
6119         calls->instance_ptr = o;
6120
6121         LDKEntropySource ret = {
6122                 .this_arg = (void*) calls,
6123                 .get_secure_random_bytes = get_secure_random_bytes_LDKEntropySource_jcall,
6124                 .free = LDKEntropySource_JCalls_free,
6125         };
6126         return ret;
6127 }
6128 uint64_t  CS_LDK_LDKEntropySource_new(int32_t o) {
6129         LDKEntropySource *res_ptr = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
6130         *res_ptr = LDKEntropySource_init(o);
6131         return tag_ptr(res_ptr, true);
6132 }
6133 int8_tArray  CS_LDK_EntropySource_get_secure_random_bytes(int64_t this_arg) {
6134         void* this_arg_ptr = untag_ptr(this_arg);
6135         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6136         LDKEntropySource* this_arg_conv = (LDKEntropySource*)this_arg_ptr;
6137         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6138         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
6139         return ret_arr;
6140 }
6141
6142 uint32_t CS_LDK_LDKUnsignedGossipMessage_ty_from_ptr(int64_t ptr) {
6143         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
6144         switch(obj->tag) {
6145                 case LDKUnsignedGossipMessage_ChannelAnnouncement: return 0;
6146                 case LDKUnsignedGossipMessage_ChannelUpdate: return 1;
6147                 case LDKUnsignedGossipMessage_NodeAnnouncement: return 2;
6148                 default: abort();
6149         }
6150 }
6151 int64_t CS_LDK_LDKUnsignedGossipMessage_ChannelAnnouncement_get_channel_announcement(int64_t ptr) {
6152         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
6153         CHECK(obj->tag == LDKUnsignedGossipMessage_ChannelAnnouncement);
6154         LDKUnsignedChannelAnnouncement channel_announcement_var = obj->channel_announcement;
6155                         int64_t channel_announcement_ref = 0;
6156                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_announcement_var);
6157                         channel_announcement_ref = tag_ptr(channel_announcement_var.inner, false);
6158         return channel_announcement_ref;
6159 }
6160 int64_t CS_LDK_LDKUnsignedGossipMessage_ChannelUpdate_get_channel_update(int64_t ptr) {
6161         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
6162         CHECK(obj->tag == LDKUnsignedGossipMessage_ChannelUpdate);
6163         LDKUnsignedChannelUpdate channel_update_var = obj->channel_update;
6164                         int64_t channel_update_ref = 0;
6165                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_update_var);
6166                         channel_update_ref = tag_ptr(channel_update_var.inner, false);
6167         return channel_update_ref;
6168 }
6169 int64_t CS_LDK_LDKUnsignedGossipMessage_NodeAnnouncement_get_node_announcement(int64_t ptr) {
6170         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
6171         CHECK(obj->tag == LDKUnsignedGossipMessage_NodeAnnouncement);
6172         LDKUnsignedNodeAnnouncement node_announcement_var = obj->node_announcement;
6173                         int64_t node_announcement_ref = 0;
6174                         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_announcement_var);
6175                         node_announcement_ref = tag_ptr(node_announcement_var.inner, false);
6176         return node_announcement_ref;
6177 }
6178 typedef struct LDKNodeSigner_JCalls {
6179         atomic_size_t refcnt;
6180         uint32_t instance_ptr;
6181 } LDKNodeSigner_JCalls;
6182 static void LDKNodeSigner_JCalls_free(void* this_arg) {
6183         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6184         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6185                 FREE(j_calls);
6186         }
6187 }
6188 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKNodeSigner_jcall(const void* this_arg) {
6189         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6190         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 31);
6191         LDKThirtyTwoBytes ret_ref;
6192         CHECK(ret->arr_len == 32);
6193         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6194         return ret_ref;
6195 }
6196 LDKCResult_PublicKeyNoneZ get_node_id_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient) {
6197         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6198         int32_t recipient_conv = LDKRecipient_to_cs(recipient);
6199         uint64_t ret = js_invoke_function_l_Recipient(j_calls->instance_ptr, 32, recipient_conv);
6200         void* ret_ptr = untag_ptr(ret);
6201         CHECK_ACCESS(ret_ptr);
6202         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
6203         FREE(untag_ptr(ret));
6204         return ret_conv;
6205 }
6206 LDKCResult_ThirtyTwoBytesNoneZ ecdh_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_BigEndianScalarZ tweak) {
6207         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6208         int32_t recipient_conv = LDKRecipient_to_cs(recipient);
6209         int8_tArray other_key_arr = init_int8_tArray(33, __LINE__);
6210         memcpy(other_key_arr->elems, other_key.compressed_form, 33);
6211         LDKCOption_BigEndianScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
6212         *tweak_copy = tweak;
6213         int64_t tweak_ref = tag_ptr(tweak_copy, true);
6214         uint64_t ret = js_invoke_function_l_Recipientll(j_calls->instance_ptr, 33, recipient_conv, (int64_t)other_key_arr, tweak_ref);
6215         void* ret_ptr = untag_ptr(ret);
6216         CHECK_ACCESS(ret_ptr);
6217         LDKCResult_ThirtyTwoBytesNoneZ ret_conv = *(LDKCResult_ThirtyTwoBytesNoneZ*)(ret_ptr);
6218         FREE(untag_ptr(ret));
6219         return ret_conv;
6220 }
6221 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKNodeSigner_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_U5Z invoice_data, LDKRecipient recipient) {
6222         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6223         LDKu8slice hrp_bytes_var = hrp_bytes;
6224         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
6225         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
6226         LDKCVec_U5Z invoice_data_var = invoice_data;
6227         ptrArray invoice_data_arr = NULL;
6228         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
6229         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 8);
6230         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
6231                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
6232                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
6233         }
6234         
6235         FREE(invoice_data_var.data);
6236         int32_t recipient_conv = LDKRecipient_to_cs(recipient);
6237         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);
6238         void* ret_ptr = untag_ptr(ret);
6239         CHECK_ACCESS(ret_ptr);
6240         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6241         FREE(untag_ptr(ret));
6242         return ret_conv;
6243 }
6244 LDKCResult_SchnorrSignatureNoneZ sign_bolt12_invoice_request_LDKNodeSigner_jcall(const void* this_arg, const LDKUnsignedInvoiceRequest * invoice_request) {
6245         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6246         LDKUnsignedInvoiceRequest invoice_request_var = *invoice_request;
6247         int64_t invoice_request_ref = 0;
6248         // WARNING: we may need a move here but no clone is available for LDKUnsignedInvoiceRequest
6249         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_request_var);
6250         invoice_request_ref = tag_ptr(invoice_request_var.inner, invoice_request_var.is_owned);
6251         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 35, invoice_request_ref);
6252         void* ret_ptr = untag_ptr(ret);
6253         CHECK_ACCESS(ret_ptr);
6254         LDKCResult_SchnorrSignatureNoneZ ret_conv = *(LDKCResult_SchnorrSignatureNoneZ*)(ret_ptr);
6255         FREE(untag_ptr(ret));
6256         return ret_conv;
6257 }
6258 LDKCResult_SchnorrSignatureNoneZ sign_bolt12_invoice_LDKNodeSigner_jcall(const void* this_arg, const LDKUnsignedBolt12Invoice * invoice) {
6259         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6260         LDKUnsignedBolt12Invoice invoice_var = *invoice;
6261         int64_t invoice_ref = 0;
6262         // WARNING: we may need a move here but no clone is available for LDKUnsignedBolt12Invoice
6263         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_var);
6264         invoice_ref = tag_ptr(invoice_var.inner, invoice_var.is_owned);
6265         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 36, invoice_ref);
6266         void* ret_ptr = untag_ptr(ret);
6267         CHECK_ACCESS(ret_ptr);
6268         LDKCResult_SchnorrSignatureNoneZ ret_conv = *(LDKCResult_SchnorrSignatureNoneZ*)(ret_ptr);
6269         FREE(untag_ptr(ret));
6270         return ret_conv;
6271 }
6272 LDKCResult_ECDSASignatureNoneZ sign_gossip_message_LDKNodeSigner_jcall(const void* this_arg, LDKUnsignedGossipMessage msg) {
6273         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6274         LDKUnsignedGossipMessage *msg_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
6275         *msg_copy = msg;
6276         int64_t msg_ref = tag_ptr(msg_copy, true);
6277         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 37, msg_ref);
6278         void* ret_ptr = untag_ptr(ret);
6279         CHECK_ACCESS(ret_ptr);
6280         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
6281         FREE(untag_ptr(ret));
6282         return ret_conv;
6283 }
6284 static void LDKNodeSigner_JCalls_cloned(LDKNodeSigner* new_obj) {
6285         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) new_obj->this_arg;
6286         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6287 }
6288 static inline LDKNodeSigner LDKNodeSigner_init (int64_t o) {
6289         LDKNodeSigner_JCalls *calls = MALLOC(sizeof(LDKNodeSigner_JCalls), "LDKNodeSigner_JCalls");
6290         atomic_init(&calls->refcnt, 1);
6291         calls->instance_ptr = o;
6292
6293         LDKNodeSigner ret = {
6294                 .this_arg = (void*) calls,
6295                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKNodeSigner_jcall,
6296                 .get_node_id = get_node_id_LDKNodeSigner_jcall,
6297                 .ecdh = ecdh_LDKNodeSigner_jcall,
6298                 .sign_invoice = sign_invoice_LDKNodeSigner_jcall,
6299                 .sign_bolt12_invoice_request = sign_bolt12_invoice_request_LDKNodeSigner_jcall,
6300                 .sign_bolt12_invoice = sign_bolt12_invoice_LDKNodeSigner_jcall,
6301                 .sign_gossip_message = sign_gossip_message_LDKNodeSigner_jcall,
6302                 .free = LDKNodeSigner_JCalls_free,
6303         };
6304         return ret;
6305 }
6306 uint64_t  CS_LDK_LDKNodeSigner_new(int32_t o) {
6307         LDKNodeSigner *res_ptr = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
6308         *res_ptr = LDKNodeSigner_init(o);
6309         return tag_ptr(res_ptr, true);
6310 }
6311 int8_tArray  CS_LDK_NodeSigner_get_inbound_payment_key_material(int64_t this_arg) {
6312         void* this_arg_ptr = untag_ptr(this_arg);
6313         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6314         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6315         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6316         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
6317         return ret_arr;
6318 }
6319
6320 int64_t  CS_LDK_NodeSigner_get_node_id(int64_t this_arg, int32_t recipient) {
6321         void* this_arg_ptr = untag_ptr(this_arg);
6322         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6323         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6324         LDKRecipient recipient_conv = LDKRecipient_from_cs(recipient);
6325         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
6326         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
6327         return tag_ptr(ret_conv, true);
6328 }
6329
6330 int64_t  CS_LDK_NodeSigner_ecdh(int64_t this_arg, int32_t recipient, int8_tArray other_key, int64_t tweak) {
6331         void* this_arg_ptr = untag_ptr(this_arg);
6332         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6333         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6334         LDKRecipient recipient_conv = LDKRecipient_from_cs(recipient);
6335         LDKPublicKey other_key_ref;
6336         CHECK(other_key->arr_len == 33);
6337         memcpy(other_key_ref.compressed_form, other_key->elems, 33); FREE(other_key);
6338         void* tweak_ptr = untag_ptr(tweak);
6339         CHECK_ACCESS(tweak_ptr);
6340         LDKCOption_BigEndianScalarZ tweak_conv = *(LDKCOption_BigEndianScalarZ*)(tweak_ptr);
6341         tweak_conv = COption_BigEndianScalarZ_clone((LDKCOption_BigEndianScalarZ*)untag_ptr(tweak));
6342         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
6343         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
6344         return tag_ptr(ret_conv, true);
6345 }
6346
6347 int64_t  CS_LDK_NodeSigner_sign_invoice(int64_t this_arg, int8_tArray hrp_bytes, ptrArray invoice_data, int32_t recipient) {
6348         void* this_arg_ptr = untag_ptr(this_arg);
6349         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6350         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6351         LDKu8slice hrp_bytes_ref;
6352         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
6353         hrp_bytes_ref.data = hrp_bytes->elems;
6354         LDKCVec_U5Z invoice_data_constr;
6355         invoice_data_constr.datalen = invoice_data->arr_len;
6356         if (invoice_data_constr.datalen > 0)
6357                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
6358         else
6359                 invoice_data_constr.data = NULL;
6360         int8_t* invoice_data_vals = (void*) invoice_data->elems;
6361         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6362                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6363                 
6364                 invoice_data_constr.data[h] = (LDKU5){ ._0 = invoice_data_conv_7 };
6365         }
6366         FREE(invoice_data);
6367         LDKRecipient recipient_conv = LDKRecipient_from_cs(recipient);
6368         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6369         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, recipient_conv);
6370         FREE(hrp_bytes);
6371         return tag_ptr(ret_conv, true);
6372 }
6373
6374 int64_t  CS_LDK_NodeSigner_sign_bolt12_invoice_request(int64_t this_arg, int64_t invoice_request) {
6375         void* this_arg_ptr = untag_ptr(this_arg);
6376         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6377         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6378         LDKUnsignedInvoiceRequest invoice_request_conv;
6379         invoice_request_conv.inner = untag_ptr(invoice_request);
6380         invoice_request_conv.is_owned = ptr_is_owned(invoice_request);
6381         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_request_conv);
6382         invoice_request_conv.is_owned = false;
6383         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
6384         *ret_conv = (this_arg_conv->sign_bolt12_invoice_request)(this_arg_conv->this_arg, &invoice_request_conv);
6385         return tag_ptr(ret_conv, true);
6386 }
6387
6388 int64_t  CS_LDK_NodeSigner_sign_bolt12_invoice(int64_t this_arg, int64_t invoice) {
6389         void* this_arg_ptr = untag_ptr(this_arg);
6390         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6391         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6392         LDKUnsignedBolt12Invoice invoice_conv;
6393         invoice_conv.inner = untag_ptr(invoice);
6394         invoice_conv.is_owned = ptr_is_owned(invoice);
6395         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
6396         invoice_conv.is_owned = false;
6397         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
6398         *ret_conv = (this_arg_conv->sign_bolt12_invoice)(this_arg_conv->this_arg, &invoice_conv);
6399         return tag_ptr(ret_conv, true);
6400 }
6401
6402 int64_t  CS_LDK_NodeSigner_sign_gossip_message(int64_t this_arg, int64_t msg) {
6403         void* this_arg_ptr = untag_ptr(this_arg);
6404         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6405         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6406         void* msg_ptr = untag_ptr(msg);
6407         CHECK_ACCESS(msg_ptr);
6408         LDKUnsignedGossipMessage msg_conv = *(LDKUnsignedGossipMessage*)(msg_ptr);
6409         msg_conv = UnsignedGossipMessage_clone((LDKUnsignedGossipMessage*)untag_ptr(msg));
6410         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
6411         *ret_conv = (this_arg_conv->sign_gossip_message)(this_arg_conv->this_arg, msg_conv);
6412         return tag_ptr(ret_conv, true);
6413 }
6414
6415 typedef struct LDKSignerProvider_JCalls {
6416         atomic_size_t refcnt;
6417         uint32_t instance_ptr;
6418 } LDKSignerProvider_JCalls;
6419 static void LDKSignerProvider_JCalls_free(void* this_arg) {
6420         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6421         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6422                 FREE(j_calls);
6423         }
6424 }
6425 LDKThirtyTwoBytes generate_channel_keys_id_LDKSignerProvider_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis, LDKU128 user_channel_id) {
6426         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6427         jboolean inbound_conv = inbound;
6428         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6429         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
6430         memcpy(user_channel_id_arr->elems, user_channel_id.le_bytes, 16);
6431         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);
6432         LDKThirtyTwoBytes ret_ref;
6433         CHECK(ret->arr_len == 32);
6434         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6435         return ret_ref;
6436 }
6437 LDKWriteableEcdsaChannelSigner derive_channel_signer_LDKSignerProvider_jcall(const void* this_arg, uint64_t channel_value_satoshis, LDKThirtyTwoBytes channel_keys_id) {
6438         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6439         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6440         int8_tArray channel_keys_id_arr = init_int8_tArray(32, __LINE__);
6441         memcpy(channel_keys_id_arr->elems, channel_keys_id.data, 32);
6442         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 39, channel_value_satoshis_conv, (int64_t)channel_keys_id_arr);
6443         void* ret_ptr = untag_ptr(ret);
6444         CHECK_ACCESS(ret_ptr);
6445         LDKWriteableEcdsaChannelSigner ret_conv = *(LDKWriteableEcdsaChannelSigner*)(ret_ptr);
6446         FREE(untag_ptr(ret));
6447         return ret_conv;
6448 }
6449 LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer_LDKSignerProvider_jcall(const void* this_arg, LDKu8slice reader) {
6450         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6451         LDKu8slice reader_var = reader;
6452         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
6453         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
6454         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 40, (int64_t)reader_arr);
6455         void* ret_ptr = untag_ptr(ret);
6456         CHECK_ACCESS(ret_ptr);
6457         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ ret_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(ret_ptr);
6458         FREE(untag_ptr(ret));
6459         return ret_conv;
6460 }
6461 LDKCResult_CVec_u8ZNoneZ get_destination_script_LDKSignerProvider_jcall(const void* this_arg) {
6462         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6463         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 41);
6464         void* ret_ptr = untag_ptr(ret);
6465         CHECK_ACCESS(ret_ptr);
6466         LDKCResult_CVec_u8ZNoneZ ret_conv = *(LDKCResult_CVec_u8ZNoneZ*)(ret_ptr);
6467         FREE(untag_ptr(ret));
6468         return ret_conv;
6469 }
6470 LDKCResult_ShutdownScriptNoneZ get_shutdown_scriptpubkey_LDKSignerProvider_jcall(const void* this_arg) {
6471         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6472         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 42);
6473         void* ret_ptr = untag_ptr(ret);
6474         CHECK_ACCESS(ret_ptr);
6475         LDKCResult_ShutdownScriptNoneZ ret_conv = *(LDKCResult_ShutdownScriptNoneZ*)(ret_ptr);
6476         FREE(untag_ptr(ret));
6477         return ret_conv;
6478 }
6479 static void LDKSignerProvider_JCalls_cloned(LDKSignerProvider* new_obj) {
6480         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) new_obj->this_arg;
6481         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6482 }
6483 static inline LDKSignerProvider LDKSignerProvider_init (int64_t o) {
6484         LDKSignerProvider_JCalls *calls = MALLOC(sizeof(LDKSignerProvider_JCalls), "LDKSignerProvider_JCalls");
6485         atomic_init(&calls->refcnt, 1);
6486         calls->instance_ptr = o;
6487
6488         LDKSignerProvider ret = {
6489                 .this_arg = (void*) calls,
6490                 .generate_channel_keys_id = generate_channel_keys_id_LDKSignerProvider_jcall,
6491                 .derive_channel_signer = derive_channel_signer_LDKSignerProvider_jcall,
6492                 .read_chan_signer = read_chan_signer_LDKSignerProvider_jcall,
6493                 .get_destination_script = get_destination_script_LDKSignerProvider_jcall,
6494                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKSignerProvider_jcall,
6495                 .free = LDKSignerProvider_JCalls_free,
6496         };
6497         return ret;
6498 }
6499 uint64_t  CS_LDK_LDKSignerProvider_new(int32_t o) {
6500         LDKSignerProvider *res_ptr = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
6501         *res_ptr = LDKSignerProvider_init(o);
6502         return tag_ptr(res_ptr, true);
6503 }
6504 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) {
6505         void* this_arg_ptr = untag_ptr(this_arg);
6506         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6507         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6508         LDKU128 user_channel_id_ref;
6509         CHECK(user_channel_id->arr_len == 16);
6510         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
6511         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6512         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);
6513         return ret_arr;
6514 }
6515
6516 int64_t  CS_LDK_SignerProvider_derive_channel_signer(int64_t this_arg, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
6517         void* this_arg_ptr = untag_ptr(this_arg);
6518         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6519         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6520         LDKThirtyTwoBytes channel_keys_id_ref;
6521         CHECK(channel_keys_id->arr_len == 32);
6522         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
6523         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
6524         *ret_ret = (this_arg_conv->derive_channel_signer)(this_arg_conv->this_arg, channel_value_satoshis, channel_keys_id_ref);
6525         return tag_ptr(ret_ret, true);
6526 }
6527
6528 int64_t  CS_LDK_SignerProvider_read_chan_signer(int64_t this_arg, int8_tArray reader) {
6529         void* this_arg_ptr = untag_ptr(this_arg);
6530         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6531         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6532         LDKu8slice reader_ref;
6533         reader_ref.datalen = reader->arr_len;
6534         reader_ref.data = reader->elems;
6535         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
6536         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6537         FREE(reader);
6538         return tag_ptr(ret_conv, true);
6539 }
6540
6541 int64_t  CS_LDK_SignerProvider_get_destination_script(int64_t this_arg) {
6542         void* this_arg_ptr = untag_ptr(this_arg);
6543         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6544         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6545         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
6546         *ret_conv = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6547         return tag_ptr(ret_conv, true);
6548 }
6549
6550 int64_t  CS_LDK_SignerProvider_get_shutdown_scriptpubkey(int64_t this_arg) {
6551         void* this_arg_ptr = untag_ptr(this_arg);
6552         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6553         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6554         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
6555         *ret_conv = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6556         return tag_ptr(ret_conv, true);
6557 }
6558
6559 typedef struct LDKFeeEstimator_JCalls {
6560         atomic_size_t refcnt;
6561         uint32_t instance_ptr;
6562 } LDKFeeEstimator_JCalls;
6563 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6564         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6565         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6566                 FREE(j_calls);
6567         }
6568 }
6569 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6570         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6571         int32_t confirmation_target_conv = LDKConfirmationTarget_to_cs(confirmation_target);
6572         return js_invoke_function_i_ConfirmationTarget(j_calls->instance_ptr, 43, confirmation_target_conv);
6573 }
6574 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6575         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6576         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6577 }
6578 static inline LDKFeeEstimator LDKFeeEstimator_init (int64_t o) {
6579         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6580         atomic_init(&calls->refcnt, 1);
6581         calls->instance_ptr = o;
6582
6583         LDKFeeEstimator ret = {
6584                 .this_arg = (void*) calls,
6585                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6586                 .free = LDKFeeEstimator_JCalls_free,
6587         };
6588         return ret;
6589 }
6590 uint64_t  CS_LDK_LDKFeeEstimator_new(int32_t o) {
6591         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6592         *res_ptr = LDKFeeEstimator_init(o);
6593         return tag_ptr(res_ptr, true);
6594 }
6595 int32_t  CS_LDK_FeeEstimator_get_est_sat_per_1000_weight(int64_t this_arg, int32_t confirmation_target) {
6596         void* this_arg_ptr = untag_ptr(this_arg);
6597         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6598         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6599         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_cs(confirmation_target);
6600         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6601         return ret_conv;
6602 }
6603
6604 typedef struct LDKRouter_JCalls {
6605         atomic_size_t refcnt;
6606         uint32_t instance_ptr;
6607 } LDKRouter_JCalls;
6608 static void LDKRouter_JCalls_free(void* this_arg) {
6609         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
6610         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6611                 FREE(j_calls);
6612         }
6613 }
6614 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs) {
6615         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
6616         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
6617         memcpy(payer_arr->elems, payer.compressed_form, 33);
6618         LDKRouteParameters route_params_var = *route_params;
6619         int64_t route_params_ref = 0;
6620         route_params_var = RouteParameters_clone(&route_params_var);
6621         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
6622         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
6623         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
6624         int64_tArray first_hops_arr = NULL;
6625         if (first_hops != NULL) {
6626                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
6627                 first_hops_arr = init_int64_tArray(first_hops_var.datalen, __LINE__);
6628                 int64_t *first_hops_arr_ptr = (int64_t*)(((uint8_t*)first_hops_arr) + 8);
6629                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
6630                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
6631                         int64_t first_hops_conv_16_ref = 0;
6632                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
6633                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
6634                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
6635                 }
6636         
6637         }
6638         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
6639         int64_t inflight_htlcs_ref = 0;
6640         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
6641         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
6642         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);
6643         void* ret_ptr = untag_ptr(ret);
6644         CHECK_ACCESS(ret_ptr);
6645         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
6646         FREE(untag_ptr(ret));
6647         return ret_conv;
6648 }
6649 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) {
6650         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
6651         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
6652         memcpy(payer_arr->elems, payer.compressed_form, 33);
6653         LDKRouteParameters route_params_var = *route_params;
6654         int64_t route_params_ref = 0;
6655         route_params_var = RouteParameters_clone(&route_params_var);
6656         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
6657         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
6658         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
6659         int64_tArray first_hops_arr = NULL;
6660         if (first_hops != NULL) {
6661                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
6662                 first_hops_arr = init_int64_tArray(first_hops_var.datalen, __LINE__);
6663                 int64_t *first_hops_arr_ptr = (int64_t*)(((uint8_t*)first_hops_arr) + 8);
6664                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
6665                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
6666                         int64_t first_hops_conv_16_ref = 0;
6667                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
6668                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
6669                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
6670                 }
6671         
6672         }
6673         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
6674         int64_t inflight_htlcs_ref = 0;
6675         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
6676         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
6677         int8_tArray _payment_hash_arr = init_int8_tArray(32, __LINE__);
6678         memcpy(_payment_hash_arr->elems, _payment_hash.data, 32);
6679         int8_tArray _payment_id_arr = init_int8_tArray(32, __LINE__);
6680         memcpy(_payment_id_arr->elems, _payment_id.data, 32);
6681         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);
6682         void* ret_ptr = untag_ptr(ret);
6683         CHECK_ACCESS(ret_ptr);
6684         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
6685         FREE(untag_ptr(ret));
6686         return ret_conv;
6687 }
6688 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
6689         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
6690         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6691 }
6692 static inline LDKRouter LDKRouter_init (int64_t o) {
6693         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
6694         atomic_init(&calls->refcnt, 1);
6695         calls->instance_ptr = o;
6696
6697         LDKRouter ret = {
6698                 .this_arg = (void*) calls,
6699                 .find_route = find_route_LDKRouter_jcall,
6700                 .find_route_with_id = find_route_with_id_LDKRouter_jcall,
6701                 .free = LDKRouter_JCalls_free,
6702         };
6703         return ret;
6704 }
6705 uint64_t  CS_LDK_LDKRouter_new(int32_t o) {
6706         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
6707         *res_ptr = LDKRouter_init(o);
6708         return tag_ptr(res_ptr, true);
6709 }
6710 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) {
6711         void* this_arg_ptr = untag_ptr(this_arg);
6712         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6713         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
6714         LDKPublicKey payer_ref;
6715         CHECK(payer->arr_len == 33);
6716         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
6717         LDKRouteParameters route_params_conv;
6718         route_params_conv.inner = untag_ptr(route_params);
6719         route_params_conv.is_owned = ptr_is_owned(route_params);
6720         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
6721         route_params_conv.is_owned = false;
6722         LDKCVec_ChannelDetailsZ first_hops_constr;
6723         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
6724         if (first_hops != NULL) {
6725                 first_hops_constr.datalen = first_hops->arr_len;
6726                 if (first_hops_constr.datalen > 0)
6727                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
6728                 else
6729                         first_hops_constr.data = NULL;
6730                 int64_t* first_hops_vals = first_hops->elems;
6731                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
6732                         int64_t first_hops_conv_16 = first_hops_vals[q];
6733                         LDKChannelDetails first_hops_conv_16_conv;
6734                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
6735                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
6736                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
6737                         first_hops_conv_16_conv.is_owned = false;
6738                         first_hops_constr.data[q] = first_hops_conv_16_conv;
6739                 }
6740                 FREE(first_hops);
6741                 first_hops_ptr = &first_hops_constr;
6742         }
6743         LDKInFlightHtlcs inflight_htlcs_conv;
6744         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
6745         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
6746         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
6747         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
6748         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6749         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, inflight_htlcs_conv);
6750         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
6751         return tag_ptr(ret_conv, true);
6752 }
6753
6754 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) {
6755         void* this_arg_ptr = untag_ptr(this_arg);
6756         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6757         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
6758         LDKPublicKey payer_ref;
6759         CHECK(payer->arr_len == 33);
6760         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
6761         LDKRouteParameters route_params_conv;
6762         route_params_conv.inner = untag_ptr(route_params);
6763         route_params_conv.is_owned = ptr_is_owned(route_params);
6764         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
6765         route_params_conv.is_owned = false;
6766         LDKCVec_ChannelDetailsZ first_hops_constr;
6767         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
6768         if (first_hops != NULL) {
6769                 first_hops_constr.datalen = first_hops->arr_len;
6770                 if (first_hops_constr.datalen > 0)
6771                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
6772                 else
6773                         first_hops_constr.data = NULL;
6774                 int64_t* first_hops_vals = first_hops->elems;
6775                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
6776                         int64_t first_hops_conv_16 = first_hops_vals[q];
6777                         LDKChannelDetails first_hops_conv_16_conv;
6778                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
6779                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
6780                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
6781                         first_hops_conv_16_conv.is_owned = false;
6782                         first_hops_constr.data[q] = first_hops_conv_16_conv;
6783                 }
6784                 FREE(first_hops);
6785                 first_hops_ptr = &first_hops_constr;
6786         }
6787         LDKInFlightHtlcs inflight_htlcs_conv;
6788         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
6789         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
6790         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
6791         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
6792         LDKThirtyTwoBytes _payment_hash_ref;
6793         CHECK(_payment_hash->arr_len == 32);
6794         memcpy(_payment_hash_ref.data, _payment_hash->elems, 32); FREE(_payment_hash);
6795         LDKThirtyTwoBytes _payment_id_ref;
6796         CHECK(_payment_id->arr_len == 32);
6797         memcpy(_payment_id_ref.data, _payment_id->elems, 32); FREE(_payment_id);
6798         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6799         *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);
6800         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
6801         return tag_ptr(ret_conv, true);
6802 }
6803
6804 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesChannelManagerZ_get_a(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ *NONNULL_PTR owner){
6805         return ThirtyTwoBytes_clone(&owner->a);
6806 }
6807 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_get_a(int64_t owner) {
6808         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesChannelManagerZ*)untag_ptr(owner);
6809         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6810         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesChannelManagerZ_get_a(owner_conv).data, 32);
6811         return ret_arr;
6812 }
6813
6814 static inline struct LDKChannelManager C2Tuple_ThirtyTwoBytesChannelManagerZ_get_b(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ *NONNULL_PTR owner){
6815         LDKChannelManager ret = owner->b;
6816         ret.is_owned = false;
6817         return ret;
6818 }
6819 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_get_b(int64_t owner) {
6820         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesChannelManagerZ*)untag_ptr(owner);
6821         LDKChannelManager ret_var = C2Tuple_ThirtyTwoBytesChannelManagerZ_get_b(owner_conv);
6822         int64_t ret_ref = 0;
6823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6825         return ret_ref;
6826 }
6827
6828 static inline struct LDKC2Tuple_ThirtyTwoBytesChannelManagerZ *CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6829 CHECK(owner->result_ok);
6830         return &*owner->contents.result;
6831 }
6832 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_ok(int64_t owner) {
6833         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ*)untag_ptr(owner);
6834         int64_t ret_ret = tag_ptr(CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
6835         return ret_ret;
6836 }
6837
6838 static inline struct LDKDecodeError CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6839 CHECK(!owner->result_ok);
6840         return DecodeError_clone(&*owner->contents.err);
6841 }
6842 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_err(int64_t owner) {
6843         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ*)untag_ptr(owner);
6844         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6845         *ret_copy = CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_err(owner_conv);
6846         int64_t ret_ref = tag_ptr(ret_copy, true);
6847         return ret_ref;
6848 }
6849
6850 uint32_t CS_LDK_LDKMaxDustHTLCExposure_ty_from_ptr(int64_t ptr) {
6851         LDKMaxDustHTLCExposure *obj = (LDKMaxDustHTLCExposure*)untag_ptr(ptr);
6852         switch(obj->tag) {
6853                 case LDKMaxDustHTLCExposure_FixedLimitMsat: return 0;
6854                 case LDKMaxDustHTLCExposure_FeeRateMultiplier: return 1;
6855                 default: abort();
6856         }
6857 }
6858 int64_t CS_LDK_LDKMaxDustHTLCExposure_FixedLimitMsat_get_fixed_limit_msat(int64_t ptr) {
6859         LDKMaxDustHTLCExposure *obj = (LDKMaxDustHTLCExposure*)untag_ptr(ptr);
6860         CHECK(obj->tag == LDKMaxDustHTLCExposure_FixedLimitMsat);
6861         int64_t fixed_limit_msat_conv = obj->fixed_limit_msat;
6862         return fixed_limit_msat_conv;
6863 }
6864 int64_t CS_LDK_LDKMaxDustHTLCExposure_FeeRateMultiplier_get_fee_rate_multiplier(int64_t ptr) {
6865         LDKMaxDustHTLCExposure *obj = (LDKMaxDustHTLCExposure*)untag_ptr(ptr);
6866         CHECK(obj->tag == LDKMaxDustHTLCExposure_FeeRateMultiplier);
6867         int64_t fee_rate_multiplier_conv = obj->fee_rate_multiplier;
6868         return fee_rate_multiplier_conv;
6869 }
6870 static inline struct LDKMaxDustHTLCExposure CResult_MaxDustHTLCExposureDecodeErrorZ_get_ok(LDKCResult_MaxDustHTLCExposureDecodeErrorZ *NONNULL_PTR owner){
6871 CHECK(owner->result_ok);
6872         return MaxDustHTLCExposure_clone(&*owner->contents.result);
6873 }
6874 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_get_ok(int64_t owner) {
6875         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* owner_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(owner);
6876         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
6877         *ret_copy = CResult_MaxDustHTLCExposureDecodeErrorZ_get_ok(owner_conv);
6878         int64_t ret_ref = tag_ptr(ret_copy, true);
6879         return ret_ref;
6880 }
6881
6882 static inline struct LDKDecodeError CResult_MaxDustHTLCExposureDecodeErrorZ_get_err(LDKCResult_MaxDustHTLCExposureDecodeErrorZ *NONNULL_PTR owner){
6883 CHECK(!owner->result_ok);
6884         return DecodeError_clone(&*owner->contents.err);
6885 }
6886 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_get_err(int64_t owner) {
6887         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* owner_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(owner);
6888         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6889         *ret_copy = CResult_MaxDustHTLCExposureDecodeErrorZ_get_err(owner_conv);
6890         int64_t ret_ref = tag_ptr(ret_copy, true);
6891         return ret_ref;
6892 }
6893
6894 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6895         LDKChannelConfig ret = *owner->contents.result;
6896         ret.is_owned = false;
6897         return ret;
6898 }
6899 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_get_ok(int64_t owner) {
6900         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
6901         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
6902         int64_t ret_ref = 0;
6903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6905         return ret_ref;
6906 }
6907
6908 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6909 CHECK(!owner->result_ok);
6910         return DecodeError_clone(&*owner->contents.err);
6911 }
6912 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_get_err(int64_t owner) {
6913         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
6914         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6915         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
6916         int64_t ret_ref = tag_ptr(ret_copy, true);
6917         return ret_ref;
6918 }
6919
6920 uint32_t CS_LDK_LDKCOption_MaxDustHTLCExposureZ_ty_from_ptr(int64_t ptr) {
6921         LDKCOption_MaxDustHTLCExposureZ *obj = (LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(ptr);
6922         switch(obj->tag) {
6923                 case LDKCOption_MaxDustHTLCExposureZ_Some: return 0;
6924                 case LDKCOption_MaxDustHTLCExposureZ_None: return 1;
6925                 default: abort();
6926         }
6927 }
6928 int64_t CS_LDK_LDKCOption_MaxDustHTLCExposureZ_Some_get_some(int64_t ptr) {
6929         LDKCOption_MaxDustHTLCExposureZ *obj = (LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(ptr);
6930         CHECK(obj->tag == LDKCOption_MaxDustHTLCExposureZ_Some);
6931         int64_t some_ref = tag_ptr(&obj->some, false);
6932         return some_ref;
6933 }
6934 uint32_t CS_LDK_LDKCOption_APIErrorZ_ty_from_ptr(int64_t ptr) {
6935         LDKCOption_APIErrorZ *obj = (LDKCOption_APIErrorZ*)untag_ptr(ptr);
6936         switch(obj->tag) {
6937                 case LDKCOption_APIErrorZ_Some: return 0;
6938                 case LDKCOption_APIErrorZ_None: return 1;
6939                 default: abort();
6940         }
6941 }
6942 int64_t CS_LDK_LDKCOption_APIErrorZ_Some_get_some(int64_t ptr) {
6943         LDKCOption_APIErrorZ *obj = (LDKCOption_APIErrorZ*)untag_ptr(ptr);
6944         CHECK(obj->tag == LDKCOption_APIErrorZ_Some);
6945         int64_t some_ref = tag_ptr(&obj->some, false);
6946         return some_ref;
6947 }
6948 static inline struct LDKCOption_APIErrorZ CResult_COption_APIErrorZDecodeErrorZ_get_ok(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
6949 CHECK(owner->result_ok);
6950         return COption_APIErrorZ_clone(&*owner->contents.result);
6951 }
6952 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_get_ok(int64_t owner) {
6953         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
6954         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
6955         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_ok(owner_conv);
6956         int64_t ret_ref = tag_ptr(ret_copy, true);
6957         return ret_ref;
6958 }
6959
6960 static inline struct LDKDecodeError CResult_COption_APIErrorZDecodeErrorZ_get_err(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
6961 CHECK(!owner->result_ok);
6962         return DecodeError_clone(&*owner->contents.err);
6963 }
6964 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_get_err(int64_t owner) {
6965         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
6966         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6967         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_err(owner_conv);
6968         int64_t ret_ref = tag_ptr(ret_copy, true);
6969         return ret_ref;
6970 }
6971
6972 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6973         LDKChannelMonitorUpdate ret = *owner->contents.result;
6974         ret.is_owned = false;
6975         return ret;
6976 }
6977 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(int64_t owner) {
6978         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
6979         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6980         int64_t ret_ref = 0;
6981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6982         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6983         return ret_ref;
6984 }
6985
6986 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6987 CHECK(!owner->result_ok);
6988         return DecodeError_clone(&*owner->contents.err);
6989 }
6990 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(int64_t owner) {
6991         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
6992         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6993         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6994         int64_t ret_ref = tag_ptr(ret_copy, true);
6995         return ret_ref;
6996 }
6997
6998 uint32_t CS_LDK_LDKCOption_MonitorEventZ_ty_from_ptr(int64_t ptr) {
6999         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
7000         switch(obj->tag) {
7001                 case LDKCOption_MonitorEventZ_Some: return 0;
7002                 case LDKCOption_MonitorEventZ_None: return 1;
7003                 default: abort();
7004         }
7005 }
7006 int64_t CS_LDK_LDKCOption_MonitorEventZ_Some_get_some(int64_t ptr) {
7007         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
7008         CHECK(obj->tag == LDKCOption_MonitorEventZ_Some);
7009         int64_t some_ref = tag_ptr(&obj->some, false);
7010         return some_ref;
7011 }
7012 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7013 CHECK(owner->result_ok);
7014         return COption_MonitorEventZ_clone(&*owner->contents.result);
7015 }
7016 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(int64_t owner) {
7017         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
7018         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7019         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7020         int64_t ret_ref = tag_ptr(ret_copy, true);
7021         return ret_ref;
7022 }
7023
7024 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7025 CHECK(!owner->result_ok);
7026         return DecodeError_clone(&*owner->contents.err);
7027 }
7028 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_get_err(int64_t owner) {
7029         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
7030         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7031         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
7032         int64_t ret_ref = tag_ptr(ret_copy, true);
7033         return ret_ref;
7034 }
7035
7036 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7037         LDKHTLCUpdate ret = *owner->contents.result;
7038         ret.is_owned = false;
7039         return ret;
7040 }
7041 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_get_ok(int64_t owner) {
7042         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
7043         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
7044         int64_t ret_ref = 0;
7045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7046         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7047         return ret_ref;
7048 }
7049
7050 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7051 CHECK(!owner->result_ok);
7052         return DecodeError_clone(&*owner->contents.err);
7053 }
7054 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_get_err(int64_t owner) {
7055         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
7056         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7057         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
7058         int64_t ret_ref = tag_ptr(ret_copy, true);
7059         return ret_ref;
7060 }
7061
7062 static inline struct LDKOutPoint C2Tuple_OutPointCVec_u8ZZ_get_a(LDKC2Tuple_OutPointCVec_u8ZZ *NONNULL_PTR owner){
7063         LDKOutPoint ret = owner->a;
7064         ret.is_owned = false;
7065         return ret;
7066 }
7067 int64_t  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_get_a(int64_t owner) {
7068         LDKC2Tuple_OutPointCVec_u8ZZ* owner_conv = (LDKC2Tuple_OutPointCVec_u8ZZ*)untag_ptr(owner);
7069         LDKOutPoint ret_var = C2Tuple_OutPointCVec_u8ZZ_get_a(owner_conv);
7070         int64_t ret_ref = 0;
7071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7072         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7073         return ret_ref;
7074 }
7075
7076 static inline struct LDKCVec_u8Z C2Tuple_OutPointCVec_u8ZZ_get_b(LDKC2Tuple_OutPointCVec_u8ZZ *NONNULL_PTR owner){
7077         return CVec_u8Z_clone(&owner->b);
7078 }
7079 int8_tArray  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_get_b(int64_t owner) {
7080         LDKC2Tuple_OutPointCVec_u8ZZ* owner_conv = (LDKC2Tuple_OutPointCVec_u8ZZ*)untag_ptr(owner);
7081         LDKCVec_u8Z ret_var = C2Tuple_OutPointCVec_u8ZZ_get_b(owner_conv);
7082         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7083         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7084         CVec_u8Z_free(ret_var);
7085         return ret_arr;
7086 }
7087
7088 static inline uint32_t C2Tuple_u32CVec_u8ZZ_get_a(LDKC2Tuple_u32CVec_u8ZZ *NONNULL_PTR owner){
7089         return owner->a;
7090 }
7091 int32_t  CS_LDK_C2Tuple_u32CVec_u8ZZ_get_a(int64_t owner) {
7092         LDKC2Tuple_u32CVec_u8ZZ* owner_conv = (LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(owner);
7093         int32_t ret_conv = C2Tuple_u32CVec_u8ZZ_get_a(owner_conv);
7094         return ret_conv;
7095 }
7096
7097 static inline struct LDKCVec_u8Z C2Tuple_u32CVec_u8ZZ_get_b(LDKC2Tuple_u32CVec_u8ZZ *NONNULL_PTR owner){
7098         return CVec_u8Z_clone(&owner->b);
7099 }
7100 int8_tArray  CS_LDK_C2Tuple_u32CVec_u8ZZ_get_b(int64_t owner) {
7101         LDKC2Tuple_u32CVec_u8ZZ* owner_conv = (LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(owner);
7102         LDKCVec_u8Z ret_var = C2Tuple_u32CVec_u8ZZ_get_b(owner_conv);
7103         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7104         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7105         CVec_u8Z_free(ret_var);
7106         return ret_arr;
7107 }
7108
7109 static inline LDKCVec_C2Tuple_u32CVec_u8ZZZ CVec_C2Tuple_u32CVec_u8ZZZ_clone(const LDKCVec_C2Tuple_u32CVec_u8ZZZ *orig) {
7110         LDKCVec_C2Tuple_u32CVec_u8ZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ) * orig->datalen, "LDKCVec_C2Tuple_u32CVec_u8ZZZ clone bytes"), .datalen = orig->datalen };
7111         for (size_t i = 0; i < ret.datalen; i++) {
7112                 ret.data[i] = C2Tuple_u32CVec_u8ZZ_clone(&orig->data[i]);
7113         }
7114         return ret;
7115 }
7116 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_a(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ *NONNULL_PTR owner){
7117         return ThirtyTwoBytes_clone(&owner->a);
7118 }
7119 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_a(int64_t owner) {
7120         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)untag_ptr(owner);
7121         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
7122         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_a(owner_conv).data, 32);
7123         return ret_arr;
7124 }
7125
7126 static inline struct LDKCVec_C2Tuple_u32CVec_u8ZZZ C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_b(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ *NONNULL_PTR owner){
7127         return CVec_C2Tuple_u32CVec_u8ZZZ_clone(&owner->b);
7128 }
7129 int64_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_b(int64_t owner) {
7130         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)untag_ptr(owner);
7131         LDKCVec_C2Tuple_u32CVec_u8ZZZ ret_var = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_b(owner_conv);
7132         int64_tArray ret_arr = NULL;
7133         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
7134         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
7135         for (size_t x = 0; x < ret_var.datalen; x++) {
7136                 LDKC2Tuple_u32CVec_u8ZZ* ret_conv_23_conv = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKC2Tuple_u32CVec_u8ZZ");
7137                 *ret_conv_23_conv = ret_var.data[x];
7138                 ret_arr_ptr[x] = tag_ptr(ret_conv_23_conv, true);
7139         }
7140         
7141         FREE(ret_var.data);
7142         return ret_arr;
7143 }
7144
7145 static inline LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ *orig) {
7146         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 };
7147         for (size_t i = 0; i < ret.datalen; i++) {
7148                 ret.data[i] = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(&orig->data[i]);
7149         }
7150         return ret;
7151 }
7152 static inline LDKCVec_CommitmentTransactionZ CVec_CommitmentTransactionZ_clone(const LDKCVec_CommitmentTransactionZ *orig) {
7153         LDKCVec_CommitmentTransactionZ ret = { .data = MALLOC(sizeof(LDKCommitmentTransaction) * orig->datalen, "LDKCVec_CommitmentTransactionZ clone bytes"), .datalen = orig->datalen };
7154         for (size_t i = 0; i < ret.datalen; i++) {
7155                 ret.data[i] = CommitmentTransaction_clone(&orig->data[i]);
7156         }
7157         return ret;
7158 }
7159 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7160         return owner->a;
7161 }
7162 int32_t  CS_LDK_C2Tuple_u32TxOutZ_get_a(int64_t owner) {
7163         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
7164         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
7165         return ret_conv;
7166 }
7167
7168 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7169         return TxOut_clone(&owner->b);
7170 }
7171 int64_t  CS_LDK_C2Tuple_u32TxOutZ_get_b(int64_t owner) {
7172         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
7173         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7174         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
7175         return tag_ptr(ret_ref, true);
7176 }
7177
7178 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
7179         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
7180         for (size_t i = 0; i < ret.datalen; i++) {
7181                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
7182         }
7183         return ret;
7184 }
7185 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7186         return ThirtyTwoBytes_clone(&owner->a);
7187 }
7188 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_a(int64_t owner) {
7189         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
7190         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
7191         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
7192         return ret_arr;
7193 }
7194
7195 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7196         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
7197 }
7198 int64_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_b(int64_t owner) {
7199         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
7200         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
7201         int64_tArray ret_arr = NULL;
7202         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
7203         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
7204         for (size_t u = 0; u < ret_var.datalen; u++) {
7205                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7206                 *ret_conv_20_conv = ret_var.data[u];
7207                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
7208         }
7209         
7210         FREE(ret_var.data);
7211         return ret_arr;
7212 }
7213
7214 static inline LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ *orig) {
7215         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 };
7216         for (size_t i = 0; i < ret.datalen; i++) {
7217                 ret.data[i] = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
7218         }
7219         return ret;
7220 }
7221 uint32_t CS_LDK_LDKBalance_ty_from_ptr(int64_t ptr) {
7222         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7223         switch(obj->tag) {
7224                 case LDKBalance_ClaimableOnChannelClose: return 0;
7225                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
7226                 case LDKBalance_ContentiousClaimable: return 2;
7227                 case LDKBalance_MaybeTimeoutClaimableHTLC: return 3;
7228                 case LDKBalance_MaybePreimageClaimableHTLC: return 4;
7229                 case LDKBalance_CounterpartyRevokedOutputClaimable: return 5;
7230                 default: abort();
7231         }
7232 }
7233 int64_t CS_LDK_LDKBalance_ClaimableOnChannelClose_get_amount_satoshis(int64_t ptr) {
7234         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7235         CHECK(obj->tag == LDKBalance_ClaimableOnChannelClose);
7236         int64_t amount_satoshis_conv = obj->claimable_on_channel_close.amount_satoshis;
7237         return amount_satoshis_conv;
7238 }
7239 int64_t CS_LDK_LDKBalance_ClaimableAwaitingConfirmations_get_amount_satoshis(int64_t ptr) {
7240         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7241         CHECK(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
7242         int64_t amount_satoshis_conv = obj->claimable_awaiting_confirmations.amount_satoshis;
7243         return amount_satoshis_conv;
7244 }
7245 int32_t CS_LDK_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(int64_t ptr) {
7246         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7247         CHECK(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
7248         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
7249         return confirmation_height_conv;
7250 }
7251 int64_t CS_LDK_LDKBalance_ContentiousClaimable_get_amount_satoshis(int64_t ptr) {
7252         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7253         CHECK(obj->tag == LDKBalance_ContentiousClaimable);
7254         int64_t amount_satoshis_conv = obj->contentious_claimable.amount_satoshis;
7255         return amount_satoshis_conv;
7256 }
7257 int32_t CS_LDK_LDKBalance_ContentiousClaimable_get_timeout_height(int64_t ptr) {
7258         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7259         CHECK(obj->tag == LDKBalance_ContentiousClaimable);
7260         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
7261         return timeout_height_conv;
7262 }
7263 int8_tArray CS_LDK_LDKBalance_ContentiousClaimable_get_payment_hash(int64_t ptr) {
7264         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7265         CHECK(obj->tag == LDKBalance_ContentiousClaimable);
7266         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
7267         memcpy(payment_hash_arr->elems, obj->contentious_claimable.payment_hash.data, 32);
7268         return payment_hash_arr;
7269 }
7270 int8_tArray CS_LDK_LDKBalance_ContentiousClaimable_get_payment_preimage(int64_t ptr) {
7271         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7272         CHECK(obj->tag == LDKBalance_ContentiousClaimable);
7273         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
7274         memcpy(payment_preimage_arr->elems, obj->contentious_claimable.payment_preimage.data, 32);
7275         return payment_preimage_arr;
7276 }
7277 int64_t CS_LDK_LDKBalance_MaybeTimeoutClaimableHTLC_get_amount_satoshis(int64_t ptr) {
7278         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7279         CHECK(obj->tag == LDKBalance_MaybeTimeoutClaimableHTLC);
7280         int64_t amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.amount_satoshis;
7281         return amount_satoshis_conv;
7282 }
7283 int32_t CS_LDK_LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_height(int64_t ptr) {
7284         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7285         CHECK(obj->tag == LDKBalance_MaybeTimeoutClaimableHTLC);
7286         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
7287         return claimable_height_conv;
7288 }
7289 int8_tArray CS_LDK_LDKBalance_MaybeTimeoutClaimableHTLC_get_payment_hash(int64_t ptr) {
7290         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7291         CHECK(obj->tag == LDKBalance_MaybeTimeoutClaimableHTLC);
7292         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
7293         memcpy(payment_hash_arr->elems, obj->maybe_timeout_claimable_htlc.payment_hash.data, 32);
7294         return payment_hash_arr;
7295 }
7296 int64_t CS_LDK_LDKBalance_MaybePreimageClaimableHTLC_get_amount_satoshis(int64_t ptr) {
7297         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7298         CHECK(obj->tag == LDKBalance_MaybePreimageClaimableHTLC);
7299         int64_t amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.amount_satoshis;
7300         return amount_satoshis_conv;
7301 }
7302 int32_t CS_LDK_LDKBalance_MaybePreimageClaimableHTLC_get_expiry_height(int64_t ptr) {
7303         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7304         CHECK(obj->tag == LDKBalance_MaybePreimageClaimableHTLC);
7305         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
7306         return expiry_height_conv;
7307 }
7308 int8_tArray CS_LDK_LDKBalance_MaybePreimageClaimableHTLC_get_payment_hash(int64_t ptr) {
7309         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7310         CHECK(obj->tag == LDKBalance_MaybePreimageClaimableHTLC);
7311         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
7312         memcpy(payment_hash_arr->elems, obj->maybe_preimage_claimable_htlc.payment_hash.data, 32);
7313         return payment_hash_arr;
7314 }
7315 int64_t CS_LDK_LDKBalance_CounterpartyRevokedOutputClaimable_get_amount_satoshis(int64_t ptr) {
7316         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7317         CHECK(obj->tag == LDKBalance_CounterpartyRevokedOutputClaimable);
7318         int64_t amount_satoshis_conv = obj->counterparty_revoked_output_claimable.amount_satoshis;
7319         return amount_satoshis_conv;
7320 }
7321 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
7322         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
7323         for (size_t i = 0; i < ret.datalen; i++) {
7324                 ret.data[i] = Balance_clone(&orig->data[i]);
7325         }
7326         return ret;
7327 }
7328 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_a(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ *NONNULL_PTR owner){
7329         return ThirtyTwoBytes_clone(&owner->a);
7330 }
7331 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_a(int64_t owner) {
7332         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(owner);
7333         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
7334         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_a(owner_conv).data, 32);
7335         return ret_arr;
7336 }
7337
7338 static inline struct LDKChannelMonitor C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_b(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ *NONNULL_PTR owner){
7339         LDKChannelMonitor ret = owner->b;
7340         ret.is_owned = false;
7341         return ret;
7342 }
7343 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_b(int64_t owner) {
7344         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(owner);
7345         LDKChannelMonitor ret_var = C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_b(owner_conv);
7346         int64_t ret_ref = 0;
7347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7349         return ret_ref;
7350 }
7351
7352 static inline struct LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7353 CHECK(owner->result_ok);
7354         return C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(&*owner->contents.result);
7355 }
7356 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_ok(int64_t owner) {
7357         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
7358         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
7359         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
7360         return tag_ptr(ret_conv, true);
7361 }
7362
7363 static inline struct LDKDecodeError CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7364 CHECK(!owner->result_ok);
7365         return DecodeError_clone(&*owner->contents.err);
7366 }
7367 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_err(int64_t owner) {
7368         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
7369         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7370         *ret_copy = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_err(owner_conv);
7371         int64_t ret_ref = tag_ptr(ret_copy, true);
7372         return ret_ref;
7373 }
7374
7375 typedef struct LDKType_JCalls {
7376         atomic_size_t refcnt;
7377         uint32_t instance_ptr;
7378 } LDKType_JCalls;
7379 static void LDKType_JCalls_free(void* this_arg) {
7380         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7381         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7382                 FREE(j_calls);
7383         }
7384 }
7385 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7386         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7387         return js_invoke_function_s_(j_calls->instance_ptr, 46);
7388 }
7389 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7390         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7391         jstring ret = (jstring)js_invoke_function_l_(j_calls->instance_ptr, 47);
7392         LDKStr ret_conv = str_ref_to_owned_c(ret);
7393         return ret_conv;
7394 }
7395 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7396         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7397         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 48);
7398         LDKCVec_u8Z ret_ref;
7399         ret_ref.datalen = ret->arr_len;
7400         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7401         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
7402         return ret_ref;
7403 }
7404 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7405         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7406         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7407 }
7408 static inline LDKType LDKType_init (int64_t o) {
7409         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7410         atomic_init(&calls->refcnt, 1);
7411         calls->instance_ptr = o;
7412
7413         LDKType ret = {
7414                 .this_arg = (void*) calls,
7415                 .type_id = type_id_LDKType_jcall,
7416                 .debug_str = debug_str_LDKType_jcall,
7417                 .write = write_LDKType_jcall,
7418                 .cloned = LDKType_JCalls_cloned,
7419                 .free = LDKType_JCalls_free,
7420         };
7421         return ret;
7422 }
7423 uint64_t  CS_LDK_LDKType_new(int32_t o) {
7424         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7425         *res_ptr = LDKType_init(o);
7426         return tag_ptr(res_ptr, true);
7427 }
7428 int16_t  CS_LDK_Type_type_id(int64_t this_arg) {
7429         void* this_arg_ptr = untag_ptr(this_arg);
7430         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7431         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7432         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7433         return ret_conv;
7434 }
7435
7436 jstring  CS_LDK_Type_debug_str(int64_t this_arg) {
7437         void* this_arg_ptr = untag_ptr(this_arg);
7438         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7439         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7440         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7441         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
7442         Str_free(ret_str);
7443         return ret_conv;
7444 }
7445
7446 int8_tArray  CS_LDK_Type_write(int64_t this_arg) {
7447         void* this_arg_ptr = untag_ptr(this_arg);
7448         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7449         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7450         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7451         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7452         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7453         CVec_u8Z_free(ret_var);
7454         return ret_arr;
7455 }
7456
7457 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7458         return owner->a;
7459 }
7460 int8_tArray  CS_LDK_C2Tuple_PublicKeyTypeZ_get_a(int64_t owner) {
7461         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
7462         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
7463         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
7464         return ret_arr;
7465 }
7466
7467 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7468         return Type_clone(&owner->b);
7469 }
7470 int64_t  CS_LDK_C2Tuple_PublicKeyTypeZ_get_b(int64_t owner) {
7471         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
7472         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
7473         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
7474         return tag_ptr(ret_ret, true);
7475 }
7476
7477 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
7478         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
7479         for (size_t i = 0; i < ret.datalen; i++) {
7480                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
7481         }
7482         return ret;
7483 }
7484 typedef struct LDKOnionMessageContents_JCalls {
7485         atomic_size_t refcnt;
7486         uint32_t instance_ptr;
7487 } LDKOnionMessageContents_JCalls;
7488 static void LDKOnionMessageContents_JCalls_free(void* this_arg) {
7489         LDKOnionMessageContents_JCalls *j_calls = (LDKOnionMessageContents_JCalls*) this_arg;
7490         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7491                 FREE(j_calls);
7492         }
7493 }
7494 uint64_t tlv_type_LDKOnionMessageContents_jcall(const void* this_arg) {
7495         LDKOnionMessageContents_JCalls *j_calls = (LDKOnionMessageContents_JCalls*) this_arg;
7496         return js_invoke_function_l_(j_calls->instance_ptr, 49);
7497 }
7498 LDKCVec_u8Z write_LDKOnionMessageContents_jcall(const void* this_arg) {
7499         LDKOnionMessageContents_JCalls *j_calls = (LDKOnionMessageContents_JCalls*) this_arg;
7500         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 50);
7501         LDKCVec_u8Z ret_ref;
7502         ret_ref.datalen = ret->arr_len;
7503         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7504         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
7505         return ret_ref;
7506 }
7507 static void LDKOnionMessageContents_JCalls_cloned(LDKOnionMessageContents* new_obj) {
7508         LDKOnionMessageContents_JCalls *j_calls = (LDKOnionMessageContents_JCalls*) new_obj->this_arg;
7509         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7510 }
7511 static inline LDKOnionMessageContents LDKOnionMessageContents_init (int64_t o) {
7512         LDKOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKOnionMessageContents_JCalls), "LDKOnionMessageContents_JCalls");
7513         atomic_init(&calls->refcnt, 1);
7514         calls->instance_ptr = o;
7515
7516         LDKOnionMessageContents ret = {
7517                 .this_arg = (void*) calls,
7518                 .tlv_type = tlv_type_LDKOnionMessageContents_jcall,
7519                 .write = write_LDKOnionMessageContents_jcall,
7520                 .cloned = LDKOnionMessageContents_JCalls_cloned,
7521                 .free = LDKOnionMessageContents_JCalls_free,
7522         };
7523         return ret;
7524 }
7525 uint64_t  CS_LDK_LDKOnionMessageContents_new(int32_t o) {
7526         LDKOnionMessageContents *res_ptr = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
7527         *res_ptr = LDKOnionMessageContents_init(o);
7528         return tag_ptr(res_ptr, true);
7529 }
7530 int64_t  CS_LDK_OnionMessageContents_tlv_type(int64_t this_arg) {
7531         void* this_arg_ptr = untag_ptr(this_arg);
7532         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7533         LDKOnionMessageContents* this_arg_conv = (LDKOnionMessageContents*)this_arg_ptr;
7534         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
7535         return ret_conv;
7536 }
7537
7538 int8_tArray  CS_LDK_OnionMessageContents_write(int64_t this_arg) {
7539         void* this_arg_ptr = untag_ptr(this_arg);
7540         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7541         LDKOnionMessageContents* this_arg_conv = (LDKOnionMessageContents*)this_arg_ptr;
7542         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7543         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7544         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7545         CVec_u8Z_free(ret_var);
7546         return ret_arr;
7547 }
7548
7549 uint32_t CS_LDK_LDKCOption_OnionMessageContentsZ_ty_from_ptr(int64_t ptr) {
7550         LDKCOption_OnionMessageContentsZ *obj = (LDKCOption_OnionMessageContentsZ*)untag_ptr(ptr);
7551         switch(obj->tag) {
7552                 case LDKCOption_OnionMessageContentsZ_Some: return 0;
7553                 case LDKCOption_OnionMessageContentsZ_None: return 1;
7554                 default: abort();
7555         }
7556 }
7557 int64_t CS_LDK_LDKCOption_OnionMessageContentsZ_Some_get_some(int64_t ptr) {
7558         LDKCOption_OnionMessageContentsZ *obj = (LDKCOption_OnionMessageContentsZ*)untag_ptr(ptr);
7559         CHECK(obj->tag == LDKCOption_OnionMessageContentsZ_Some);
7560         LDKOnionMessageContents* some_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
7561         *some_ret = OnionMessageContents_clone(&obj->some);
7562         return tag_ptr(some_ret, true);
7563 }
7564 static inline struct LDKCOption_OnionMessageContentsZ CResult_COption_OnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
7565 CHECK(owner->result_ok);
7566         return COption_OnionMessageContentsZ_clone(&*owner->contents.result);
7567 }
7568 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_get_ok(int64_t owner) {
7569         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
7570         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
7571         *ret_copy = CResult_COption_OnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
7572         int64_t ret_ref = tag_ptr(ret_copy, true);
7573         return ret_ref;
7574 }
7575
7576 static inline struct LDKDecodeError CResult_COption_OnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
7577 CHECK(!owner->result_ok);
7578         return DecodeError_clone(&*owner->contents.err);
7579 }
7580 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_get_err(int64_t owner) {
7581         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
7582         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7583         *ret_copy = CResult_COption_OnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
7584         int64_t ret_ref = tag_ptr(ret_copy, true);
7585         return ret_ref;
7586 }
7587
7588 static inline struct LDKOnionMessageContents C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_a(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR owner){
7589         return OnionMessageContents_clone(&owner->a);
7590 }
7591 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_a(int64_t owner) {
7592         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(owner);
7593         LDKOnionMessageContents* ret_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
7594         *ret_ret = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_a(owner_conv);
7595         return tag_ptr(ret_ret, true);
7596 }
7597
7598 static inline struct LDKDestination C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_b(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR owner){
7599         return Destination_clone(&owner->b);
7600 }
7601 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_b(int64_t owner) {
7602         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(owner);
7603         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
7604         *ret_copy = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_b(owner_conv);
7605         int64_t ret_ref = tag_ptr(ret_copy, true);
7606         return ret_ref;
7607 }
7608
7609 static inline struct LDKBlindedPath C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_c(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR owner){
7610         LDKBlindedPath ret = owner->c;
7611         ret.is_owned = false;
7612         return ret;
7613 }
7614 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_c(int64_t owner) {
7615         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(owner);
7616         LDKBlindedPath ret_var = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_c(owner_conv);
7617         int64_t ret_ref = 0;
7618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7619         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7620         return ret_ref;
7621 }
7622
7623 static inline LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_clone(const LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ *orig) {
7624         LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ) * orig->datalen, "LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ clone bytes"), .datalen = orig->datalen };
7625         for (size_t i = 0; i < ret.datalen; i++) {
7626                 ret.data[i] = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(&orig->data[i]);
7627         }
7628         return ret;
7629 }
7630 uint32_t CS_LDK_LDKCOption_TypeZ_ty_from_ptr(int64_t ptr) {
7631         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
7632         switch(obj->tag) {
7633                 case LDKCOption_TypeZ_Some: return 0;
7634                 case LDKCOption_TypeZ_None: return 1;
7635                 default: abort();
7636         }
7637 }
7638 int64_t CS_LDK_LDKCOption_TypeZ_Some_get_some(int64_t ptr) {
7639         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
7640         CHECK(obj->tag == LDKCOption_TypeZ_Some);
7641         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7642         *some_ret = Type_clone(&obj->some);
7643         return tag_ptr(some_ret, true);
7644 }
7645 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7646 CHECK(owner->result_ok);
7647         return COption_TypeZ_clone(&*owner->contents.result);
7648 }
7649 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_get_ok(int64_t owner) {
7650         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7651         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7652         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7653         int64_t ret_ref = tag_ptr(ret_copy, true);
7654         return ret_ref;
7655 }
7656
7657 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7658 CHECK(!owner->result_ok);
7659         return DecodeError_clone(&*owner->contents.err);
7660 }
7661 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_get_err(int64_t owner) {
7662         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7663         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7664         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7665         int64_t ret_ref = tag_ptr(ret_copy, true);
7666         return ret_ref;
7667 }
7668
7669 uint32_t CS_LDK_LDKCOption_SocketAddressZ_ty_from_ptr(int64_t ptr) {
7670         LDKCOption_SocketAddressZ *obj = (LDKCOption_SocketAddressZ*)untag_ptr(ptr);
7671         switch(obj->tag) {
7672                 case LDKCOption_SocketAddressZ_Some: return 0;
7673                 case LDKCOption_SocketAddressZ_None: return 1;
7674                 default: abort();
7675         }
7676 }
7677 int64_t CS_LDK_LDKCOption_SocketAddressZ_Some_get_some(int64_t ptr) {
7678         LDKCOption_SocketAddressZ *obj = (LDKCOption_SocketAddressZ*)untag_ptr(ptr);
7679         CHECK(obj->tag == LDKCOption_SocketAddressZ_Some);
7680         int64_t some_ref = tag_ptr(&obj->some, false);
7681         return some_ref;
7682 }
7683 static inline struct LDKPublicKey C2Tuple_PublicKeyCOption_SocketAddressZZ_get_a(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ *NONNULL_PTR owner){
7684         return owner->a;
7685 }
7686 int8_tArray  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_get_a(int64_t owner) {
7687         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)untag_ptr(owner);
7688         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
7689         memcpy(ret_arr->elems, C2Tuple_PublicKeyCOption_SocketAddressZZ_get_a(owner_conv).compressed_form, 33);
7690         return ret_arr;
7691 }
7692
7693 static inline struct LDKCOption_SocketAddressZ C2Tuple_PublicKeyCOption_SocketAddressZZ_get_b(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ *NONNULL_PTR owner){
7694         return COption_SocketAddressZ_clone(&owner->b);
7695 }
7696 int64_t  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_get_b(int64_t owner) {
7697         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)untag_ptr(owner);
7698         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
7699         *ret_copy = C2Tuple_PublicKeyCOption_SocketAddressZZ_get_b(owner_conv);
7700         int64_t ret_ref = tag_ptr(ret_copy, true);
7701         return ret_ref;
7702 }
7703
7704 static inline LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_clone(const LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ *orig) {
7705         LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ clone bytes"), .datalen = orig->datalen };
7706         for (size_t i = 0; i < ret.datalen; i++) {
7707                 ret.data[i] = C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(&orig->data[i]);
7708         }
7709         return ret;
7710 }
7711 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7712 CHECK(owner->result_ok);
7713         return CVec_u8Z_clone(&*owner->contents.result);
7714 }
7715 int8_tArray  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(int64_t owner) {
7716         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
7717         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7718         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7719         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7720         CVec_u8Z_free(ret_var);
7721         return ret_arr;
7722 }
7723
7724 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7725         LDKPeerHandleError ret = *owner->contents.err;
7726         ret.is_owned = false;
7727         return ret;
7728 }
7729 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_get_err(int64_t owner) {
7730         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
7731         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
7732         int64_t ret_ref = 0;
7733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7735         return ret_ref;
7736 }
7737
7738 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7739 CHECK(owner->result_ok);
7740         return *owner->contents.result;
7741 }
7742 void  CS_LDK_CResult_NonePeerHandleErrorZ_get_ok(int64_t owner) {
7743         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
7744         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
7745 }
7746
7747 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7748         LDKPeerHandleError ret = *owner->contents.err;
7749         ret.is_owned = false;
7750         return ret;
7751 }
7752 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_get_err(int64_t owner) {
7753         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
7754         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
7755         int64_t ret_ref = 0;
7756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7757         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7758         return ret_ref;
7759 }
7760
7761 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7762 CHECK(owner->result_ok);
7763         return *owner->contents.result;
7764 }
7765 jboolean  CS_LDK_CResult_boolPeerHandleErrorZ_get_ok(int64_t owner) {
7766         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
7767         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
7768         return ret_conv;
7769 }
7770
7771 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7772         LDKPeerHandleError ret = *owner->contents.err;
7773         ret.is_owned = false;
7774         return ret;
7775 }
7776 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_get_err(int64_t owner) {
7777         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
7778         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
7779         int64_t ret_ref = 0;
7780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7782         return ret_ref;
7783 }
7784
7785 uint32_t CS_LDK_LDKGraphSyncError_ty_from_ptr(int64_t ptr) {
7786         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
7787         switch(obj->tag) {
7788                 case LDKGraphSyncError_DecodeError: return 0;
7789                 case LDKGraphSyncError_LightningError: return 1;
7790                 default: abort();
7791         }
7792 }
7793 int64_t CS_LDK_LDKGraphSyncError_DecodeError_get_decode_error(int64_t ptr) {
7794         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
7795         CHECK(obj->tag == LDKGraphSyncError_DecodeError);
7796         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
7797         return decode_error_ref;
7798 }
7799 int64_t CS_LDK_LDKGraphSyncError_LightningError_get_lightning_error(int64_t ptr) {
7800         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
7801         CHECK(obj->tag == LDKGraphSyncError_LightningError);
7802         LDKLightningError lightning_error_var = obj->lightning_error;
7803                         int64_t lightning_error_ref = 0;
7804                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
7805                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
7806         return lightning_error_ref;
7807 }
7808 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
7809 CHECK(owner->result_ok);
7810         return *owner->contents.result;
7811 }
7812 int32_t  CS_LDK_CResult_u32GraphSyncErrorZ_get_ok(int64_t owner) {
7813         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
7814         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
7815         return ret_conv;
7816 }
7817
7818 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
7819 CHECK(!owner->result_ok);
7820         return GraphSyncError_clone(&*owner->contents.err);
7821 }
7822 int64_t  CS_LDK_CResult_u32GraphSyncErrorZ_get_err(int64_t owner) {
7823         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
7824         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
7825         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
7826         int64_t ret_ref = tag_ptr(ret_copy, true);
7827         return ret_ref;
7828 }
7829
7830 static inline struct LDKCVec_u8Z CResult_CVec_u8ZIOErrorZ_get_ok(LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR owner){
7831 CHECK(owner->result_ok);
7832         return CVec_u8Z_clone(&*owner->contents.result);
7833 }
7834 int8_tArray  CS_LDK_CResult_CVec_u8ZIOErrorZ_get_ok(int64_t owner) {
7835         LDKCResult_CVec_u8ZIOErrorZ* owner_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(owner);
7836         LDKCVec_u8Z ret_var = CResult_CVec_u8ZIOErrorZ_get_ok(owner_conv);
7837         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7838         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7839         CVec_u8Z_free(ret_var);
7840         return ret_arr;
7841 }
7842
7843 static inline enum LDKIOError CResult_CVec_u8ZIOErrorZ_get_err(LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR owner){
7844 CHECK(!owner->result_ok);
7845         return *owner->contents.err;
7846 }
7847 int32_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_get_err(int64_t owner) {
7848         LDKCResult_CVec_u8ZIOErrorZ* owner_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(owner);
7849         int32_t ret_conv = LDKIOError_to_cs(CResult_CVec_u8ZIOErrorZ_get_err(owner_conv));
7850         return ret_conv;
7851 }
7852
7853 static inline struct LDKCVec_StrZ CResult_CVec_StrZIOErrorZ_get_ok(LDKCResult_CVec_StrZIOErrorZ *NONNULL_PTR owner){
7854 CHECK(owner->result_ok);
7855         return *owner->contents.result;
7856 }
7857 ptrArray  CS_LDK_CResult_CVec_StrZIOErrorZ_get_ok(int64_t owner) {
7858         LDKCResult_CVec_StrZIOErrorZ* owner_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(owner);
7859         LDKCVec_StrZ ret_var = CResult_CVec_StrZIOErrorZ_get_ok(owner_conv);
7860         ptrArray ret_arr = NULL;
7861         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
7862         jstring *ret_arr_ptr = (jstring*)(((uint8_t*)ret_arr) + 8);
7863         for (size_t i = 0; i < ret_var.datalen; i++) {
7864                 LDKStr ret_conv_8_str = ret_var.data[i];
7865                 jstring ret_conv_8_conv = str_ref_to_cs(ret_conv_8_str.chars, ret_conv_8_str.len);
7866                 ret_arr_ptr[i] = ret_conv_8_conv;
7867         }
7868         
7869         return ret_arr;
7870 }
7871
7872 static inline enum LDKIOError CResult_CVec_StrZIOErrorZ_get_err(LDKCResult_CVec_StrZIOErrorZ *NONNULL_PTR owner){
7873 CHECK(!owner->result_ok);
7874         return *owner->contents.err;
7875 }
7876 int32_t  CS_LDK_CResult_CVec_StrZIOErrorZ_get_err(int64_t owner) {
7877         LDKCResult_CVec_StrZIOErrorZ* owner_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(owner);
7878         int32_t ret_conv = LDKIOError_to_cs(CResult_CVec_StrZIOErrorZ_get_err(owner_conv));
7879         return ret_conv;
7880 }
7881
7882 static inline LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ *orig) {
7883         LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
7884         for (size_t i = 0; i < ret.datalen; i++) {
7885                 ret.data[i] = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(&orig->data[i]);
7886         }
7887         return ret;
7888 }
7889 static inline struct LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_ok(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ *NONNULL_PTR owner){
7890 CHECK(owner->result_ok);
7891         return CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_clone(&*owner->contents.result);
7892 }
7893 int64_tArray  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_ok(int64_t owner) {
7894         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(owner);
7895         LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_ok(owner_conv);
7896         int64_tArray ret_arr = NULL;
7897         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
7898         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
7899         for (size_t o = 0; o < ret_var.datalen; o++) {
7900                 LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
7901                 *ret_conv_40_conv = ret_var.data[o];
7902                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
7903         }
7904         
7905         FREE(ret_var.data);
7906         return ret_arr;
7907 }
7908
7909 static inline enum LDKIOError CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_err(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ *NONNULL_PTR owner){
7910 CHECK(!owner->result_ok);
7911         return *owner->contents.err;
7912 }
7913 int32_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_err(int64_t owner) {
7914         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(owner);
7915         int32_t ret_conv = LDKIOError_to_cs(CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_err(owner_conv));
7916         return ret_conv;
7917 }
7918
7919 static inline struct LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ *NONNULL_PTR owner){
7920 CHECK(owner->result_ok);
7921         return C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(&*owner->contents.result);
7922 }
7923 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_ok(int64_t owner) {
7924         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(owner);
7925         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
7926         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_ok(owner_conv);
7927         return tag_ptr(ret_conv, true);
7928 }
7929
7930 static inline enum LDKIOError CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ *NONNULL_PTR owner){
7931 CHECK(!owner->result_ok);
7932         return *owner->contents.err;
7933 }
7934 int32_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_err(int64_t owner) {
7935         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(owner);
7936         int32_t ret_conv = LDKIOError_to_cs(CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_err(owner_conv));
7937         return ret_conv;
7938 }
7939
7940 uint32_t CS_LDK_LDKCOption_SecretKeyZ_ty_from_ptr(int64_t ptr) {
7941         LDKCOption_SecretKeyZ *obj = (LDKCOption_SecretKeyZ*)untag_ptr(ptr);
7942         switch(obj->tag) {
7943                 case LDKCOption_SecretKeyZ_Some: return 0;
7944                 case LDKCOption_SecretKeyZ_None: return 1;
7945                 default: abort();
7946         }
7947 }
7948 int8_tArray CS_LDK_LDKCOption_SecretKeyZ_Some_get_some(int64_t ptr) {
7949         LDKCOption_SecretKeyZ *obj = (LDKCOption_SecretKeyZ*)untag_ptr(ptr);
7950         CHECK(obj->tag == LDKCOption_SecretKeyZ_Some);
7951         int8_tArray some_arr = init_int8_tArray(32, __LINE__);
7952         memcpy(some_arr->elems, obj->some.bytes, 32);
7953         return some_arr;
7954 }
7955 static inline struct LDKVerifiedInvoiceRequest CResult_VerifiedInvoiceRequestNoneZ_get_ok(LDKCResult_VerifiedInvoiceRequestNoneZ *NONNULL_PTR owner){
7956         LDKVerifiedInvoiceRequest ret = *owner->contents.result;
7957         ret.is_owned = false;
7958         return ret;
7959 }
7960 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_get_ok(int64_t owner) {
7961         LDKCResult_VerifiedInvoiceRequestNoneZ* owner_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(owner);
7962         LDKVerifiedInvoiceRequest ret_var = CResult_VerifiedInvoiceRequestNoneZ_get_ok(owner_conv);
7963         int64_t ret_ref = 0;
7964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7965         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7966         return ret_ref;
7967 }
7968
7969 static inline void CResult_VerifiedInvoiceRequestNoneZ_get_err(LDKCResult_VerifiedInvoiceRequestNoneZ *NONNULL_PTR owner){
7970 CHECK(!owner->result_ok);
7971         return *owner->contents.err;
7972 }
7973 void  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_get_err(int64_t owner) {
7974         LDKCResult_VerifiedInvoiceRequestNoneZ* owner_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(owner);
7975         CResult_VerifiedInvoiceRequestNoneZ_get_err(owner_conv);
7976 }
7977
7978 static inline LDKCVec_WitnessZ CVec_WitnessZ_clone(const LDKCVec_WitnessZ *orig) {
7979         LDKCVec_WitnessZ ret = { .data = MALLOC(sizeof(LDKWitness) * orig->datalen, "LDKCVec_WitnessZ clone bytes"), .datalen = orig->datalen };
7980         for (size_t i = 0; i < ret.datalen; i++) {
7981                 ret.data[i] = Witness_clone(&orig->data[i]);
7982         }
7983         return ret;
7984 }
7985 uint32_t CS_LDK_LDKCOption_i64Z_ty_from_ptr(int64_t ptr) {
7986         LDKCOption_i64Z *obj = (LDKCOption_i64Z*)untag_ptr(ptr);
7987         switch(obj->tag) {
7988                 case LDKCOption_i64Z_Some: return 0;
7989                 case LDKCOption_i64Z_None: return 1;
7990                 default: abort();
7991         }
7992 }
7993 int64_t CS_LDK_LDKCOption_i64Z_Some_get_some(int64_t ptr) {
7994         LDKCOption_i64Z *obj = (LDKCOption_i64Z*)untag_ptr(ptr);
7995         CHECK(obj->tag == LDKCOption_i64Z_Some);
7996         int64_t some_conv = obj->some;
7997         return some_conv;
7998 }
7999 static inline struct LDKSocketAddress CResult_SocketAddressDecodeErrorZ_get_ok(LDKCResult_SocketAddressDecodeErrorZ *NONNULL_PTR owner){
8000 CHECK(owner->result_ok);
8001         return SocketAddress_clone(&*owner->contents.result);
8002 }
8003 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_get_ok(int64_t owner) {
8004         LDKCResult_SocketAddressDecodeErrorZ* owner_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(owner);
8005         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
8006         *ret_copy = CResult_SocketAddressDecodeErrorZ_get_ok(owner_conv);
8007         int64_t ret_ref = tag_ptr(ret_copy, true);
8008         return ret_ref;
8009 }
8010
8011 static inline struct LDKDecodeError CResult_SocketAddressDecodeErrorZ_get_err(LDKCResult_SocketAddressDecodeErrorZ *NONNULL_PTR owner){
8012 CHECK(!owner->result_ok);
8013         return DecodeError_clone(&*owner->contents.err);
8014 }
8015 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_get_err(int64_t owner) {
8016         LDKCResult_SocketAddressDecodeErrorZ* owner_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(owner);
8017         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8018         *ret_copy = CResult_SocketAddressDecodeErrorZ_get_err(owner_conv);
8019         int64_t ret_ref = tag_ptr(ret_copy, true);
8020         return ret_ref;
8021 }
8022
8023 static inline struct LDKSocketAddress CResult_SocketAddressSocketAddressParseErrorZ_get_ok(LDKCResult_SocketAddressSocketAddressParseErrorZ *NONNULL_PTR owner){
8024 CHECK(owner->result_ok);
8025         return SocketAddress_clone(&*owner->contents.result);
8026 }
8027 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_get_ok(int64_t owner) {
8028         LDKCResult_SocketAddressSocketAddressParseErrorZ* owner_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(owner);
8029         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
8030         *ret_copy = CResult_SocketAddressSocketAddressParseErrorZ_get_ok(owner_conv);
8031         int64_t ret_ref = tag_ptr(ret_copy, true);
8032         return ret_ref;
8033 }
8034
8035 static inline enum LDKSocketAddressParseError CResult_SocketAddressSocketAddressParseErrorZ_get_err(LDKCResult_SocketAddressSocketAddressParseErrorZ *NONNULL_PTR owner){
8036 CHECK(!owner->result_ok);
8037         return SocketAddressParseError_clone(&*owner->contents.err);
8038 }
8039 int32_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_get_err(int64_t owner) {
8040         LDKCResult_SocketAddressSocketAddressParseErrorZ* owner_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(owner);
8041         int32_t ret_conv = LDKSocketAddressParseError_to_cs(CResult_SocketAddressSocketAddressParseErrorZ_get_err(owner_conv));
8042         return ret_conv;
8043 }
8044
8045 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8046         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8047         for (size_t i = 0; i < ret.datalen; i++) {
8048                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8049         }
8050         return ret;
8051 }
8052 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8053         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8054         for (size_t i = 0; i < ret.datalen; i++) {
8055                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8056         }
8057         return ret;
8058 }
8059 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8060         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8061         for (size_t i = 0; i < ret.datalen; i++) {
8062                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8063         }
8064         return ret;
8065 }
8066 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8067         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8068         for (size_t i = 0; i < ret.datalen; i++) {
8069                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8070         }
8071         return ret;
8072 }
8073 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8074         LDKAcceptChannel ret = *owner->contents.result;
8075         ret.is_owned = false;
8076         return ret;
8077 }
8078 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_get_ok(int64_t owner) {
8079         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
8080         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8081         int64_t ret_ref = 0;
8082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8084         return ret_ref;
8085 }
8086
8087 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8088 CHECK(!owner->result_ok);
8089         return DecodeError_clone(&*owner->contents.err);
8090 }
8091 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_get_err(int64_t owner) {
8092         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
8093         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8094         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8095         int64_t ret_ref = tag_ptr(ret_copy, true);
8096         return ret_ref;
8097 }
8098
8099 static inline struct LDKAcceptChannelV2 CResult_AcceptChannelV2DecodeErrorZ_get_ok(LDKCResult_AcceptChannelV2DecodeErrorZ *NONNULL_PTR owner){
8100         LDKAcceptChannelV2 ret = *owner->contents.result;
8101         ret.is_owned = false;
8102         return ret;
8103 }
8104 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_get_ok(int64_t owner) {
8105         LDKCResult_AcceptChannelV2DecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(owner);
8106         LDKAcceptChannelV2 ret_var = CResult_AcceptChannelV2DecodeErrorZ_get_ok(owner_conv);
8107         int64_t ret_ref = 0;
8108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8110         return ret_ref;
8111 }
8112
8113 static inline struct LDKDecodeError CResult_AcceptChannelV2DecodeErrorZ_get_err(LDKCResult_AcceptChannelV2DecodeErrorZ *NONNULL_PTR owner){
8114 CHECK(!owner->result_ok);
8115         return DecodeError_clone(&*owner->contents.err);
8116 }
8117 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_get_err(int64_t owner) {
8118         LDKCResult_AcceptChannelV2DecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(owner);
8119         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8120         *ret_copy = CResult_AcceptChannelV2DecodeErrorZ_get_err(owner_conv);
8121         int64_t ret_ref = tag_ptr(ret_copy, true);
8122         return ret_ref;
8123 }
8124
8125 static inline struct LDKTxAddInput CResult_TxAddInputDecodeErrorZ_get_ok(LDKCResult_TxAddInputDecodeErrorZ *NONNULL_PTR owner){
8126         LDKTxAddInput ret = *owner->contents.result;
8127         ret.is_owned = false;
8128         return ret;
8129 }
8130 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_get_ok(int64_t owner) {
8131         LDKCResult_TxAddInputDecodeErrorZ* owner_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(owner);
8132         LDKTxAddInput ret_var = CResult_TxAddInputDecodeErrorZ_get_ok(owner_conv);
8133         int64_t ret_ref = 0;
8134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8136         return ret_ref;
8137 }
8138
8139 static inline struct LDKDecodeError CResult_TxAddInputDecodeErrorZ_get_err(LDKCResult_TxAddInputDecodeErrorZ *NONNULL_PTR owner){
8140 CHECK(!owner->result_ok);
8141         return DecodeError_clone(&*owner->contents.err);
8142 }
8143 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_get_err(int64_t owner) {
8144         LDKCResult_TxAddInputDecodeErrorZ* owner_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(owner);
8145         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8146         *ret_copy = CResult_TxAddInputDecodeErrorZ_get_err(owner_conv);
8147         int64_t ret_ref = tag_ptr(ret_copy, true);
8148         return ret_ref;
8149 }
8150
8151 static inline struct LDKTxAddOutput CResult_TxAddOutputDecodeErrorZ_get_ok(LDKCResult_TxAddOutputDecodeErrorZ *NONNULL_PTR owner){
8152         LDKTxAddOutput ret = *owner->contents.result;
8153         ret.is_owned = false;
8154         return ret;
8155 }
8156 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_get_ok(int64_t owner) {
8157         LDKCResult_TxAddOutputDecodeErrorZ* owner_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(owner);
8158         LDKTxAddOutput ret_var = CResult_TxAddOutputDecodeErrorZ_get_ok(owner_conv);
8159         int64_t ret_ref = 0;
8160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8161         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8162         return ret_ref;
8163 }
8164
8165 static inline struct LDKDecodeError CResult_TxAddOutputDecodeErrorZ_get_err(LDKCResult_TxAddOutputDecodeErrorZ *NONNULL_PTR owner){
8166 CHECK(!owner->result_ok);
8167         return DecodeError_clone(&*owner->contents.err);
8168 }
8169 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_get_err(int64_t owner) {
8170         LDKCResult_TxAddOutputDecodeErrorZ* owner_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(owner);
8171         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8172         *ret_copy = CResult_TxAddOutputDecodeErrorZ_get_err(owner_conv);
8173         int64_t ret_ref = tag_ptr(ret_copy, true);
8174         return ret_ref;
8175 }
8176
8177 static inline struct LDKTxRemoveInput CResult_TxRemoveInputDecodeErrorZ_get_ok(LDKCResult_TxRemoveInputDecodeErrorZ *NONNULL_PTR owner){
8178         LDKTxRemoveInput ret = *owner->contents.result;
8179         ret.is_owned = false;
8180         return ret;
8181 }
8182 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_get_ok(int64_t owner) {
8183         LDKCResult_TxRemoveInputDecodeErrorZ* owner_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(owner);
8184         LDKTxRemoveInput ret_var = CResult_TxRemoveInputDecodeErrorZ_get_ok(owner_conv);
8185         int64_t ret_ref = 0;
8186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8187         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8188         return ret_ref;
8189 }
8190
8191 static inline struct LDKDecodeError CResult_TxRemoveInputDecodeErrorZ_get_err(LDKCResult_TxRemoveInputDecodeErrorZ *NONNULL_PTR owner){
8192 CHECK(!owner->result_ok);
8193         return DecodeError_clone(&*owner->contents.err);
8194 }
8195 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_get_err(int64_t owner) {
8196         LDKCResult_TxRemoveInputDecodeErrorZ* owner_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(owner);
8197         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8198         *ret_copy = CResult_TxRemoveInputDecodeErrorZ_get_err(owner_conv);
8199         int64_t ret_ref = tag_ptr(ret_copy, true);
8200         return ret_ref;
8201 }
8202
8203 static inline struct LDKTxRemoveOutput CResult_TxRemoveOutputDecodeErrorZ_get_ok(LDKCResult_TxRemoveOutputDecodeErrorZ *NONNULL_PTR owner){
8204         LDKTxRemoveOutput ret = *owner->contents.result;
8205         ret.is_owned = false;
8206         return ret;
8207 }
8208 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_get_ok(int64_t owner) {
8209         LDKCResult_TxRemoveOutputDecodeErrorZ* owner_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(owner);
8210         LDKTxRemoveOutput ret_var = CResult_TxRemoveOutputDecodeErrorZ_get_ok(owner_conv);
8211         int64_t ret_ref = 0;
8212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8213         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8214         return ret_ref;
8215 }
8216
8217 static inline struct LDKDecodeError CResult_TxRemoveOutputDecodeErrorZ_get_err(LDKCResult_TxRemoveOutputDecodeErrorZ *NONNULL_PTR owner){
8218 CHECK(!owner->result_ok);
8219         return DecodeError_clone(&*owner->contents.err);
8220 }
8221 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_get_err(int64_t owner) {
8222         LDKCResult_TxRemoveOutputDecodeErrorZ* owner_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(owner);
8223         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8224         *ret_copy = CResult_TxRemoveOutputDecodeErrorZ_get_err(owner_conv);
8225         int64_t ret_ref = tag_ptr(ret_copy, true);
8226         return ret_ref;
8227 }
8228
8229 static inline struct LDKTxComplete CResult_TxCompleteDecodeErrorZ_get_ok(LDKCResult_TxCompleteDecodeErrorZ *NONNULL_PTR owner){
8230         LDKTxComplete ret = *owner->contents.result;
8231         ret.is_owned = false;
8232         return ret;
8233 }
8234 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_get_ok(int64_t owner) {
8235         LDKCResult_TxCompleteDecodeErrorZ* owner_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(owner);
8236         LDKTxComplete ret_var = CResult_TxCompleteDecodeErrorZ_get_ok(owner_conv);
8237         int64_t ret_ref = 0;
8238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8239         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8240         return ret_ref;
8241 }
8242
8243 static inline struct LDKDecodeError CResult_TxCompleteDecodeErrorZ_get_err(LDKCResult_TxCompleteDecodeErrorZ *NONNULL_PTR owner){
8244 CHECK(!owner->result_ok);
8245         return DecodeError_clone(&*owner->contents.err);
8246 }
8247 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_get_err(int64_t owner) {
8248         LDKCResult_TxCompleteDecodeErrorZ* owner_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(owner);
8249         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8250         *ret_copy = CResult_TxCompleteDecodeErrorZ_get_err(owner_conv);
8251         int64_t ret_ref = tag_ptr(ret_copy, true);
8252         return ret_ref;
8253 }
8254
8255 static inline struct LDKTxSignatures CResult_TxSignaturesDecodeErrorZ_get_ok(LDKCResult_TxSignaturesDecodeErrorZ *NONNULL_PTR owner){
8256         LDKTxSignatures ret = *owner->contents.result;
8257         ret.is_owned = false;
8258         return ret;
8259 }
8260 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_get_ok(int64_t owner) {
8261         LDKCResult_TxSignaturesDecodeErrorZ* owner_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(owner);
8262         LDKTxSignatures ret_var = CResult_TxSignaturesDecodeErrorZ_get_ok(owner_conv);
8263         int64_t ret_ref = 0;
8264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8266         return ret_ref;
8267 }
8268
8269 static inline struct LDKDecodeError CResult_TxSignaturesDecodeErrorZ_get_err(LDKCResult_TxSignaturesDecodeErrorZ *NONNULL_PTR owner){
8270 CHECK(!owner->result_ok);
8271         return DecodeError_clone(&*owner->contents.err);
8272 }
8273 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_get_err(int64_t owner) {
8274         LDKCResult_TxSignaturesDecodeErrorZ* owner_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(owner);
8275         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8276         *ret_copy = CResult_TxSignaturesDecodeErrorZ_get_err(owner_conv);
8277         int64_t ret_ref = tag_ptr(ret_copy, true);
8278         return ret_ref;
8279 }
8280
8281 static inline struct LDKTxInitRbf CResult_TxInitRbfDecodeErrorZ_get_ok(LDKCResult_TxInitRbfDecodeErrorZ *NONNULL_PTR owner){
8282         LDKTxInitRbf ret = *owner->contents.result;
8283         ret.is_owned = false;
8284         return ret;
8285 }
8286 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_get_ok(int64_t owner) {
8287         LDKCResult_TxInitRbfDecodeErrorZ* owner_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(owner);
8288         LDKTxInitRbf ret_var = CResult_TxInitRbfDecodeErrorZ_get_ok(owner_conv);
8289         int64_t ret_ref = 0;
8290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8292         return ret_ref;
8293 }
8294
8295 static inline struct LDKDecodeError CResult_TxInitRbfDecodeErrorZ_get_err(LDKCResult_TxInitRbfDecodeErrorZ *NONNULL_PTR owner){
8296 CHECK(!owner->result_ok);
8297         return DecodeError_clone(&*owner->contents.err);
8298 }
8299 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_get_err(int64_t owner) {
8300         LDKCResult_TxInitRbfDecodeErrorZ* owner_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(owner);
8301         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8302         *ret_copy = CResult_TxInitRbfDecodeErrorZ_get_err(owner_conv);
8303         int64_t ret_ref = tag_ptr(ret_copy, true);
8304         return ret_ref;
8305 }
8306
8307 static inline struct LDKTxAckRbf CResult_TxAckRbfDecodeErrorZ_get_ok(LDKCResult_TxAckRbfDecodeErrorZ *NONNULL_PTR owner){
8308         LDKTxAckRbf ret = *owner->contents.result;
8309         ret.is_owned = false;
8310         return ret;
8311 }
8312 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_get_ok(int64_t owner) {
8313         LDKCResult_TxAckRbfDecodeErrorZ* owner_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(owner);
8314         LDKTxAckRbf ret_var = CResult_TxAckRbfDecodeErrorZ_get_ok(owner_conv);
8315         int64_t ret_ref = 0;
8316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8318         return ret_ref;
8319 }
8320
8321 static inline struct LDKDecodeError CResult_TxAckRbfDecodeErrorZ_get_err(LDKCResult_TxAckRbfDecodeErrorZ *NONNULL_PTR owner){
8322 CHECK(!owner->result_ok);
8323         return DecodeError_clone(&*owner->contents.err);
8324 }
8325 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_get_err(int64_t owner) {
8326         LDKCResult_TxAckRbfDecodeErrorZ* owner_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(owner);
8327         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8328         *ret_copy = CResult_TxAckRbfDecodeErrorZ_get_err(owner_conv);
8329         int64_t ret_ref = tag_ptr(ret_copy, true);
8330         return ret_ref;
8331 }
8332
8333 static inline struct LDKTxAbort CResult_TxAbortDecodeErrorZ_get_ok(LDKCResult_TxAbortDecodeErrorZ *NONNULL_PTR owner){
8334         LDKTxAbort ret = *owner->contents.result;
8335         ret.is_owned = false;
8336         return ret;
8337 }
8338 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_get_ok(int64_t owner) {
8339         LDKCResult_TxAbortDecodeErrorZ* owner_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(owner);
8340         LDKTxAbort ret_var = CResult_TxAbortDecodeErrorZ_get_ok(owner_conv);
8341         int64_t ret_ref = 0;
8342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8344         return ret_ref;
8345 }
8346
8347 static inline struct LDKDecodeError CResult_TxAbortDecodeErrorZ_get_err(LDKCResult_TxAbortDecodeErrorZ *NONNULL_PTR owner){
8348 CHECK(!owner->result_ok);
8349         return DecodeError_clone(&*owner->contents.err);
8350 }
8351 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_get_err(int64_t owner) {
8352         LDKCResult_TxAbortDecodeErrorZ* owner_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(owner);
8353         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8354         *ret_copy = CResult_TxAbortDecodeErrorZ_get_err(owner_conv);
8355         int64_t ret_ref = tag_ptr(ret_copy, true);
8356         return ret_ref;
8357 }
8358
8359 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8360         LDKAnnouncementSignatures ret = *owner->contents.result;
8361         ret.is_owned = false;
8362         return ret;
8363 }
8364 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(int64_t owner) {
8365         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
8366         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8367         int64_t ret_ref = 0;
8368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8370         return ret_ref;
8371 }
8372
8373 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8374 CHECK(!owner->result_ok);
8375         return DecodeError_clone(&*owner->contents.err);
8376 }
8377 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(int64_t owner) {
8378         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
8379         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8380         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8381         int64_t ret_ref = tag_ptr(ret_copy, true);
8382         return ret_ref;
8383 }
8384
8385 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8386         LDKChannelReestablish ret = *owner->contents.result;
8387         ret.is_owned = false;
8388         return ret;
8389 }
8390 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_get_ok(int64_t owner) {
8391         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
8392         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8393         int64_t ret_ref = 0;
8394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8396         return ret_ref;
8397 }
8398
8399 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8400 CHECK(!owner->result_ok);
8401         return DecodeError_clone(&*owner->contents.err);
8402 }
8403 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_get_err(int64_t owner) {
8404         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
8405         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8406         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8407         int64_t ret_ref = tag_ptr(ret_copy, true);
8408         return ret_ref;
8409 }
8410
8411 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8412         LDKClosingSigned ret = *owner->contents.result;
8413         ret.is_owned = false;
8414         return ret;
8415 }
8416 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_get_ok(int64_t owner) {
8417         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
8418         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8419         int64_t ret_ref = 0;
8420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8422         return ret_ref;
8423 }
8424
8425 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8426 CHECK(!owner->result_ok);
8427         return DecodeError_clone(&*owner->contents.err);
8428 }
8429 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_get_err(int64_t owner) {
8430         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
8431         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8432         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8433         int64_t ret_ref = tag_ptr(ret_copy, true);
8434         return ret_ref;
8435 }
8436
8437 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8438         LDKClosingSignedFeeRange ret = *owner->contents.result;
8439         ret.is_owned = false;
8440         return ret;
8441 }
8442 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(int64_t owner) {
8443         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
8444         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8445         int64_t ret_ref = 0;
8446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8447         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8448         return ret_ref;
8449 }
8450
8451 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8452 CHECK(!owner->result_ok);
8453         return DecodeError_clone(&*owner->contents.err);
8454 }
8455 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(int64_t owner) {
8456         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
8457         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8458         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8459         int64_t ret_ref = tag_ptr(ret_copy, true);
8460         return ret_ref;
8461 }
8462
8463 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8464         LDKCommitmentSigned ret = *owner->contents.result;
8465         ret.is_owned = false;
8466         return ret;
8467 }
8468 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_get_ok(int64_t owner) {
8469         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
8470         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8471         int64_t ret_ref = 0;
8472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8474         return ret_ref;
8475 }
8476
8477 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8478 CHECK(!owner->result_ok);
8479         return DecodeError_clone(&*owner->contents.err);
8480 }
8481 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_get_err(int64_t owner) {
8482         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
8483         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8484         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8485         int64_t ret_ref = tag_ptr(ret_copy, true);
8486         return ret_ref;
8487 }
8488
8489 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8490         LDKFundingCreated ret = *owner->contents.result;
8491         ret.is_owned = false;
8492         return ret;
8493 }
8494 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_get_ok(int64_t owner) {
8495         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
8496         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8497         int64_t ret_ref = 0;
8498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8500         return ret_ref;
8501 }
8502
8503 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8504 CHECK(!owner->result_ok);
8505         return DecodeError_clone(&*owner->contents.err);
8506 }
8507 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_get_err(int64_t owner) {
8508         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
8509         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8510         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8511         int64_t ret_ref = tag_ptr(ret_copy, true);
8512         return ret_ref;
8513 }
8514
8515 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8516         LDKFundingSigned ret = *owner->contents.result;
8517         ret.is_owned = false;
8518         return ret;
8519 }
8520 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_get_ok(int64_t owner) {
8521         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
8522         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8523         int64_t ret_ref = 0;
8524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8525         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8526         return ret_ref;
8527 }
8528
8529 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8530 CHECK(!owner->result_ok);
8531         return DecodeError_clone(&*owner->contents.err);
8532 }
8533 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_get_err(int64_t owner) {
8534         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
8535         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8536         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8537         int64_t ret_ref = tag_ptr(ret_copy, true);
8538         return ret_ref;
8539 }
8540
8541 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8542         LDKChannelReady ret = *owner->contents.result;
8543         ret.is_owned = false;
8544         return ret;
8545 }
8546 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_get_ok(int64_t owner) {
8547         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
8548         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
8549         int64_t ret_ref = 0;
8550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8552         return ret_ref;
8553 }
8554
8555 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8556 CHECK(!owner->result_ok);
8557         return DecodeError_clone(&*owner->contents.err);
8558 }
8559 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_get_err(int64_t owner) {
8560         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
8561         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8562         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
8563         int64_t ret_ref = tag_ptr(ret_copy, true);
8564         return ret_ref;
8565 }
8566
8567 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8568         LDKInit ret = *owner->contents.result;
8569         ret.is_owned = false;
8570         return ret;
8571 }
8572 int64_t  CS_LDK_CResult_InitDecodeErrorZ_get_ok(int64_t owner) {
8573         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
8574         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8575         int64_t ret_ref = 0;
8576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8578         return ret_ref;
8579 }
8580
8581 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8582 CHECK(!owner->result_ok);
8583         return DecodeError_clone(&*owner->contents.err);
8584 }
8585 int64_t  CS_LDK_CResult_InitDecodeErrorZ_get_err(int64_t owner) {
8586         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
8587         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8588         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
8589         int64_t ret_ref = tag_ptr(ret_copy, true);
8590         return ret_ref;
8591 }
8592
8593 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8594         LDKOpenChannel ret = *owner->contents.result;
8595         ret.is_owned = false;
8596         return ret;
8597 }
8598 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_get_ok(int64_t owner) {
8599         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
8600         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8601         int64_t ret_ref = 0;
8602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8604         return ret_ref;
8605 }
8606
8607 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8608 CHECK(!owner->result_ok);
8609         return DecodeError_clone(&*owner->contents.err);
8610 }
8611 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_get_err(int64_t owner) {
8612         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
8613         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8614         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8615         int64_t ret_ref = tag_ptr(ret_copy, true);
8616         return ret_ref;
8617 }
8618
8619 static inline struct LDKOpenChannelV2 CResult_OpenChannelV2DecodeErrorZ_get_ok(LDKCResult_OpenChannelV2DecodeErrorZ *NONNULL_PTR owner){
8620         LDKOpenChannelV2 ret = *owner->contents.result;
8621         ret.is_owned = false;
8622         return ret;
8623 }
8624 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_get_ok(int64_t owner) {
8625         LDKCResult_OpenChannelV2DecodeErrorZ* owner_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(owner);
8626         LDKOpenChannelV2 ret_var = CResult_OpenChannelV2DecodeErrorZ_get_ok(owner_conv);
8627         int64_t ret_ref = 0;
8628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8629         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8630         return ret_ref;
8631 }
8632
8633 static inline struct LDKDecodeError CResult_OpenChannelV2DecodeErrorZ_get_err(LDKCResult_OpenChannelV2DecodeErrorZ *NONNULL_PTR owner){
8634 CHECK(!owner->result_ok);
8635         return DecodeError_clone(&*owner->contents.err);
8636 }
8637 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_get_err(int64_t owner) {
8638         LDKCResult_OpenChannelV2DecodeErrorZ* owner_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(owner);
8639         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8640         *ret_copy = CResult_OpenChannelV2DecodeErrorZ_get_err(owner_conv);
8641         int64_t ret_ref = tag_ptr(ret_copy, true);
8642         return ret_ref;
8643 }
8644
8645 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8646         LDKRevokeAndACK ret = *owner->contents.result;
8647         ret.is_owned = false;
8648         return ret;
8649 }
8650 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_get_ok(int64_t owner) {
8651         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
8652         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8653         int64_t ret_ref = 0;
8654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8656         return ret_ref;
8657 }
8658
8659 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8660 CHECK(!owner->result_ok);
8661         return DecodeError_clone(&*owner->contents.err);
8662 }
8663 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_get_err(int64_t owner) {
8664         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
8665         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8666         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8667         int64_t ret_ref = tag_ptr(ret_copy, true);
8668         return ret_ref;
8669 }
8670
8671 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8672         LDKShutdown ret = *owner->contents.result;
8673         ret.is_owned = false;
8674         return ret;
8675 }
8676 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_get_ok(int64_t owner) {
8677         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
8678         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8679         int64_t ret_ref = 0;
8680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8681         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8682         return ret_ref;
8683 }
8684
8685 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8686 CHECK(!owner->result_ok);
8687         return DecodeError_clone(&*owner->contents.err);
8688 }
8689 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_get_err(int64_t owner) {
8690         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
8691         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8692         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8693         int64_t ret_ref = tag_ptr(ret_copy, true);
8694         return ret_ref;
8695 }
8696
8697 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8698         LDKUpdateFailHTLC ret = *owner->contents.result;
8699         ret.is_owned = false;
8700         return ret;
8701 }
8702 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(int64_t owner) {
8703         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
8704         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8705         int64_t ret_ref = 0;
8706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8708         return ret_ref;
8709 }
8710
8711 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8712 CHECK(!owner->result_ok);
8713         return DecodeError_clone(&*owner->contents.err);
8714 }
8715 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_get_err(int64_t owner) {
8716         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
8717         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8718         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8719         int64_t ret_ref = tag_ptr(ret_copy, true);
8720         return ret_ref;
8721 }
8722
8723 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8724         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
8725         ret.is_owned = false;
8726         return ret;
8727 }
8728 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(int64_t owner) {
8729         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
8730         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8731         int64_t ret_ref = 0;
8732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8734         return ret_ref;
8735 }
8736
8737 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8738 CHECK(!owner->result_ok);
8739         return DecodeError_clone(&*owner->contents.err);
8740 }
8741 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(int64_t owner) {
8742         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
8743         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8744         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
8745         int64_t ret_ref = tag_ptr(ret_copy, true);
8746         return ret_ref;
8747 }
8748
8749 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8750         LDKUpdateFee ret = *owner->contents.result;
8751         ret.is_owned = false;
8752         return ret;
8753 }
8754 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_get_ok(int64_t owner) {
8755         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
8756         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
8757         int64_t ret_ref = 0;
8758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8760         return ret_ref;
8761 }
8762
8763 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8764 CHECK(!owner->result_ok);
8765         return DecodeError_clone(&*owner->contents.err);
8766 }
8767 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_get_err(int64_t owner) {
8768         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
8769         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8770         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
8771         int64_t ret_ref = tag_ptr(ret_copy, true);
8772         return ret_ref;
8773 }
8774
8775 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8776         LDKUpdateFulfillHTLC ret = *owner->contents.result;
8777         ret.is_owned = false;
8778         return ret;
8779 }
8780 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(int64_t owner) {
8781         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
8782         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
8783         int64_t ret_ref = 0;
8784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8785         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8786         return ret_ref;
8787 }
8788
8789 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8790 CHECK(!owner->result_ok);
8791         return DecodeError_clone(&*owner->contents.err);
8792 }
8793 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(int64_t owner) {
8794         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
8795         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8796         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
8797         int64_t ret_ref = tag_ptr(ret_copy, true);
8798         return ret_ref;
8799 }
8800
8801 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8802         LDKUpdateAddHTLC ret = *owner->contents.result;
8803         ret.is_owned = false;
8804         return ret;
8805 }
8806 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(int64_t owner) {
8807         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
8808         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
8809         int64_t ret_ref = 0;
8810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8812         return ret_ref;
8813 }
8814
8815 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8816 CHECK(!owner->result_ok);
8817         return DecodeError_clone(&*owner->contents.err);
8818 }
8819 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_get_err(int64_t owner) {
8820         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
8821         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8822         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
8823         int64_t ret_ref = tag_ptr(ret_copy, true);
8824         return ret_ref;
8825 }
8826
8827 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
8828         LDKOnionMessage ret = *owner->contents.result;
8829         ret.is_owned = false;
8830         return ret;
8831 }
8832 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_get_ok(int64_t owner) {
8833         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
8834         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
8835         int64_t ret_ref = 0;
8836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8838         return ret_ref;
8839 }
8840
8841 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
8842 CHECK(!owner->result_ok);
8843         return DecodeError_clone(&*owner->contents.err);
8844 }
8845 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_get_err(int64_t owner) {
8846         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
8847         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8848         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
8849         int64_t ret_ref = tag_ptr(ret_copy, true);
8850         return ret_ref;
8851 }
8852
8853 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8854         LDKPing ret = *owner->contents.result;
8855         ret.is_owned = false;
8856         return ret;
8857 }
8858 int64_t  CS_LDK_CResult_PingDecodeErrorZ_get_ok(int64_t owner) {
8859         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
8860         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
8861         int64_t ret_ref = 0;
8862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8864         return ret_ref;
8865 }
8866
8867 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8868 CHECK(!owner->result_ok);
8869         return DecodeError_clone(&*owner->contents.err);
8870 }
8871 int64_t  CS_LDK_CResult_PingDecodeErrorZ_get_err(int64_t owner) {
8872         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
8873         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8874         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
8875         int64_t ret_ref = tag_ptr(ret_copy, true);
8876         return ret_ref;
8877 }
8878
8879 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8880         LDKPong ret = *owner->contents.result;
8881         ret.is_owned = false;
8882         return ret;
8883 }
8884 int64_t  CS_LDK_CResult_PongDecodeErrorZ_get_ok(int64_t owner) {
8885         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
8886         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
8887         int64_t ret_ref = 0;
8888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8890         return ret_ref;
8891 }
8892
8893 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8894 CHECK(!owner->result_ok);
8895         return DecodeError_clone(&*owner->contents.err);
8896 }
8897 int64_t  CS_LDK_CResult_PongDecodeErrorZ_get_err(int64_t owner) {
8898         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
8899         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8900         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
8901         int64_t ret_ref = tag_ptr(ret_copy, true);
8902         return ret_ref;
8903 }
8904
8905 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8906         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
8907         ret.is_owned = false;
8908         return ret;
8909 }
8910 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(int64_t owner) {
8911         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8912         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8913         int64_t ret_ref = 0;
8914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8916         return ret_ref;
8917 }
8918
8919 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8920 CHECK(!owner->result_ok);
8921         return DecodeError_clone(&*owner->contents.err);
8922 }
8923 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(int64_t owner) {
8924         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8925         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8926         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8927         int64_t ret_ref = tag_ptr(ret_copy, true);
8928         return ret_ref;
8929 }
8930
8931 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8932         LDKChannelAnnouncement ret = *owner->contents.result;
8933         ret.is_owned = false;
8934         return ret;
8935 }
8936 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(int64_t owner) {
8937         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8938         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8939         int64_t ret_ref = 0;
8940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8942         return ret_ref;
8943 }
8944
8945 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8946 CHECK(!owner->result_ok);
8947         return DecodeError_clone(&*owner->contents.err);
8948 }
8949 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_get_err(int64_t owner) {
8950         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8951         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8952         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8953         int64_t ret_ref = tag_ptr(ret_copy, true);
8954         return ret_ref;
8955 }
8956
8957 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8958         LDKUnsignedChannelUpdate ret = *owner->contents.result;
8959         ret.is_owned = false;
8960         return ret;
8961 }
8962 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(int64_t owner) {
8963         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8964         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8965         int64_t ret_ref = 0;
8966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8967         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8968         return ret_ref;
8969 }
8970
8971 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8972 CHECK(!owner->result_ok);
8973         return DecodeError_clone(&*owner->contents.err);
8974 }
8975 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(int64_t owner) {
8976         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8977         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8978         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
8979         int64_t ret_ref = tag_ptr(ret_copy, true);
8980         return ret_ref;
8981 }
8982
8983 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8984         LDKChannelUpdate ret = *owner->contents.result;
8985         ret.is_owned = false;
8986         return ret;
8987 }
8988 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_get_ok(int64_t owner) {
8989         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8990         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8991         int64_t ret_ref = 0;
8992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8993         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8994         return ret_ref;
8995 }
8996
8997 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8998 CHECK(!owner->result_ok);
8999         return DecodeError_clone(&*owner->contents.err);
9000 }
9001 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_get_err(int64_t owner) {
9002         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
9003         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9004         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9005         int64_t ret_ref = tag_ptr(ret_copy, true);
9006         return ret_ref;
9007 }
9008
9009 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9010         LDKErrorMessage ret = *owner->contents.result;
9011         ret.is_owned = false;
9012         return ret;
9013 }
9014 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_get_ok(int64_t owner) {
9015         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
9016         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9017         int64_t ret_ref = 0;
9018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9020         return ret_ref;
9021 }
9022
9023 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9024 CHECK(!owner->result_ok);
9025         return DecodeError_clone(&*owner->contents.err);
9026 }
9027 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_get_err(int64_t owner) {
9028         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
9029         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9030         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9031         int64_t ret_ref = tag_ptr(ret_copy, true);
9032         return ret_ref;
9033 }
9034
9035 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9036         LDKWarningMessage ret = *owner->contents.result;
9037         ret.is_owned = false;
9038         return ret;
9039 }
9040 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_get_ok(int64_t owner) {
9041         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
9042         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9043         int64_t ret_ref = 0;
9044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9045         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9046         return ret_ref;
9047 }
9048
9049 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9050 CHECK(!owner->result_ok);
9051         return DecodeError_clone(&*owner->contents.err);
9052 }
9053 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_get_err(int64_t owner) {
9054         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
9055         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9056         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9057         int64_t ret_ref = tag_ptr(ret_copy, true);
9058         return ret_ref;
9059 }
9060
9061 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9062         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
9063         ret.is_owned = false;
9064         return ret;
9065 }
9066 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(int64_t owner) {
9067         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9068         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9069         int64_t ret_ref = 0;
9070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9072         return ret_ref;
9073 }
9074
9075 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9076 CHECK(!owner->result_ok);
9077         return DecodeError_clone(&*owner->contents.err);
9078 }
9079 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(int64_t owner) {
9080         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9081         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9082         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9083         int64_t ret_ref = tag_ptr(ret_copy, true);
9084         return ret_ref;
9085 }
9086
9087 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9088         LDKNodeAnnouncement ret = *owner->contents.result;
9089         ret.is_owned = false;
9090         return ret;
9091 }
9092 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_get_ok(int64_t owner) {
9093         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9094         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9095         int64_t ret_ref = 0;
9096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9097         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9098         return ret_ref;
9099 }
9100
9101 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9102 CHECK(!owner->result_ok);
9103         return DecodeError_clone(&*owner->contents.err);
9104 }
9105 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_get_err(int64_t owner) {
9106         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9107         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9108         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9109         int64_t ret_ref = tag_ptr(ret_copy, true);
9110         return ret_ref;
9111 }
9112
9113 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9114         LDKQueryShortChannelIds ret = *owner->contents.result;
9115         ret.is_owned = false;
9116         return ret;
9117 }
9118 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(int64_t owner) {
9119         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
9120         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9121         int64_t ret_ref = 0;
9122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9124         return ret_ref;
9125 }
9126
9127 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9128 CHECK(!owner->result_ok);
9129         return DecodeError_clone(&*owner->contents.err);
9130 }
9131 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(int64_t owner) {
9132         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
9133         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9134         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9135         int64_t ret_ref = tag_ptr(ret_copy, true);
9136         return ret_ref;
9137 }
9138
9139 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9140         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
9141         ret.is_owned = false;
9142         return ret;
9143 }
9144 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(int64_t owner) {
9145         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
9146         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9147         int64_t ret_ref = 0;
9148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9150         return ret_ref;
9151 }
9152
9153 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9154 CHECK(!owner->result_ok);
9155         return DecodeError_clone(&*owner->contents.err);
9156 }
9157 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(int64_t owner) {
9158         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
9159         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9160         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9161         int64_t ret_ref = tag_ptr(ret_copy, true);
9162         return ret_ref;
9163 }
9164
9165 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9166         LDKQueryChannelRange ret = *owner->contents.result;
9167         ret.is_owned = false;
9168         return ret;
9169 }
9170 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_get_ok(int64_t owner) {
9171         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
9172         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9173         int64_t ret_ref = 0;
9174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9175         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9176         return ret_ref;
9177 }
9178
9179 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9180 CHECK(!owner->result_ok);
9181         return DecodeError_clone(&*owner->contents.err);
9182 }
9183 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_get_err(int64_t owner) {
9184         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
9185         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9186         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9187         int64_t ret_ref = tag_ptr(ret_copy, true);
9188         return ret_ref;
9189 }
9190
9191 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9192         LDKReplyChannelRange ret = *owner->contents.result;
9193         ret.is_owned = false;
9194         return ret;
9195 }
9196 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(int64_t owner) {
9197         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
9198         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9199         int64_t ret_ref = 0;
9200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9201         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9202         return ret_ref;
9203 }
9204
9205 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9206 CHECK(!owner->result_ok);
9207         return DecodeError_clone(&*owner->contents.err);
9208 }
9209 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_get_err(int64_t owner) {
9210         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
9211         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9212         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9213         int64_t ret_ref = tag_ptr(ret_copy, true);
9214         return ret_ref;
9215 }
9216
9217 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9218         LDKGossipTimestampFilter ret = *owner->contents.result;
9219         ret.is_owned = false;
9220         return ret;
9221 }
9222 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(int64_t owner) {
9223         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
9224         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9225         int64_t ret_ref = 0;
9226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9227         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9228         return ret_ref;
9229 }
9230
9231 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9232 CHECK(!owner->result_ok);
9233         return DecodeError_clone(&*owner->contents.err);
9234 }
9235 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_get_err(int64_t owner) {
9236         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
9237         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9238         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9239         int64_t ret_ref = tag_ptr(ret_copy, true);
9240         return ret_ref;
9241 }
9242
9243 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9244         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9245         for (size_t i = 0; i < ret.datalen; i++) {
9246                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9247         }
9248         return ret;
9249 }
9250 uint32_t CS_LDK_LDKSignOrCreationError_ty_from_ptr(int64_t ptr) {
9251         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
9252         switch(obj->tag) {
9253                 case LDKSignOrCreationError_SignError: return 0;
9254                 case LDKSignOrCreationError_CreationError: return 1;
9255                 default: abort();
9256         }
9257 }
9258 int32_t CS_LDK_LDKSignOrCreationError_CreationError_get_creation_error(int64_t ptr) {
9259         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
9260         CHECK(obj->tag == LDKSignOrCreationError_CreationError);
9261         int32_t creation_error_conv = LDKCreationError_to_cs(obj->creation_error);
9262         return creation_error_conv;
9263 }
9264 static inline struct LDKBolt11Invoice CResult_Bolt11InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9265         LDKBolt11Invoice ret = *owner->contents.result;
9266         ret.is_owned = false;
9267         return ret;
9268 }
9269 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_get_ok(int64_t owner) {
9270         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
9271         LDKBolt11Invoice ret_var = CResult_Bolt11InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9272         int64_t ret_ref = 0;
9273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9274         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9275         return ret_ref;
9276 }
9277
9278 static inline struct LDKSignOrCreationError CResult_Bolt11InvoiceSignOrCreationErrorZ_get_err(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9279 CHECK(!owner->result_ok);
9280         return SignOrCreationError_clone(&*owner->contents.err);
9281 }
9282 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_get_err(int64_t owner) {
9283         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
9284         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9285         *ret_copy = CResult_Bolt11InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9286         int64_t ret_ref = tag_ptr(ret_copy, true);
9287         return ret_ref;
9288 }
9289
9290 static inline LDKCVec_FutureZ CVec_FutureZ_clone(const LDKCVec_FutureZ *orig) {
9291         LDKCVec_FutureZ ret = { .data = MALLOC(sizeof(LDKFuture) * orig->datalen, "LDKCVec_FutureZ clone bytes"), .datalen = orig->datalen };
9292         for (size_t i = 0; i < ret.datalen; i++) {
9293                 ret.data[i] = Future_clone(&orig->data[i]);
9294         }
9295         return ret;
9296 }
9297 static inline struct LDKOffersMessage CResult_OffersMessageDecodeErrorZ_get_ok(LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR owner){
9298 CHECK(owner->result_ok);
9299         return OffersMessage_clone(&*owner->contents.result);
9300 }
9301 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_get_ok(int64_t owner) {
9302         LDKCResult_OffersMessageDecodeErrorZ* owner_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(owner);
9303         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
9304         *ret_copy = CResult_OffersMessageDecodeErrorZ_get_ok(owner_conv);
9305         int64_t ret_ref = tag_ptr(ret_copy, true);
9306         return ret_ref;
9307 }
9308
9309 static inline struct LDKDecodeError CResult_OffersMessageDecodeErrorZ_get_err(LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR owner){
9310 CHECK(!owner->result_ok);
9311         return DecodeError_clone(&*owner->contents.err);
9312 }
9313 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_get_err(int64_t owner) {
9314         LDKCResult_OffersMessageDecodeErrorZ* owner_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(owner);
9315         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9316         *ret_copy = CResult_OffersMessageDecodeErrorZ_get_err(owner_conv);
9317         int64_t ret_ref = tag_ptr(ret_copy, true);
9318         return ret_ref;
9319 }
9320
9321 uint32_t CS_LDK_LDKCOption_HTLCClaimZ_ty_from_ptr(int64_t ptr) {
9322         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
9323         switch(obj->tag) {
9324                 case LDKCOption_HTLCClaimZ_Some: return 0;
9325                 case LDKCOption_HTLCClaimZ_None: return 1;
9326                 default: abort();
9327         }
9328 }
9329 int32_t CS_LDK_LDKCOption_HTLCClaimZ_Some_get_some(int64_t ptr) {
9330         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
9331         CHECK(obj->tag == LDKCOption_HTLCClaimZ_Some);
9332         int32_t some_conv = LDKHTLCClaim_to_cs(obj->some);
9333         return some_conv;
9334 }
9335 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
9336         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
9337         ret.is_owned = false;
9338         return ret;
9339 }
9340 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(int64_t owner) {
9341         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
9342         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
9343         int64_t ret_ref = 0;
9344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9346         return ret_ref;
9347 }
9348
9349 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
9350 CHECK(!owner->result_ok);
9351         return DecodeError_clone(&*owner->contents.err);
9352 }
9353 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(int64_t owner) {
9354         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
9355         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9356         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
9357         int64_t ret_ref = tag_ptr(ret_copy, true);
9358         return ret_ref;
9359 }
9360
9361 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
9362         LDKTxCreationKeys ret = *owner->contents.result;
9363         ret.is_owned = false;
9364         return ret;
9365 }
9366 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_get_ok(int64_t owner) {
9367         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
9368         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
9369         int64_t ret_ref = 0;
9370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9371         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9372         return ret_ref;
9373 }
9374
9375 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
9376 CHECK(!owner->result_ok);
9377         return DecodeError_clone(&*owner->contents.err);
9378 }
9379 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_get_err(int64_t owner) {
9380         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
9381         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9382         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
9383         int64_t ret_ref = tag_ptr(ret_copy, true);
9384         return ret_ref;
9385 }
9386
9387 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
9388         LDKChannelPublicKeys ret = *owner->contents.result;
9389         ret.is_owned = false;
9390         return ret;
9391 }
9392 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(int64_t owner) {
9393         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
9394         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
9395         int64_t ret_ref = 0;
9396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9397         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9398         return ret_ref;
9399 }
9400
9401 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
9402 CHECK(!owner->result_ok);
9403         return DecodeError_clone(&*owner->contents.err);
9404 }
9405 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_get_err(int64_t owner) {
9406         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
9407         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9408         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
9409         int64_t ret_ref = tag_ptr(ret_copy, true);
9410         return ret_ref;
9411 }
9412
9413 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
9414         LDKHTLCOutputInCommitment ret = *owner->contents.result;
9415         ret.is_owned = false;
9416         return ret;
9417 }
9418 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(int64_t owner) {
9419         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
9420         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
9421         int64_t ret_ref = 0;
9422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9424         return ret_ref;
9425 }
9426
9427 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
9428 CHECK(!owner->result_ok);
9429         return DecodeError_clone(&*owner->contents.err);
9430 }
9431 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(int64_t owner) {
9432         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
9433         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9434         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
9435         int64_t ret_ref = tag_ptr(ret_copy, true);
9436         return ret_ref;
9437 }
9438
9439 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
9440         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
9441         ret.is_owned = false;
9442         return ret;
9443 }
9444 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(int64_t owner) {
9445         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
9446         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
9447         int64_t ret_ref = 0;
9448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9449         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9450         return ret_ref;
9451 }
9452
9453 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
9454 CHECK(!owner->result_ok);
9455         return DecodeError_clone(&*owner->contents.err);
9456 }
9457 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(int64_t owner) {
9458         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
9459         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9460         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
9461         int64_t ret_ref = tag_ptr(ret_copy, true);
9462         return ret_ref;
9463 }
9464
9465 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
9466         LDKChannelTransactionParameters ret = *owner->contents.result;
9467         ret.is_owned = false;
9468         return ret;
9469 }
9470 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(int64_t owner) {
9471         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
9472         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
9473         int64_t ret_ref = 0;
9474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9475         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9476         return ret_ref;
9477 }
9478
9479 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
9480 CHECK(!owner->result_ok);
9481         return DecodeError_clone(&*owner->contents.err);
9482 }
9483 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(int64_t owner) {
9484         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
9485         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9486         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
9487         int64_t ret_ref = tag_ptr(ret_copy, true);
9488         return ret_ref;
9489 }
9490
9491 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9492         LDKHolderCommitmentTransaction ret = *owner->contents.result;
9493         ret.is_owned = false;
9494         return ret;
9495 }
9496 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(int64_t owner) {
9497         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9498         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
9499         int64_t ret_ref = 0;
9500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9501         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9502         return ret_ref;
9503 }
9504
9505 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9506 CHECK(!owner->result_ok);
9507         return DecodeError_clone(&*owner->contents.err);
9508 }
9509 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(int64_t owner) {
9510         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9511         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9512         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
9513         int64_t ret_ref = tag_ptr(ret_copy, true);
9514         return ret_ref;
9515 }
9516
9517 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9518         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
9519         ret.is_owned = false;
9520         return ret;
9521 }
9522 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(int64_t owner) {
9523         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9524         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
9525         int64_t ret_ref = 0;
9526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9527         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9528         return ret_ref;
9529 }
9530
9531 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9532 CHECK(!owner->result_ok);
9533         return DecodeError_clone(&*owner->contents.err);
9534 }
9535 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(int64_t owner) {
9536         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9537         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9538         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
9539         int64_t ret_ref = tag_ptr(ret_copy, true);
9540         return ret_ref;
9541 }
9542
9543 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
9544         LDKTrustedClosingTransaction ret = *owner->contents.result;
9545         ret.is_owned = false;
9546         return ret;
9547 }
9548 int64_t  CS_LDK_CResult_TrustedClosingTransactionNoneZ_get_ok(int64_t owner) {
9549         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
9550         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
9551         int64_t ret_ref = 0;
9552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9554         return ret_ref;
9555 }
9556
9557 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
9558 CHECK(!owner->result_ok);
9559         return *owner->contents.err;
9560 }
9561 void  CS_LDK_CResult_TrustedClosingTransactionNoneZ_get_err(int64_t owner) {
9562         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
9563         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
9564 }
9565
9566 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9567         LDKCommitmentTransaction ret = *owner->contents.result;
9568         ret.is_owned = false;
9569         return ret;
9570 }
9571 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_get_ok(int64_t owner) {
9572         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9573         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
9574         int64_t ret_ref = 0;
9575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9577         return ret_ref;
9578 }
9579
9580 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9581 CHECK(!owner->result_ok);
9582         return DecodeError_clone(&*owner->contents.err);
9583 }
9584 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_get_err(int64_t owner) {
9585         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9586         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9587         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
9588         int64_t ret_ref = tag_ptr(ret_copy, true);
9589         return ret_ref;
9590 }
9591
9592 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
9593         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
9594         ret.is_owned = false;
9595         return ret;
9596 }
9597 int64_t  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_get_ok(int64_t owner) {
9598         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
9599         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
9600         int64_t ret_ref = 0;
9601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9602         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9603         return ret_ref;
9604 }
9605
9606 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
9607 CHECK(!owner->result_ok);
9608         return *owner->contents.err;
9609 }
9610 void  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_get_err(int64_t owner) {
9611         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
9612         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
9613 }
9614
9615 static inline struct LDKCVec_ECDSASignatureZ CResult_CVec_ECDSASignatureZNoneZ_get_ok(LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR owner){
9616 CHECK(owner->result_ok);
9617         return *owner->contents.result;
9618 }
9619 ptrArray  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_get_ok(int64_t owner) {
9620         LDKCResult_CVec_ECDSASignatureZNoneZ* owner_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(owner);
9621         LDKCVec_ECDSASignatureZ ret_var = CResult_CVec_ECDSASignatureZNoneZ_get_ok(owner_conv);
9622         ptrArray ret_arr = NULL;
9623         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
9624         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
9625         for (size_t i = 0; i < ret_var.datalen; i++) {
9626                 int8_tArray ret_conv_8_arr = init_int8_tArray(64, __LINE__);
9627                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compact_form, 64);
9628                 ret_arr_ptr[i] = ret_conv_8_arr;
9629         }
9630         
9631         return ret_arr;
9632 }
9633
9634 static inline void CResult_CVec_ECDSASignatureZNoneZ_get_err(LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR owner){
9635 CHECK(!owner->result_ok);
9636         return *owner->contents.err;
9637 }
9638 void  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_get_err(int64_t owner) {
9639         LDKCResult_CVec_ECDSASignatureZNoneZ* owner_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(owner);
9640         CResult_CVec_ECDSASignatureZNoneZ_get_err(owner_conv);
9641 }
9642
9643 uint32_t CS_LDK_LDKCOption_usizeZ_ty_from_ptr(int64_t ptr) {
9644         LDKCOption_usizeZ *obj = (LDKCOption_usizeZ*)untag_ptr(ptr);
9645         switch(obj->tag) {
9646                 case LDKCOption_usizeZ_Some: return 0;
9647                 case LDKCOption_usizeZ_None: return 1;
9648                 default: abort();
9649         }
9650 }
9651 int64_t CS_LDK_LDKCOption_usizeZ_Some_get_some(int64_t ptr) {
9652         LDKCOption_usizeZ *obj = (LDKCOption_usizeZ*)untag_ptr(ptr);
9653         CHECK(obj->tag == LDKCOption_usizeZ_Some);
9654         int64_t some_conv = obj->some;
9655         return some_conv;
9656 }
9657 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
9658         LDKShutdownScript ret = *owner->contents.result;
9659         ret.is_owned = false;
9660         return ret;
9661 }
9662 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_get_ok(int64_t owner) {
9663         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
9664         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
9665         int64_t ret_ref = 0;
9666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9668         return ret_ref;
9669 }
9670
9671 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
9672 CHECK(!owner->result_ok);
9673         return DecodeError_clone(&*owner->contents.err);
9674 }
9675 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_get_err(int64_t owner) {
9676         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
9677         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9678         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
9679         int64_t ret_ref = tag_ptr(ret_copy, true);
9680         return ret_ref;
9681 }
9682
9683 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
9684         LDKShutdownScript ret = *owner->contents.result;
9685         ret.is_owned = false;
9686         return ret;
9687 }
9688 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(int64_t owner) {
9689         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
9690         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
9691         int64_t ret_ref = 0;
9692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9694         return ret_ref;
9695 }
9696
9697 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
9698         LDKInvalidShutdownScript ret = *owner->contents.err;
9699         ret.is_owned = false;
9700         return ret;
9701 }
9702 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(int64_t owner) {
9703         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
9704         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
9705         int64_t ret_ref = 0;
9706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9708         return ret_ref;
9709 }
9710
9711 uint32_t CS_LDK_LDKPaymentPurpose_ty_from_ptr(int64_t ptr) {
9712         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
9713         switch(obj->tag) {
9714                 case LDKPaymentPurpose_InvoicePayment: return 0;
9715                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
9716                 default: abort();
9717         }
9718 }
9719 int64_t CS_LDK_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(int64_t ptr) {
9720         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
9721         CHECK(obj->tag == LDKPaymentPurpose_InvoicePayment);
9722         int64_t payment_preimage_ref = tag_ptr(&obj->invoice_payment.payment_preimage, false);
9723         return payment_preimage_ref;
9724 }
9725 int8_tArray CS_LDK_LDKPaymentPurpose_InvoicePayment_get_payment_secret(int64_t ptr) {
9726         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
9727         CHECK(obj->tag == LDKPaymentPurpose_InvoicePayment);
9728         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
9729         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
9730         return payment_secret_arr;
9731 }
9732 int8_tArray CS_LDK_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(int64_t ptr) {
9733         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
9734         CHECK(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
9735         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
9736         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
9737         return spontaneous_payment_arr;
9738 }
9739 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
9740 CHECK(owner->result_ok);
9741         return PaymentPurpose_clone(&*owner->contents.result);
9742 }
9743 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_get_ok(int64_t owner) {
9744         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
9745         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
9746         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
9747         int64_t ret_ref = tag_ptr(ret_copy, true);
9748         return ret_ref;
9749 }
9750
9751 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
9752 CHECK(!owner->result_ok);
9753         return DecodeError_clone(&*owner->contents.err);
9754 }
9755 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_get_err(int64_t owner) {
9756         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
9757         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9758         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
9759         int64_t ret_ref = tag_ptr(ret_copy, true);
9760         return ret_ref;
9761 }
9762
9763 static inline struct LDKClaimedHTLC CResult_ClaimedHTLCDecodeErrorZ_get_ok(LDKCResult_ClaimedHTLCDecodeErrorZ *NONNULL_PTR owner){
9764         LDKClaimedHTLC ret = *owner->contents.result;
9765         ret.is_owned = false;
9766         return ret;
9767 }
9768 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_get_ok(int64_t owner) {
9769         LDKCResult_ClaimedHTLCDecodeErrorZ* owner_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(owner);
9770         LDKClaimedHTLC ret_var = CResult_ClaimedHTLCDecodeErrorZ_get_ok(owner_conv);
9771         int64_t ret_ref = 0;
9772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9774         return ret_ref;
9775 }
9776
9777 static inline struct LDKDecodeError CResult_ClaimedHTLCDecodeErrorZ_get_err(LDKCResult_ClaimedHTLCDecodeErrorZ *NONNULL_PTR owner){
9778 CHECK(!owner->result_ok);
9779         return DecodeError_clone(&*owner->contents.err);
9780 }
9781 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_get_err(int64_t owner) {
9782         LDKCResult_ClaimedHTLCDecodeErrorZ* owner_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(owner);
9783         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9784         *ret_copy = CResult_ClaimedHTLCDecodeErrorZ_get_err(owner_conv);
9785         int64_t ret_ref = tag_ptr(ret_copy, true);
9786         return ret_ref;
9787 }
9788
9789 uint32_t CS_LDK_LDKPathFailure_ty_from_ptr(int64_t ptr) {
9790         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
9791         switch(obj->tag) {
9792                 case LDKPathFailure_InitialSend: return 0;
9793                 case LDKPathFailure_OnPath: return 1;
9794                 default: abort();
9795         }
9796 }
9797 int64_t CS_LDK_LDKPathFailure_InitialSend_get_err(int64_t ptr) {
9798         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
9799         CHECK(obj->tag == LDKPathFailure_InitialSend);
9800         int64_t err_ref = tag_ptr(&obj->initial_send.err, false);
9801         return err_ref;
9802 }
9803 int64_t CS_LDK_LDKPathFailure_OnPath_get_network_update(int64_t ptr) {
9804         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
9805         CHECK(obj->tag == LDKPathFailure_OnPath);
9806         int64_t network_update_ref = tag_ptr(&obj->on_path.network_update, false);
9807         return network_update_ref;
9808 }
9809 uint32_t CS_LDK_LDKCOption_PathFailureZ_ty_from_ptr(int64_t ptr) {
9810         LDKCOption_PathFailureZ *obj = (LDKCOption_PathFailureZ*)untag_ptr(ptr);
9811         switch(obj->tag) {
9812                 case LDKCOption_PathFailureZ_Some: return 0;
9813                 case LDKCOption_PathFailureZ_None: return 1;
9814                 default: abort();
9815         }
9816 }
9817 int64_t CS_LDK_LDKCOption_PathFailureZ_Some_get_some(int64_t ptr) {
9818         LDKCOption_PathFailureZ *obj = (LDKCOption_PathFailureZ*)untag_ptr(ptr);
9819         CHECK(obj->tag == LDKCOption_PathFailureZ_Some);
9820         int64_t some_ref = tag_ptr(&obj->some, false);
9821         return some_ref;
9822 }
9823 static inline struct LDKCOption_PathFailureZ CResult_COption_PathFailureZDecodeErrorZ_get_ok(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
9824 CHECK(owner->result_ok);
9825         return COption_PathFailureZ_clone(&*owner->contents.result);
9826 }
9827 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_get_ok(int64_t owner) {
9828         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
9829         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
9830         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_ok(owner_conv);
9831         int64_t ret_ref = tag_ptr(ret_copy, true);
9832         return ret_ref;
9833 }
9834
9835 static inline struct LDKDecodeError CResult_COption_PathFailureZDecodeErrorZ_get_err(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
9836 CHECK(!owner->result_ok);
9837         return DecodeError_clone(&*owner->contents.err);
9838 }
9839 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_get_err(int64_t owner) {
9840         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
9841         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9842         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_err(owner_conv);
9843         int64_t ret_ref = tag_ptr(ret_copy, true);
9844         return ret_ref;
9845 }
9846
9847 uint32_t CS_LDK_LDKClosureReason_ty_from_ptr(int64_t ptr) {
9848         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
9849         switch(obj->tag) {
9850                 case LDKClosureReason_CounterpartyForceClosed: return 0;
9851                 case LDKClosureReason_HolderForceClosed: return 1;
9852                 case LDKClosureReason_CooperativeClosure: return 2;
9853                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
9854                 case LDKClosureReason_FundingTimedOut: return 4;
9855                 case LDKClosureReason_ProcessingError: return 5;
9856                 case LDKClosureReason_DisconnectedPeer: return 6;
9857                 case LDKClosureReason_OutdatedChannelManager: return 7;
9858                 case LDKClosureReason_CounterpartyCoopClosedUnfundedChannel: return 8;
9859                 case LDKClosureReason_FundingBatchClosure: return 9;
9860                 default: abort();
9861         }
9862 }
9863 int64_t CS_LDK_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(int64_t ptr) {
9864         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
9865         CHECK(obj->tag == LDKClosureReason_CounterpartyForceClosed);
9866         LDKUntrustedString peer_msg_var = obj->counterparty_force_closed.peer_msg;
9867                         int64_t peer_msg_ref = 0;
9868                         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_var);
9869                         peer_msg_ref = tag_ptr(peer_msg_var.inner, false);
9870         return peer_msg_ref;
9871 }
9872 jstring CS_LDK_LDKClosureReason_ProcessingError_get_err(int64_t ptr) {
9873         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
9874         CHECK(obj->tag == LDKClosureReason_ProcessingError);
9875         LDKStr err_str = obj->processing_error.err;
9876                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
9877         return err_conv;
9878 }
9879 uint32_t CS_LDK_LDKCOption_ClosureReasonZ_ty_from_ptr(int64_t ptr) {
9880         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
9881         switch(obj->tag) {
9882                 case LDKCOption_ClosureReasonZ_Some: return 0;
9883                 case LDKCOption_ClosureReasonZ_None: return 1;
9884                 default: abort();
9885         }
9886 }
9887 int64_t CS_LDK_LDKCOption_ClosureReasonZ_Some_get_some(int64_t ptr) {
9888         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
9889         CHECK(obj->tag == LDKCOption_ClosureReasonZ_Some);
9890         int64_t some_ref = tag_ptr(&obj->some, false);
9891         return some_ref;
9892 }
9893 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
9894 CHECK(owner->result_ok);
9895         return COption_ClosureReasonZ_clone(&*owner->contents.result);
9896 }
9897 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(int64_t owner) {
9898         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
9899         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9900         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
9901         int64_t ret_ref = tag_ptr(ret_copy, true);
9902         return ret_ref;
9903 }
9904
9905 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
9906 CHECK(!owner->result_ok);
9907         return DecodeError_clone(&*owner->contents.err);
9908 }
9909 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(int64_t owner) {
9910         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
9911         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9912         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
9913         int64_t ret_ref = tag_ptr(ret_copy, true);
9914         return ret_ref;
9915 }
9916
9917 uint32_t CS_LDK_LDKHTLCDestination_ty_from_ptr(int64_t ptr) {
9918         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9919         switch(obj->tag) {
9920                 case LDKHTLCDestination_NextHopChannel: return 0;
9921                 case LDKHTLCDestination_UnknownNextHop: return 1;
9922                 case LDKHTLCDestination_InvalidForward: return 2;
9923                 case LDKHTLCDestination_FailedPayment: return 3;
9924                 default: abort();
9925         }
9926 }
9927 int8_tArray CS_LDK_LDKHTLCDestination_NextHopChannel_get_node_id(int64_t ptr) {
9928         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9929         CHECK(obj->tag == LDKHTLCDestination_NextHopChannel);
9930         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
9931         memcpy(node_id_arr->elems, obj->next_hop_channel.node_id.compressed_form, 33);
9932         return node_id_arr;
9933 }
9934 int8_tArray CS_LDK_LDKHTLCDestination_NextHopChannel_get_channel_id(int64_t ptr) {
9935         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9936         CHECK(obj->tag == LDKHTLCDestination_NextHopChannel);
9937         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
9938         memcpy(channel_id_arr->elems, obj->next_hop_channel.channel_id.data, 32);
9939         return channel_id_arr;
9940 }
9941 int64_t CS_LDK_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid(int64_t ptr) {
9942         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9943         CHECK(obj->tag == LDKHTLCDestination_UnknownNextHop);
9944         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
9945         return requested_forward_scid_conv;
9946 }
9947 int64_t CS_LDK_LDKHTLCDestination_InvalidForward_get_requested_forward_scid(int64_t ptr) {
9948         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9949         CHECK(obj->tag == LDKHTLCDestination_InvalidForward);
9950         int64_t requested_forward_scid_conv = obj->invalid_forward.requested_forward_scid;
9951         return requested_forward_scid_conv;
9952 }
9953 int8_tArray CS_LDK_LDKHTLCDestination_FailedPayment_get_payment_hash(int64_t ptr) {
9954         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9955         CHECK(obj->tag == LDKHTLCDestination_FailedPayment);
9956         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
9957         memcpy(payment_hash_arr->elems, obj->failed_payment.payment_hash.data, 32);
9958         return payment_hash_arr;
9959 }
9960 uint32_t CS_LDK_LDKCOption_HTLCDestinationZ_ty_from_ptr(int64_t ptr) {
9961         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
9962         switch(obj->tag) {
9963                 case LDKCOption_HTLCDestinationZ_Some: return 0;
9964                 case LDKCOption_HTLCDestinationZ_None: return 1;
9965                 default: abort();
9966         }
9967 }
9968 int64_t CS_LDK_LDKCOption_HTLCDestinationZ_Some_get_some(int64_t ptr) {
9969         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
9970         CHECK(obj->tag == LDKCOption_HTLCDestinationZ_Some);
9971         int64_t some_ref = tag_ptr(&obj->some, false);
9972         return some_ref;
9973 }
9974 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
9975 CHECK(owner->result_ok);
9976         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
9977 }
9978 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(int64_t owner) {
9979         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
9980         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
9981         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
9982         int64_t ret_ref = tag_ptr(ret_copy, true);
9983         return ret_ref;
9984 }
9985
9986 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
9987 CHECK(!owner->result_ok);
9988         return DecodeError_clone(&*owner->contents.err);
9989 }
9990 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(int64_t owner) {
9991         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
9992         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9993         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
9994         int64_t ret_ref = tag_ptr(ret_copy, true);
9995         return ret_ref;
9996 }
9997
9998 static inline enum LDKPaymentFailureReason CResult_PaymentFailureReasonDecodeErrorZ_get_ok(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR owner){
9999 CHECK(owner->result_ok);
10000         return PaymentFailureReason_clone(&*owner->contents.result);
10001 }
10002 int32_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_get_ok(int64_t owner) {
10003         LDKCResult_PaymentFailureReasonDecodeErrorZ* owner_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(owner);
10004         int32_t ret_conv = LDKPaymentFailureReason_to_cs(CResult_PaymentFailureReasonDecodeErrorZ_get_ok(owner_conv));
10005         return ret_conv;
10006 }
10007
10008 static inline struct LDKDecodeError CResult_PaymentFailureReasonDecodeErrorZ_get_err(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR owner){
10009 CHECK(!owner->result_ok);
10010         return DecodeError_clone(&*owner->contents.err);
10011 }
10012 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_get_err(int64_t owner) {
10013         LDKCResult_PaymentFailureReasonDecodeErrorZ* owner_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(owner);
10014         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10015         *ret_copy = CResult_PaymentFailureReasonDecodeErrorZ_get_err(owner_conv);
10016         int64_t ret_ref = tag_ptr(ret_copy, true);
10017         return ret_ref;
10018 }
10019
10020 uint32_t CS_LDK_LDKCOption_U128Z_ty_from_ptr(int64_t ptr) {
10021         LDKCOption_U128Z *obj = (LDKCOption_U128Z*)untag_ptr(ptr);
10022         switch(obj->tag) {
10023                 case LDKCOption_U128Z_Some: return 0;
10024                 case LDKCOption_U128Z_None: return 1;
10025                 default: abort();
10026         }
10027 }
10028 int8_tArray CS_LDK_LDKCOption_U128Z_Some_get_some(int64_t ptr) {
10029         LDKCOption_U128Z *obj = (LDKCOption_U128Z*)untag_ptr(ptr);
10030         CHECK(obj->tag == LDKCOption_U128Z_Some);
10031         int8_tArray some_arr = init_int8_tArray(16, __LINE__);
10032         memcpy(some_arr->elems, obj->some.le_bytes, 16);
10033         return some_arr;
10034 }
10035 static inline LDKCVec_ClaimedHTLCZ CVec_ClaimedHTLCZ_clone(const LDKCVec_ClaimedHTLCZ *orig) {
10036         LDKCVec_ClaimedHTLCZ ret = { .data = MALLOC(sizeof(LDKClaimedHTLC) * orig->datalen, "LDKCVec_ClaimedHTLCZ clone bytes"), .datalen = orig->datalen };
10037         for (size_t i = 0; i < ret.datalen; i++) {
10038                 ret.data[i] = ClaimedHTLC_clone(&orig->data[i]);
10039         }
10040         return ret;
10041 }
10042 uint32_t CS_LDK_LDKCOption_PaymentFailureReasonZ_ty_from_ptr(int64_t ptr) {
10043         LDKCOption_PaymentFailureReasonZ *obj = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(ptr);
10044         switch(obj->tag) {
10045                 case LDKCOption_PaymentFailureReasonZ_Some: return 0;
10046                 case LDKCOption_PaymentFailureReasonZ_None: return 1;
10047                 default: abort();
10048         }
10049 }
10050 int32_t CS_LDK_LDKCOption_PaymentFailureReasonZ_Some_get_some(int64_t ptr) {
10051         LDKCOption_PaymentFailureReasonZ *obj = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(ptr);
10052         CHECK(obj->tag == LDKCOption_PaymentFailureReasonZ_Some);
10053         int32_t some_conv = LDKPaymentFailureReason_to_cs(obj->some);
10054         return some_conv;
10055 }
10056 uint32_t CS_LDK_LDKBumpTransactionEvent_ty_from_ptr(int64_t ptr) {
10057         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10058         switch(obj->tag) {
10059                 case LDKBumpTransactionEvent_ChannelClose: return 0;
10060                 case LDKBumpTransactionEvent_HTLCResolution: return 1;
10061                 default: abort();
10062         }
10063 }
10064 int8_tArray CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_claim_id(int64_t ptr) {
10065         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10066         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10067         int8_tArray claim_id_arr = init_int8_tArray(32, __LINE__);
10068         memcpy(claim_id_arr->elems, obj->channel_close.claim_id.data, 32);
10069         return claim_id_arr;
10070 }
10071 int32_t CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_package_target_feerate_sat_per_1000_weight(int64_t ptr) {
10072         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10073         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10074         int32_t package_target_feerate_sat_per_1000_weight_conv = obj->channel_close.package_target_feerate_sat_per_1000_weight;
10075         return package_target_feerate_sat_per_1000_weight_conv;
10076 }
10077 int8_tArray CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_commitment_tx(int64_t ptr) {
10078         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10079         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10080         LDKTransaction commitment_tx_var = obj->channel_close.commitment_tx;
10081                         int8_tArray commitment_tx_arr = init_int8_tArray(commitment_tx_var.datalen, __LINE__);
10082                         memcpy(commitment_tx_arr->elems, commitment_tx_var.data, commitment_tx_var.datalen);
10083         return commitment_tx_arr;
10084 }
10085 int64_t CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_commitment_tx_fee_satoshis(int64_t ptr) {
10086         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10087         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10088         int64_t commitment_tx_fee_satoshis_conv = obj->channel_close.commitment_tx_fee_satoshis;
10089         return commitment_tx_fee_satoshis_conv;
10090 }
10091 int64_t CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_anchor_descriptor(int64_t ptr) {
10092         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10093         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10094         LDKAnchorDescriptor anchor_descriptor_var = obj->channel_close.anchor_descriptor;
10095                         int64_t anchor_descriptor_ref = 0;
10096                         CHECK_INNER_FIELD_ACCESS_OR_NULL(anchor_descriptor_var);
10097                         anchor_descriptor_ref = tag_ptr(anchor_descriptor_var.inner, false);
10098         return anchor_descriptor_ref;
10099 }
10100 int64_tArray CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_pending_htlcs(int64_t ptr) {
10101         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10102         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10103         LDKCVec_HTLCOutputInCommitmentZ pending_htlcs_var = obj->channel_close.pending_htlcs;
10104                         int64_tArray pending_htlcs_arr = NULL;
10105                         pending_htlcs_arr = init_int64_tArray(pending_htlcs_var.datalen, __LINE__);
10106                         int64_t *pending_htlcs_arr_ptr = (int64_t*)(((uint8_t*)pending_htlcs_arr) + 8);
10107                         for (size_t y = 0; y < pending_htlcs_var.datalen; y++) {
10108                                 LDKHTLCOutputInCommitment pending_htlcs_conv_24_var = pending_htlcs_var.data[y];
10109                                 int64_t pending_htlcs_conv_24_ref = 0;
10110                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(pending_htlcs_conv_24_var);
10111                                 pending_htlcs_conv_24_ref = tag_ptr(pending_htlcs_conv_24_var.inner, false);
10112                                 pending_htlcs_arr_ptr[y] = pending_htlcs_conv_24_ref;
10113                         }
10114                         
10115         return pending_htlcs_arr;
10116 }
10117 int8_tArray CS_LDK_LDKBumpTransactionEvent_HTLCResolution_get_claim_id(int64_t ptr) {
10118         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10119         CHECK(obj->tag == LDKBumpTransactionEvent_HTLCResolution);
10120         int8_tArray claim_id_arr = init_int8_tArray(32, __LINE__);
10121         memcpy(claim_id_arr->elems, obj->htlc_resolution.claim_id.data, 32);
10122         return claim_id_arr;
10123 }
10124 int32_t CS_LDK_LDKBumpTransactionEvent_HTLCResolution_get_target_feerate_sat_per_1000_weight(int64_t ptr) {
10125         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10126         CHECK(obj->tag == LDKBumpTransactionEvent_HTLCResolution);
10127         int32_t target_feerate_sat_per_1000_weight_conv = obj->htlc_resolution.target_feerate_sat_per_1000_weight;
10128         return target_feerate_sat_per_1000_weight_conv;
10129 }
10130 int64_tArray CS_LDK_LDKBumpTransactionEvent_HTLCResolution_get_htlc_descriptors(int64_t ptr) {
10131         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10132         CHECK(obj->tag == LDKBumpTransactionEvent_HTLCResolution);
10133         LDKCVec_HTLCDescriptorZ htlc_descriptors_var = obj->htlc_resolution.htlc_descriptors;
10134                         int64_tArray htlc_descriptors_arr = NULL;
10135                         htlc_descriptors_arr = init_int64_tArray(htlc_descriptors_var.datalen, __LINE__);
10136                         int64_t *htlc_descriptors_arr_ptr = (int64_t*)(((uint8_t*)htlc_descriptors_arr) + 8);
10137                         for (size_t q = 0; q < htlc_descriptors_var.datalen; q++) {
10138                                 LDKHTLCDescriptor htlc_descriptors_conv_16_var = htlc_descriptors_var.data[q];
10139                                 int64_t htlc_descriptors_conv_16_ref = 0;
10140                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_descriptors_conv_16_var);
10141                                 htlc_descriptors_conv_16_ref = tag_ptr(htlc_descriptors_conv_16_var.inner, false);
10142                                 htlc_descriptors_arr_ptr[q] = htlc_descriptors_conv_16_ref;
10143                         }
10144                         
10145         return htlc_descriptors_arr;
10146 }
10147 int32_t CS_LDK_LDKBumpTransactionEvent_HTLCResolution_get_tx_lock_time(int64_t ptr) {
10148         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10149         CHECK(obj->tag == LDKBumpTransactionEvent_HTLCResolution);
10150         int32_t tx_lock_time_conv = obj->htlc_resolution.tx_lock_time;
10151         return tx_lock_time_conv;
10152 }
10153 uint32_t CS_LDK_LDKEvent_ty_from_ptr(int64_t ptr) {
10154         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10155         switch(obj->tag) {
10156                 case LDKEvent_FundingGenerationReady: return 0;
10157                 case LDKEvent_PaymentClaimable: return 1;
10158                 case LDKEvent_PaymentClaimed: return 2;
10159                 case LDKEvent_InvoiceRequestFailed: return 3;
10160                 case LDKEvent_PaymentSent: return 4;
10161                 case LDKEvent_PaymentFailed: return 5;
10162                 case LDKEvent_PaymentPathSuccessful: return 6;
10163                 case LDKEvent_PaymentPathFailed: return 7;
10164                 case LDKEvent_ProbeSuccessful: return 8;
10165                 case LDKEvent_ProbeFailed: return 9;
10166                 case LDKEvent_PendingHTLCsForwardable: return 10;
10167                 case LDKEvent_HTLCIntercepted: return 11;
10168                 case LDKEvent_SpendableOutputs: return 12;
10169                 case LDKEvent_PaymentForwarded: return 13;
10170                 case LDKEvent_ChannelPending: return 14;
10171                 case LDKEvent_ChannelReady: return 15;
10172                 case LDKEvent_ChannelClosed: return 16;
10173                 case LDKEvent_DiscardFunding: return 17;
10174                 case LDKEvent_OpenChannelRequest: return 18;
10175                 case LDKEvent_HTLCHandlingFailed: return 19;
10176                 case LDKEvent_BumpTransaction: return 20;
10177                 default: abort();
10178         }
10179 }
10180 int8_tArray CS_LDK_LDKEvent_FundingGenerationReady_get_temporary_channel_id(int64_t ptr) {
10181         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10182         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10183         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
10184         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
10185         return temporary_channel_id_arr;
10186 }
10187 int8_tArray CS_LDK_LDKEvent_FundingGenerationReady_get_counterparty_node_id(int64_t ptr) {
10188         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10189         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10190         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10191         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
10192         return counterparty_node_id_arr;
10193 }
10194 int64_t CS_LDK_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(int64_t ptr) {
10195         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10196         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10197         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
10198         return channel_value_satoshis_conv;
10199 }
10200 int8_tArray CS_LDK_LDKEvent_FundingGenerationReady_get_output_script(int64_t ptr) {
10201         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10202         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10203         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
10204                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
10205                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
10206         return output_script_arr;
10207 }
10208 int8_tArray CS_LDK_LDKEvent_FundingGenerationReady_get_user_channel_id(int64_t ptr) {
10209         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10210         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10211         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
10212         memcpy(user_channel_id_arr->elems, obj->funding_generation_ready.user_channel_id.le_bytes, 16);
10213         return user_channel_id_arr;
10214 }
10215 int8_tArray CS_LDK_LDKEvent_PaymentClaimable_get_receiver_node_id(int64_t ptr) {
10216         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10217         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10218         int8_tArray receiver_node_id_arr = init_int8_tArray(33, __LINE__);
10219         memcpy(receiver_node_id_arr->elems, obj->payment_claimable.receiver_node_id.compressed_form, 33);
10220         return receiver_node_id_arr;
10221 }
10222 int8_tArray CS_LDK_LDKEvent_PaymentClaimable_get_payment_hash(int64_t ptr) {
10223         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10224         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10225         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10226         memcpy(payment_hash_arr->elems, obj->payment_claimable.payment_hash.data, 32);
10227         return payment_hash_arr;
10228 }
10229 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_onion_fields(int64_t ptr) {
10230         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10231         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10232         LDKRecipientOnionFields onion_fields_var = obj->payment_claimable.onion_fields;
10233                         int64_t onion_fields_ref = 0;
10234                         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_var);
10235                         onion_fields_ref = tag_ptr(onion_fields_var.inner, false);
10236         return onion_fields_ref;
10237 }
10238 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_amount_msat(int64_t ptr) {
10239         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10240         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10241         int64_t amount_msat_conv = obj->payment_claimable.amount_msat;
10242         return amount_msat_conv;
10243 }
10244 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_counterparty_skimmed_fee_msat(int64_t ptr) {
10245         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10246         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10247         int64_t counterparty_skimmed_fee_msat_conv = obj->payment_claimable.counterparty_skimmed_fee_msat;
10248         return counterparty_skimmed_fee_msat_conv;
10249 }
10250 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_purpose(int64_t ptr) {
10251         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10252         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10253         int64_t purpose_ref = tag_ptr(&obj->payment_claimable.purpose, false);
10254         return purpose_ref;
10255 }
10256 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_via_channel_id(int64_t ptr) {
10257         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10258         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10259         int64_t via_channel_id_ref = tag_ptr(&obj->payment_claimable.via_channel_id, false);
10260         return via_channel_id_ref;
10261 }
10262 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_via_user_channel_id(int64_t ptr) {
10263         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10264         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10265         int64_t via_user_channel_id_ref = tag_ptr(&obj->payment_claimable.via_user_channel_id, false);
10266         return via_user_channel_id_ref;
10267 }
10268 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_claim_deadline(int64_t ptr) {
10269         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10270         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10271         int64_t claim_deadline_ref = tag_ptr(&obj->payment_claimable.claim_deadline, false);
10272         return claim_deadline_ref;
10273 }
10274 int8_tArray CS_LDK_LDKEvent_PaymentClaimed_get_receiver_node_id(int64_t ptr) {
10275         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10276         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10277         int8_tArray receiver_node_id_arr = init_int8_tArray(33, __LINE__);
10278         memcpy(receiver_node_id_arr->elems, obj->payment_claimed.receiver_node_id.compressed_form, 33);
10279         return receiver_node_id_arr;
10280 }
10281 int8_tArray CS_LDK_LDKEvent_PaymentClaimed_get_payment_hash(int64_t ptr) {
10282         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10283         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10284         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10285         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
10286         return payment_hash_arr;
10287 }
10288 int64_t CS_LDK_LDKEvent_PaymentClaimed_get_amount_msat(int64_t ptr) {
10289         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10290         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10291         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
10292         return amount_msat_conv;
10293 }
10294 int64_t CS_LDK_LDKEvent_PaymentClaimed_get_purpose(int64_t ptr) {
10295         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10296         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10297         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
10298         return purpose_ref;
10299 }
10300 int64_tArray CS_LDK_LDKEvent_PaymentClaimed_get_htlcs(int64_t ptr) {
10301         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10302         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10303         LDKCVec_ClaimedHTLCZ htlcs_var = obj->payment_claimed.htlcs;
10304                         int64_tArray htlcs_arr = NULL;
10305                         htlcs_arr = init_int64_tArray(htlcs_var.datalen, __LINE__);
10306                         int64_t *htlcs_arr_ptr = (int64_t*)(((uint8_t*)htlcs_arr) + 8);
10307                         for (size_t n = 0; n < htlcs_var.datalen; n++) {
10308                                 LDKClaimedHTLC htlcs_conv_13_var = htlcs_var.data[n];
10309                                 int64_t htlcs_conv_13_ref = 0;
10310                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(htlcs_conv_13_var);
10311                                 htlcs_conv_13_ref = tag_ptr(htlcs_conv_13_var.inner, false);
10312                                 htlcs_arr_ptr[n] = htlcs_conv_13_ref;
10313                         }
10314                         
10315         return htlcs_arr;
10316 }
10317 int64_t CS_LDK_LDKEvent_PaymentClaimed_get_sender_intended_total_msat(int64_t ptr) {
10318         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10319         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10320         int64_t sender_intended_total_msat_ref = tag_ptr(&obj->payment_claimed.sender_intended_total_msat, false);
10321         return sender_intended_total_msat_ref;
10322 }
10323 int8_tArray CS_LDK_LDKEvent_InvoiceRequestFailed_get_payment_id(int64_t ptr) {
10324         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10325         CHECK(obj->tag == LDKEvent_InvoiceRequestFailed);
10326         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10327         memcpy(payment_id_arr->elems, obj->invoice_request_failed.payment_id.data, 32);
10328         return payment_id_arr;
10329 }
10330 int64_t CS_LDK_LDKEvent_PaymentSent_get_payment_id(int64_t ptr) {
10331         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10332         CHECK(obj->tag == LDKEvent_PaymentSent);
10333         int64_t payment_id_ref = tag_ptr(&obj->payment_sent.payment_id, false);
10334         return payment_id_ref;
10335 }
10336 int8_tArray CS_LDK_LDKEvent_PaymentSent_get_payment_preimage(int64_t ptr) {
10337         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10338         CHECK(obj->tag == LDKEvent_PaymentSent);
10339         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10340         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
10341         return payment_preimage_arr;
10342 }
10343 int8_tArray CS_LDK_LDKEvent_PaymentSent_get_payment_hash(int64_t ptr) {
10344         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10345         CHECK(obj->tag == LDKEvent_PaymentSent);
10346         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10347         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
10348         return payment_hash_arr;
10349 }
10350 int64_t CS_LDK_LDKEvent_PaymentSent_get_fee_paid_msat(int64_t ptr) {
10351         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10352         CHECK(obj->tag == LDKEvent_PaymentSent);
10353         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
10354         return fee_paid_msat_ref;
10355 }
10356 int8_tArray CS_LDK_LDKEvent_PaymentFailed_get_payment_id(int64_t ptr) {
10357         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10358         CHECK(obj->tag == LDKEvent_PaymentFailed);
10359         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10360         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
10361         return payment_id_arr;
10362 }
10363 int8_tArray CS_LDK_LDKEvent_PaymentFailed_get_payment_hash(int64_t ptr) {
10364         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10365         CHECK(obj->tag == LDKEvent_PaymentFailed);
10366         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10367         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
10368         return payment_hash_arr;
10369 }
10370 int64_t CS_LDK_LDKEvent_PaymentFailed_get_reason(int64_t ptr) {
10371         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10372         CHECK(obj->tag == LDKEvent_PaymentFailed);
10373         int64_t reason_ref = tag_ptr(&obj->payment_failed.reason, false);
10374         return reason_ref;
10375 }
10376 int8_tArray CS_LDK_LDKEvent_PaymentPathSuccessful_get_payment_id(int64_t ptr) {
10377         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10378         CHECK(obj->tag == LDKEvent_PaymentPathSuccessful);
10379         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10380         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
10381         return payment_id_arr;
10382 }
10383 int64_t CS_LDK_LDKEvent_PaymentPathSuccessful_get_payment_hash(int64_t ptr) {
10384         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10385         CHECK(obj->tag == LDKEvent_PaymentPathSuccessful);
10386         int64_t payment_hash_ref = tag_ptr(&obj->payment_path_successful.payment_hash, false);
10387         return payment_hash_ref;
10388 }
10389 int64_t CS_LDK_LDKEvent_PaymentPathSuccessful_get_path(int64_t ptr) {
10390         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10391         CHECK(obj->tag == LDKEvent_PaymentPathSuccessful);
10392         LDKPath path_var = obj->payment_path_successful.path;
10393                         int64_t path_ref = 0;
10394                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
10395                         path_ref = tag_ptr(path_var.inner, false);
10396         return path_ref;
10397 }
10398 int64_t CS_LDK_LDKEvent_PaymentPathFailed_get_payment_id(int64_t ptr) {
10399         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10400         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10401         int64_t payment_id_ref = tag_ptr(&obj->payment_path_failed.payment_id, false);
10402         return payment_id_ref;
10403 }
10404 int8_tArray CS_LDK_LDKEvent_PaymentPathFailed_get_payment_hash(int64_t ptr) {
10405         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10406         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10407         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10408         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
10409         return payment_hash_arr;
10410 }
10411 jboolean CS_LDK_LDKEvent_PaymentPathFailed_get_payment_failed_permanently(int64_t ptr) {
10412         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10413         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10414         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
10415         return payment_failed_permanently_conv;
10416 }
10417 int64_t CS_LDK_LDKEvent_PaymentPathFailed_get_failure(int64_t ptr) {
10418         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10419         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10420         int64_t failure_ref = tag_ptr(&obj->payment_path_failed.failure, false);
10421         return failure_ref;
10422 }
10423 int64_t CS_LDK_LDKEvent_PaymentPathFailed_get_path(int64_t ptr) {
10424         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10425         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10426         LDKPath path_var = obj->payment_path_failed.path;
10427                         int64_t path_ref = 0;
10428                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
10429                         path_ref = tag_ptr(path_var.inner, false);
10430         return path_ref;
10431 }
10432 int64_t CS_LDK_LDKEvent_PaymentPathFailed_get_short_channel_id(int64_t ptr) {
10433         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10434         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10435         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
10436         return short_channel_id_ref;
10437 }
10438 int8_tArray CS_LDK_LDKEvent_ProbeSuccessful_get_payment_id(int64_t ptr) {
10439         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10440         CHECK(obj->tag == LDKEvent_ProbeSuccessful);
10441         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10442         memcpy(payment_id_arr->elems, obj->probe_successful.payment_id.data, 32);
10443         return payment_id_arr;
10444 }
10445 int8_tArray CS_LDK_LDKEvent_ProbeSuccessful_get_payment_hash(int64_t ptr) {
10446         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10447         CHECK(obj->tag == LDKEvent_ProbeSuccessful);
10448         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10449         memcpy(payment_hash_arr->elems, obj->probe_successful.payment_hash.data, 32);
10450         return payment_hash_arr;
10451 }
10452 int64_t CS_LDK_LDKEvent_ProbeSuccessful_get_path(int64_t ptr) {
10453         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10454         CHECK(obj->tag == LDKEvent_ProbeSuccessful);
10455         LDKPath path_var = obj->probe_successful.path;
10456                         int64_t path_ref = 0;
10457                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
10458                         path_ref = tag_ptr(path_var.inner, false);
10459         return path_ref;
10460 }
10461 int8_tArray CS_LDK_LDKEvent_ProbeFailed_get_payment_id(int64_t ptr) {
10462         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10463         CHECK(obj->tag == LDKEvent_ProbeFailed);
10464         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10465         memcpy(payment_id_arr->elems, obj->probe_failed.payment_id.data, 32);
10466         return payment_id_arr;
10467 }
10468 int8_tArray CS_LDK_LDKEvent_ProbeFailed_get_payment_hash(int64_t ptr) {
10469         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10470         CHECK(obj->tag == LDKEvent_ProbeFailed);
10471         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10472         memcpy(payment_hash_arr->elems, obj->probe_failed.payment_hash.data, 32);
10473         return payment_hash_arr;
10474 }
10475 int64_t CS_LDK_LDKEvent_ProbeFailed_get_path(int64_t ptr) {
10476         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10477         CHECK(obj->tag == LDKEvent_ProbeFailed);
10478         LDKPath path_var = obj->probe_failed.path;
10479                         int64_t path_ref = 0;
10480                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
10481                         path_ref = tag_ptr(path_var.inner, false);
10482         return path_ref;
10483 }
10484 int64_t CS_LDK_LDKEvent_ProbeFailed_get_short_channel_id(int64_t ptr) {
10485         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10486         CHECK(obj->tag == LDKEvent_ProbeFailed);
10487         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
10488         return short_channel_id_ref;
10489 }
10490 int64_t CS_LDK_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(int64_t ptr) {
10491         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10492         CHECK(obj->tag == LDKEvent_PendingHTLCsForwardable);
10493         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
10494         return time_forwardable_conv;
10495 }
10496 int8_tArray CS_LDK_LDKEvent_HTLCIntercepted_get_intercept_id(int64_t ptr) {
10497         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10498         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10499         int8_tArray intercept_id_arr = init_int8_tArray(32, __LINE__);
10500         memcpy(intercept_id_arr->elems, obj->htlc_intercepted.intercept_id.data, 32);
10501         return intercept_id_arr;
10502 }
10503 int64_t CS_LDK_LDKEvent_HTLCIntercepted_get_requested_next_hop_scid(int64_t ptr) {
10504         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10505         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10506         int64_t requested_next_hop_scid_conv = obj->htlc_intercepted.requested_next_hop_scid;
10507         return requested_next_hop_scid_conv;
10508 }
10509 int8_tArray CS_LDK_LDKEvent_HTLCIntercepted_get_payment_hash(int64_t ptr) {
10510         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10511         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10512         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10513         memcpy(payment_hash_arr->elems, obj->htlc_intercepted.payment_hash.data, 32);
10514         return payment_hash_arr;
10515 }
10516 int64_t CS_LDK_LDKEvent_HTLCIntercepted_get_inbound_amount_msat(int64_t ptr) {
10517         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10518         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10519         int64_t inbound_amount_msat_conv = obj->htlc_intercepted.inbound_amount_msat;
10520         return inbound_amount_msat_conv;
10521 }
10522 int64_t CS_LDK_LDKEvent_HTLCIntercepted_get_expected_outbound_amount_msat(int64_t ptr) {
10523         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10524         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10525         int64_t expected_outbound_amount_msat_conv = obj->htlc_intercepted.expected_outbound_amount_msat;
10526         return expected_outbound_amount_msat_conv;
10527 }
10528 int64_tArray CS_LDK_LDKEvent_SpendableOutputs_get_outputs(int64_t ptr) {
10529         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10530         CHECK(obj->tag == LDKEvent_SpendableOutputs);
10531         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
10532                         int64_tArray outputs_arr = NULL;
10533                         outputs_arr = init_int64_tArray(outputs_var.datalen, __LINE__);
10534                         int64_t *outputs_arr_ptr = (int64_t*)(((uint8_t*)outputs_arr) + 8);
10535                         for (size_t b = 0; b < outputs_var.datalen; b++) {
10536                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
10537                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
10538                         }
10539                         
10540         return outputs_arr;
10541 }
10542 int64_t CS_LDK_LDKEvent_SpendableOutputs_get_channel_id(int64_t ptr) {
10543         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10544         CHECK(obj->tag == LDKEvent_SpendableOutputs);
10545         int64_t channel_id_ref = tag_ptr(&obj->spendable_outputs.channel_id, false);
10546         return channel_id_ref;
10547 }
10548 int64_t CS_LDK_LDKEvent_PaymentForwarded_get_prev_channel_id(int64_t ptr) {
10549         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10550         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10551         int64_t prev_channel_id_ref = tag_ptr(&obj->payment_forwarded.prev_channel_id, false);
10552         return prev_channel_id_ref;
10553 }
10554 int64_t CS_LDK_LDKEvent_PaymentForwarded_get_next_channel_id(int64_t ptr) {
10555         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10556         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10557         int64_t next_channel_id_ref = tag_ptr(&obj->payment_forwarded.next_channel_id, false);
10558         return next_channel_id_ref;
10559 }
10560 int64_t CS_LDK_LDKEvent_PaymentForwarded_get_fee_earned_msat(int64_t ptr) {
10561         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10562         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10563         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
10564         return fee_earned_msat_ref;
10565 }
10566 jboolean CS_LDK_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(int64_t ptr) {
10567         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10568         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10569         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
10570         return claim_from_onchain_tx_conv;
10571 }
10572 int64_t CS_LDK_LDKEvent_PaymentForwarded_get_outbound_amount_forwarded_msat(int64_t ptr) {
10573         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10574         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10575         int64_t outbound_amount_forwarded_msat_ref = tag_ptr(&obj->payment_forwarded.outbound_amount_forwarded_msat, false);
10576         return outbound_amount_forwarded_msat_ref;
10577 }
10578 int8_tArray CS_LDK_LDKEvent_ChannelPending_get_channel_id(int64_t ptr) {
10579         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10580         CHECK(obj->tag == LDKEvent_ChannelPending);
10581         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
10582         memcpy(channel_id_arr->elems, obj->channel_pending.channel_id.data, 32);
10583         return channel_id_arr;
10584 }
10585 int8_tArray CS_LDK_LDKEvent_ChannelPending_get_user_channel_id(int64_t ptr) {
10586         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10587         CHECK(obj->tag == LDKEvent_ChannelPending);
10588         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
10589         memcpy(user_channel_id_arr->elems, obj->channel_pending.user_channel_id.le_bytes, 16);
10590         return user_channel_id_arr;
10591 }
10592 int64_t CS_LDK_LDKEvent_ChannelPending_get_former_temporary_channel_id(int64_t ptr) {
10593         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10594         CHECK(obj->tag == LDKEvent_ChannelPending);
10595         int64_t former_temporary_channel_id_ref = tag_ptr(&obj->channel_pending.former_temporary_channel_id, false);
10596         return former_temporary_channel_id_ref;
10597 }
10598 int8_tArray CS_LDK_LDKEvent_ChannelPending_get_counterparty_node_id(int64_t ptr) {
10599         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10600         CHECK(obj->tag == LDKEvent_ChannelPending);
10601         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10602         memcpy(counterparty_node_id_arr->elems, obj->channel_pending.counterparty_node_id.compressed_form, 33);
10603         return counterparty_node_id_arr;
10604 }
10605 int64_t CS_LDK_LDKEvent_ChannelPending_get_funding_txo(int64_t ptr) {
10606         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10607         CHECK(obj->tag == LDKEvent_ChannelPending);
10608         LDKOutPoint funding_txo_var = obj->channel_pending.funding_txo;
10609                         int64_t funding_txo_ref = 0;
10610                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
10611                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
10612         return funding_txo_ref;
10613 }
10614 int8_tArray CS_LDK_LDKEvent_ChannelReady_get_channel_id(int64_t ptr) {
10615         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10616         CHECK(obj->tag == LDKEvent_ChannelReady);
10617         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
10618         memcpy(channel_id_arr->elems, obj->channel_ready.channel_id.data, 32);
10619         return channel_id_arr;
10620 }
10621 int8_tArray CS_LDK_LDKEvent_ChannelReady_get_user_channel_id(int64_t ptr) {
10622         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10623         CHECK(obj->tag == LDKEvent_ChannelReady);
10624         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
10625         memcpy(user_channel_id_arr->elems, obj->channel_ready.user_channel_id.le_bytes, 16);
10626         return user_channel_id_arr;
10627 }
10628 int8_tArray CS_LDK_LDKEvent_ChannelReady_get_counterparty_node_id(int64_t ptr) {
10629         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10630         CHECK(obj->tag == LDKEvent_ChannelReady);
10631         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10632         memcpy(counterparty_node_id_arr->elems, obj->channel_ready.counterparty_node_id.compressed_form, 33);
10633         return counterparty_node_id_arr;
10634 }
10635 int64_t CS_LDK_LDKEvent_ChannelReady_get_channel_type(int64_t ptr) {
10636         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10637         CHECK(obj->tag == LDKEvent_ChannelReady);
10638         LDKChannelTypeFeatures channel_type_var = obj->channel_ready.channel_type;
10639                         int64_t channel_type_ref = 0;
10640                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
10641                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
10642         return channel_type_ref;
10643 }
10644 int8_tArray CS_LDK_LDKEvent_ChannelClosed_get_channel_id(int64_t ptr) {
10645         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10646         CHECK(obj->tag == LDKEvent_ChannelClosed);
10647         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
10648         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
10649         return channel_id_arr;
10650 }
10651 int8_tArray CS_LDK_LDKEvent_ChannelClosed_get_user_channel_id(int64_t ptr) {
10652         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10653         CHECK(obj->tag == LDKEvent_ChannelClosed);
10654         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
10655         memcpy(user_channel_id_arr->elems, obj->channel_closed.user_channel_id.le_bytes, 16);
10656         return user_channel_id_arr;
10657 }
10658 int64_t CS_LDK_LDKEvent_ChannelClosed_get_reason(int64_t ptr) {
10659         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10660         CHECK(obj->tag == LDKEvent_ChannelClosed);
10661         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
10662         return reason_ref;
10663 }
10664 int8_tArray CS_LDK_LDKEvent_ChannelClosed_get_counterparty_node_id(int64_t ptr) {
10665         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10666         CHECK(obj->tag == LDKEvent_ChannelClosed);
10667         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10668         memcpy(counterparty_node_id_arr->elems, obj->channel_closed.counterparty_node_id.compressed_form, 33);
10669         return counterparty_node_id_arr;
10670 }
10671 int64_t CS_LDK_LDKEvent_ChannelClosed_get_channel_capacity_sats(int64_t ptr) {
10672         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10673         CHECK(obj->tag == LDKEvent_ChannelClosed);
10674         int64_t channel_capacity_sats_ref = tag_ptr(&obj->channel_closed.channel_capacity_sats, false);
10675         return channel_capacity_sats_ref;
10676 }
10677 int8_tArray CS_LDK_LDKEvent_DiscardFunding_get_channel_id(int64_t ptr) {
10678         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10679         CHECK(obj->tag == LDKEvent_DiscardFunding);
10680         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
10681         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
10682         return channel_id_arr;
10683 }
10684 int8_tArray CS_LDK_LDKEvent_DiscardFunding_get_transaction(int64_t ptr) {
10685         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10686         CHECK(obj->tag == LDKEvent_DiscardFunding);
10687         LDKTransaction transaction_var = obj->discard_funding.transaction;
10688                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
10689                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
10690         return transaction_arr;
10691 }
10692 int8_tArray CS_LDK_LDKEvent_OpenChannelRequest_get_temporary_channel_id(int64_t ptr) {
10693         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10694         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10695         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
10696         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
10697         return temporary_channel_id_arr;
10698 }
10699 int8_tArray CS_LDK_LDKEvent_OpenChannelRequest_get_counterparty_node_id(int64_t ptr) {
10700         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10701         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10702         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10703         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
10704         return counterparty_node_id_arr;
10705 }
10706 int64_t CS_LDK_LDKEvent_OpenChannelRequest_get_funding_satoshis(int64_t ptr) {
10707         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10708         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10709         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
10710         return funding_satoshis_conv;
10711 }
10712 int64_t CS_LDK_LDKEvent_OpenChannelRequest_get_push_msat(int64_t ptr) {
10713         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10714         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10715         int64_t push_msat_conv = obj->open_channel_request.push_msat;
10716         return push_msat_conv;
10717 }
10718 int64_t CS_LDK_LDKEvent_OpenChannelRequest_get_channel_type(int64_t ptr) {
10719         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10720         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10721         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
10722                         int64_t channel_type_ref = 0;
10723                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
10724                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
10725         return channel_type_ref;
10726 }
10727 int8_tArray CS_LDK_LDKEvent_HTLCHandlingFailed_get_prev_channel_id(int64_t ptr) {
10728         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10729         CHECK(obj->tag == LDKEvent_HTLCHandlingFailed);
10730         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
10731         memcpy(prev_channel_id_arr->elems, obj->htlc_handling_failed.prev_channel_id.data, 32);
10732         return prev_channel_id_arr;
10733 }
10734 int64_t CS_LDK_LDKEvent_HTLCHandlingFailed_get_failed_next_destination(int64_t ptr) {
10735         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10736         CHECK(obj->tag == LDKEvent_HTLCHandlingFailed);
10737         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
10738         return failed_next_destination_ref;
10739 }
10740 int64_t CS_LDK_LDKEvent_BumpTransaction_get_bump_transaction(int64_t ptr) {
10741         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10742         CHECK(obj->tag == LDKEvent_BumpTransaction);
10743         int64_t bump_transaction_ref = tag_ptr(&obj->bump_transaction, false);
10744         return bump_transaction_ref;
10745 }
10746 uint32_t CS_LDK_LDKCOption_EventZ_ty_from_ptr(int64_t ptr) {
10747         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
10748         switch(obj->tag) {
10749                 case LDKCOption_EventZ_Some: return 0;
10750                 case LDKCOption_EventZ_None: return 1;
10751                 default: abort();
10752         }
10753 }
10754 int64_t CS_LDK_LDKCOption_EventZ_Some_get_some(int64_t ptr) {
10755         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
10756         CHECK(obj->tag == LDKCOption_EventZ_Some);
10757         int64_t some_ref = tag_ptr(&obj->some, false);
10758         return some_ref;
10759 }
10760 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
10761 CHECK(owner->result_ok);
10762         return COption_EventZ_clone(&*owner->contents.result);
10763 }
10764 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_get_ok(int64_t owner) {
10765         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
10766         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
10767         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
10768         int64_t ret_ref = tag_ptr(ret_copy, true);
10769         return ret_ref;
10770 }
10771
10772 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
10773 CHECK(!owner->result_ok);
10774         return DecodeError_clone(&*owner->contents.err);
10775 }
10776 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_get_err(int64_t owner) {
10777         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
10778         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10779         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
10780         int64_t ret_ref = tag_ptr(ret_copy, true);
10781         return ret_ref;
10782 }
10783
10784 uint32_t CS_LDK_LDKBolt11ParseError_ty_from_ptr(int64_t ptr) {
10785         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10786         switch(obj->tag) {
10787                 case LDKBolt11ParseError_Bech32Error: return 0;
10788                 case LDKBolt11ParseError_ParseAmountError: return 1;
10789                 case LDKBolt11ParseError_MalformedSignature: return 2;
10790                 case LDKBolt11ParseError_BadPrefix: return 3;
10791                 case LDKBolt11ParseError_UnknownCurrency: return 4;
10792                 case LDKBolt11ParseError_UnknownSiPrefix: return 5;
10793                 case LDKBolt11ParseError_MalformedHRP: return 6;
10794                 case LDKBolt11ParseError_TooShortDataPart: return 7;
10795                 case LDKBolt11ParseError_UnexpectedEndOfTaggedFields: return 8;
10796                 case LDKBolt11ParseError_DescriptionDecodeError: return 9;
10797                 case LDKBolt11ParseError_PaddingError: return 10;
10798                 case LDKBolt11ParseError_IntegerOverflowError: return 11;
10799                 case LDKBolt11ParseError_InvalidSegWitProgramLength: return 12;
10800                 case LDKBolt11ParseError_InvalidPubKeyHashLength: return 13;
10801                 case LDKBolt11ParseError_InvalidScriptHashLength: return 14;
10802                 case LDKBolt11ParseError_InvalidRecoveryId: return 15;
10803                 case LDKBolt11ParseError_InvalidSliceLength: return 16;
10804                 case LDKBolt11ParseError_Skip: return 17;
10805                 default: abort();
10806         }
10807 }
10808 int64_t CS_LDK_LDKBolt11ParseError_Bech32Error_get_bech32_error(int64_t ptr) {
10809         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10810         CHECK(obj->tag == LDKBolt11ParseError_Bech32Error);
10811         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
10812         return bech32_error_ref;
10813 }
10814 int32_t CS_LDK_LDKBolt11ParseError_ParseAmountError_get_parse_amount_error(int64_t ptr) {
10815         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10816         CHECK(obj->tag == LDKBolt11ParseError_ParseAmountError);
10817         /*obj->parse_amount_error*/
10818         return 0;
10819 }
10820 int32_t CS_LDK_LDKBolt11ParseError_MalformedSignature_get_malformed_signature(int64_t ptr) {
10821         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10822         CHECK(obj->tag == LDKBolt11ParseError_MalformedSignature);
10823         int32_t malformed_signature_conv = LDKSecp256k1Error_to_cs(obj->malformed_signature);
10824         return malformed_signature_conv;
10825 }
10826 int32_t CS_LDK_LDKBolt11ParseError_DescriptionDecodeError_get_description_decode_error(int64_t ptr) {
10827         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10828         CHECK(obj->tag == LDKBolt11ParseError_DescriptionDecodeError);
10829         /*obj->description_decode_error*/
10830         return 0;
10831 }
10832 jstring CS_LDK_LDKBolt11ParseError_InvalidSliceLength_get_invalid_slice_length(int64_t ptr) {
10833         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10834         CHECK(obj->tag == LDKBolt11ParseError_InvalidSliceLength);
10835         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
10836                         jstring invalid_slice_length_conv = str_ref_to_cs(invalid_slice_length_str.chars, invalid_slice_length_str.len);
10837         return invalid_slice_length_conv;
10838 }
10839 static inline enum LDKSiPrefix CResult_SiPrefixBolt11ParseErrorZ_get_ok(LDKCResult_SiPrefixBolt11ParseErrorZ *NONNULL_PTR owner){
10840 CHECK(owner->result_ok);
10841         return SiPrefix_clone(&*owner->contents.result);
10842 }
10843 int32_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_get_ok(int64_t owner) {
10844         LDKCResult_SiPrefixBolt11ParseErrorZ* owner_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(owner);
10845         int32_t ret_conv = LDKSiPrefix_to_cs(CResult_SiPrefixBolt11ParseErrorZ_get_ok(owner_conv));
10846         return ret_conv;
10847 }
10848
10849 static inline struct LDKBolt11ParseError CResult_SiPrefixBolt11ParseErrorZ_get_err(LDKCResult_SiPrefixBolt11ParseErrorZ *NONNULL_PTR owner){
10850 CHECK(!owner->result_ok);
10851         return Bolt11ParseError_clone(&*owner->contents.err);
10852 }
10853 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_get_err(int64_t owner) {
10854         LDKCResult_SiPrefixBolt11ParseErrorZ* owner_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(owner);
10855         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
10856         *ret_copy = CResult_SiPrefixBolt11ParseErrorZ_get_err(owner_conv);
10857         int64_t ret_ref = tag_ptr(ret_copy, true);
10858         return ret_ref;
10859 }
10860
10861 uint32_t CS_LDK_LDKParseOrSemanticError_ty_from_ptr(int64_t ptr) {
10862         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10863         switch(obj->tag) {
10864                 case LDKParseOrSemanticError_ParseError: return 0;
10865                 case LDKParseOrSemanticError_SemanticError: return 1;
10866                 default: abort();
10867         }
10868 }
10869 int64_t CS_LDK_LDKParseOrSemanticError_ParseError_get_parse_error(int64_t ptr) {
10870         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10871         CHECK(obj->tag == LDKParseOrSemanticError_ParseError);
10872         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
10873         return parse_error_ref;
10874 }
10875 int32_t CS_LDK_LDKParseOrSemanticError_SemanticError_get_semantic_error(int64_t ptr) {
10876         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10877         CHECK(obj->tag == LDKParseOrSemanticError_SemanticError);
10878         int32_t semantic_error_conv = LDKBolt11SemanticError_to_cs(obj->semantic_error);
10879         return semantic_error_conv;
10880 }
10881 static inline struct LDKBolt11Invoice CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10882         LDKBolt11Invoice ret = *owner->contents.result;
10883         ret.is_owned = false;
10884         return ret;
10885 }
10886 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_ok(int64_t owner) {
10887         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10888         LDKBolt11Invoice ret_var = CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
10889         int64_t ret_ref = 0;
10890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10891         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10892         return ret_ref;
10893 }
10894
10895 static inline struct LDKParseOrSemanticError CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10896 CHECK(!owner->result_ok);
10897         return ParseOrSemanticError_clone(&*owner->contents.err);
10898 }
10899 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_err(int64_t owner) {
10900         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10901         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
10902         *ret_copy = CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
10903         int64_t ret_ref = tag_ptr(ret_copy, true);
10904         return ret_ref;
10905 }
10906
10907 static inline struct LDKSignedRawBolt11Invoice CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_ok(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ *NONNULL_PTR owner){
10908         LDKSignedRawBolt11Invoice ret = *owner->contents.result;
10909         ret.is_owned = false;
10910         return ret;
10911 }
10912 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_ok(int64_t owner) {
10913         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* owner_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(owner);
10914         LDKSignedRawBolt11Invoice ret_var = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_ok(owner_conv);
10915         int64_t ret_ref = 0;
10916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10918         return ret_ref;
10919 }
10920
10921 static inline struct LDKBolt11ParseError CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_err(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ *NONNULL_PTR owner){
10922 CHECK(!owner->result_ok);
10923         return Bolt11ParseError_clone(&*owner->contents.err);
10924 }
10925 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_err(int64_t owner) {
10926         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* owner_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(owner);
10927         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
10928         *ret_copy = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_err(owner_conv);
10929         int64_t ret_ref = tag_ptr(ret_copy, true);
10930         return ret_ref;
10931 }
10932
10933 static inline struct LDKRawBolt11Invoice C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_a(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR owner){
10934         LDKRawBolt11Invoice ret = owner->a;
10935         ret.is_owned = false;
10936         return ret;
10937 }
10938 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_a(int64_t owner) {
10939         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(owner);
10940         LDKRawBolt11Invoice ret_var = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_a(owner_conv);
10941         int64_t ret_ref = 0;
10942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10944         return ret_ref;
10945 }
10946
10947 static inline struct LDKThirtyTwoBytes C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_b(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR owner){
10948         return ThirtyTwoBytes_clone(&owner->b);
10949 }
10950 int8_tArray  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_b(int64_t owner) {
10951         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(owner);
10952         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
10953         memcpy(ret_arr->elems, C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_b(owner_conv).data, 32);
10954         return ret_arr;
10955 }
10956
10957 static inline struct LDKBolt11InvoiceSignature C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_c(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR owner){
10958         LDKBolt11InvoiceSignature ret = owner->c;
10959         ret.is_owned = false;
10960         return ret;
10961 }
10962 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_c(int64_t owner) {
10963         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(owner);
10964         LDKBolt11InvoiceSignature ret_var = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_c(owner_conv);
10965         int64_t ret_ref = 0;
10966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10967         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10968         return ret_ref;
10969 }
10970
10971 static inline struct LDKPayeePubKey CResult_PayeePubKeySecp256k1ErrorZ_get_ok(LDKCResult_PayeePubKeySecp256k1ErrorZ *NONNULL_PTR owner){
10972         LDKPayeePubKey ret = *owner->contents.result;
10973         ret.is_owned = false;
10974         return ret;
10975 }
10976 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_get_ok(int64_t owner) {
10977         LDKCResult_PayeePubKeySecp256k1ErrorZ* owner_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(owner);
10978         LDKPayeePubKey ret_var = CResult_PayeePubKeySecp256k1ErrorZ_get_ok(owner_conv);
10979         int64_t ret_ref = 0;
10980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10982         return ret_ref;
10983 }
10984
10985 static inline enum LDKSecp256k1Error CResult_PayeePubKeySecp256k1ErrorZ_get_err(LDKCResult_PayeePubKeySecp256k1ErrorZ *NONNULL_PTR owner){
10986 CHECK(!owner->result_ok);
10987         return *owner->contents.err;
10988 }
10989 int32_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_get_err(int64_t owner) {
10990         LDKCResult_PayeePubKeySecp256k1ErrorZ* owner_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(owner);
10991         int32_t ret_conv = LDKSecp256k1Error_to_cs(CResult_PayeePubKeySecp256k1ErrorZ_get_err(owner_conv));
10992         return ret_conv;
10993 }
10994
10995 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
10996         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
10997         for (size_t i = 0; i < ret.datalen; i++) {
10998                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
10999         }
11000         return ret;
11001 }
11002 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
11003         LDKPositiveTimestamp ret = *owner->contents.result;
11004         ret.is_owned = false;
11005         return ret;
11006 }
11007 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_get_ok(int64_t owner) {
11008         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
11009         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
11010         int64_t ret_ref = 0;
11011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11013         return ret_ref;
11014 }
11015
11016 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
11017 CHECK(!owner->result_ok);
11018         return CreationError_clone(&*owner->contents.err);
11019 }
11020 int32_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_get_err(int64_t owner) {
11021         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
11022         int32_t ret_conv = LDKCreationError_to_cs(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
11023         return ret_conv;
11024 }
11025
11026 static inline void CResult_NoneBolt11SemanticErrorZ_get_ok(LDKCResult_NoneBolt11SemanticErrorZ *NONNULL_PTR owner){
11027 CHECK(owner->result_ok);
11028         return *owner->contents.result;
11029 }
11030 void  CS_LDK_CResult_NoneBolt11SemanticErrorZ_get_ok(int64_t owner) {
11031         LDKCResult_NoneBolt11SemanticErrorZ* owner_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(owner);
11032         CResult_NoneBolt11SemanticErrorZ_get_ok(owner_conv);
11033 }
11034
11035 static inline enum LDKBolt11SemanticError CResult_NoneBolt11SemanticErrorZ_get_err(LDKCResult_NoneBolt11SemanticErrorZ *NONNULL_PTR owner){
11036 CHECK(!owner->result_ok);
11037         return Bolt11SemanticError_clone(&*owner->contents.err);
11038 }
11039 int32_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_get_err(int64_t owner) {
11040         LDKCResult_NoneBolt11SemanticErrorZ* owner_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(owner);
11041         int32_t ret_conv = LDKBolt11SemanticError_to_cs(CResult_NoneBolt11SemanticErrorZ_get_err(owner_conv));
11042         return ret_conv;
11043 }
11044
11045 static inline struct LDKBolt11Invoice CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_ok(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ *NONNULL_PTR owner){
11046         LDKBolt11Invoice ret = *owner->contents.result;
11047         ret.is_owned = false;
11048         return ret;
11049 }
11050 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_ok(int64_t owner) {
11051         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(owner);
11052         LDKBolt11Invoice ret_var = CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_ok(owner_conv);
11053         int64_t ret_ref = 0;
11054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11056         return ret_ref;
11057 }
11058
11059 static inline enum LDKBolt11SemanticError CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_err(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ *NONNULL_PTR owner){
11060 CHECK(!owner->result_ok);
11061         return Bolt11SemanticError_clone(&*owner->contents.err);
11062 }
11063 int32_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_err(int64_t owner) {
11064         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(owner);
11065         int32_t ret_conv = LDKBolt11SemanticError_to_cs(CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_err(owner_conv));
11066         return ret_conv;
11067 }
11068
11069 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
11070         LDKDescription ret = *owner->contents.result;
11071         ret.is_owned = false;
11072         return ret;
11073 }
11074 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_get_ok(int64_t owner) {
11075         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
11076         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
11077         int64_t ret_ref = 0;
11078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11080         return ret_ref;
11081 }
11082
11083 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
11084 CHECK(!owner->result_ok);
11085         return CreationError_clone(&*owner->contents.err);
11086 }
11087 int32_t  CS_LDK_CResult_DescriptionCreationErrorZ_get_err(int64_t owner) {
11088         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
11089         int32_t ret_conv = LDKCreationError_to_cs(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
11090         return ret_conv;
11091 }
11092
11093 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
11094         LDKPrivateRoute ret = *owner->contents.result;
11095         ret.is_owned = false;
11096         return ret;
11097 }
11098 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_get_ok(int64_t owner) {
11099         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
11100         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
11101         int64_t ret_ref = 0;
11102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11104         return ret_ref;
11105 }
11106
11107 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
11108 CHECK(!owner->result_ok);
11109         return CreationError_clone(&*owner->contents.err);
11110 }
11111 int32_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_get_err(int64_t owner) {
11112         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
11113         int32_t ret_conv = LDKCreationError_to_cs(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
11114         return ret_conv;
11115 }
11116
11117 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
11118         LDKOutPoint ret = *owner->contents.result;
11119         ret.is_owned = false;
11120         return ret;
11121 }
11122 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_get_ok(int64_t owner) {
11123         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
11124         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
11125         int64_t ret_ref = 0;
11126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11128         return ret_ref;
11129 }
11130
11131 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
11132 CHECK(!owner->result_ok);
11133         return DecodeError_clone(&*owner->contents.err);
11134 }
11135 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_get_err(int64_t owner) {
11136         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
11137         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11138         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
11139         int64_t ret_ref = tag_ptr(ret_copy, true);
11140         return ret_ref;
11141 }
11142
11143 static inline struct LDKBigSize CResult_BigSizeDecodeErrorZ_get_ok(LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR owner){
11144         LDKBigSize ret = *owner->contents.result;
11145         ret.is_owned = false;
11146         return ret;
11147 }
11148 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_get_ok(int64_t owner) {
11149         LDKCResult_BigSizeDecodeErrorZ* owner_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(owner);
11150         LDKBigSize ret_var = CResult_BigSizeDecodeErrorZ_get_ok(owner_conv);
11151         int64_t ret_ref = 0;
11152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11153         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11154         return ret_ref;
11155 }
11156
11157 static inline struct LDKDecodeError CResult_BigSizeDecodeErrorZ_get_err(LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR owner){
11158 CHECK(!owner->result_ok);
11159         return DecodeError_clone(&*owner->contents.err);
11160 }
11161 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_get_err(int64_t owner) {
11162         LDKCResult_BigSizeDecodeErrorZ* owner_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(owner);
11163         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11164         *ret_copy = CResult_BigSizeDecodeErrorZ_get_err(owner_conv);
11165         int64_t ret_ref = tag_ptr(ret_copy, true);
11166         return ret_ref;
11167 }
11168
11169 static inline struct LDKHostname CResult_HostnameDecodeErrorZ_get_ok(LDKCResult_HostnameDecodeErrorZ *NONNULL_PTR owner){
11170         LDKHostname ret = *owner->contents.result;
11171         ret.is_owned = false;
11172         return ret;
11173 }
11174 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_get_ok(int64_t owner) {
11175         LDKCResult_HostnameDecodeErrorZ* owner_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(owner);
11176         LDKHostname ret_var = CResult_HostnameDecodeErrorZ_get_ok(owner_conv);
11177         int64_t ret_ref = 0;
11178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11180         return ret_ref;
11181 }
11182
11183 static inline struct LDKDecodeError CResult_HostnameDecodeErrorZ_get_err(LDKCResult_HostnameDecodeErrorZ *NONNULL_PTR owner){
11184 CHECK(!owner->result_ok);
11185         return DecodeError_clone(&*owner->contents.err);
11186 }
11187 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_get_err(int64_t owner) {
11188         LDKCResult_HostnameDecodeErrorZ* owner_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(owner);
11189         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11190         *ret_copy = CResult_HostnameDecodeErrorZ_get_err(owner_conv);
11191         int64_t ret_ref = tag_ptr(ret_copy, true);
11192         return ret_ref;
11193 }
11194
11195 static inline struct LDKTransactionU16LenLimited CResult_TransactionU16LenLimitedNoneZ_get_ok(LDKCResult_TransactionU16LenLimitedNoneZ *NONNULL_PTR owner){
11196         LDKTransactionU16LenLimited ret = *owner->contents.result;
11197         ret.is_owned = false;
11198         return ret;
11199 }
11200 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_get_ok(int64_t owner) {
11201         LDKCResult_TransactionU16LenLimitedNoneZ* owner_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(owner);
11202         LDKTransactionU16LenLimited ret_var = CResult_TransactionU16LenLimitedNoneZ_get_ok(owner_conv);
11203         int64_t ret_ref = 0;
11204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11205         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11206         return ret_ref;
11207 }
11208
11209 static inline void CResult_TransactionU16LenLimitedNoneZ_get_err(LDKCResult_TransactionU16LenLimitedNoneZ *NONNULL_PTR owner){
11210 CHECK(!owner->result_ok);
11211         return *owner->contents.err;
11212 }
11213 void  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_get_err(int64_t owner) {
11214         LDKCResult_TransactionU16LenLimitedNoneZ* owner_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(owner);
11215         CResult_TransactionU16LenLimitedNoneZ_get_err(owner_conv);
11216 }
11217
11218 static inline struct LDKTransactionU16LenLimited CResult_TransactionU16LenLimitedDecodeErrorZ_get_ok(LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR owner){
11219         LDKTransactionU16LenLimited ret = *owner->contents.result;
11220         ret.is_owned = false;
11221         return ret;
11222 }
11223 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_get_ok(int64_t owner) {
11224         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* owner_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(owner);
11225         LDKTransactionU16LenLimited ret_var = CResult_TransactionU16LenLimitedDecodeErrorZ_get_ok(owner_conv);
11226         int64_t ret_ref = 0;
11227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11229         return ret_ref;
11230 }
11231
11232 static inline struct LDKDecodeError CResult_TransactionU16LenLimitedDecodeErrorZ_get_err(LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR owner){
11233 CHECK(!owner->result_ok);
11234         return DecodeError_clone(&*owner->contents.err);
11235 }
11236 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_get_err(int64_t owner) {
11237         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* owner_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(owner);
11238         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11239         *ret_copy = CResult_TransactionU16LenLimitedDecodeErrorZ_get_err(owner_conv);
11240         int64_t ret_ref = tag_ptr(ret_copy, true);
11241         return ret_ref;
11242 }
11243
11244 static inline struct LDKUntrustedString CResult_UntrustedStringDecodeErrorZ_get_ok(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR owner){
11245         LDKUntrustedString ret = *owner->contents.result;
11246         ret.is_owned = false;
11247         return ret;
11248 }
11249 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_get_ok(int64_t owner) {
11250         LDKCResult_UntrustedStringDecodeErrorZ* owner_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(owner);
11251         LDKUntrustedString ret_var = CResult_UntrustedStringDecodeErrorZ_get_ok(owner_conv);
11252         int64_t ret_ref = 0;
11253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11255         return ret_ref;
11256 }
11257
11258 static inline struct LDKDecodeError CResult_UntrustedStringDecodeErrorZ_get_err(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR owner){
11259 CHECK(!owner->result_ok);
11260         return DecodeError_clone(&*owner->contents.err);
11261 }
11262 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_get_err(int64_t owner) {
11263         LDKCResult_UntrustedStringDecodeErrorZ* owner_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(owner);
11264         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11265         *ret_copy = CResult_UntrustedStringDecodeErrorZ_get_err(owner_conv);
11266         int64_t ret_ref = tag_ptr(ret_copy, true);
11267         return ret_ref;
11268 }
11269
11270 static inline struct LDKReceiveTlvs CResult_ReceiveTlvsDecodeErrorZ_get_ok(LDKCResult_ReceiveTlvsDecodeErrorZ *NONNULL_PTR owner){
11271         LDKReceiveTlvs ret = *owner->contents.result;
11272         ret.is_owned = false;
11273         return ret;
11274 }
11275 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_get_ok(int64_t owner) {
11276         LDKCResult_ReceiveTlvsDecodeErrorZ* owner_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(owner);
11277         LDKReceiveTlvs ret_var = CResult_ReceiveTlvsDecodeErrorZ_get_ok(owner_conv);
11278         int64_t ret_ref = 0;
11279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11280         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11281         return ret_ref;
11282 }
11283
11284 static inline struct LDKDecodeError CResult_ReceiveTlvsDecodeErrorZ_get_err(LDKCResult_ReceiveTlvsDecodeErrorZ *NONNULL_PTR owner){
11285 CHECK(!owner->result_ok);
11286         return DecodeError_clone(&*owner->contents.err);
11287 }
11288 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_get_err(int64_t owner) {
11289         LDKCResult_ReceiveTlvsDecodeErrorZ* owner_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(owner);
11290         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11291         *ret_copy = CResult_ReceiveTlvsDecodeErrorZ_get_err(owner_conv);
11292         int64_t ret_ref = tag_ptr(ret_copy, true);
11293         return ret_ref;
11294 }
11295
11296 static inline struct LDKPaymentRelay CResult_PaymentRelayDecodeErrorZ_get_ok(LDKCResult_PaymentRelayDecodeErrorZ *NONNULL_PTR owner){
11297         LDKPaymentRelay ret = *owner->contents.result;
11298         ret.is_owned = false;
11299         return ret;
11300 }
11301 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_get_ok(int64_t owner) {
11302         LDKCResult_PaymentRelayDecodeErrorZ* owner_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(owner);
11303         LDKPaymentRelay ret_var = CResult_PaymentRelayDecodeErrorZ_get_ok(owner_conv);
11304         int64_t ret_ref = 0;
11305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11307         return ret_ref;
11308 }
11309
11310 static inline struct LDKDecodeError CResult_PaymentRelayDecodeErrorZ_get_err(LDKCResult_PaymentRelayDecodeErrorZ *NONNULL_PTR owner){
11311 CHECK(!owner->result_ok);
11312         return DecodeError_clone(&*owner->contents.err);
11313 }
11314 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_get_err(int64_t owner) {
11315         LDKCResult_PaymentRelayDecodeErrorZ* owner_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(owner);
11316         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11317         *ret_copy = CResult_PaymentRelayDecodeErrorZ_get_err(owner_conv);
11318         int64_t ret_ref = tag_ptr(ret_copy, true);
11319         return ret_ref;
11320 }
11321
11322 static inline struct LDKPaymentConstraints CResult_PaymentConstraintsDecodeErrorZ_get_ok(LDKCResult_PaymentConstraintsDecodeErrorZ *NONNULL_PTR owner){
11323         LDKPaymentConstraints ret = *owner->contents.result;
11324         ret.is_owned = false;
11325         return ret;
11326 }
11327 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_get_ok(int64_t owner) {
11328         LDKCResult_PaymentConstraintsDecodeErrorZ* owner_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(owner);
11329         LDKPaymentConstraints ret_var = CResult_PaymentConstraintsDecodeErrorZ_get_ok(owner_conv);
11330         int64_t ret_ref = 0;
11331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11332         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11333         return ret_ref;
11334 }
11335
11336 static inline struct LDKDecodeError CResult_PaymentConstraintsDecodeErrorZ_get_err(LDKCResult_PaymentConstraintsDecodeErrorZ *NONNULL_PTR owner){
11337 CHECK(!owner->result_ok);
11338         return DecodeError_clone(&*owner->contents.err);
11339 }
11340 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_get_err(int64_t owner) {
11341         LDKCResult_PaymentConstraintsDecodeErrorZ* owner_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(owner);
11342         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11343         *ret_copy = CResult_PaymentConstraintsDecodeErrorZ_get_err(owner_conv);
11344         int64_t ret_ref = tag_ptr(ret_copy, true);
11345         return ret_ref;
11346 }
11347
11348 uint32_t CS_LDK_LDKPaymentError_ty_from_ptr(int64_t ptr) {
11349         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
11350         switch(obj->tag) {
11351                 case LDKPaymentError_Invoice: return 0;
11352                 case LDKPaymentError_Sending: return 1;
11353                 default: abort();
11354         }
11355 }
11356 jstring CS_LDK_LDKPaymentError_Invoice_get_invoice(int64_t ptr) {
11357         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
11358         CHECK(obj->tag == LDKPaymentError_Invoice);
11359         LDKStr invoice_str = obj->invoice;
11360                         jstring invoice_conv = str_ref_to_cs(invoice_str.chars, invoice_str.len);
11361         return invoice_conv;
11362 }
11363 int32_t CS_LDK_LDKPaymentError_Sending_get_sending(int64_t ptr) {
11364         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
11365         CHECK(obj->tag == LDKPaymentError_Sending);
11366         int32_t sending_conv = LDKRetryableSendFailure_to_cs(obj->sending);
11367         return sending_conv;
11368 }
11369 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesPaymentErrorZ_get_ok(LDKCResult_ThirtyTwoBytesPaymentErrorZ *NONNULL_PTR owner){
11370 CHECK(owner->result_ok);
11371         return ThirtyTwoBytes_clone(&*owner->contents.result);
11372 }
11373 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_get_ok(int64_t owner) {
11374         LDKCResult_ThirtyTwoBytesPaymentErrorZ* owner_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(owner);
11375         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
11376         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesPaymentErrorZ_get_ok(owner_conv).data, 32);
11377         return ret_arr;
11378 }
11379
11380 static inline struct LDKPaymentError CResult_ThirtyTwoBytesPaymentErrorZ_get_err(LDKCResult_ThirtyTwoBytesPaymentErrorZ *NONNULL_PTR owner){
11381 CHECK(!owner->result_ok);
11382         return PaymentError_clone(&*owner->contents.err);
11383 }
11384 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_get_err(int64_t owner) {
11385         LDKCResult_ThirtyTwoBytesPaymentErrorZ* owner_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(owner);
11386         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
11387         *ret_copy = CResult_ThirtyTwoBytesPaymentErrorZ_get_err(owner_conv);
11388         int64_t ret_ref = tag_ptr(ret_copy, true);
11389         return ret_ref;
11390 }
11391
11392 static inline void CResult_NonePaymentErrorZ_get_ok(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
11393 CHECK(owner->result_ok);
11394         return *owner->contents.result;
11395 }
11396 void  CS_LDK_CResult_NonePaymentErrorZ_get_ok(int64_t owner) {
11397         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
11398         CResult_NonePaymentErrorZ_get_ok(owner_conv);
11399 }
11400
11401 static inline struct LDKPaymentError CResult_NonePaymentErrorZ_get_err(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
11402 CHECK(!owner->result_ok);
11403         return PaymentError_clone(&*owner->contents.err);
11404 }
11405 int64_t  CS_LDK_CResult_NonePaymentErrorZ_get_err(int64_t owner) {
11406         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
11407         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
11408         *ret_copy = CResult_NonePaymentErrorZ_get_err(owner_conv);
11409         int64_t ret_ref = tag_ptr(ret_copy, true);
11410         return ret_ref;
11411 }
11412
11413 uint32_t CS_LDK_LDKProbingError_ty_from_ptr(int64_t ptr) {
11414         LDKProbingError *obj = (LDKProbingError*)untag_ptr(ptr);
11415         switch(obj->tag) {
11416                 case LDKProbingError_Invoice: return 0;
11417                 case LDKProbingError_Sending: return 1;
11418                 default: abort();
11419         }
11420 }
11421 jstring CS_LDK_LDKProbingError_Invoice_get_invoice(int64_t ptr) {
11422         LDKProbingError *obj = (LDKProbingError*)untag_ptr(ptr);
11423         CHECK(obj->tag == LDKProbingError_Invoice);
11424         LDKStr invoice_str = obj->invoice;
11425                         jstring invoice_conv = str_ref_to_cs(invoice_str.chars, invoice_str.len);
11426         return invoice_conv;
11427 }
11428 int64_t CS_LDK_LDKProbingError_Sending_get_sending(int64_t ptr) {
11429         LDKProbingError *obj = (LDKProbingError*)untag_ptr(ptr);
11430         CHECK(obj->tag == LDKProbingError_Sending);
11431         int64_t sending_ref = tag_ptr(&obj->sending, false);
11432         return sending_ref;
11433 }
11434 static inline struct LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_ok(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ *NONNULL_PTR owner){
11435 CHECK(owner->result_ok);
11436         return CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_clone(&*owner->contents.result);
11437 }
11438 int64_tArray  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_ok(int64_t owner) {
11439         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(owner);
11440         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ ret_var = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_ok(owner_conv);
11441         int64_tArray ret_arr = NULL;
11442         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
11443         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
11444         for (size_t o = 0; o < ret_var.datalen; o++) {
11445                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
11446                 *ret_conv_40_conv = ret_var.data[o];
11447                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
11448         }
11449         
11450         FREE(ret_var.data);
11451         return ret_arr;
11452 }
11453
11454 static inline struct LDKProbingError CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_err(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ *NONNULL_PTR owner){
11455 CHECK(!owner->result_ok);
11456         return ProbingError_clone(&*owner->contents.err);
11457 }
11458 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_err(int64_t owner) {
11459         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(owner);
11460         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
11461         *ret_copy = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_err(owner_conv);
11462         int64_t ret_ref = tag_ptr(ret_copy, true);
11463         return ret_ref;
11464 }
11465
11466 static inline struct LDKStr CResult_StrSecp256k1ErrorZ_get_ok(LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR owner){
11467 CHECK(owner->result_ok);
11468         return *owner->contents.result;
11469 }
11470 jstring  CS_LDK_CResult_StrSecp256k1ErrorZ_get_ok(int64_t owner) {
11471         LDKCResult_StrSecp256k1ErrorZ* owner_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(owner);
11472         LDKStr ret_str = CResult_StrSecp256k1ErrorZ_get_ok(owner_conv);
11473         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
11474         return ret_conv;
11475 }
11476
11477 static inline enum LDKSecp256k1Error CResult_StrSecp256k1ErrorZ_get_err(LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR owner){
11478 CHECK(!owner->result_ok);
11479         return *owner->contents.err;
11480 }
11481 int32_t  CS_LDK_CResult_StrSecp256k1ErrorZ_get_err(int64_t owner) {
11482         LDKCResult_StrSecp256k1ErrorZ* owner_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(owner);
11483         int32_t ret_conv = LDKSecp256k1Error_to_cs(CResult_StrSecp256k1ErrorZ_get_err(owner_conv));
11484         return ret_conv;
11485 }
11486
11487 static inline struct LDKOnionMessagePath CResult_OnionMessagePathNoneZ_get_ok(LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR owner){
11488         LDKOnionMessagePath ret = *owner->contents.result;
11489         ret.is_owned = false;
11490         return ret;
11491 }
11492 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_get_ok(int64_t owner) {
11493         LDKCResult_OnionMessagePathNoneZ* owner_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(owner);
11494         LDKOnionMessagePath ret_var = CResult_OnionMessagePathNoneZ_get_ok(owner_conv);
11495         int64_t ret_ref = 0;
11496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11498         return ret_ref;
11499 }
11500
11501 static inline void CResult_OnionMessagePathNoneZ_get_err(LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR owner){
11502 CHECK(!owner->result_ok);
11503         return *owner->contents.err;
11504 }
11505 void  CS_LDK_CResult_OnionMessagePathNoneZ_get_err(int64_t owner) {
11506         LDKCResult_OnionMessagePathNoneZ* owner_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(owner);
11507         CResult_OnionMessagePathNoneZ_get_err(owner_conv);
11508 }
11509
11510 static inline struct LDKPublicKey C2Tuple_PublicKeyOnionMessageZ_get_a(LDKC2Tuple_PublicKeyOnionMessageZ *NONNULL_PTR owner){
11511         return owner->a;
11512 }
11513 int8_tArray  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_get_a(int64_t owner) {
11514         LDKC2Tuple_PublicKeyOnionMessageZ* owner_conv = (LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(owner);
11515         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
11516         memcpy(ret_arr->elems, C2Tuple_PublicKeyOnionMessageZ_get_a(owner_conv).compressed_form, 33);
11517         return ret_arr;
11518 }
11519
11520 static inline struct LDKOnionMessage C2Tuple_PublicKeyOnionMessageZ_get_b(LDKC2Tuple_PublicKeyOnionMessageZ *NONNULL_PTR owner){
11521         LDKOnionMessage ret = owner->b;
11522         ret.is_owned = false;
11523         return ret;
11524 }
11525 int64_t  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_get_b(int64_t owner) {
11526         LDKC2Tuple_PublicKeyOnionMessageZ* owner_conv = (LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(owner);
11527         LDKOnionMessage ret_var = C2Tuple_PublicKeyOnionMessageZ_get_b(owner_conv);
11528         int64_t ret_ref = 0;
11529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11531         return ret_ref;
11532 }
11533
11534 uint32_t CS_LDK_LDKSendError_ty_from_ptr(int64_t ptr) {
11535         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
11536         switch(obj->tag) {
11537                 case LDKSendError_Secp256k1: return 0;
11538                 case LDKSendError_TooBigPacket: return 1;
11539                 case LDKSendError_TooFewBlindedHops: return 2;
11540                 case LDKSendError_InvalidFirstHop: return 3;
11541                 case LDKSendError_InvalidMessage: return 4;
11542                 case LDKSendError_BufferFull: return 5;
11543                 case LDKSendError_GetNodeIdFailed: return 6;
11544                 case LDKSendError_BlindedPathAdvanceFailed: return 7;
11545                 default: abort();
11546         }
11547 }
11548 int32_t CS_LDK_LDKSendError_Secp256k1_get_secp256k1(int64_t ptr) {
11549         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
11550         CHECK(obj->tag == LDKSendError_Secp256k1);
11551         int32_t secp256k1_conv = LDKSecp256k1Error_to_cs(obj->secp256k1);
11552         return secp256k1_conv;
11553 }
11554 static inline struct LDKC2Tuple_PublicKeyOnionMessageZ CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_ok(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ *NONNULL_PTR owner){
11555 CHECK(owner->result_ok);
11556         return C2Tuple_PublicKeyOnionMessageZ_clone(&*owner->contents.result);
11557 }
11558 int64_t  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_ok(int64_t owner) {
11559         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* owner_conv = (LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ*)untag_ptr(owner);
11560         LDKC2Tuple_PublicKeyOnionMessageZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyOnionMessageZ), "LDKC2Tuple_PublicKeyOnionMessageZ");
11561         *ret_conv = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_ok(owner_conv);
11562         return tag_ptr(ret_conv, true);
11563 }
11564
11565 static inline struct LDKSendError CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_err(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ *NONNULL_PTR owner){
11566 CHECK(!owner->result_ok);
11567         return SendError_clone(&*owner->contents.err);
11568 }
11569 int64_t  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_err(int64_t owner) {
11570         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* owner_conv = (LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ*)untag_ptr(owner);
11571         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
11572         *ret_copy = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_err(owner_conv);
11573         int64_t ret_ref = tag_ptr(ret_copy, true);
11574         return ret_ref;
11575 }
11576
11577 uint32_t CS_LDK_LDKParsedOnionMessageContents_ty_from_ptr(int64_t ptr) {
11578         LDKParsedOnionMessageContents *obj = (LDKParsedOnionMessageContents*)untag_ptr(ptr);
11579         switch(obj->tag) {
11580                 case LDKParsedOnionMessageContents_Offers: return 0;
11581                 case LDKParsedOnionMessageContents_Custom: return 1;
11582                 default: abort();
11583         }
11584 }
11585 int64_t CS_LDK_LDKParsedOnionMessageContents_Offers_get_offers(int64_t ptr) {
11586         LDKParsedOnionMessageContents *obj = (LDKParsedOnionMessageContents*)untag_ptr(ptr);
11587         CHECK(obj->tag == LDKParsedOnionMessageContents_Offers);
11588         int64_t offers_ref = tag_ptr(&obj->offers, false);
11589         return offers_ref;
11590 }
11591 int64_t CS_LDK_LDKParsedOnionMessageContents_Custom_get_custom(int64_t ptr) {
11592         LDKParsedOnionMessageContents *obj = (LDKParsedOnionMessageContents*)untag_ptr(ptr);
11593         CHECK(obj->tag == LDKParsedOnionMessageContents_Custom);
11594         LDKOnionMessageContents* custom_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
11595         *custom_ret = OnionMessageContents_clone(&obj->custom);
11596         return tag_ptr(custom_ret, true);
11597 }
11598 uint32_t CS_LDK_LDKPeeledOnion_ty_from_ptr(int64_t ptr) {
11599         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11600         switch(obj->tag) {
11601                 case LDKPeeledOnion_Forward: return 0;
11602                 case LDKPeeledOnion_Receive: return 1;
11603                 default: abort();
11604         }
11605 }
11606 int8_tArray CS_LDK_LDKPeeledOnion_Forward_get__0(int64_t ptr) {
11607         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11608         CHECK(obj->tag == LDKPeeledOnion_Forward);
11609         int8_tArray _0_arr = init_int8_tArray(33, __LINE__);
11610         memcpy(_0_arr->elems, obj->forward._0.compressed_form, 33);
11611         return _0_arr;
11612 }
11613 int64_t CS_LDK_LDKPeeledOnion_Forward_get__1(int64_t ptr) {
11614         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11615         CHECK(obj->tag == LDKPeeledOnion_Forward);
11616         LDKOnionMessage _1_var = obj->forward._1;
11617                         int64_t _1_ref = 0;
11618                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_1_var);
11619                         _1_ref = tag_ptr(_1_var.inner, false);
11620         return _1_ref;
11621 }
11622 int64_t CS_LDK_LDKPeeledOnion_Receive_get__0(int64_t ptr) {
11623         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11624         CHECK(obj->tag == LDKPeeledOnion_Receive);
11625         int64_t _0_ref = tag_ptr(&obj->receive._0, false);
11626         return _0_ref;
11627 }
11628 int8_tArray CS_LDK_LDKPeeledOnion_Receive_get__1(int64_t ptr) {
11629         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11630         CHECK(obj->tag == LDKPeeledOnion_Receive);
11631         int8_tArray _1_arr = init_int8_tArray(32, __LINE__);
11632         memcpy(_1_arr->elems, obj->receive._1.data, 32);
11633         return _1_arr;
11634 }
11635 int64_t CS_LDK_LDKPeeledOnion_Receive_get__2(int64_t ptr) {
11636         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11637         CHECK(obj->tag == LDKPeeledOnion_Receive);
11638         LDKBlindedPath _2_var = obj->receive._2;
11639                         int64_t _2_ref = 0;
11640                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_2_var);
11641                         _2_ref = tag_ptr(_2_var.inner, false);
11642         return _2_ref;
11643 }
11644 static inline struct LDKPeeledOnion CResult_PeeledOnionNoneZ_get_ok(LDKCResult_PeeledOnionNoneZ *NONNULL_PTR owner){
11645 CHECK(owner->result_ok);
11646         return PeeledOnion_clone(&*owner->contents.result);
11647 }
11648 int64_t  CS_LDK_CResult_PeeledOnionNoneZ_get_ok(int64_t owner) {
11649         LDKCResult_PeeledOnionNoneZ* owner_conv = (LDKCResult_PeeledOnionNoneZ*)untag_ptr(owner);
11650         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
11651         *ret_copy = CResult_PeeledOnionNoneZ_get_ok(owner_conv);
11652         int64_t ret_ref = tag_ptr(ret_copy, true);
11653         return ret_ref;
11654 }
11655
11656 static inline void CResult_PeeledOnionNoneZ_get_err(LDKCResult_PeeledOnionNoneZ *NONNULL_PTR owner){
11657 CHECK(!owner->result_ok);
11658         return *owner->contents.err;
11659 }
11660 void  CS_LDK_CResult_PeeledOnionNoneZ_get_err(int64_t owner) {
11661         LDKCResult_PeeledOnionNoneZ* owner_conv = (LDKCResult_PeeledOnionNoneZ*)untag_ptr(owner);
11662         CResult_PeeledOnionNoneZ_get_err(owner_conv);
11663 }
11664
11665 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
11666 CHECK(owner->result_ok);
11667         return *owner->contents.result;
11668 }
11669 void  CS_LDK_CResult_NoneSendErrorZ_get_ok(int64_t owner) {
11670         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
11671         CResult_NoneSendErrorZ_get_ok(owner_conv);
11672 }
11673
11674 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
11675 CHECK(!owner->result_ok);
11676         return SendError_clone(&*owner->contents.err);
11677 }
11678 int64_t  CS_LDK_CResult_NoneSendErrorZ_get_err(int64_t owner) {
11679         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
11680         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
11681         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
11682         int64_t ret_ref = tag_ptr(ret_copy, true);
11683         return ret_ref;
11684 }
11685
11686 static inline struct LDKBlindedPath CResult_BlindedPathNoneZ_get_ok(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
11687         LDKBlindedPath ret = *owner->contents.result;
11688         ret.is_owned = false;
11689         return ret;
11690 }
11691 int64_t  CS_LDK_CResult_BlindedPathNoneZ_get_ok(int64_t owner) {
11692         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
11693         LDKBlindedPath ret_var = CResult_BlindedPathNoneZ_get_ok(owner_conv);
11694         int64_t ret_ref = 0;
11695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11696         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11697         return ret_ref;
11698 }
11699
11700 static inline void CResult_BlindedPathNoneZ_get_err(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
11701 CHECK(!owner->result_ok);
11702         return *owner->contents.err;
11703 }
11704 void  CS_LDK_CResult_BlindedPathNoneZ_get_err(int64_t owner) {
11705         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
11706         CResult_BlindedPathNoneZ_get_err(owner_conv);
11707 }
11708
11709 static inline struct LDKC2Tuple_BlindedPayInfoBlindedPathZ CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_ok(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR owner){
11710 CHECK(owner->result_ok);
11711         return C2Tuple_BlindedPayInfoBlindedPathZ_clone(&*owner->contents.result);
11712 }
11713 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_ok(int64_t owner) {
11714         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* owner_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(owner);
11715         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
11716         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_ok(owner_conv);
11717         return tag_ptr(ret_conv, true);
11718 }
11719
11720 static inline void CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_err(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR owner){
11721 CHECK(!owner->result_ok);
11722         return *owner->contents.err;
11723 }
11724 void  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_err(int64_t owner) {
11725         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* owner_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(owner);
11726         CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_err(owner_conv);
11727 }
11728
11729 static inline struct LDKBlindedPath CResult_BlindedPathDecodeErrorZ_get_ok(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
11730         LDKBlindedPath ret = *owner->contents.result;
11731         ret.is_owned = false;
11732         return ret;
11733 }
11734 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_get_ok(int64_t owner) {
11735         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
11736         LDKBlindedPath ret_var = CResult_BlindedPathDecodeErrorZ_get_ok(owner_conv);
11737         int64_t ret_ref = 0;
11738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11740         return ret_ref;
11741 }
11742
11743 static inline struct LDKDecodeError CResult_BlindedPathDecodeErrorZ_get_err(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
11744 CHECK(!owner->result_ok);
11745         return DecodeError_clone(&*owner->contents.err);
11746 }
11747 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_get_err(int64_t owner) {
11748         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
11749         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11750         *ret_copy = CResult_BlindedPathDecodeErrorZ_get_err(owner_conv);
11751         int64_t ret_ref = tag_ptr(ret_copy, true);
11752         return ret_ref;
11753 }
11754
11755 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
11756         LDKBlindedHop ret = *owner->contents.result;
11757         ret.is_owned = false;
11758         return ret;
11759 }
11760 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_get_ok(int64_t owner) {
11761         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
11762         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
11763         int64_t ret_ref = 0;
11764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11766         return ret_ref;
11767 }
11768
11769 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
11770 CHECK(!owner->result_ok);
11771         return DecodeError_clone(&*owner->contents.err);
11772 }
11773 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_get_err(int64_t owner) {
11774         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
11775         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11776         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
11777         int64_t ret_ref = tag_ptr(ret_copy, true);
11778         return ret_ref;
11779 }
11780
11781 static inline struct LDKInvoiceError CResult_InvoiceErrorDecodeErrorZ_get_ok(LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR owner){
11782         LDKInvoiceError ret = *owner->contents.result;
11783         ret.is_owned = false;
11784         return ret;
11785 }
11786 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_get_ok(int64_t owner) {
11787         LDKCResult_InvoiceErrorDecodeErrorZ* owner_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(owner);
11788         LDKInvoiceError ret_var = CResult_InvoiceErrorDecodeErrorZ_get_ok(owner_conv);
11789         int64_t ret_ref = 0;
11790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11792         return ret_ref;
11793 }
11794
11795 static inline struct LDKDecodeError CResult_InvoiceErrorDecodeErrorZ_get_err(LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR owner){
11796 CHECK(!owner->result_ok);
11797         return DecodeError_clone(&*owner->contents.err);
11798 }
11799 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_get_err(int64_t owner) {
11800         LDKCResult_InvoiceErrorDecodeErrorZ* owner_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(owner);
11801         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11802         *ret_copy = CResult_InvoiceErrorDecodeErrorZ_get_err(owner_conv);
11803         int64_t ret_ref = tag_ptr(ret_copy, true);
11804         return ret_ref;
11805 }
11806
11807 typedef struct LDKFilter_JCalls {
11808         atomic_size_t refcnt;
11809         uint32_t instance_ptr;
11810 } LDKFilter_JCalls;
11811 static void LDKFilter_JCalls_free(void* this_arg) {
11812         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11813         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11814                 FREE(j_calls);
11815         }
11816 }
11817 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
11818         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11819         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
11820         memcpy(txid_arr->elems, *txid, 32);
11821         LDKu8slice script_pubkey_var = script_pubkey;
11822         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
11823         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
11824         js_invoke_function_void_ll(j_calls->instance_ptr, 51, (int64_t)txid_arr, (int64_t)script_pubkey_arr);
11825 }
11826 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
11827         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11828         LDKWatchedOutput output_var = output;
11829         int64_t output_ref = 0;
11830         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
11831         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
11832         js_invoke_function_void_l(j_calls->instance_ptr, 52, output_ref);
11833 }
11834 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
11835         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
11836         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11837 }
11838 static inline LDKFilter LDKFilter_init (int64_t o) {
11839         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
11840         atomic_init(&calls->refcnt, 1);
11841         calls->instance_ptr = o;
11842
11843         LDKFilter ret = {
11844                 .this_arg = (void*) calls,
11845                 .register_tx = register_tx_LDKFilter_jcall,
11846                 .register_output = register_output_LDKFilter_jcall,
11847                 .free = LDKFilter_JCalls_free,
11848         };
11849         return ret;
11850 }
11851 uint64_t  CS_LDK_LDKFilter_new(int32_t o) {
11852         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11853         *res_ptr = LDKFilter_init(o);
11854         return tag_ptr(res_ptr, true);
11855 }
11856 void  CS_LDK_Filter_register_tx(int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
11857         void* this_arg_ptr = untag_ptr(this_arg);
11858         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11859         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11860         uint8_t txid_arr[32];
11861         CHECK(txid->arr_len == 32);
11862         memcpy(txid_arr, txid->elems, 32); FREE(txid);
11863         uint8_t (*txid_ref)[32] = &txid_arr;
11864         LDKu8slice script_pubkey_ref;
11865         script_pubkey_ref.datalen = script_pubkey->arr_len;
11866         script_pubkey_ref.data = script_pubkey->elems;
11867         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
11868         FREE(script_pubkey);
11869 }
11870
11871 void  CS_LDK_Filter_register_output(int64_t this_arg, int64_t output) {
11872         void* this_arg_ptr = untag_ptr(this_arg);
11873         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11874         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11875         LDKWatchedOutput output_conv;
11876         output_conv.inner = untag_ptr(output);
11877         output_conv.is_owned = ptr_is_owned(output);
11878         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
11879         output_conv = WatchedOutput_clone(&output_conv);
11880         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
11881 }
11882
11883 uint32_t CS_LDK_LDKCOption_FilterZ_ty_from_ptr(int64_t ptr) {
11884         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
11885         switch(obj->tag) {
11886                 case LDKCOption_FilterZ_Some: return 0;
11887                 case LDKCOption_FilterZ_None: return 1;
11888                 default: abort();
11889         }
11890 }
11891 int64_t CS_LDK_LDKCOption_FilterZ_Some_get_some(int64_t ptr) {
11892         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
11893         CHECK(obj->tag == LDKCOption_FilterZ_Some);
11894         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
11895         *some_ret = obj->some;
11896                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
11897                         if ((*some_ret).free == LDKFilter_JCalls_free) {
11898                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11899                                 LDKFilter_JCalls_cloned(&(*some_ret));
11900                         }
11901         return tag_ptr(some_ret, true);
11902 }
11903 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11904         LDKLockedChannelMonitor ret = *owner->contents.result;
11905         ret.is_owned = false;
11906         return ret;
11907 }
11908 int64_t  CS_LDK_CResult_LockedChannelMonitorNoneZ_get_ok(int64_t owner) {
11909         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11910         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
11911         int64_t ret_ref = 0;
11912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11914         return ret_ref;
11915 }
11916
11917 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11918 CHECK(!owner->result_ok);
11919         return *owner->contents.err;
11920 }
11921 void  CS_LDK_CResult_LockedChannelMonitorNoneZ_get_err(int64_t owner) {
11922         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11923         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
11924 }
11925
11926 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
11927         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
11928         for (size_t i = 0; i < ret.datalen; i++) {
11929                 ret.data[i] = OutPoint_clone(&orig->data[i]);
11930         }
11931         return ret;
11932 }
11933 static inline LDKCVec_MonitorUpdateIdZ CVec_MonitorUpdateIdZ_clone(const LDKCVec_MonitorUpdateIdZ *orig) {
11934         LDKCVec_MonitorUpdateIdZ ret = { .data = MALLOC(sizeof(LDKMonitorUpdateId) * orig->datalen, "LDKCVec_MonitorUpdateIdZ clone bytes"), .datalen = orig->datalen };
11935         for (size_t i = 0; i < ret.datalen; i++) {
11936                 ret.data[i] = MonitorUpdateId_clone(&orig->data[i]);
11937         }
11938         return ret;
11939 }
11940 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11941         LDKOutPoint ret = owner->a;
11942         ret.is_owned = false;
11943         return ret;
11944 }
11945 int64_t  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(int64_t owner) {
11946         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11947         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(owner_conv);
11948         int64_t ret_ref = 0;
11949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11950         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11951         return ret_ref;
11952 }
11953
11954 static inline struct LDKCVec_MonitorUpdateIdZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11955         return CVec_MonitorUpdateIdZ_clone(&owner->b);
11956 }
11957 int64_tArray  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(int64_t owner) {
11958         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11959         LDKCVec_MonitorUpdateIdZ ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(owner_conv);
11960         int64_tArray ret_arr = NULL;
11961         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
11962         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
11963         for (size_t r = 0; r < ret_var.datalen; r++) {
11964                 LDKMonitorUpdateId ret_conv_17_var = ret_var.data[r];
11965                 int64_t ret_conv_17_ref = 0;
11966                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_17_var);
11967                 ret_conv_17_ref = tag_ptr(ret_conv_17_var.inner, ret_conv_17_var.is_owned);
11968                 ret_arr_ptr[r] = ret_conv_17_ref;
11969         }
11970         
11971         FREE(ret_var.data);
11972         return ret_arr;
11973 }
11974
11975 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ *orig) {
11976         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ clone bytes"), .datalen = orig->datalen };
11977         for (size_t i = 0; i < ret.datalen; i++) {
11978                 ret.data[i] = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(&orig->data[i]);
11979         }
11980         return ret;
11981 }
11982 typedef struct LDKKVStore_JCalls {
11983         atomic_size_t refcnt;
11984         uint32_t instance_ptr;
11985 } LDKKVStore_JCalls;
11986 static void LDKKVStore_JCalls_free(void* this_arg) {
11987         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
11988         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11989                 FREE(j_calls);
11990         }
11991 }
11992 LDKCResult_CVec_u8ZIOErrorZ read_LDKKVStore_jcall(const void* this_arg, LDKStr primary_namespace, LDKStr secondary_namespace, LDKStr key) {
11993         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
11994         LDKStr primary_namespace_str = primary_namespace;
11995         jstring primary_namespace_conv = str_ref_to_cs(primary_namespace_str.chars, primary_namespace_str.len);
11996         Str_free(primary_namespace_str);
11997         LDKStr secondary_namespace_str = secondary_namespace;
11998         jstring secondary_namespace_conv = str_ref_to_cs(secondary_namespace_str.chars, secondary_namespace_str.len);
11999         Str_free(secondary_namespace_str);
12000         LDKStr key_str = key;
12001         jstring key_conv = str_ref_to_cs(key_str.chars, key_str.len);
12002         Str_free(key_str);
12003         uint64_t ret = js_invoke_function_l_lll(j_calls->instance_ptr, 53, (int64_t)primary_namespace_conv, (int64_t)secondary_namespace_conv, (int64_t)key_conv);
12004         void* ret_ptr = untag_ptr(ret);
12005         CHECK_ACCESS(ret_ptr);
12006         LDKCResult_CVec_u8ZIOErrorZ ret_conv = *(LDKCResult_CVec_u8ZIOErrorZ*)(ret_ptr);
12007         FREE(untag_ptr(ret));
12008         return ret_conv;
12009 }
12010 LDKCResult_NoneIOErrorZ write_LDKKVStore_jcall(const void* this_arg, LDKStr primary_namespace, LDKStr secondary_namespace, LDKStr key, LDKu8slice buf) {
12011         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
12012         LDKStr primary_namespace_str = primary_namespace;
12013         jstring primary_namespace_conv = str_ref_to_cs(primary_namespace_str.chars, primary_namespace_str.len);
12014         Str_free(primary_namespace_str);
12015         LDKStr secondary_namespace_str = secondary_namespace;
12016         jstring secondary_namespace_conv = str_ref_to_cs(secondary_namespace_str.chars, secondary_namespace_str.len);
12017         Str_free(secondary_namespace_str);
12018         LDKStr key_str = key;
12019         jstring key_conv = str_ref_to_cs(key_str.chars, key_str.len);
12020         Str_free(key_str);
12021         LDKu8slice buf_var = buf;
12022         int8_tArray buf_arr = init_int8_tArray(buf_var.datalen, __LINE__);
12023         memcpy(buf_arr->elems, buf_var.data, buf_var.datalen);
12024         uint64_t ret = js_invoke_function_l_llll(j_calls->instance_ptr, 54, (int64_t)primary_namespace_conv, (int64_t)secondary_namespace_conv, (int64_t)key_conv, (int64_t)buf_arr);
12025         void* ret_ptr = untag_ptr(ret);
12026         CHECK_ACCESS(ret_ptr);
12027         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12028         FREE(untag_ptr(ret));
12029         return ret_conv;
12030 }
12031 LDKCResult_NoneIOErrorZ remove_LDKKVStore_jcall(const void* this_arg, LDKStr primary_namespace, LDKStr secondary_namespace, LDKStr key, bool lazy) {
12032         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
12033         LDKStr primary_namespace_str = primary_namespace;
12034         jstring primary_namespace_conv = str_ref_to_cs(primary_namespace_str.chars, primary_namespace_str.len);
12035         Str_free(primary_namespace_str);
12036         LDKStr secondary_namespace_str = secondary_namespace;
12037         jstring secondary_namespace_conv = str_ref_to_cs(secondary_namespace_str.chars, secondary_namespace_str.len);
12038         Str_free(secondary_namespace_str);
12039         LDKStr key_str = key;
12040         jstring key_conv = str_ref_to_cs(key_str.chars, key_str.len);
12041         Str_free(key_str);
12042         jboolean lazy_conv = lazy;
12043         uint64_t ret = js_invoke_function_l_lllb(j_calls->instance_ptr, 55, (int64_t)primary_namespace_conv, (int64_t)secondary_namespace_conv, (int64_t)key_conv, lazy_conv);
12044         void* ret_ptr = untag_ptr(ret);
12045         CHECK_ACCESS(ret_ptr);
12046         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12047         FREE(untag_ptr(ret));
12048         return ret_conv;
12049 }
12050 LDKCResult_CVec_StrZIOErrorZ list_LDKKVStore_jcall(const void* this_arg, LDKStr primary_namespace, LDKStr secondary_namespace) {
12051         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
12052         LDKStr primary_namespace_str = primary_namespace;
12053         jstring primary_namespace_conv = str_ref_to_cs(primary_namespace_str.chars, primary_namespace_str.len);
12054         Str_free(primary_namespace_str);
12055         LDKStr secondary_namespace_str = secondary_namespace;
12056         jstring secondary_namespace_conv = str_ref_to_cs(secondary_namespace_str.chars, secondary_namespace_str.len);
12057         Str_free(secondary_namespace_str);
12058         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 56, (int64_t)primary_namespace_conv, (int64_t)secondary_namespace_conv);
12059         void* ret_ptr = untag_ptr(ret);
12060         CHECK_ACCESS(ret_ptr);
12061         LDKCResult_CVec_StrZIOErrorZ ret_conv = *(LDKCResult_CVec_StrZIOErrorZ*)(ret_ptr);
12062         FREE(untag_ptr(ret));
12063         return ret_conv;
12064 }
12065 static void LDKKVStore_JCalls_cloned(LDKKVStore* new_obj) {
12066         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) new_obj->this_arg;
12067         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12068 }
12069 static inline LDKKVStore LDKKVStore_init (int64_t o) {
12070         LDKKVStore_JCalls *calls = MALLOC(sizeof(LDKKVStore_JCalls), "LDKKVStore_JCalls");
12071         atomic_init(&calls->refcnt, 1);
12072         calls->instance_ptr = o;
12073
12074         LDKKVStore ret = {
12075                 .this_arg = (void*) calls,
12076                 .read = read_LDKKVStore_jcall,
12077                 .write = write_LDKKVStore_jcall,
12078                 .remove = remove_LDKKVStore_jcall,
12079                 .list = list_LDKKVStore_jcall,
12080                 .free = LDKKVStore_JCalls_free,
12081         };
12082         return ret;
12083 }
12084 uint64_t  CS_LDK_LDKKVStore_new(int32_t o) {
12085         LDKKVStore *res_ptr = MALLOC(sizeof(LDKKVStore), "LDKKVStore");
12086         *res_ptr = LDKKVStore_init(o);
12087         return tag_ptr(res_ptr, true);
12088 }
12089 int64_t  CS_LDK_KVStore_read(int64_t this_arg, jstring primary_namespace, jstring secondary_namespace, jstring key) {
12090         void* this_arg_ptr = untag_ptr(this_arg);
12091         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12092         LDKKVStore* this_arg_conv = (LDKKVStore*)this_arg_ptr;
12093         LDKStr primary_namespace_conv = str_ref_to_owned_c(primary_namespace);
12094         LDKStr secondary_namespace_conv = str_ref_to_owned_c(secondary_namespace);
12095         LDKStr key_conv = str_ref_to_owned_c(key);
12096         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
12097         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, primary_namespace_conv, secondary_namespace_conv, key_conv);
12098         return tag_ptr(ret_conv, true);
12099 }
12100
12101 int64_t  CS_LDK_KVStore_write(int64_t this_arg, jstring primary_namespace, jstring secondary_namespace, jstring key, int8_tArray buf) {
12102         void* this_arg_ptr = untag_ptr(this_arg);
12103         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12104         LDKKVStore* this_arg_conv = (LDKKVStore*)this_arg_ptr;
12105         LDKStr primary_namespace_conv = str_ref_to_owned_c(primary_namespace);
12106         LDKStr secondary_namespace_conv = str_ref_to_owned_c(secondary_namespace);
12107         LDKStr key_conv = str_ref_to_owned_c(key);
12108         LDKu8slice buf_ref;
12109         buf_ref.datalen = buf->arr_len;
12110         buf_ref.data = buf->elems;
12111         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12112         *ret_conv = (this_arg_conv->write)(this_arg_conv->this_arg, primary_namespace_conv, secondary_namespace_conv, key_conv, buf_ref);
12113         FREE(buf);
12114         return tag_ptr(ret_conv, true);
12115 }
12116
12117 int64_t  CS_LDK_KVStore_remove(int64_t this_arg, jstring primary_namespace, jstring secondary_namespace, jstring key, jboolean lazy) {
12118         void* this_arg_ptr = untag_ptr(this_arg);
12119         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12120         LDKKVStore* this_arg_conv = (LDKKVStore*)this_arg_ptr;
12121         LDKStr primary_namespace_conv = str_ref_to_owned_c(primary_namespace);
12122         LDKStr secondary_namespace_conv = str_ref_to_owned_c(secondary_namespace);
12123         LDKStr key_conv = str_ref_to_owned_c(key);
12124         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12125         *ret_conv = (this_arg_conv->remove)(this_arg_conv->this_arg, primary_namespace_conv, secondary_namespace_conv, key_conv, lazy);
12126         return tag_ptr(ret_conv, true);
12127 }
12128
12129 int64_t  CS_LDK_KVStore_list(int64_t this_arg, jstring primary_namespace, jstring secondary_namespace) {
12130         void* this_arg_ptr = untag_ptr(this_arg);
12131         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12132         LDKKVStore* this_arg_conv = (LDKKVStore*)this_arg_ptr;
12133         LDKStr primary_namespace_conv = str_ref_to_owned_c(primary_namespace);
12134         LDKStr secondary_namespace_conv = str_ref_to_owned_c(secondary_namespace);
12135         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
12136         *ret_conv = (this_arg_conv->list)(this_arg_conv->this_arg, primary_namespace_conv, secondary_namespace_conv);
12137         return tag_ptr(ret_conv, true);
12138 }
12139
12140 typedef struct LDKPersister_JCalls {
12141         atomic_size_t refcnt;
12142         uint32_t instance_ptr;
12143 } LDKPersister_JCalls;
12144 static void LDKPersister_JCalls_free(void* this_arg) {
12145         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12146         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12147                 FREE(j_calls);
12148         }
12149 }
12150 LDKCResult_NoneIOErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
12151         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12152         LDKChannelManager channel_manager_var = *channel_manager;
12153         int64_t channel_manager_ref = 0;
12154         // WARNING: we may need a move here but no clone is available for LDKChannelManager
12155         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
12156         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
12157         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 57, channel_manager_ref);
12158         void* ret_ptr = untag_ptr(ret);
12159         CHECK_ACCESS(ret_ptr);
12160         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12161         FREE(untag_ptr(ret));
12162         return ret_conv;
12163 }
12164 LDKCResult_NoneIOErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
12165         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12166         LDKNetworkGraph network_graph_var = *network_graph;
12167         int64_t network_graph_ref = 0;
12168         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
12169         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
12170         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
12171         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 58, network_graph_ref);
12172         void* ret_ptr = untag_ptr(ret);
12173         CHECK_ACCESS(ret_ptr);
12174         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12175         FREE(untag_ptr(ret));
12176         return ret_conv;
12177 }
12178 LDKCResult_NoneIOErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
12179         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12180         // WARNING: This object doesn't live past this scope, needs clone!
12181         int64_t ret_scorer = tag_ptr(scorer, false);
12182         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 59, ret_scorer);
12183         void* ret_ptr = untag_ptr(ret);
12184         CHECK_ACCESS(ret_ptr);
12185         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12186         FREE(untag_ptr(ret));
12187         return ret_conv;
12188 }
12189 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
12190         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
12191         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12192 }
12193 static inline LDKPersister LDKPersister_init (int64_t o) {
12194         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
12195         atomic_init(&calls->refcnt, 1);
12196         calls->instance_ptr = o;
12197
12198         LDKPersister ret = {
12199                 .this_arg = (void*) calls,
12200                 .persist_manager = persist_manager_LDKPersister_jcall,
12201                 .persist_graph = persist_graph_LDKPersister_jcall,
12202                 .persist_scorer = persist_scorer_LDKPersister_jcall,
12203                 .free = LDKPersister_JCalls_free,
12204         };
12205         return ret;
12206 }
12207 uint64_t  CS_LDK_LDKPersister_new(int32_t o) {
12208         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
12209         *res_ptr = LDKPersister_init(o);
12210         return tag_ptr(res_ptr, true);
12211 }
12212 int64_t  CS_LDK_Persister_persist_manager(int64_t this_arg, int64_t channel_manager) {
12213         void* this_arg_ptr = untag_ptr(this_arg);
12214         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12215         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12216         LDKChannelManager channel_manager_conv;
12217         channel_manager_conv.inner = untag_ptr(channel_manager);
12218         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
12219         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
12220         channel_manager_conv.is_owned = false;
12221         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12222         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
12223         return tag_ptr(ret_conv, true);
12224 }
12225
12226 int64_t  CS_LDK_Persister_persist_graph(int64_t this_arg, int64_t network_graph) {
12227         void* this_arg_ptr = untag_ptr(this_arg);
12228         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12229         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12230         LDKNetworkGraph network_graph_conv;
12231         network_graph_conv.inner = untag_ptr(network_graph);
12232         network_graph_conv.is_owned = ptr_is_owned(network_graph);
12233         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
12234         network_graph_conv.is_owned = false;
12235         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12236         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
12237         return tag_ptr(ret_conv, true);
12238 }
12239
12240 int64_t  CS_LDK_Persister_persist_scorer(int64_t this_arg, int64_t scorer) {
12241         void* this_arg_ptr = untag_ptr(this_arg);
12242         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12243         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12244         void* scorer_ptr = untag_ptr(scorer);
12245         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
12246         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
12247         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12248         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
12249         return tag_ptr(ret_conv, true);
12250 }
12251
12252 typedef struct LDKPersist_JCalls {
12253         atomic_size_t refcnt;
12254         uint32_t instance_ptr;
12255 } LDKPersist_JCalls;
12256 static void LDKPersist_JCalls_free(void* this_arg) {
12257         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12258         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12259                 FREE(j_calls);
12260         }
12261 }
12262 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12263         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12264         LDKOutPoint channel_id_var = channel_id;
12265         int64_t channel_id_ref = 0;
12266         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12267         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12268         LDKChannelMonitor data_var = *data;
12269         int64_t data_ref = 0;
12270         data_var = ChannelMonitor_clone(&data_var);
12271         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12272         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12273         LDKMonitorUpdateId update_id_var = update_id;
12274         int64_t update_id_ref = 0;
12275         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12276         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12277         uint64_t ret = js_invoke_function_ChannelMonitorUpdateStatus_lll(j_calls->instance_ptr, 60, channel_id_ref, data_ref, update_id_ref);
12278         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_cs(ret);
12279         return ret_conv;
12280 }
12281 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, LDKChannelMonitorUpdate update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12282         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12283         LDKOutPoint channel_id_var = channel_id;
12284         int64_t channel_id_ref = 0;
12285         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12286         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12287         LDKChannelMonitorUpdate update_var = update;
12288         int64_t update_ref = 0;
12289         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
12290         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
12291         LDKChannelMonitor data_var = *data;
12292         int64_t data_ref = 0;
12293         data_var = ChannelMonitor_clone(&data_var);
12294         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12295         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12296         LDKMonitorUpdateId update_id_var = update_id;
12297         int64_t update_id_ref = 0;
12298         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12299         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12300         uint64_t ret = js_invoke_function_ChannelMonitorUpdateStatus_llll(j_calls->instance_ptr, 61, channel_id_ref, update_ref, data_ref, update_id_ref);
12301         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_cs(ret);
12302         return ret_conv;
12303 }
12304 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
12305         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
12306         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12307 }
12308 static inline LDKPersist LDKPersist_init (int64_t o) {
12309         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
12310         atomic_init(&calls->refcnt, 1);
12311         calls->instance_ptr = o;
12312
12313         LDKPersist ret = {
12314                 .this_arg = (void*) calls,
12315                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
12316                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
12317                 .free = LDKPersist_JCalls_free,
12318         };
12319         return ret;
12320 }
12321 uint64_t  CS_LDK_LDKPersist_new(int32_t o) {
12322         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
12323         *res_ptr = LDKPersist_init(o);
12324         return tag_ptr(res_ptr, true);
12325 }
12326 int32_t  CS_LDK_Persist_persist_new_channel(int64_t this_arg, int64_t channel_id, int64_t data, int64_t update_id) {
12327         void* this_arg_ptr = untag_ptr(this_arg);
12328         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12329         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12330         LDKOutPoint channel_id_conv;
12331         channel_id_conv.inner = untag_ptr(channel_id);
12332         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12333         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12334         channel_id_conv = OutPoint_clone(&channel_id_conv);
12335         LDKChannelMonitor data_conv;
12336         data_conv.inner = untag_ptr(data);
12337         data_conv.is_owned = ptr_is_owned(data);
12338         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12339         data_conv.is_owned = false;
12340         LDKMonitorUpdateId update_id_conv;
12341         update_id_conv.inner = untag_ptr(update_id);
12342         update_id_conv.is_owned = ptr_is_owned(update_id);
12343         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12344         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12345         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));
12346         return ret_conv;
12347 }
12348
12349 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) {
12350         void* this_arg_ptr = untag_ptr(this_arg);
12351         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12352         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12353         LDKOutPoint channel_id_conv;
12354         channel_id_conv.inner = untag_ptr(channel_id);
12355         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12356         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12357         channel_id_conv = OutPoint_clone(&channel_id_conv);
12358         LDKChannelMonitorUpdate update_conv;
12359         update_conv.inner = untag_ptr(update);
12360         update_conv.is_owned = ptr_is_owned(update);
12361         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
12362         update_conv = ChannelMonitorUpdate_clone(&update_conv);
12363         LDKChannelMonitor data_conv;
12364         data_conv.inner = untag_ptr(data);
12365         data_conv.is_owned = ptr_is_owned(data);
12366         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12367         data_conv.is_owned = false;
12368         LDKMonitorUpdateId update_id_conv;
12369         update_id_conv.inner = untag_ptr(update_id);
12370         update_id_conv.is_owned = ptr_is_owned(update_id);
12371         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12372         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12373         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));
12374         return ret_conv;
12375 }
12376
12377 typedef struct LDKFutureCallback_JCalls {
12378         atomic_size_t refcnt;
12379         uint32_t instance_ptr;
12380 } LDKFutureCallback_JCalls;
12381 static void LDKFutureCallback_JCalls_free(void* this_arg) {
12382         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12383         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12384                 FREE(j_calls);
12385         }
12386 }
12387 void call_LDKFutureCallback_jcall(const void* this_arg) {
12388         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12389         js_invoke_function_void_(j_calls->instance_ptr, 62);
12390 }
12391 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
12392         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
12393         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12394 }
12395 static inline LDKFutureCallback LDKFutureCallback_init (int64_t o) {
12396         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
12397         atomic_init(&calls->refcnt, 1);
12398         calls->instance_ptr = o;
12399
12400         LDKFutureCallback ret = {
12401                 .this_arg = (void*) calls,
12402                 .call = call_LDKFutureCallback_jcall,
12403                 .free = LDKFutureCallback_JCalls_free,
12404         };
12405         return ret;
12406 }
12407 uint64_t  CS_LDK_LDKFutureCallback_new(int32_t o) {
12408         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
12409         *res_ptr = LDKFutureCallback_init(o);
12410         return tag_ptr(res_ptr, true);
12411 }
12412 void  CS_LDK_FutureCallback_call(int64_t this_arg) {
12413         void* this_arg_ptr = untag_ptr(this_arg);
12414         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12415         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
12416         (this_arg_conv->call)(this_arg_conv->this_arg);
12417 }
12418
12419 typedef struct LDKListen_JCalls {
12420         atomic_size_t refcnt;
12421         uint32_t instance_ptr;
12422 } LDKListen_JCalls;
12423 static void LDKListen_JCalls_free(void* this_arg) {
12424         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12425         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12426                 FREE(j_calls);
12427         }
12428 }
12429 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12430         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12431         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
12432         memcpy(header_arr->elems, *header, 80);
12433         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12434         int64_tArray txdata_arr = NULL;
12435         txdata_arr = init_int64_tArray(txdata_var.datalen, __LINE__);
12436         int64_t *txdata_arr_ptr = (int64_t*)(((uint8_t*)txdata_arr) + 8);
12437         for (size_t c = 0; c < txdata_var.datalen; c++) {
12438                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12439                 *txdata_conv_28_conv = txdata_var.data[c];
12440                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12441         }
12442         
12443         FREE(txdata_var.data);
12444         int32_t height_conv = height;
12445         js_invoke_function_void_lli(j_calls->instance_ptr, 63, (int64_t)header_arr, (int64_t)txdata_arr, height_conv);
12446 }
12447 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
12448         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12449         LDKu8slice block_var = block;
12450         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
12451         memcpy(block_arr->elems, block_var.data, block_var.datalen);
12452         int32_t height_conv = height;
12453         js_invoke_function_void_li(j_calls->instance_ptr, 64, (int64_t)block_arr, height_conv);
12454 }
12455 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12456         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12457         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
12458         memcpy(header_arr->elems, *header, 80);
12459         int32_t height_conv = height;
12460         js_invoke_function_void_li(j_calls->instance_ptr, 65, (int64_t)header_arr, height_conv);
12461 }
12462 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
12463         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
12464         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12465 }
12466 static inline LDKListen LDKListen_init (int64_t o) {
12467         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
12468         atomic_init(&calls->refcnt, 1);
12469         calls->instance_ptr = o;
12470
12471         LDKListen ret = {
12472                 .this_arg = (void*) calls,
12473                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
12474                 .block_connected = block_connected_LDKListen_jcall,
12475                 .block_disconnected = block_disconnected_LDKListen_jcall,
12476                 .free = LDKListen_JCalls_free,
12477         };
12478         return ret;
12479 }
12480 uint64_t  CS_LDK_LDKListen_new(int32_t o) {
12481         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
12482         *res_ptr = LDKListen_init(o);
12483         return tag_ptr(res_ptr, true);
12484 }
12485 void  CS_LDK_Listen_filtered_block_connected(int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
12486         void* this_arg_ptr = untag_ptr(this_arg);
12487         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12488         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12489         uint8_t header_arr[80];
12490         CHECK(header->arr_len == 80);
12491         memcpy(header_arr, header->elems, 80); FREE(header);
12492         uint8_t (*header_ref)[80] = &header_arr;
12493         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12494         txdata_constr.datalen = txdata->arr_len;
12495         if (txdata_constr.datalen > 0)
12496                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12497         else
12498                 txdata_constr.data = NULL;
12499         int64_t* txdata_vals = txdata->elems;
12500         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12501                 int64_t txdata_conv_28 = txdata_vals[c];
12502                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12503                 CHECK_ACCESS(txdata_conv_28_ptr);
12504                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12505                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12506                 txdata_constr.data[c] = txdata_conv_28_conv;
12507         }
12508         FREE(txdata);
12509         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12510 }
12511
12512 void  CS_LDK_Listen_block_connected(int64_t this_arg, int8_tArray block, int32_t height) {
12513         void* this_arg_ptr = untag_ptr(this_arg);
12514         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12515         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12516         LDKu8slice block_ref;
12517         block_ref.datalen = block->arr_len;
12518         block_ref.data = block->elems;
12519         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
12520         FREE(block);
12521 }
12522
12523 void  CS_LDK_Listen_block_disconnected(int64_t this_arg, int8_tArray header, int32_t height) {
12524         void* this_arg_ptr = untag_ptr(this_arg);
12525         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12526         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12527         uint8_t header_arr[80];
12528         CHECK(header->arr_len == 80);
12529         memcpy(header_arr, header->elems, 80); FREE(header);
12530         uint8_t (*header_ref)[80] = &header_arr;
12531         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
12532 }
12533
12534 typedef struct LDKConfirm_JCalls {
12535         atomic_size_t refcnt;
12536         uint32_t instance_ptr;
12537 } LDKConfirm_JCalls;
12538 static void LDKConfirm_JCalls_free(void* this_arg) {
12539         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12540         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12541                 FREE(j_calls);
12542         }
12543 }
12544 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12545         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12546         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
12547         memcpy(header_arr->elems, *header, 80);
12548         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12549         int64_tArray txdata_arr = NULL;
12550         txdata_arr = init_int64_tArray(txdata_var.datalen, __LINE__);
12551         int64_t *txdata_arr_ptr = (int64_t*)(((uint8_t*)txdata_arr) + 8);
12552         for (size_t c = 0; c < txdata_var.datalen; c++) {
12553                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12554                 *txdata_conv_28_conv = txdata_var.data[c];
12555                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12556         }
12557         
12558         FREE(txdata_var.data);
12559         int32_t height_conv = height;
12560         js_invoke_function_void_lli(j_calls->instance_ptr, 66, (int64_t)header_arr, (int64_t)txdata_arr, height_conv);
12561 }
12562 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
12563         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12564         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
12565         memcpy(txid_arr->elems, *txid, 32);
12566         js_invoke_function_void_l(j_calls->instance_ptr, 67, (int64_t)txid_arr);
12567 }
12568 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12569         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12570         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
12571         memcpy(header_arr->elems, *header, 80);
12572         int32_t height_conv = height;
12573         js_invoke_function_void_li(j_calls->instance_ptr, 68, (int64_t)header_arr, height_conv);
12574 }
12575 LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
12576         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12577         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 69);
12578         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ ret_constr;
12579         ret_constr.datalen = ret->arr_len;
12580         if (ret_constr.datalen > 0)
12581                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ Elements");
12582         else
12583                 ret_constr.data = NULL;
12584         int64_t* ret_vals = ret->elems;
12585         for (size_t x = 0; x < ret_constr.datalen; x++) {
12586                 int64_t ret_conv_49 = ret_vals[x];
12587                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
12588                 CHECK_ACCESS(ret_conv_49_ptr);
12589                 LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ ret_conv_49_conv = *(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)(ret_conv_49_ptr);
12590                 FREE(untag_ptr(ret_conv_49));
12591                 ret_constr.data[x] = ret_conv_49_conv;
12592         }
12593         FREE(ret);
12594         return ret_constr;
12595 }
12596 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
12597         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
12598         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12599 }
12600 static inline LDKConfirm LDKConfirm_init (int64_t o) {
12601         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
12602         atomic_init(&calls->refcnt, 1);
12603         calls->instance_ptr = o;
12604
12605         LDKConfirm ret = {
12606                 .this_arg = (void*) calls,
12607                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
12608                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
12609                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
12610                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
12611                 .free = LDKConfirm_JCalls_free,
12612         };
12613         return ret;
12614 }
12615 uint64_t  CS_LDK_LDKConfirm_new(int32_t o) {
12616         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
12617         *res_ptr = LDKConfirm_init(o);
12618         return tag_ptr(res_ptr, true);
12619 }
12620 void  CS_LDK_Confirm_transactions_confirmed(int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
12621         void* this_arg_ptr = untag_ptr(this_arg);
12622         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12623         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12624         uint8_t header_arr[80];
12625         CHECK(header->arr_len == 80);
12626         memcpy(header_arr, header->elems, 80); FREE(header);
12627         uint8_t (*header_ref)[80] = &header_arr;
12628         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12629         txdata_constr.datalen = txdata->arr_len;
12630         if (txdata_constr.datalen > 0)
12631                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12632         else
12633                 txdata_constr.data = NULL;
12634         int64_t* txdata_vals = txdata->elems;
12635         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12636                 int64_t txdata_conv_28 = txdata_vals[c];
12637                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12638                 CHECK_ACCESS(txdata_conv_28_ptr);
12639                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12640                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12641                 txdata_constr.data[c] = txdata_conv_28_conv;
12642         }
12643         FREE(txdata);
12644         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12645 }
12646
12647 void  CS_LDK_Confirm_transaction_unconfirmed(int64_t this_arg, int8_tArray txid) {
12648         void* this_arg_ptr = untag_ptr(this_arg);
12649         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12650         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12651         uint8_t txid_arr[32];
12652         CHECK(txid->arr_len == 32);
12653         memcpy(txid_arr, txid->elems, 32); FREE(txid);
12654         uint8_t (*txid_ref)[32] = &txid_arr;
12655         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
12656 }
12657
12658 void  CS_LDK_Confirm_best_block_updated(int64_t this_arg, int8_tArray header, int32_t height) {
12659         void* this_arg_ptr = untag_ptr(this_arg);
12660         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12661         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12662         uint8_t header_arr[80];
12663         CHECK(header->arr_len == 80);
12664         memcpy(header_arr, header->elems, 80); FREE(header);
12665         uint8_t (*header_ref)[80] = &header_arr;
12666         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
12667 }
12668
12669 int64_tArray  CS_LDK_Confirm_get_relevant_txids(int64_t this_arg) {
12670         void* this_arg_ptr = untag_ptr(this_arg);
12671         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12672         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12673         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
12674         int64_tArray ret_arr = NULL;
12675         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
12676         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
12677         for (size_t x = 0; x < ret_var.datalen; x++) {
12678                 LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
12679                 *ret_conv_49_conv = ret_var.data[x];
12680                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
12681         }
12682         
12683         FREE(ret_var.data);
12684         return ret_arr;
12685 }
12686
12687 typedef struct LDKEventHandler_JCalls {
12688         atomic_size_t refcnt;
12689         uint32_t instance_ptr;
12690 } LDKEventHandler_JCalls;
12691 static void LDKEventHandler_JCalls_free(void* this_arg) {
12692         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
12693         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12694                 FREE(j_calls);
12695         }
12696 }
12697 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
12698         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
12699         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12700         *event_copy = event;
12701         int64_t event_ref = tag_ptr(event_copy, true);
12702         js_invoke_function_void_l(j_calls->instance_ptr, 70, event_ref);
12703 }
12704 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
12705         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
12706         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12707 }
12708 static inline LDKEventHandler LDKEventHandler_init (int64_t o) {
12709         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
12710         atomic_init(&calls->refcnt, 1);
12711         calls->instance_ptr = o;
12712
12713         LDKEventHandler ret = {
12714                 .this_arg = (void*) calls,
12715                 .handle_event = handle_event_LDKEventHandler_jcall,
12716                 .free = LDKEventHandler_JCalls_free,
12717         };
12718         return ret;
12719 }
12720 uint64_t  CS_LDK_LDKEventHandler_new(int32_t o) {
12721         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12722         *res_ptr = LDKEventHandler_init(o);
12723         return tag_ptr(res_ptr, true);
12724 }
12725 void  CS_LDK_EventHandler_handle_event(int64_t this_arg, int64_t event) {
12726         void* this_arg_ptr = untag_ptr(this_arg);
12727         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12728         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
12729         void* event_ptr = untag_ptr(event);
12730         CHECK_ACCESS(event_ptr);
12731         LDKEvent event_conv = *(LDKEvent*)(event_ptr);
12732         event_conv = Event_clone((LDKEvent*)untag_ptr(event));
12733         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
12734 }
12735
12736 typedef struct LDKEventsProvider_JCalls {
12737         atomic_size_t refcnt;
12738         uint32_t instance_ptr;
12739 } LDKEventsProvider_JCalls;
12740 static void LDKEventsProvider_JCalls_free(void* this_arg) {
12741         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12742         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12743                 FREE(j_calls);
12744         }
12745 }
12746 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
12747         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12748         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12749         *handler_ret = handler;
12750         js_invoke_function_void_l(j_calls->instance_ptr, 71, tag_ptr(handler_ret, true));
12751 }
12752 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
12753         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
12754         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12755 }
12756 static inline LDKEventsProvider LDKEventsProvider_init (int64_t o) {
12757         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
12758         atomic_init(&calls->refcnt, 1);
12759         calls->instance_ptr = o;
12760
12761         LDKEventsProvider ret = {
12762                 .this_arg = (void*) calls,
12763                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
12764                 .free = LDKEventsProvider_JCalls_free,
12765         };
12766         return ret;
12767 }
12768 uint64_t  CS_LDK_LDKEventsProvider_new(int32_t o) {
12769         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12770         *res_ptr = LDKEventsProvider_init(o);
12771         return tag_ptr(res_ptr, true);
12772 }
12773 void  CS_LDK_EventsProvider_process_pending_events(int64_t this_arg, int64_t handler) {
12774         void* this_arg_ptr = untag_ptr(this_arg);
12775         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12776         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
12777         void* handler_ptr = untag_ptr(handler);
12778         CHECK_ACCESS(handler_ptr);
12779         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
12780         if (handler_conv.free == LDKEventHandler_JCalls_free) {
12781                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12782                 LDKEventHandler_JCalls_cloned(&handler_conv);
12783         }
12784         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
12785 }
12786
12787 uint32_t CS_LDK_LDKFailureCode_ty_from_ptr(int64_t ptr) {
12788         LDKFailureCode *obj = (LDKFailureCode*)untag_ptr(ptr);
12789         switch(obj->tag) {
12790                 case LDKFailureCode_TemporaryNodeFailure: return 0;
12791                 case LDKFailureCode_RequiredNodeFeatureMissing: return 1;
12792                 case LDKFailureCode_IncorrectOrUnknownPaymentDetails: return 2;
12793                 case LDKFailureCode_InvalidOnionPayload: return 3;
12794                 default: abort();
12795         }
12796 }
12797 int64_t CS_LDK_LDKFailureCode_InvalidOnionPayload_get_invalid_onion_payload(int64_t ptr) {
12798         LDKFailureCode *obj = (LDKFailureCode*)untag_ptr(ptr);
12799         CHECK(obj->tag == LDKFailureCode_InvalidOnionPayload);
12800         int64_t invalid_onion_payload_ref = tag_ptr(&obj->invalid_onion_payload, false);
12801         return invalid_onion_payload_ref;
12802 }
12803 typedef struct LDKMessageSendEventsProvider_JCalls {
12804         atomic_size_t refcnt;
12805         uint32_t instance_ptr;
12806 } LDKMessageSendEventsProvider_JCalls;
12807 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
12808         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
12809         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12810                 FREE(j_calls);
12811         }
12812 }
12813 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
12814         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
12815         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 72);
12816         LDKCVec_MessageSendEventZ ret_constr;
12817         ret_constr.datalen = ret->arr_len;
12818         if (ret_constr.datalen > 0)
12819                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12820         else
12821                 ret_constr.data = NULL;
12822         int64_t* ret_vals = ret->elems;
12823         for (size_t s = 0; s < ret_constr.datalen; s++) {
12824                 int64_t ret_conv_18 = ret_vals[s];
12825                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
12826                 CHECK_ACCESS(ret_conv_18_ptr);
12827                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
12828                 FREE(untag_ptr(ret_conv_18));
12829                 ret_constr.data[s] = ret_conv_18_conv;
12830         }
12831         FREE(ret);
12832         return ret_constr;
12833 }
12834 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
12835         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
12836         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12837 }
12838 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (int64_t o) {
12839         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
12840         atomic_init(&calls->refcnt, 1);
12841         calls->instance_ptr = o;
12842
12843         LDKMessageSendEventsProvider ret = {
12844                 .this_arg = (void*) calls,
12845                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
12846                 .free = LDKMessageSendEventsProvider_JCalls_free,
12847         };
12848         return ret;
12849 }
12850 uint64_t  CS_LDK_LDKMessageSendEventsProvider_new(int32_t o) {
12851         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
12852         *res_ptr = LDKMessageSendEventsProvider_init(o);
12853         return tag_ptr(res_ptr, true);
12854 }
12855 int64_tArray  CS_LDK_MessageSendEventsProvider_get_and_clear_pending_msg_events(int64_t this_arg) {
12856         void* this_arg_ptr = untag_ptr(this_arg);
12857         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12858         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
12859         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
12860         int64_tArray ret_arr = NULL;
12861         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
12862         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
12863         for (size_t s = 0; s < ret_var.datalen; s++) {
12864                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12865                 *ret_conv_18_copy = ret_var.data[s];
12866                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
12867                 ret_arr_ptr[s] = ret_conv_18_ref;
12868         }
12869         
12870         FREE(ret_var.data);
12871         return ret_arr;
12872 }
12873
12874 typedef struct LDKChannelMessageHandler_JCalls {
12875         atomic_size_t refcnt;
12876         uint32_t instance_ptr;
12877         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12878 } LDKChannelMessageHandler_JCalls;
12879 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
12880         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12881         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12882                 FREE(j_calls);
12883         }
12884 }
12885 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKOpenChannel * msg) {
12886         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12887         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12888         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12889         LDKOpenChannel msg_var = *msg;
12890         int64_t msg_ref = 0;
12891         msg_var = OpenChannel_clone(&msg_var);
12892         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12893         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12894         js_invoke_function_void_ll(j_calls->instance_ptr, 73, (int64_t)their_node_id_arr, msg_ref);
12895 }
12896 void handle_open_channel_v2_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKOpenChannelV2 * msg) {
12897         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12898         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12899         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12900         LDKOpenChannelV2 msg_var = *msg;
12901         int64_t msg_ref = 0;
12902         msg_var = OpenChannelV2_clone(&msg_var);
12903         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12904         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12905         js_invoke_function_void_ll(j_calls->instance_ptr, 74, (int64_t)their_node_id_arr, msg_ref);
12906 }
12907 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAcceptChannel * msg) {
12908         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12909         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12910         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12911         LDKAcceptChannel msg_var = *msg;
12912         int64_t msg_ref = 0;
12913         msg_var = AcceptChannel_clone(&msg_var);
12914         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12915         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12916         js_invoke_function_void_ll(j_calls->instance_ptr, 75, (int64_t)their_node_id_arr, msg_ref);
12917 }
12918 void handle_accept_channel_v2_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAcceptChannelV2 * msg) {
12919         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12920         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12921         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12922         LDKAcceptChannelV2 msg_var = *msg;
12923         int64_t msg_ref = 0;
12924         msg_var = AcceptChannelV2_clone(&msg_var);
12925         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12926         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12927         js_invoke_function_void_ll(j_calls->instance_ptr, 76, (int64_t)their_node_id_arr, msg_ref);
12928 }
12929 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
12930         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12931         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12932         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12933         LDKFundingCreated msg_var = *msg;
12934         int64_t msg_ref = 0;
12935         msg_var = FundingCreated_clone(&msg_var);
12936         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12937         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12938         js_invoke_function_void_ll(j_calls->instance_ptr, 77, (int64_t)their_node_id_arr, msg_ref);
12939 }
12940 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
12941         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12942         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12943         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12944         LDKFundingSigned msg_var = *msg;
12945         int64_t msg_ref = 0;
12946         msg_var = FundingSigned_clone(&msg_var);
12947         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12948         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12949         js_invoke_function_void_ll(j_calls->instance_ptr, 78, (int64_t)their_node_id_arr, msg_ref);
12950 }
12951 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
12952         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12953         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12954         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12955         LDKChannelReady msg_var = *msg;
12956         int64_t msg_ref = 0;
12957         msg_var = ChannelReady_clone(&msg_var);
12958         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12959         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12960         js_invoke_function_void_ll(j_calls->instance_ptr, 79, (int64_t)their_node_id_arr, msg_ref);
12961 }
12962 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
12963         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12964         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12965         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12966         LDKShutdown msg_var = *msg;
12967         int64_t msg_ref = 0;
12968         msg_var = Shutdown_clone(&msg_var);
12969         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12970         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12971         js_invoke_function_void_ll(j_calls->instance_ptr, 80, (int64_t)their_node_id_arr, msg_ref);
12972 }
12973 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12974         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12975         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12976         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12977         LDKClosingSigned msg_var = *msg;
12978         int64_t msg_ref = 0;
12979         msg_var = ClosingSigned_clone(&msg_var);
12980         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12981         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12982         js_invoke_function_void_ll(j_calls->instance_ptr, 81, (int64_t)their_node_id_arr, msg_ref);
12983 }
12984 void handle_tx_add_input_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxAddInput * msg) {
12985         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12986         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12987         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12988         LDKTxAddInput msg_var = *msg;
12989         int64_t msg_ref = 0;
12990         msg_var = TxAddInput_clone(&msg_var);
12991         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12992         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12993         js_invoke_function_void_ll(j_calls->instance_ptr, 82, (int64_t)their_node_id_arr, msg_ref);
12994 }
12995 void handle_tx_add_output_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxAddOutput * msg) {
12996         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12997         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12998         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12999         LDKTxAddOutput msg_var = *msg;
13000         int64_t msg_ref = 0;
13001         msg_var = TxAddOutput_clone(&msg_var);
13002         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13003         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13004         js_invoke_function_void_ll(j_calls->instance_ptr, 83, (int64_t)their_node_id_arr, msg_ref);
13005 }
13006 void handle_tx_remove_input_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxRemoveInput * msg) {
13007         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13008         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13009         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13010         LDKTxRemoveInput msg_var = *msg;
13011         int64_t msg_ref = 0;
13012         msg_var = TxRemoveInput_clone(&msg_var);
13013         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13014         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13015         js_invoke_function_void_ll(j_calls->instance_ptr, 84, (int64_t)their_node_id_arr, msg_ref);
13016 }
13017 void handle_tx_remove_output_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxRemoveOutput * msg) {
13018         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13019         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13020         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13021         LDKTxRemoveOutput msg_var = *msg;
13022         int64_t msg_ref = 0;
13023         msg_var = TxRemoveOutput_clone(&msg_var);
13024         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13025         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13026         js_invoke_function_void_ll(j_calls->instance_ptr, 85, (int64_t)their_node_id_arr, msg_ref);
13027 }
13028 void handle_tx_complete_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxComplete * msg) {
13029         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13030         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13031         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13032         LDKTxComplete msg_var = *msg;
13033         int64_t msg_ref = 0;
13034         msg_var = TxComplete_clone(&msg_var);
13035         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13036         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13037         js_invoke_function_void_ll(j_calls->instance_ptr, 86, (int64_t)their_node_id_arr, msg_ref);
13038 }
13039 void handle_tx_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxSignatures * msg) {
13040         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13041         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13042         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13043         LDKTxSignatures msg_var = *msg;
13044         int64_t msg_ref = 0;
13045         msg_var = TxSignatures_clone(&msg_var);
13046         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13047         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13048         js_invoke_function_void_ll(j_calls->instance_ptr, 87, (int64_t)their_node_id_arr, msg_ref);
13049 }
13050 void handle_tx_init_rbf_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxInitRbf * msg) {
13051         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13052         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13053         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13054         LDKTxInitRbf msg_var = *msg;
13055         int64_t msg_ref = 0;
13056         msg_var = TxInitRbf_clone(&msg_var);
13057         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13058         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13059         js_invoke_function_void_ll(j_calls->instance_ptr, 88, (int64_t)their_node_id_arr, msg_ref);
13060 }
13061 void handle_tx_ack_rbf_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxAckRbf * msg) {
13062         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13063         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13064         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13065         LDKTxAckRbf msg_var = *msg;
13066         int64_t msg_ref = 0;
13067         msg_var = TxAckRbf_clone(&msg_var);
13068         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13069         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13070         js_invoke_function_void_ll(j_calls->instance_ptr, 89, (int64_t)their_node_id_arr, msg_ref);
13071 }
13072 void handle_tx_abort_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxAbort * msg) {
13073         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13074         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13075         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13076         LDKTxAbort msg_var = *msg;
13077         int64_t msg_ref = 0;
13078         msg_var = TxAbort_clone(&msg_var);
13079         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13080         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13081         js_invoke_function_void_ll(j_calls->instance_ptr, 90, (int64_t)their_node_id_arr, msg_ref);
13082 }
13083 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
13084         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13085         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13086         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13087         LDKUpdateAddHTLC msg_var = *msg;
13088         int64_t msg_ref = 0;
13089         msg_var = UpdateAddHTLC_clone(&msg_var);
13090         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13091         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13092         js_invoke_function_void_ll(j_calls->instance_ptr, 91, (int64_t)their_node_id_arr, msg_ref);
13093 }
13094 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
13095         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13096         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13097         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13098         LDKUpdateFulfillHTLC msg_var = *msg;
13099         int64_t msg_ref = 0;
13100         msg_var = UpdateFulfillHTLC_clone(&msg_var);
13101         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13102         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13103         js_invoke_function_void_ll(j_calls->instance_ptr, 92, (int64_t)their_node_id_arr, msg_ref);
13104 }
13105 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
13106         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13107         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13108         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13109         LDKUpdateFailHTLC msg_var = *msg;
13110         int64_t msg_ref = 0;
13111         msg_var = UpdateFailHTLC_clone(&msg_var);
13112         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13113         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13114         js_invoke_function_void_ll(j_calls->instance_ptr, 93, (int64_t)their_node_id_arr, msg_ref);
13115 }
13116 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
13117         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13118         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13119         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13120         LDKUpdateFailMalformedHTLC msg_var = *msg;
13121         int64_t msg_ref = 0;
13122         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
13123         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13124         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13125         js_invoke_function_void_ll(j_calls->instance_ptr, 94, (int64_t)their_node_id_arr, msg_ref);
13126 }
13127 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
13128         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13129         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13130         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13131         LDKCommitmentSigned msg_var = *msg;
13132         int64_t msg_ref = 0;
13133         msg_var = CommitmentSigned_clone(&msg_var);
13134         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13135         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13136         js_invoke_function_void_ll(j_calls->instance_ptr, 95, (int64_t)their_node_id_arr, msg_ref);
13137 }
13138 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
13139         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13140         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13141         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13142         LDKRevokeAndACK msg_var = *msg;
13143         int64_t msg_ref = 0;
13144         msg_var = RevokeAndACK_clone(&msg_var);
13145         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13146         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13147         js_invoke_function_void_ll(j_calls->instance_ptr, 96, (int64_t)their_node_id_arr, msg_ref);
13148 }
13149 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
13150         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13151         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13152         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13153         LDKUpdateFee msg_var = *msg;
13154         int64_t msg_ref = 0;
13155         msg_var = UpdateFee_clone(&msg_var);
13156         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13157         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13158         js_invoke_function_void_ll(j_calls->instance_ptr, 97, (int64_t)their_node_id_arr, msg_ref);
13159 }
13160 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
13161         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13162         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13163         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13164         LDKAnnouncementSignatures msg_var = *msg;
13165         int64_t msg_ref = 0;
13166         msg_var = AnnouncementSignatures_clone(&msg_var);
13167         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13168         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13169         js_invoke_function_void_ll(j_calls->instance_ptr, 98, (int64_t)their_node_id_arr, msg_ref);
13170 }
13171 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13172         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13173         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13174         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13175         js_invoke_function_void_l(j_calls->instance_ptr, 99, (int64_t)their_node_id_arr);
13176 }
13177 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg, bool inbound) {
13178         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13179         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13180         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13181         LDKInit msg_var = *msg;
13182         int64_t msg_ref = 0;
13183         msg_var = Init_clone(&msg_var);
13184         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13185         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13186         jboolean inbound_conv = inbound;
13187         uint64_t ret = js_invoke_function_l_llb(j_calls->instance_ptr, 100, (int64_t)their_node_id_arr, msg_ref, inbound_conv);
13188         void* ret_ptr = untag_ptr(ret);
13189         CHECK_ACCESS(ret_ptr);
13190         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13191         FREE(untag_ptr(ret));
13192         return ret_conv;
13193 }
13194 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
13195         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13196         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13197         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13198         LDKChannelReestablish msg_var = *msg;
13199         int64_t msg_ref = 0;
13200         msg_var = ChannelReestablish_clone(&msg_var);
13201         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13202         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13203         js_invoke_function_void_ll(j_calls->instance_ptr, 101, (int64_t)their_node_id_arr, msg_ref);
13204 }
13205 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
13206         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13207         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13208         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13209         LDKChannelUpdate msg_var = *msg;
13210         int64_t msg_ref = 0;
13211         msg_var = ChannelUpdate_clone(&msg_var);
13212         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13213         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13214         js_invoke_function_void_ll(j_calls->instance_ptr, 102, (int64_t)their_node_id_arr, msg_ref);
13215 }
13216 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
13217         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13218         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13219         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13220         LDKErrorMessage msg_var = *msg;
13221         int64_t msg_ref = 0;
13222         msg_var = ErrorMessage_clone(&msg_var);
13223         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13224         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13225         js_invoke_function_void_ll(j_calls->instance_ptr, 103, (int64_t)their_node_id_arr, msg_ref);
13226 }
13227 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
13228         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13229         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 104);
13230         LDKNodeFeatures ret_conv;
13231         ret_conv.inner = untag_ptr(ret);
13232         ret_conv.is_owned = ptr_is_owned(ret);
13233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13234         return ret_conv;
13235 }
13236 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13237         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13238         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13239         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13240         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 105, (int64_t)their_node_id_arr);
13241         LDKInitFeatures ret_conv;
13242         ret_conv.inner = untag_ptr(ret);
13243         ret_conv.is_owned = ptr_is_owned(ret);
13244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13245         return ret_conv;
13246 }
13247 LDKCOption_CVec_ThirtyTwoBytesZZ get_chain_hashes_LDKChannelMessageHandler_jcall(const void* this_arg) {
13248         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13249         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 106);
13250         void* ret_ptr = untag_ptr(ret);
13251         CHECK_ACCESS(ret_ptr);
13252         LDKCOption_CVec_ThirtyTwoBytesZZ ret_conv = *(LDKCOption_CVec_ThirtyTwoBytesZZ*)(ret_ptr);
13253         FREE(untag_ptr(ret));
13254         return ret_conv;
13255 }
13256 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
13257         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
13258         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13259         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13260 }
13261 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (int64_t o, int64_t MessageSendEventsProvider) {
13262         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
13263         atomic_init(&calls->refcnt, 1);
13264         calls->instance_ptr = o;
13265
13266         LDKChannelMessageHandler ret = {
13267                 .this_arg = (void*) calls,
13268                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
13269                 .handle_open_channel_v2 = handle_open_channel_v2_LDKChannelMessageHandler_jcall,
13270                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
13271                 .handle_accept_channel_v2 = handle_accept_channel_v2_LDKChannelMessageHandler_jcall,
13272                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
13273                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
13274                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
13275                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
13276                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
13277                 .handle_tx_add_input = handle_tx_add_input_LDKChannelMessageHandler_jcall,
13278                 .handle_tx_add_output = handle_tx_add_output_LDKChannelMessageHandler_jcall,
13279                 .handle_tx_remove_input = handle_tx_remove_input_LDKChannelMessageHandler_jcall,
13280                 .handle_tx_remove_output = handle_tx_remove_output_LDKChannelMessageHandler_jcall,
13281                 .handle_tx_complete = handle_tx_complete_LDKChannelMessageHandler_jcall,
13282                 .handle_tx_signatures = handle_tx_signatures_LDKChannelMessageHandler_jcall,
13283                 .handle_tx_init_rbf = handle_tx_init_rbf_LDKChannelMessageHandler_jcall,
13284                 .handle_tx_ack_rbf = handle_tx_ack_rbf_LDKChannelMessageHandler_jcall,
13285                 .handle_tx_abort = handle_tx_abort_LDKChannelMessageHandler_jcall,
13286                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
13287                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
13288                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
13289                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
13290                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
13291                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
13292                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
13293                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
13294                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
13295                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
13296                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
13297                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
13298                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
13299                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
13300                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
13301                 .get_chain_hashes = get_chain_hashes_LDKChannelMessageHandler_jcall,
13302                 .free = LDKChannelMessageHandler_JCalls_free,
13303                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
13304         };
13305         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13306         return ret;
13307 }
13308 uint64_t  CS_LDK_LDKChannelMessageHandler_new(int32_t o, int32_t MessageSendEventsProvider) {
13309         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13310         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
13311         return tag_ptr(res_ptr, true);
13312 }
13313 void  CS_LDK_ChannelMessageHandler_handle_open_channel(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13314         void* this_arg_ptr = untag_ptr(this_arg);
13315         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13316         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13317         LDKPublicKey their_node_id_ref;
13318         CHECK(their_node_id->arr_len == 33);
13319         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13320         LDKOpenChannel msg_conv;
13321         msg_conv.inner = untag_ptr(msg);
13322         msg_conv.is_owned = ptr_is_owned(msg);
13323         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13324         msg_conv.is_owned = false;
13325         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13326 }
13327
13328 void  CS_LDK_ChannelMessageHandler_handle_open_channel_v2(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13329         void* this_arg_ptr = untag_ptr(this_arg);
13330         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13331         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13332         LDKPublicKey their_node_id_ref;
13333         CHECK(their_node_id->arr_len == 33);
13334         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13335         LDKOpenChannelV2 msg_conv;
13336         msg_conv.inner = untag_ptr(msg);
13337         msg_conv.is_owned = ptr_is_owned(msg);
13338         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13339         msg_conv.is_owned = false;
13340         (this_arg_conv->handle_open_channel_v2)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13341 }
13342
13343 void  CS_LDK_ChannelMessageHandler_handle_accept_channel(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13344         void* this_arg_ptr = untag_ptr(this_arg);
13345         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13346         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13347         LDKPublicKey their_node_id_ref;
13348         CHECK(their_node_id->arr_len == 33);
13349         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13350         LDKAcceptChannel msg_conv;
13351         msg_conv.inner = untag_ptr(msg);
13352         msg_conv.is_owned = ptr_is_owned(msg);
13353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13354         msg_conv.is_owned = false;
13355         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13356 }
13357
13358 void  CS_LDK_ChannelMessageHandler_handle_accept_channel_v2(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13359         void* this_arg_ptr = untag_ptr(this_arg);
13360         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13361         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13362         LDKPublicKey their_node_id_ref;
13363         CHECK(their_node_id->arr_len == 33);
13364         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13365         LDKAcceptChannelV2 msg_conv;
13366         msg_conv.inner = untag_ptr(msg);
13367         msg_conv.is_owned = ptr_is_owned(msg);
13368         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13369         msg_conv.is_owned = false;
13370         (this_arg_conv->handle_accept_channel_v2)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13371 }
13372
13373 void  CS_LDK_ChannelMessageHandler_handle_funding_created(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13374         void* this_arg_ptr = untag_ptr(this_arg);
13375         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13376         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13377         LDKPublicKey their_node_id_ref;
13378         CHECK(their_node_id->arr_len == 33);
13379         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13380         LDKFundingCreated msg_conv;
13381         msg_conv.inner = untag_ptr(msg);
13382         msg_conv.is_owned = ptr_is_owned(msg);
13383         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13384         msg_conv.is_owned = false;
13385         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13386 }
13387
13388 void  CS_LDK_ChannelMessageHandler_handle_funding_signed(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13389         void* this_arg_ptr = untag_ptr(this_arg);
13390         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13391         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13392         LDKPublicKey their_node_id_ref;
13393         CHECK(their_node_id->arr_len == 33);
13394         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13395         LDKFundingSigned msg_conv;
13396         msg_conv.inner = untag_ptr(msg);
13397         msg_conv.is_owned = ptr_is_owned(msg);
13398         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13399         msg_conv.is_owned = false;
13400         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13401 }
13402
13403 void  CS_LDK_ChannelMessageHandler_handle_channel_ready(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13404         void* this_arg_ptr = untag_ptr(this_arg);
13405         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13406         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13407         LDKPublicKey their_node_id_ref;
13408         CHECK(their_node_id->arr_len == 33);
13409         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13410         LDKChannelReady msg_conv;
13411         msg_conv.inner = untag_ptr(msg);
13412         msg_conv.is_owned = ptr_is_owned(msg);
13413         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13414         msg_conv.is_owned = false;
13415         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13416 }
13417
13418 void  CS_LDK_ChannelMessageHandler_handle_shutdown(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13419         void* this_arg_ptr = untag_ptr(this_arg);
13420         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13421         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13422         LDKPublicKey their_node_id_ref;
13423         CHECK(their_node_id->arr_len == 33);
13424         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13425         LDKShutdown msg_conv;
13426         msg_conv.inner = untag_ptr(msg);
13427         msg_conv.is_owned = ptr_is_owned(msg);
13428         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13429         msg_conv.is_owned = false;
13430         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13431 }
13432
13433 void  CS_LDK_ChannelMessageHandler_handle_closing_signed(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13434         void* this_arg_ptr = untag_ptr(this_arg);
13435         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13436         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13437         LDKPublicKey their_node_id_ref;
13438         CHECK(their_node_id->arr_len == 33);
13439         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13440         LDKClosingSigned msg_conv;
13441         msg_conv.inner = untag_ptr(msg);
13442         msg_conv.is_owned = ptr_is_owned(msg);
13443         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13444         msg_conv.is_owned = false;
13445         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13446 }
13447
13448 void  CS_LDK_ChannelMessageHandler_handle_tx_add_input(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13449         void* this_arg_ptr = untag_ptr(this_arg);
13450         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13451         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13452         LDKPublicKey their_node_id_ref;
13453         CHECK(their_node_id->arr_len == 33);
13454         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13455         LDKTxAddInput msg_conv;
13456         msg_conv.inner = untag_ptr(msg);
13457         msg_conv.is_owned = ptr_is_owned(msg);
13458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13459         msg_conv.is_owned = false;
13460         (this_arg_conv->handle_tx_add_input)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13461 }
13462
13463 void  CS_LDK_ChannelMessageHandler_handle_tx_add_output(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13464         void* this_arg_ptr = untag_ptr(this_arg);
13465         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13466         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13467         LDKPublicKey their_node_id_ref;
13468         CHECK(their_node_id->arr_len == 33);
13469         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13470         LDKTxAddOutput msg_conv;
13471         msg_conv.inner = untag_ptr(msg);
13472         msg_conv.is_owned = ptr_is_owned(msg);
13473         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13474         msg_conv.is_owned = false;
13475         (this_arg_conv->handle_tx_add_output)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13476 }
13477
13478 void  CS_LDK_ChannelMessageHandler_handle_tx_remove_input(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13479         void* this_arg_ptr = untag_ptr(this_arg);
13480         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13481         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13482         LDKPublicKey their_node_id_ref;
13483         CHECK(their_node_id->arr_len == 33);
13484         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13485         LDKTxRemoveInput msg_conv;
13486         msg_conv.inner = untag_ptr(msg);
13487         msg_conv.is_owned = ptr_is_owned(msg);
13488         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13489         msg_conv.is_owned = false;
13490         (this_arg_conv->handle_tx_remove_input)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13491 }
13492
13493 void  CS_LDK_ChannelMessageHandler_handle_tx_remove_output(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13494         void* this_arg_ptr = untag_ptr(this_arg);
13495         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13496         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13497         LDKPublicKey their_node_id_ref;
13498         CHECK(their_node_id->arr_len == 33);
13499         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13500         LDKTxRemoveOutput msg_conv;
13501         msg_conv.inner = untag_ptr(msg);
13502         msg_conv.is_owned = ptr_is_owned(msg);
13503         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13504         msg_conv.is_owned = false;
13505         (this_arg_conv->handle_tx_remove_output)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13506 }
13507
13508 void  CS_LDK_ChannelMessageHandler_handle_tx_complete(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13509         void* this_arg_ptr = untag_ptr(this_arg);
13510         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13511         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13512         LDKPublicKey their_node_id_ref;
13513         CHECK(their_node_id->arr_len == 33);
13514         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13515         LDKTxComplete msg_conv;
13516         msg_conv.inner = untag_ptr(msg);
13517         msg_conv.is_owned = ptr_is_owned(msg);
13518         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13519         msg_conv.is_owned = false;
13520         (this_arg_conv->handle_tx_complete)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13521 }
13522
13523 void  CS_LDK_ChannelMessageHandler_handle_tx_signatures(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13524         void* this_arg_ptr = untag_ptr(this_arg);
13525         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13526         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13527         LDKPublicKey their_node_id_ref;
13528         CHECK(their_node_id->arr_len == 33);
13529         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13530         LDKTxSignatures msg_conv;
13531         msg_conv.inner = untag_ptr(msg);
13532         msg_conv.is_owned = ptr_is_owned(msg);
13533         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13534         msg_conv.is_owned = false;
13535         (this_arg_conv->handle_tx_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13536 }
13537
13538 void  CS_LDK_ChannelMessageHandler_handle_tx_init_rbf(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13539         void* this_arg_ptr = untag_ptr(this_arg);
13540         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13541         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13542         LDKPublicKey their_node_id_ref;
13543         CHECK(their_node_id->arr_len == 33);
13544         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13545         LDKTxInitRbf msg_conv;
13546         msg_conv.inner = untag_ptr(msg);
13547         msg_conv.is_owned = ptr_is_owned(msg);
13548         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13549         msg_conv.is_owned = false;
13550         (this_arg_conv->handle_tx_init_rbf)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13551 }
13552
13553 void  CS_LDK_ChannelMessageHandler_handle_tx_ack_rbf(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13554         void* this_arg_ptr = untag_ptr(this_arg);
13555         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13556         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13557         LDKPublicKey their_node_id_ref;
13558         CHECK(their_node_id->arr_len == 33);
13559         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13560         LDKTxAckRbf msg_conv;
13561         msg_conv.inner = untag_ptr(msg);
13562         msg_conv.is_owned = ptr_is_owned(msg);
13563         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13564         msg_conv.is_owned = false;
13565         (this_arg_conv->handle_tx_ack_rbf)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13566 }
13567
13568 void  CS_LDK_ChannelMessageHandler_handle_tx_abort(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13569         void* this_arg_ptr = untag_ptr(this_arg);
13570         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13571         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13572         LDKPublicKey their_node_id_ref;
13573         CHECK(their_node_id->arr_len == 33);
13574         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13575         LDKTxAbort msg_conv;
13576         msg_conv.inner = untag_ptr(msg);
13577         msg_conv.is_owned = ptr_is_owned(msg);
13578         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13579         msg_conv.is_owned = false;
13580         (this_arg_conv->handle_tx_abort)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13581 }
13582
13583 void  CS_LDK_ChannelMessageHandler_handle_update_add_htlc(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13584         void* this_arg_ptr = untag_ptr(this_arg);
13585         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13586         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13587         LDKPublicKey their_node_id_ref;
13588         CHECK(their_node_id->arr_len == 33);
13589         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13590         LDKUpdateAddHTLC msg_conv;
13591         msg_conv.inner = untag_ptr(msg);
13592         msg_conv.is_owned = ptr_is_owned(msg);
13593         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13594         msg_conv.is_owned = false;
13595         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13596 }
13597
13598 void  CS_LDK_ChannelMessageHandler_handle_update_fulfill_htlc(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13599         void* this_arg_ptr = untag_ptr(this_arg);
13600         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13601         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13602         LDKPublicKey their_node_id_ref;
13603         CHECK(their_node_id->arr_len == 33);
13604         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13605         LDKUpdateFulfillHTLC msg_conv;
13606         msg_conv.inner = untag_ptr(msg);
13607         msg_conv.is_owned = ptr_is_owned(msg);
13608         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13609         msg_conv.is_owned = false;
13610         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13611 }
13612
13613 void  CS_LDK_ChannelMessageHandler_handle_update_fail_htlc(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13614         void* this_arg_ptr = untag_ptr(this_arg);
13615         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13616         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13617         LDKPublicKey their_node_id_ref;
13618         CHECK(their_node_id->arr_len == 33);
13619         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13620         LDKUpdateFailHTLC msg_conv;
13621         msg_conv.inner = untag_ptr(msg);
13622         msg_conv.is_owned = ptr_is_owned(msg);
13623         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13624         msg_conv.is_owned = false;
13625         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13626 }
13627
13628 void  CS_LDK_ChannelMessageHandler_handle_update_fail_malformed_htlc(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13629         void* this_arg_ptr = untag_ptr(this_arg);
13630         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13631         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13632         LDKPublicKey their_node_id_ref;
13633         CHECK(their_node_id->arr_len == 33);
13634         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13635         LDKUpdateFailMalformedHTLC msg_conv;
13636         msg_conv.inner = untag_ptr(msg);
13637         msg_conv.is_owned = ptr_is_owned(msg);
13638         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13639         msg_conv.is_owned = false;
13640         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13641 }
13642
13643 void  CS_LDK_ChannelMessageHandler_handle_commitment_signed(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13644         void* this_arg_ptr = untag_ptr(this_arg);
13645         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13646         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13647         LDKPublicKey their_node_id_ref;
13648         CHECK(their_node_id->arr_len == 33);
13649         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13650         LDKCommitmentSigned msg_conv;
13651         msg_conv.inner = untag_ptr(msg);
13652         msg_conv.is_owned = ptr_is_owned(msg);
13653         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13654         msg_conv.is_owned = false;
13655         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13656 }
13657
13658 void  CS_LDK_ChannelMessageHandler_handle_revoke_and_ack(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13659         void* this_arg_ptr = untag_ptr(this_arg);
13660         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13661         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13662         LDKPublicKey their_node_id_ref;
13663         CHECK(their_node_id->arr_len == 33);
13664         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13665         LDKRevokeAndACK msg_conv;
13666         msg_conv.inner = untag_ptr(msg);
13667         msg_conv.is_owned = ptr_is_owned(msg);
13668         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13669         msg_conv.is_owned = false;
13670         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13671 }
13672
13673 void  CS_LDK_ChannelMessageHandler_handle_update_fee(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13674         void* this_arg_ptr = untag_ptr(this_arg);
13675         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13676         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13677         LDKPublicKey their_node_id_ref;
13678         CHECK(their_node_id->arr_len == 33);
13679         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13680         LDKUpdateFee msg_conv;
13681         msg_conv.inner = untag_ptr(msg);
13682         msg_conv.is_owned = ptr_is_owned(msg);
13683         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13684         msg_conv.is_owned = false;
13685         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13686 }
13687
13688 void  CS_LDK_ChannelMessageHandler_handle_announcement_signatures(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13689         void* this_arg_ptr = untag_ptr(this_arg);
13690         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13691         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13692         LDKPublicKey their_node_id_ref;
13693         CHECK(their_node_id->arr_len == 33);
13694         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13695         LDKAnnouncementSignatures msg_conv;
13696         msg_conv.inner = untag_ptr(msg);
13697         msg_conv.is_owned = ptr_is_owned(msg);
13698         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13699         msg_conv.is_owned = false;
13700         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13701 }
13702
13703 void  CS_LDK_ChannelMessageHandler_peer_disconnected(int64_t this_arg, int8_tArray their_node_id) {
13704         void* this_arg_ptr = untag_ptr(this_arg);
13705         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13706         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13707         LDKPublicKey their_node_id_ref;
13708         CHECK(their_node_id->arr_len == 33);
13709         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13710         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
13711 }
13712
13713 int64_t  CS_LDK_ChannelMessageHandler_peer_connected(int64_t this_arg, int8_tArray their_node_id, int64_t msg, jboolean inbound) {
13714         void* this_arg_ptr = untag_ptr(this_arg);
13715         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13716         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13717         LDKPublicKey their_node_id_ref;
13718         CHECK(their_node_id->arr_len == 33);
13719         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13720         LDKInit msg_conv;
13721         msg_conv.inner = untag_ptr(msg);
13722         msg_conv.is_owned = ptr_is_owned(msg);
13723         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13724         msg_conv.is_owned = false;
13725         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13726         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv, inbound);
13727         return tag_ptr(ret_conv, true);
13728 }
13729
13730 void  CS_LDK_ChannelMessageHandler_handle_channel_reestablish(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13731         void* this_arg_ptr = untag_ptr(this_arg);
13732         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13733         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13734         LDKPublicKey their_node_id_ref;
13735         CHECK(their_node_id->arr_len == 33);
13736         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13737         LDKChannelReestablish msg_conv;
13738         msg_conv.inner = untag_ptr(msg);
13739         msg_conv.is_owned = ptr_is_owned(msg);
13740         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13741         msg_conv.is_owned = false;
13742         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13743 }
13744
13745 void  CS_LDK_ChannelMessageHandler_handle_channel_update(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13746         void* this_arg_ptr = untag_ptr(this_arg);
13747         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13748         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13749         LDKPublicKey their_node_id_ref;
13750         CHECK(their_node_id->arr_len == 33);
13751         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13752         LDKChannelUpdate msg_conv;
13753         msg_conv.inner = untag_ptr(msg);
13754         msg_conv.is_owned = ptr_is_owned(msg);
13755         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13756         msg_conv.is_owned = false;
13757         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13758 }
13759
13760 void  CS_LDK_ChannelMessageHandler_handle_error(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13761         void* this_arg_ptr = untag_ptr(this_arg);
13762         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13763         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13764         LDKPublicKey their_node_id_ref;
13765         CHECK(their_node_id->arr_len == 33);
13766         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13767         LDKErrorMessage msg_conv;
13768         msg_conv.inner = untag_ptr(msg);
13769         msg_conv.is_owned = ptr_is_owned(msg);
13770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13771         msg_conv.is_owned = false;
13772         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13773 }
13774
13775 int64_t  CS_LDK_ChannelMessageHandler_provided_node_features(int64_t this_arg) {
13776         void* this_arg_ptr = untag_ptr(this_arg);
13777         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13778         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13779         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13780         int64_t ret_ref = 0;
13781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13783         return ret_ref;
13784 }
13785
13786 int64_t  CS_LDK_ChannelMessageHandler_provided_init_features(int64_t this_arg, int8_tArray their_node_id) {
13787         void* this_arg_ptr = untag_ptr(this_arg);
13788         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13789         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13790         LDKPublicKey their_node_id_ref;
13791         CHECK(their_node_id->arr_len == 33);
13792         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13793         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13794         int64_t ret_ref = 0;
13795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13797         return ret_ref;
13798 }
13799
13800 int64_t  CS_LDK_ChannelMessageHandler_get_chain_hashes(int64_t this_arg) {
13801         void* this_arg_ptr = untag_ptr(this_arg);
13802         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13803         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13804         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
13805         *ret_copy = (this_arg_conv->get_chain_hashes)(this_arg_conv->this_arg);
13806         int64_t ret_ref = tag_ptr(ret_copy, true);
13807         return ret_ref;
13808 }
13809
13810 typedef struct LDKOffersMessageHandler_JCalls {
13811         atomic_size_t refcnt;
13812         uint32_t instance_ptr;
13813 } LDKOffersMessageHandler_JCalls;
13814 static void LDKOffersMessageHandler_JCalls_free(void* this_arg) {
13815         LDKOffersMessageHandler_JCalls *j_calls = (LDKOffersMessageHandler_JCalls*) this_arg;
13816         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13817                 FREE(j_calls);
13818         }
13819 }
13820 LDKCOption_OffersMessageZ handle_message_LDKOffersMessageHandler_jcall(const void* this_arg, LDKOffersMessage message) {
13821         LDKOffersMessageHandler_JCalls *j_calls = (LDKOffersMessageHandler_JCalls*) this_arg;
13822         LDKOffersMessage *message_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
13823         *message_copy = message;
13824         int64_t message_ref = tag_ptr(message_copy, true);
13825         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 107, message_ref);
13826         void* ret_ptr = untag_ptr(ret);
13827         CHECK_ACCESS(ret_ptr);
13828         LDKCOption_OffersMessageZ ret_conv = *(LDKCOption_OffersMessageZ*)(ret_ptr);
13829         FREE(untag_ptr(ret));
13830         return ret_conv;
13831 }
13832 LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ release_pending_messages_LDKOffersMessageHandler_jcall(const void* this_arg) {
13833         LDKOffersMessageHandler_JCalls *j_calls = (LDKOffersMessageHandler_JCalls*) this_arg;
13834         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 108);
13835         LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ ret_constr;
13836         ret_constr.datalen = ret->arr_len;
13837         if (ret_constr.datalen > 0)
13838                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ Elements");
13839         else
13840                 ret_constr.data = NULL;
13841         int64_t* ret_vals = ret->elems;
13842         for (size_t x = 0; x < ret_constr.datalen; x++) {
13843                 int64_t ret_conv_49 = ret_vals[x];
13844                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
13845                 CHECK_ACCESS(ret_conv_49_ptr);
13846                 LDKC3Tuple_OffersMessageDestinationBlindedPathZ ret_conv_49_conv = *(LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)(ret_conv_49_ptr);
13847                 FREE(untag_ptr(ret_conv_49));
13848                 ret_constr.data[x] = ret_conv_49_conv;
13849         }
13850         FREE(ret);
13851         return ret_constr;
13852 }
13853 static void LDKOffersMessageHandler_JCalls_cloned(LDKOffersMessageHandler* new_obj) {
13854         LDKOffersMessageHandler_JCalls *j_calls = (LDKOffersMessageHandler_JCalls*) new_obj->this_arg;
13855         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13856 }
13857 static inline LDKOffersMessageHandler LDKOffersMessageHandler_init (int64_t o) {
13858         LDKOffersMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOffersMessageHandler_JCalls), "LDKOffersMessageHandler_JCalls");
13859         atomic_init(&calls->refcnt, 1);
13860         calls->instance_ptr = o;
13861
13862         LDKOffersMessageHandler ret = {
13863                 .this_arg = (void*) calls,
13864                 .handle_message = handle_message_LDKOffersMessageHandler_jcall,
13865                 .release_pending_messages = release_pending_messages_LDKOffersMessageHandler_jcall,
13866                 .free = LDKOffersMessageHandler_JCalls_free,
13867         };
13868         return ret;
13869 }
13870 uint64_t  CS_LDK_LDKOffersMessageHandler_new(int32_t o) {
13871         LDKOffersMessageHandler *res_ptr = MALLOC(sizeof(LDKOffersMessageHandler), "LDKOffersMessageHandler");
13872         *res_ptr = LDKOffersMessageHandler_init(o);
13873         return tag_ptr(res_ptr, true);
13874 }
13875 int64_t  CS_LDK_OffersMessageHandler_handle_message(int64_t this_arg, int64_t message) {
13876         void* this_arg_ptr = untag_ptr(this_arg);
13877         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13878         LDKOffersMessageHandler* this_arg_conv = (LDKOffersMessageHandler*)this_arg_ptr;
13879         void* message_ptr = untag_ptr(message);
13880         CHECK_ACCESS(message_ptr);
13881         LDKOffersMessage message_conv = *(LDKOffersMessage*)(message_ptr);
13882         message_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(message));
13883         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
13884         *ret_copy = (this_arg_conv->handle_message)(this_arg_conv->this_arg, message_conv);
13885         int64_t ret_ref = tag_ptr(ret_copy, true);
13886         return ret_ref;
13887 }
13888
13889 int64_tArray  CS_LDK_OffersMessageHandler_release_pending_messages(int64_t this_arg) {
13890         void* this_arg_ptr = untag_ptr(this_arg);
13891         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13892         LDKOffersMessageHandler* this_arg_conv = (LDKOffersMessageHandler*)this_arg_ptr;
13893         LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ ret_var = (this_arg_conv->release_pending_messages)(this_arg_conv->this_arg);
13894         int64_tArray ret_arr = NULL;
13895         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
13896         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
13897         for (size_t x = 0; x < ret_var.datalen; x++) {
13898                 LDKC3Tuple_OffersMessageDestinationBlindedPathZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKC3Tuple_OffersMessageDestinationBlindedPathZ");
13899                 *ret_conv_49_conv = ret_var.data[x];
13900                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
13901         }
13902         
13903         FREE(ret_var.data);
13904         return ret_arr;
13905 }
13906
13907 typedef struct LDKRoutingMessageHandler_JCalls {
13908         atomic_size_t refcnt;
13909         uint32_t instance_ptr;
13910         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
13911 } LDKRoutingMessageHandler_JCalls;
13912 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
13913         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13914         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13915                 FREE(j_calls);
13916         }
13917 }
13918 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
13919         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13920         LDKNodeAnnouncement msg_var = *msg;
13921         int64_t msg_ref = 0;
13922         msg_var = NodeAnnouncement_clone(&msg_var);
13923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13924         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13925         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 109, msg_ref);
13926         void* ret_ptr = untag_ptr(ret);
13927         CHECK_ACCESS(ret_ptr);
13928         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13929         FREE(untag_ptr(ret));
13930         return ret_conv;
13931 }
13932 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
13933         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13934         LDKChannelAnnouncement msg_var = *msg;
13935         int64_t msg_ref = 0;
13936         msg_var = ChannelAnnouncement_clone(&msg_var);
13937         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13938         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13939         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 110, msg_ref);
13940         void* ret_ptr = untag_ptr(ret);
13941         CHECK_ACCESS(ret_ptr);
13942         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13943         FREE(untag_ptr(ret));
13944         return ret_conv;
13945 }
13946 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13947         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13948         LDKChannelUpdate msg_var = *msg;
13949         int64_t msg_ref = 0;
13950         msg_var = ChannelUpdate_clone(&msg_var);
13951         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13952         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13953         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 111, msg_ref);
13954         void* ret_ptr = untag_ptr(ret);
13955         CHECK_ACCESS(ret_ptr);
13956         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13957         FREE(untag_ptr(ret));
13958         return ret_conv;
13959 }
13960 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
13961         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13962         int64_t starting_point_conv = starting_point;
13963         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 112, starting_point_conv);
13964         void* ret_ptr = untag_ptr(ret);
13965         CHECK_ACCESS(ret_ptr);
13966         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
13967         FREE(untag_ptr(ret));
13968         return ret_conv;
13969 }
13970 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKNodeId starting_point) {
13971         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13972         LDKNodeId starting_point_var = starting_point;
13973         int64_t starting_point_ref = 0;
13974         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_var);
13975         starting_point_ref = tag_ptr(starting_point_var.inner, starting_point_var.is_owned);
13976         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 113, starting_point_ref);
13977         LDKNodeAnnouncement ret_conv;
13978         ret_conv.inner = untag_ptr(ret);
13979         ret_conv.is_owned = ptr_is_owned(ret);
13980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13981         return ret_conv;
13982 }
13983 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
13984         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13985         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13986         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13987         LDKInit init_var = *init;
13988         int64_t init_ref = 0;
13989         init_var = Init_clone(&init_var);
13990         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13991         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13992         jboolean inbound_conv = inbound;
13993         uint64_t ret = js_invoke_function_l_llb(j_calls->instance_ptr, 114, (int64_t)their_node_id_arr, init_ref, inbound_conv);
13994         void* ret_ptr = untag_ptr(ret);
13995         CHECK_ACCESS(ret_ptr);
13996         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13997         FREE(untag_ptr(ret));
13998         return ret_conv;
13999 }
14000 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
14001         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14002         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14003         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14004         LDKReplyChannelRange msg_var = msg;
14005         int64_t msg_ref = 0;
14006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14007         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14008         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 115, (int64_t)their_node_id_arr, msg_ref);
14009         void* ret_ptr = untag_ptr(ret);
14010         CHECK_ACCESS(ret_ptr);
14011         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14012         FREE(untag_ptr(ret));
14013         return ret_conv;
14014 }
14015 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
14016         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14017         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14018         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14019         LDKReplyShortChannelIdsEnd msg_var = msg;
14020         int64_t msg_ref = 0;
14021         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14022         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14023         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 116, (int64_t)their_node_id_arr, msg_ref);
14024         void* ret_ptr = untag_ptr(ret);
14025         CHECK_ACCESS(ret_ptr);
14026         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14027         FREE(untag_ptr(ret));
14028         return ret_conv;
14029 }
14030 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
14031         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14032         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14033         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14034         LDKQueryChannelRange msg_var = msg;
14035         int64_t msg_ref = 0;
14036         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14037         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14038         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 117, (int64_t)their_node_id_arr, msg_ref);
14039         void* ret_ptr = untag_ptr(ret);
14040         CHECK_ACCESS(ret_ptr);
14041         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14042         FREE(untag_ptr(ret));
14043         return ret_conv;
14044 }
14045 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
14046         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14047         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14048         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14049         LDKQueryShortChannelIds msg_var = msg;
14050         int64_t msg_ref = 0;
14051         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14052         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14053         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 118, (int64_t)their_node_id_arr, msg_ref);
14054         void* ret_ptr = untag_ptr(ret);
14055         CHECK_ACCESS(ret_ptr);
14056         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14057         FREE(untag_ptr(ret));
14058         return ret_conv;
14059 }
14060 bool processing_queue_high_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14061         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14062         return js_invoke_function_b_(j_calls->instance_ptr, 119);
14063 }
14064 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14065         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14066         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 120);
14067         LDKNodeFeatures ret_conv;
14068         ret_conv.inner = untag_ptr(ret);
14069         ret_conv.is_owned = ptr_is_owned(ret);
14070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14071         return ret_conv;
14072 }
14073 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14074         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14075         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14076         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14077         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 121, (int64_t)their_node_id_arr);
14078         LDKInitFeatures ret_conv;
14079         ret_conv.inner = untag_ptr(ret);
14080         ret_conv.is_owned = ptr_is_owned(ret);
14081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14082         return ret_conv;
14083 }
14084 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
14085         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
14086         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14087         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
14088 }
14089 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (int64_t o, int64_t MessageSendEventsProvider) {
14090         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
14091         atomic_init(&calls->refcnt, 1);
14092         calls->instance_ptr = o;
14093
14094         LDKRoutingMessageHandler ret = {
14095                 .this_arg = (void*) calls,
14096                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
14097                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
14098                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
14099                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
14100                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
14101                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
14102                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
14103                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
14104                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
14105                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
14106                 .processing_queue_high = processing_queue_high_LDKRoutingMessageHandler_jcall,
14107                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
14108                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
14109                 .free = LDKRoutingMessageHandler_JCalls_free,
14110                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
14111         };
14112         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
14113         return ret;
14114 }
14115 uint64_t  CS_LDK_LDKRoutingMessageHandler_new(int32_t o, int32_t MessageSendEventsProvider) {
14116         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
14117         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
14118         return tag_ptr(res_ptr, true);
14119 }
14120 int64_t  CS_LDK_RoutingMessageHandler_handle_node_announcement(int64_t this_arg, int64_t msg) {
14121         void* this_arg_ptr = untag_ptr(this_arg);
14122         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14123         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14124         LDKNodeAnnouncement msg_conv;
14125         msg_conv.inner = untag_ptr(msg);
14126         msg_conv.is_owned = ptr_is_owned(msg);
14127         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14128         msg_conv.is_owned = false;
14129         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14130         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
14131         return tag_ptr(ret_conv, true);
14132 }
14133
14134 int64_t  CS_LDK_RoutingMessageHandler_handle_channel_announcement(int64_t this_arg, int64_t msg) {
14135         void* this_arg_ptr = untag_ptr(this_arg);
14136         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14137         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14138         LDKChannelAnnouncement msg_conv;
14139         msg_conv.inner = untag_ptr(msg);
14140         msg_conv.is_owned = ptr_is_owned(msg);
14141         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14142         msg_conv.is_owned = false;
14143         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14144         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
14145         return tag_ptr(ret_conv, true);
14146 }
14147
14148 int64_t  CS_LDK_RoutingMessageHandler_handle_channel_update(int64_t this_arg, int64_t msg) {
14149         void* this_arg_ptr = untag_ptr(this_arg);
14150         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14151         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14152         LDKChannelUpdate msg_conv;
14153         msg_conv.inner = untag_ptr(msg);
14154         msg_conv.is_owned = ptr_is_owned(msg);
14155         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14156         msg_conv.is_owned = false;
14157         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14158         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
14159         return tag_ptr(ret_conv, true);
14160 }
14161
14162 int64_t  CS_LDK_RoutingMessageHandler_get_next_channel_announcement(int64_t this_arg, int64_t starting_point) {
14163         void* this_arg_ptr = untag_ptr(this_arg);
14164         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14165         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14166         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14167         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
14168         int64_t ret_ref = tag_ptr(ret_copy, true);
14169         return ret_ref;
14170 }
14171
14172 int64_t  CS_LDK_RoutingMessageHandler_get_next_node_announcement(int64_t this_arg, int64_t starting_point) {
14173         void* this_arg_ptr = untag_ptr(this_arg);
14174         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14175         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14176         LDKNodeId starting_point_conv;
14177         starting_point_conv.inner = untag_ptr(starting_point);
14178         starting_point_conv.is_owned = ptr_is_owned(starting_point);
14179         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_conv);
14180         starting_point_conv = NodeId_clone(&starting_point_conv);
14181         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_conv);
14182         int64_t ret_ref = 0;
14183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14184         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14185         return ret_ref;
14186 }
14187
14188 int64_t  CS_LDK_RoutingMessageHandler_peer_connected(int64_t this_arg, int8_tArray their_node_id, int64_t init, jboolean inbound) {
14189         void* this_arg_ptr = untag_ptr(this_arg);
14190         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14191         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14192         LDKPublicKey their_node_id_ref;
14193         CHECK(their_node_id->arr_len == 33);
14194         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14195         LDKInit init_conv;
14196         init_conv.inner = untag_ptr(init);
14197         init_conv.is_owned = ptr_is_owned(init);
14198         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14199         init_conv.is_owned = false;
14200         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14201         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
14202         return tag_ptr(ret_conv, true);
14203 }
14204
14205 int64_t  CS_LDK_RoutingMessageHandler_handle_reply_channel_range(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
14206         void* this_arg_ptr = untag_ptr(this_arg);
14207         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14208         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14209         LDKPublicKey their_node_id_ref;
14210         CHECK(their_node_id->arr_len == 33);
14211         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14212         LDKReplyChannelRange msg_conv;
14213         msg_conv.inner = untag_ptr(msg);
14214         msg_conv.is_owned = ptr_is_owned(msg);
14215         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14216         msg_conv = ReplyChannelRange_clone(&msg_conv);
14217         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14218         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14219         return tag_ptr(ret_conv, true);
14220 }
14221
14222 int64_t  CS_LDK_RoutingMessageHandler_handle_reply_short_channel_ids_end(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
14223         void* this_arg_ptr = untag_ptr(this_arg);
14224         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14225         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14226         LDKPublicKey their_node_id_ref;
14227         CHECK(their_node_id->arr_len == 33);
14228         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14229         LDKReplyShortChannelIdsEnd msg_conv;
14230         msg_conv.inner = untag_ptr(msg);
14231         msg_conv.is_owned = ptr_is_owned(msg);
14232         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14233         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
14234         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14235         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14236         return tag_ptr(ret_conv, true);
14237 }
14238
14239 int64_t  CS_LDK_RoutingMessageHandler_handle_query_channel_range(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
14240         void* this_arg_ptr = untag_ptr(this_arg);
14241         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14242         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14243         LDKPublicKey their_node_id_ref;
14244         CHECK(their_node_id->arr_len == 33);
14245         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14246         LDKQueryChannelRange msg_conv;
14247         msg_conv.inner = untag_ptr(msg);
14248         msg_conv.is_owned = ptr_is_owned(msg);
14249         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14250         msg_conv = QueryChannelRange_clone(&msg_conv);
14251         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14252         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14253         return tag_ptr(ret_conv, true);
14254 }
14255
14256 int64_t  CS_LDK_RoutingMessageHandler_handle_query_short_channel_ids(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
14257         void* this_arg_ptr = untag_ptr(this_arg);
14258         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14259         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14260         LDKPublicKey their_node_id_ref;
14261         CHECK(their_node_id->arr_len == 33);
14262         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14263         LDKQueryShortChannelIds msg_conv;
14264         msg_conv.inner = untag_ptr(msg);
14265         msg_conv.is_owned = ptr_is_owned(msg);
14266         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14267         msg_conv = QueryShortChannelIds_clone(&msg_conv);
14268         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14269         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14270         return tag_ptr(ret_conv, true);
14271 }
14272
14273 jboolean  CS_LDK_RoutingMessageHandler_processing_queue_high(int64_t this_arg) {
14274         void* this_arg_ptr = untag_ptr(this_arg);
14275         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14276         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14277         jboolean ret_conv = (this_arg_conv->processing_queue_high)(this_arg_conv->this_arg);
14278         return ret_conv;
14279 }
14280
14281 int64_t  CS_LDK_RoutingMessageHandler_provided_node_features(int64_t this_arg) {
14282         void* this_arg_ptr = untag_ptr(this_arg);
14283         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14284         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14285         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14286         int64_t ret_ref = 0;
14287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14288         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14289         return ret_ref;
14290 }
14291
14292 int64_t  CS_LDK_RoutingMessageHandler_provided_init_features(int64_t this_arg, int8_tArray their_node_id) {
14293         void* this_arg_ptr = untag_ptr(this_arg);
14294         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14295         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14296         LDKPublicKey their_node_id_ref;
14297         CHECK(their_node_id->arr_len == 33);
14298         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14299         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14300         int64_t ret_ref = 0;
14301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14303         return ret_ref;
14304 }
14305
14306 typedef struct LDKOnionMessageHandler_JCalls {
14307         atomic_size_t refcnt;
14308         uint32_t instance_ptr;
14309 } LDKOnionMessageHandler_JCalls;
14310 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
14311         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14312         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14313                 FREE(j_calls);
14314         }
14315 }
14316 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
14317         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14318         int8_tArray peer_node_id_arr = init_int8_tArray(33, __LINE__);
14319         memcpy(peer_node_id_arr->elems, peer_node_id.compressed_form, 33);
14320         LDKOnionMessage msg_var = *msg;
14321         int64_t msg_ref = 0;
14322         msg_var = OnionMessage_clone(&msg_var);
14323         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14324         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14325         js_invoke_function_void_ll(j_calls->instance_ptr, 122, (int64_t)peer_node_id_arr, msg_ref);
14326 }
14327 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
14328         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14329         int8_tArray peer_node_id_arr = init_int8_tArray(33, __LINE__);
14330         memcpy(peer_node_id_arr->elems, peer_node_id.compressed_form, 33);
14331         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 123, (int64_t)peer_node_id_arr);
14332         LDKOnionMessage ret_conv;
14333         ret_conv.inner = untag_ptr(ret);
14334         ret_conv.is_owned = ptr_is_owned(ret);
14335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14336         return ret_conv;
14337 }
14338 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
14339         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14340         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14341         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14342         LDKInit init_var = *init;
14343         int64_t init_ref = 0;
14344         init_var = Init_clone(&init_var);
14345         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
14346         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
14347         jboolean inbound_conv = inbound;
14348         uint64_t ret = js_invoke_function_l_llb(j_calls->instance_ptr, 124, (int64_t)their_node_id_arr, init_ref, inbound_conv);
14349         void* ret_ptr = untag_ptr(ret);
14350         CHECK_ACCESS(ret_ptr);
14351         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
14352         FREE(untag_ptr(ret));
14353         return ret_conv;
14354 }
14355 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14356         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14357         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14358         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14359         js_invoke_function_void_l(j_calls->instance_ptr, 125, (int64_t)their_node_id_arr);
14360 }
14361 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
14362         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14363         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 126);
14364         LDKNodeFeatures ret_conv;
14365         ret_conv.inner = untag_ptr(ret);
14366         ret_conv.is_owned = ptr_is_owned(ret);
14367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14368         return ret_conv;
14369 }
14370 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14371         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14372         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14373         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14374         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 127, (int64_t)their_node_id_arr);
14375         LDKInitFeatures ret_conv;
14376         ret_conv.inner = untag_ptr(ret);
14377         ret_conv.is_owned = ptr_is_owned(ret);
14378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14379         return ret_conv;
14380 }
14381 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
14382         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
14383         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14384 }
14385 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (int64_t o) {
14386         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
14387         atomic_init(&calls->refcnt, 1);
14388         calls->instance_ptr = o;
14389
14390         LDKOnionMessageHandler ret = {
14391                 .this_arg = (void*) calls,
14392                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
14393                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageHandler_jcall,
14394                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
14395                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
14396                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
14397                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
14398                 .free = LDKOnionMessageHandler_JCalls_free,
14399         };
14400         return ret;
14401 }
14402 uint64_t  CS_LDK_LDKOnionMessageHandler_new(int32_t o) {
14403         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
14404         *res_ptr = LDKOnionMessageHandler_init(o);
14405         return tag_ptr(res_ptr, true);
14406 }
14407 void  CS_LDK_OnionMessageHandler_handle_onion_message(int64_t this_arg, int8_tArray peer_node_id, int64_t msg) {
14408         void* this_arg_ptr = untag_ptr(this_arg);
14409         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14410         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14411         LDKPublicKey peer_node_id_ref;
14412         CHECK(peer_node_id->arr_len == 33);
14413         memcpy(peer_node_id_ref.compressed_form, peer_node_id->elems, 33); FREE(peer_node_id);
14414         LDKOnionMessage msg_conv;
14415         msg_conv.inner = untag_ptr(msg);
14416         msg_conv.is_owned = ptr_is_owned(msg);
14417         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14418         msg_conv.is_owned = false;
14419         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
14420 }
14421
14422 int64_t  CS_LDK_OnionMessageHandler_next_onion_message_for_peer(int64_t this_arg, int8_tArray peer_node_id) {
14423         void* this_arg_ptr = untag_ptr(this_arg);
14424         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14425         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14426         LDKPublicKey peer_node_id_ref;
14427         CHECK(peer_node_id->arr_len == 33);
14428         memcpy(peer_node_id_ref.compressed_form, peer_node_id->elems, 33); FREE(peer_node_id);
14429         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
14430         int64_t ret_ref = 0;
14431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14432         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14433         return ret_ref;
14434 }
14435
14436 int64_t  CS_LDK_OnionMessageHandler_peer_connected(int64_t this_arg, int8_tArray their_node_id, int64_t init, jboolean inbound) {
14437         void* this_arg_ptr = untag_ptr(this_arg);
14438         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14439         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14440         LDKPublicKey their_node_id_ref;
14441         CHECK(their_node_id->arr_len == 33);
14442         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14443         LDKInit init_conv;
14444         init_conv.inner = untag_ptr(init);
14445         init_conv.is_owned = ptr_is_owned(init);
14446         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14447         init_conv.is_owned = false;
14448         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14449         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
14450         return tag_ptr(ret_conv, true);
14451 }
14452
14453 void  CS_LDK_OnionMessageHandler_peer_disconnected(int64_t this_arg, int8_tArray their_node_id) {
14454         void* this_arg_ptr = untag_ptr(this_arg);
14455         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14456         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14457         LDKPublicKey their_node_id_ref;
14458         CHECK(their_node_id->arr_len == 33);
14459         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14460         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
14461 }
14462
14463 int64_t  CS_LDK_OnionMessageHandler_provided_node_features(int64_t this_arg) {
14464         void* this_arg_ptr = untag_ptr(this_arg);
14465         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14466         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14467         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14468         int64_t ret_ref = 0;
14469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14471         return ret_ref;
14472 }
14473
14474 int64_t  CS_LDK_OnionMessageHandler_provided_init_features(int64_t this_arg, int8_tArray their_node_id) {
14475         void* this_arg_ptr = untag_ptr(this_arg);
14476         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14477         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14478         LDKPublicKey their_node_id_ref;
14479         CHECK(their_node_id->arr_len == 33);
14480         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14481         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14482         int64_t ret_ref = 0;
14483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14485         return ret_ref;
14486 }
14487
14488 typedef struct LDKCustomMessageReader_JCalls {
14489         atomic_size_t refcnt;
14490         uint32_t instance_ptr;
14491 } LDKCustomMessageReader_JCalls;
14492 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
14493         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14494         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14495                 FREE(j_calls);
14496         }
14497 }
14498 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
14499         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14500         int16_t message_type_conv = message_type;
14501         LDKu8slice buffer_var = buffer;
14502         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
14503         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
14504         uint64_t ret = js_invoke_function_l_sl(j_calls->instance_ptr, 128, message_type_conv, (int64_t)buffer_arr);
14505         void* ret_ptr = untag_ptr(ret);
14506         CHECK_ACCESS(ret_ptr);
14507         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
14508         FREE(untag_ptr(ret));
14509         return ret_conv;
14510 }
14511 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
14512         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
14513         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14514 }
14515 static inline LDKCustomMessageReader LDKCustomMessageReader_init (int64_t o) {
14516         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
14517         atomic_init(&calls->refcnt, 1);
14518         calls->instance_ptr = o;
14519
14520         LDKCustomMessageReader ret = {
14521                 .this_arg = (void*) calls,
14522                 .read = read_LDKCustomMessageReader_jcall,
14523                 .free = LDKCustomMessageReader_JCalls_free,
14524         };
14525         return ret;
14526 }
14527 uint64_t  CS_LDK_LDKCustomMessageReader_new(int32_t o) {
14528         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
14529         *res_ptr = LDKCustomMessageReader_init(o);
14530         return tag_ptr(res_ptr, true);
14531 }
14532 int64_t  CS_LDK_CustomMessageReader_read(int64_t this_arg, int16_t message_type, int8_tArray buffer) {
14533         void* this_arg_ptr = untag_ptr(this_arg);
14534         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14535         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
14536         LDKu8slice buffer_ref;
14537         buffer_ref.datalen = buffer->arr_len;
14538         buffer_ref.data = buffer->elems;
14539         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14540         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
14541         FREE(buffer);
14542         return tag_ptr(ret_conv, true);
14543 }
14544
14545 typedef struct LDKCustomMessageHandler_JCalls {
14546         atomic_size_t refcnt;
14547         uint32_t instance_ptr;
14548         LDKCustomMessageReader_JCalls* CustomMessageReader;
14549 } LDKCustomMessageHandler_JCalls;
14550 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
14551         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14552         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14553                 FREE(j_calls);
14554         }
14555 }
14556 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
14557         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14558         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
14559         *msg_ret = msg;
14560         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
14561         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
14562         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 129, tag_ptr(msg_ret, true), (int64_t)sender_node_id_arr);
14563         void* ret_ptr = untag_ptr(ret);
14564         CHECK_ACCESS(ret_ptr);
14565         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14566         FREE(untag_ptr(ret));
14567         return ret_conv;
14568 }
14569 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
14570         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14571         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 130);
14572         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
14573         ret_constr.datalen = ret->arr_len;
14574         if (ret_constr.datalen > 0)
14575                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
14576         else
14577                 ret_constr.data = NULL;
14578         int64_t* ret_vals = ret->elems;
14579         for (size_t z = 0; z < ret_constr.datalen; z++) {
14580                 int64_t ret_conv_25 = ret_vals[z];
14581                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
14582                 CHECK_ACCESS(ret_conv_25_ptr);
14583                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
14584                 FREE(untag_ptr(ret_conv_25));
14585                 ret_constr.data[z] = ret_conv_25_conv;
14586         }
14587         FREE(ret);
14588         return ret_constr;
14589 }
14590 LDKNodeFeatures provided_node_features_LDKCustomMessageHandler_jcall(const void* this_arg) {
14591         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14592         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 131);
14593         LDKNodeFeatures ret_conv;
14594         ret_conv.inner = untag_ptr(ret);
14595         ret_conv.is_owned = ptr_is_owned(ret);
14596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14597         return ret_conv;
14598 }
14599 LDKInitFeatures provided_init_features_LDKCustomMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14600         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14601         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14602         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14603         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 132, (int64_t)their_node_id_arr);
14604         LDKInitFeatures ret_conv;
14605         ret_conv.inner = untag_ptr(ret);
14606         ret_conv.is_owned = ptr_is_owned(ret);
14607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14608         return ret_conv;
14609 }
14610 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
14611         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
14612         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14613         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
14614 }
14615 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (int64_t o, int64_t CustomMessageReader) {
14616         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
14617         atomic_init(&calls->refcnt, 1);
14618         calls->instance_ptr = o;
14619
14620         LDKCustomMessageHandler ret = {
14621                 .this_arg = (void*) calls,
14622                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
14623                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
14624                 .provided_node_features = provided_node_features_LDKCustomMessageHandler_jcall,
14625                 .provided_init_features = provided_init_features_LDKCustomMessageHandler_jcall,
14626                 .free = LDKCustomMessageHandler_JCalls_free,
14627                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
14628         };
14629         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
14630         return ret;
14631 }
14632 uint64_t  CS_LDK_LDKCustomMessageHandler_new(int32_t o, int32_t CustomMessageReader) {
14633         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
14634         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
14635         return tag_ptr(res_ptr, true);
14636 }
14637 int64_t  CS_LDK_CustomMessageHandler_handle_custom_message(int64_t this_arg, int64_t msg, int8_tArray sender_node_id) {
14638         void* this_arg_ptr = untag_ptr(this_arg);
14639         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14640         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14641         void* msg_ptr = untag_ptr(msg);
14642         CHECK_ACCESS(msg_ptr);
14643         LDKType msg_conv = *(LDKType*)(msg_ptr);
14644         if (msg_conv.free == LDKType_JCalls_free) {
14645                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14646                 LDKType_JCalls_cloned(&msg_conv);
14647         }
14648         LDKPublicKey sender_node_id_ref;
14649         CHECK(sender_node_id->arr_len == 33);
14650         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
14651         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14652         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
14653         return tag_ptr(ret_conv, true);
14654 }
14655
14656 int64_tArray  CS_LDK_CustomMessageHandler_get_and_clear_pending_msg(int64_t this_arg) {
14657         void* this_arg_ptr = untag_ptr(this_arg);
14658         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14659         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14660         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
14661         int64_tArray ret_arr = NULL;
14662         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
14663         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
14664         for (size_t z = 0; z < ret_var.datalen; z++) {
14665                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
14666                 *ret_conv_25_conv = ret_var.data[z];
14667                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
14668         }
14669         
14670         FREE(ret_var.data);
14671         return ret_arr;
14672 }
14673
14674 int64_t  CS_LDK_CustomMessageHandler_provided_node_features(int64_t this_arg) {
14675         void* this_arg_ptr = untag_ptr(this_arg);
14676         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14677         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14678         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14679         int64_t ret_ref = 0;
14680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14681         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14682         return ret_ref;
14683 }
14684
14685 int64_t  CS_LDK_CustomMessageHandler_provided_init_features(int64_t this_arg, int8_tArray their_node_id) {
14686         void* this_arg_ptr = untag_ptr(this_arg);
14687         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14688         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14689         LDKPublicKey their_node_id_ref;
14690         CHECK(their_node_id->arr_len == 33);
14691         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14692         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14693         int64_t ret_ref = 0;
14694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14696         return ret_ref;
14697 }
14698
14699 typedef struct LDKCustomOnionMessageHandler_JCalls {
14700         atomic_size_t refcnt;
14701         uint32_t instance_ptr;
14702 } LDKCustomOnionMessageHandler_JCalls;
14703 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
14704         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14705         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14706                 FREE(j_calls);
14707         }
14708 }
14709 LDKCOption_OnionMessageContentsZ handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKOnionMessageContents msg) {
14710         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14711         LDKOnionMessageContents* msg_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
14712         *msg_ret = msg;
14713         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 133, tag_ptr(msg_ret, true));
14714         void* ret_ptr = untag_ptr(ret);
14715         CHECK_ACCESS(ret_ptr);
14716         LDKCOption_OnionMessageContentsZ ret_conv = *(LDKCOption_OnionMessageContentsZ*)(ret_ptr);
14717         FREE(untag_ptr(ret));
14718         return ret_conv;
14719 }
14720 LDKCResult_COption_OnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
14721         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14722         int64_t message_type_conv = message_type;
14723         LDKu8slice buffer_var = buffer;
14724         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
14725         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
14726         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 134, message_type_conv, (int64_t)buffer_arr);
14727         void* ret_ptr = untag_ptr(ret);
14728         CHECK_ACCESS(ret_ptr);
14729         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)(ret_ptr);
14730         FREE(untag_ptr(ret));
14731         return ret_conv;
14732 }
14733 LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ release_pending_custom_messages_LDKCustomOnionMessageHandler_jcall(const void* this_arg) {
14734         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14735         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 135);
14736         LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ ret_constr;
14737         ret_constr.datalen = ret->arr_len;
14738         if (ret_constr.datalen > 0)
14739                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ Elements");
14740         else
14741                 ret_constr.data = NULL;
14742         int64_t* ret_vals = ret->elems;
14743         for (size_t e = 0; e < ret_constr.datalen; e++) {
14744                 int64_t ret_conv_56 = ret_vals[e];
14745                 void* ret_conv_56_ptr = untag_ptr(ret_conv_56);
14746                 CHECK_ACCESS(ret_conv_56_ptr);
14747                 LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ ret_conv_56_conv = *(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)(ret_conv_56_ptr);
14748                 FREE(untag_ptr(ret_conv_56));
14749                 ret_constr.data[e] = ret_conv_56_conv;
14750         }
14751         FREE(ret);
14752         return ret_constr;
14753 }
14754 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
14755         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
14756         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14757 }
14758 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (int64_t o) {
14759         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
14760         atomic_init(&calls->refcnt, 1);
14761         calls->instance_ptr = o;
14762
14763         LDKCustomOnionMessageHandler ret = {
14764                 .this_arg = (void*) calls,
14765                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
14766                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
14767                 .release_pending_custom_messages = release_pending_custom_messages_LDKCustomOnionMessageHandler_jcall,
14768                 .free = LDKCustomOnionMessageHandler_JCalls_free,
14769         };
14770         return ret;
14771 }
14772 uint64_t  CS_LDK_LDKCustomOnionMessageHandler_new(int32_t o) {
14773         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
14774         *res_ptr = LDKCustomOnionMessageHandler_init(o);
14775         return tag_ptr(res_ptr, true);
14776 }
14777 int64_t  CS_LDK_CustomOnionMessageHandler_handle_custom_message(int64_t this_arg, int64_t msg) {
14778         void* this_arg_ptr = untag_ptr(this_arg);
14779         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14780         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14781         void* msg_ptr = untag_ptr(msg);
14782         CHECK_ACCESS(msg_ptr);
14783         LDKOnionMessageContents msg_conv = *(LDKOnionMessageContents*)(msg_ptr);
14784         if (msg_conv.free == LDKOnionMessageContents_JCalls_free) {
14785                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14786                 LDKOnionMessageContents_JCalls_cloned(&msg_conv);
14787         }
14788         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
14789         *ret_copy = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
14790         int64_t ret_ref = tag_ptr(ret_copy, true);
14791         return ret_ref;
14792 }
14793
14794 int64_t  CS_LDK_CustomOnionMessageHandler_read_custom_message(int64_t this_arg, int64_t message_type, int8_tArray buffer) {
14795         void* this_arg_ptr = untag_ptr(this_arg);
14796         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14797         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14798         LDKu8slice buffer_ref;
14799         buffer_ref.datalen = buffer->arr_len;
14800         buffer_ref.data = buffer->elems;
14801         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
14802         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
14803         FREE(buffer);
14804         return tag_ptr(ret_conv, true);
14805 }
14806
14807 int64_tArray  CS_LDK_CustomOnionMessageHandler_release_pending_custom_messages(int64_t this_arg) {
14808         void* this_arg_ptr = untag_ptr(this_arg);
14809         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14810         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14811         LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ ret_var = (this_arg_conv->release_pending_custom_messages)(this_arg_conv->this_arg);
14812         int64_tArray ret_arr = NULL;
14813         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
14814         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
14815         for (size_t e = 0; e < ret_var.datalen; e++) {
14816                 LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* ret_conv_56_conv = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ");
14817                 *ret_conv_56_conv = ret_var.data[e];
14818                 ret_arr_ptr[e] = tag_ptr(ret_conv_56_conv, true);
14819         }
14820         
14821         FREE(ret_var.data);
14822         return ret_arr;
14823 }
14824
14825 typedef struct LDKSocketDescriptor_JCalls {
14826         atomic_size_t refcnt;
14827         uint32_t instance_ptr;
14828 } LDKSocketDescriptor_JCalls;
14829 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
14830         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14831         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14832                 FREE(j_calls);
14833         }
14834 }
14835 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
14836         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14837         LDKu8slice data_var = data;
14838         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
14839         memcpy(data_arr->elems, data_var.data, data_var.datalen);
14840         jboolean resume_read_conv = resume_read;
14841         return js_invoke_function_l_lb(j_calls->instance_ptr, 136, (int64_t)data_arr, resume_read_conv);
14842 }
14843 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
14844         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14845         js_invoke_function_void_(j_calls->instance_ptr, 137);
14846 }
14847 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
14848         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14849         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14850         *other_arg_clone = SocketDescriptor_clone(other_arg);
14851         return js_invoke_function_b_l(j_calls->instance_ptr, 138, tag_ptr(other_arg_clone, true));
14852 }
14853 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
14854         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14855         return js_invoke_function_l_(j_calls->instance_ptr, 139);
14856 }
14857 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
14858         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
14859         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14860 }
14861 static inline LDKSocketDescriptor LDKSocketDescriptor_init (int64_t o) {
14862         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
14863         atomic_init(&calls->refcnt, 1);
14864         calls->instance_ptr = o;
14865
14866         LDKSocketDescriptor ret = {
14867                 .this_arg = (void*) calls,
14868                 .send_data = send_data_LDKSocketDescriptor_jcall,
14869                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
14870                 .eq = eq_LDKSocketDescriptor_jcall,
14871                 .hash = hash_LDKSocketDescriptor_jcall,
14872                 .cloned = LDKSocketDescriptor_JCalls_cloned,
14873                 .free = LDKSocketDescriptor_JCalls_free,
14874         };
14875         return ret;
14876 }
14877 uint64_t  CS_LDK_LDKSocketDescriptor_new(int32_t o) {
14878         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14879         *res_ptr = LDKSocketDescriptor_init(o);
14880         return tag_ptr(res_ptr, true);
14881 }
14882 int64_t  CS_LDK_SocketDescriptor_send_data(int64_t this_arg, int8_tArray data, jboolean resume_read) {
14883         void* this_arg_ptr = untag_ptr(this_arg);
14884         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14885         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14886         LDKu8slice data_ref;
14887         data_ref.datalen = data->arr_len;
14888         data_ref.data = data->elems;
14889         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14890         FREE(data);
14891         return ret_conv;
14892 }
14893
14894 void  CS_LDK_SocketDescriptor_disconnect_socket(int64_t this_arg) {
14895         void* this_arg_ptr = untag_ptr(this_arg);
14896         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14897         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14898         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14899 }
14900
14901 int64_t  CS_LDK_SocketDescriptor_hash(int64_t this_arg) {
14902         void* this_arg_ptr = untag_ptr(this_arg);
14903         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14904         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14905         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14906         return ret_conv;
14907 }
14908
14909 uint32_t CS_LDK_LDKEffectiveCapacity_ty_from_ptr(int64_t ptr) {
14910         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14911         switch(obj->tag) {
14912                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
14913                 case LDKEffectiveCapacity_AdvertisedMaxHTLC: return 1;
14914                 case LDKEffectiveCapacity_Total: return 2;
14915                 case LDKEffectiveCapacity_Infinite: return 3;
14916                 case LDKEffectiveCapacity_HintMaxHTLC: return 4;
14917                 case LDKEffectiveCapacity_Unknown: return 5;
14918                 default: abort();
14919         }
14920 }
14921 int64_t CS_LDK_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(int64_t ptr) {
14922         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14923         CHECK(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
14924         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14925         return liquidity_msat_conv;
14926 }
14927 int64_t CS_LDK_LDKEffectiveCapacity_AdvertisedMaxHTLC_get_amount_msat(int64_t ptr) {
14928         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14929         CHECK(obj->tag == LDKEffectiveCapacity_AdvertisedMaxHTLC);
14930         int64_t amount_msat_conv = obj->advertised_max_htlc.amount_msat;
14931         return amount_msat_conv;
14932 }
14933 int64_t CS_LDK_LDKEffectiveCapacity_Total_get_capacity_msat(int64_t ptr) {
14934         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14935         CHECK(obj->tag == LDKEffectiveCapacity_Total);
14936         int64_t capacity_msat_conv = obj->total.capacity_msat;
14937         return capacity_msat_conv;
14938 }
14939 int64_t CS_LDK_LDKEffectiveCapacity_Total_get_htlc_maximum_msat(int64_t ptr) {
14940         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14941         CHECK(obj->tag == LDKEffectiveCapacity_Total);
14942         int64_t htlc_maximum_msat_conv = obj->total.htlc_maximum_msat;
14943         return htlc_maximum_msat_conv;
14944 }
14945 int64_t CS_LDK_LDKEffectiveCapacity_HintMaxHTLC_get_amount_msat(int64_t ptr) {
14946         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14947         CHECK(obj->tag == LDKEffectiveCapacity_HintMaxHTLC);
14948         int64_t amount_msat_conv = obj->hint_max_htlc.amount_msat;
14949         return amount_msat_conv;
14950 }
14951 uint32_t CS_LDK_LDKPayee_ty_from_ptr(int64_t ptr) {
14952         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14953         switch(obj->tag) {
14954                 case LDKPayee_Blinded: return 0;
14955                 case LDKPayee_Clear: return 1;
14956                 default: abort();
14957         }
14958 }
14959 int64_tArray CS_LDK_LDKPayee_Blinded_get_route_hints(int64_t ptr) {
14960         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14961         CHECK(obj->tag == LDKPayee_Blinded);
14962         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints_var = obj->blinded.route_hints;
14963                         int64_tArray route_hints_arr = NULL;
14964                         route_hints_arr = init_int64_tArray(route_hints_var.datalen, __LINE__);
14965                         int64_t *route_hints_arr_ptr = (int64_t*)(((uint8_t*)route_hints_arr) + 8);
14966                         for (size_t l = 0; l < route_hints_var.datalen; l++) {
14967                                 LDKC2Tuple_BlindedPayInfoBlindedPathZ* route_hints_conv_37_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
14968                                 *route_hints_conv_37_conv = route_hints_var.data[l];
14969                                 *route_hints_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(route_hints_conv_37_conv);
14970                                 route_hints_arr_ptr[l] = tag_ptr(route_hints_conv_37_conv, true);
14971                         }
14972                         
14973         return route_hints_arr;
14974 }
14975 int64_t CS_LDK_LDKPayee_Blinded_get_features(int64_t ptr) {
14976         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14977         CHECK(obj->tag == LDKPayee_Blinded);
14978         LDKBolt12InvoiceFeatures features_var = obj->blinded.features;
14979                         int64_t features_ref = 0;
14980                         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_var);
14981                         features_ref = tag_ptr(features_var.inner, false);
14982         return features_ref;
14983 }
14984 int8_tArray CS_LDK_LDKPayee_Clear_get_node_id(int64_t ptr) {
14985         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14986         CHECK(obj->tag == LDKPayee_Clear);
14987         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
14988         memcpy(node_id_arr->elems, obj->clear.node_id.compressed_form, 33);
14989         return node_id_arr;
14990 }
14991 int64_tArray CS_LDK_LDKPayee_Clear_get_route_hints(int64_t ptr) {
14992         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14993         CHECK(obj->tag == LDKPayee_Clear);
14994         LDKCVec_RouteHintZ route_hints_var = obj->clear.route_hints;
14995                         int64_tArray route_hints_arr = NULL;
14996                         route_hints_arr = init_int64_tArray(route_hints_var.datalen, __LINE__);
14997                         int64_t *route_hints_arr_ptr = (int64_t*)(((uint8_t*)route_hints_arr) + 8);
14998                         for (size_t l = 0; l < route_hints_var.datalen; l++) {
14999                                 LDKRouteHint route_hints_conv_11_var = route_hints_var.data[l];
15000                                 int64_t route_hints_conv_11_ref = 0;
15001                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_conv_11_var);
15002                                 route_hints_conv_11_ref = tag_ptr(route_hints_conv_11_var.inner, false);
15003                                 route_hints_arr_ptr[l] = route_hints_conv_11_ref;
15004                         }
15005                         
15006         return route_hints_arr;
15007 }
15008 int64_t CS_LDK_LDKPayee_Clear_get_features(int64_t ptr) {
15009         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
15010         CHECK(obj->tag == LDKPayee_Clear);
15011         LDKBolt11InvoiceFeatures features_var = obj->clear.features;
15012                         int64_t features_ref = 0;
15013                         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_var);
15014                         features_ref = tag_ptr(features_var.inner, false);
15015         return features_ref;
15016 }
15017 int32_t CS_LDK_LDKPayee_Clear_get_final_cltv_expiry_delta(int64_t ptr) {
15018         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
15019         CHECK(obj->tag == LDKPayee_Clear);
15020         int32_t final_cltv_expiry_delta_conv = obj->clear.final_cltv_expiry_delta;
15021         return final_cltv_expiry_delta_conv;
15022 }
15023 typedef struct LDKScore_JCalls {
15024         atomic_size_t refcnt;
15025         uint32_t instance_ptr;
15026         LDKScoreLookUp_JCalls* ScoreLookUp;
15027         LDKScoreUpdate_JCalls* ScoreUpdate;
15028 } LDKScore_JCalls;
15029 static void LDKScore_JCalls_free(void* this_arg) {
15030         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
15031         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15032                 FREE(j_calls);
15033         }
15034 }
15035 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
15036         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
15037         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 140);
15038         LDKCVec_u8Z ret_ref;
15039         ret_ref.datalen = ret->arr_len;
15040         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
15041         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
15042         return ret_ref;
15043 }
15044 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
15045         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
15046         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15047         atomic_fetch_add_explicit(&j_calls->ScoreLookUp->refcnt, 1, memory_order_release);
15048         atomic_fetch_add_explicit(&j_calls->ScoreUpdate->refcnt, 1, memory_order_release);
15049 }
15050 static inline LDKScore LDKScore_init (int64_t o, int64_t ScoreLookUp, int64_t ScoreUpdate) {
15051         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
15052         atomic_init(&calls->refcnt, 1);
15053         calls->instance_ptr = o;
15054
15055         LDKScore ret = {
15056                 .this_arg = (void*) calls,
15057                 .write = write_LDKScore_jcall,
15058                 .free = LDKScore_JCalls_free,
15059                 .ScoreLookUp = LDKScoreLookUp_init(ScoreLookUp),
15060                 .ScoreUpdate = LDKScoreUpdate_init(ScoreUpdate),
15061         };
15062         calls->ScoreLookUp = ret.ScoreLookUp.this_arg;
15063         calls->ScoreUpdate = ret.ScoreUpdate.this_arg;
15064         return ret;
15065 }
15066 uint64_t  CS_LDK_LDKScore_new(int32_t o, int32_t ScoreLookUp, int32_t ScoreUpdate) {
15067         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
15068         *res_ptr = LDKScore_init(o, ScoreLookUp, ScoreUpdate);
15069         return tag_ptr(res_ptr, true);
15070 }
15071 int8_tArray  CS_LDK_Score_write(int64_t this_arg) {
15072         void* this_arg_ptr = untag_ptr(this_arg);
15073         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15074         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
15075         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
15076         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
15077         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
15078         CVec_u8Z_free(ret_var);
15079         return ret_arr;
15080 }
15081
15082 typedef struct LDKMessageRouter_JCalls {
15083         atomic_size_t refcnt;
15084         uint32_t instance_ptr;
15085 } LDKMessageRouter_JCalls;
15086 static void LDKMessageRouter_JCalls_free(void* this_arg) {
15087         LDKMessageRouter_JCalls *j_calls = (LDKMessageRouter_JCalls*) this_arg;
15088         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15089                 FREE(j_calls);
15090         }
15091 }
15092 LDKCResult_OnionMessagePathNoneZ find_path_LDKMessageRouter_jcall(const void* this_arg, LDKPublicKey sender, LDKCVec_PublicKeyZ peers, LDKDestination destination) {
15093         LDKMessageRouter_JCalls *j_calls = (LDKMessageRouter_JCalls*) this_arg;
15094         int8_tArray sender_arr = init_int8_tArray(33, __LINE__);
15095         memcpy(sender_arr->elems, sender.compressed_form, 33);
15096         LDKCVec_PublicKeyZ peers_var = peers;
15097         ptrArray peers_arr = NULL;
15098         peers_arr = init_ptrArray(peers_var.datalen, __LINE__);
15099         int8_tArray *peers_arr_ptr = (int8_tArray*)(((uint8_t*)peers_arr) + 8);
15100         for (size_t i = 0; i < peers_var.datalen; i++) {
15101                 int8_tArray peers_conv_8_arr = init_int8_tArray(33, __LINE__);
15102                 memcpy(peers_conv_8_arr->elems, peers_var.data[i].compressed_form, 33);
15103                 peers_arr_ptr[i] = peers_conv_8_arr;
15104         }
15105         
15106         FREE(peers_var.data);
15107         LDKDestination *destination_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
15108         *destination_copy = destination;
15109         int64_t destination_ref = tag_ptr(destination_copy, true);
15110         uint64_t ret = js_invoke_function_l_lll(j_calls->instance_ptr, 141, (int64_t)sender_arr, (int64_t)peers_arr, destination_ref);
15111         void* ret_ptr = untag_ptr(ret);
15112         CHECK_ACCESS(ret_ptr);
15113         LDKCResult_OnionMessagePathNoneZ ret_conv = *(LDKCResult_OnionMessagePathNoneZ*)(ret_ptr);
15114         FREE(untag_ptr(ret));
15115         return ret_conv;
15116 }
15117 static void LDKMessageRouter_JCalls_cloned(LDKMessageRouter* new_obj) {
15118         LDKMessageRouter_JCalls *j_calls = (LDKMessageRouter_JCalls*) new_obj->this_arg;
15119         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15120 }
15121 static inline LDKMessageRouter LDKMessageRouter_init (int64_t o) {
15122         LDKMessageRouter_JCalls *calls = MALLOC(sizeof(LDKMessageRouter_JCalls), "LDKMessageRouter_JCalls");
15123         atomic_init(&calls->refcnt, 1);
15124         calls->instance_ptr = o;
15125
15126         LDKMessageRouter ret = {
15127                 .this_arg = (void*) calls,
15128                 .find_path = find_path_LDKMessageRouter_jcall,
15129                 .free = LDKMessageRouter_JCalls_free,
15130         };
15131         return ret;
15132 }
15133 uint64_t  CS_LDK_LDKMessageRouter_new(int32_t o) {
15134         LDKMessageRouter *res_ptr = MALLOC(sizeof(LDKMessageRouter), "LDKMessageRouter");
15135         *res_ptr = LDKMessageRouter_init(o);
15136         return tag_ptr(res_ptr, true);
15137 }
15138 int64_t  CS_LDK_MessageRouter_find_path(int64_t this_arg, int8_tArray sender, ptrArray peers, int64_t destination) {
15139         void* this_arg_ptr = untag_ptr(this_arg);
15140         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15141         LDKMessageRouter* this_arg_conv = (LDKMessageRouter*)this_arg_ptr;
15142         LDKPublicKey sender_ref;
15143         CHECK(sender->arr_len == 33);
15144         memcpy(sender_ref.compressed_form, sender->elems, 33); FREE(sender);
15145         LDKCVec_PublicKeyZ peers_constr;
15146         peers_constr.datalen = peers->arr_len;
15147         if (peers_constr.datalen > 0)
15148                 peers_constr.data = MALLOC(peers_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
15149         else
15150                 peers_constr.data = NULL;
15151         int8_tArray* peers_vals = (void*) peers->elems;
15152         for (size_t i = 0; i < peers_constr.datalen; i++) {
15153                 int8_tArray peers_conv_8 = peers_vals[i];
15154                 LDKPublicKey peers_conv_8_ref;
15155                 CHECK(peers_conv_8->arr_len == 33);
15156                 memcpy(peers_conv_8_ref.compressed_form, peers_conv_8->elems, 33); FREE(peers_conv_8);
15157                 peers_constr.data[i] = peers_conv_8_ref;
15158         }
15159         FREE(peers);
15160         void* destination_ptr = untag_ptr(destination);
15161         CHECK_ACCESS(destination_ptr);
15162         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
15163         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
15164         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
15165         *ret_conv = (this_arg_conv->find_path)(this_arg_conv->this_arg, sender_ref, peers_constr, destination_conv);
15166         return tag_ptr(ret_conv, true);
15167 }
15168
15169 typedef struct LDKCoinSelectionSource_JCalls {
15170         atomic_size_t refcnt;
15171         uint32_t instance_ptr;
15172 } LDKCoinSelectionSource_JCalls;
15173 static void LDKCoinSelectionSource_JCalls_free(void* this_arg) {
15174         LDKCoinSelectionSource_JCalls *j_calls = (LDKCoinSelectionSource_JCalls*) this_arg;
15175         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15176                 FREE(j_calls);
15177         }
15178 }
15179 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) {
15180         LDKCoinSelectionSource_JCalls *j_calls = (LDKCoinSelectionSource_JCalls*) this_arg;
15181         int8_tArray claim_id_arr = init_int8_tArray(32, __LINE__);
15182         memcpy(claim_id_arr->elems, claim_id.data, 32);
15183         LDKCVec_InputZ must_spend_var = must_spend;
15184         int64_tArray must_spend_arr = NULL;
15185         must_spend_arr = init_int64_tArray(must_spend_var.datalen, __LINE__);
15186         int64_t *must_spend_arr_ptr = (int64_t*)(((uint8_t*)must_spend_arr) + 8);
15187         for (size_t h = 0; h < must_spend_var.datalen; h++) {
15188                 LDKInput must_spend_conv_7_var = must_spend_var.data[h];
15189                 int64_t must_spend_conv_7_ref = 0;
15190                 CHECK_INNER_FIELD_ACCESS_OR_NULL(must_spend_conv_7_var);
15191                 must_spend_conv_7_ref = tag_ptr(must_spend_conv_7_var.inner, must_spend_conv_7_var.is_owned);
15192                 must_spend_arr_ptr[h] = must_spend_conv_7_ref;
15193         }
15194         
15195         FREE(must_spend_var.data);
15196         LDKCVec_TxOutZ must_pay_to_var = must_pay_to;
15197         int64_tArray must_pay_to_arr = NULL;
15198         must_pay_to_arr = init_int64_tArray(must_pay_to_var.datalen, __LINE__);
15199         int64_t *must_pay_to_arr_ptr = (int64_t*)(((uint8_t*)must_pay_to_arr) + 8);
15200         for (size_t h = 0; h < must_pay_to_var.datalen; h++) {
15201                 LDKTxOut* must_pay_to_conv_7_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15202                 *must_pay_to_conv_7_ref = must_pay_to_var.data[h];
15203                 must_pay_to_arr_ptr[h] = tag_ptr(must_pay_to_conv_7_ref, true);
15204         }
15205         
15206         FREE(must_pay_to_var.data);
15207         int32_t target_feerate_sat_per_1000_weight_conv = target_feerate_sat_per_1000_weight;
15208         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);
15209         void* ret_ptr = untag_ptr(ret);
15210         CHECK_ACCESS(ret_ptr);
15211         LDKCResult_CoinSelectionNoneZ ret_conv = *(LDKCResult_CoinSelectionNoneZ*)(ret_ptr);
15212         FREE(untag_ptr(ret));
15213         return ret_conv;
15214 }
15215 LDKCResult_TransactionNoneZ sign_tx_LDKCoinSelectionSource_jcall(const void* this_arg, LDKTransaction tx) {
15216         LDKCoinSelectionSource_JCalls *j_calls = (LDKCoinSelectionSource_JCalls*) this_arg;
15217         LDKTransaction tx_var = tx;
15218         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
15219         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
15220         Transaction_free(tx_var);
15221         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 143, (int64_t)tx_arr);
15222         void* ret_ptr = untag_ptr(ret);
15223         CHECK_ACCESS(ret_ptr);
15224         LDKCResult_TransactionNoneZ ret_conv = *(LDKCResult_TransactionNoneZ*)(ret_ptr);
15225         FREE(untag_ptr(ret));
15226         return ret_conv;
15227 }
15228 static void LDKCoinSelectionSource_JCalls_cloned(LDKCoinSelectionSource* new_obj) {
15229         LDKCoinSelectionSource_JCalls *j_calls = (LDKCoinSelectionSource_JCalls*) new_obj->this_arg;
15230         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15231 }
15232 static inline LDKCoinSelectionSource LDKCoinSelectionSource_init (int64_t o) {
15233         LDKCoinSelectionSource_JCalls *calls = MALLOC(sizeof(LDKCoinSelectionSource_JCalls), "LDKCoinSelectionSource_JCalls");
15234         atomic_init(&calls->refcnt, 1);
15235         calls->instance_ptr = o;
15236
15237         LDKCoinSelectionSource ret = {
15238                 .this_arg = (void*) calls,
15239                 .select_confirmed_utxos = select_confirmed_utxos_LDKCoinSelectionSource_jcall,
15240                 .sign_tx = sign_tx_LDKCoinSelectionSource_jcall,
15241                 .free = LDKCoinSelectionSource_JCalls_free,
15242         };
15243         return ret;
15244 }
15245 uint64_t  CS_LDK_LDKCoinSelectionSource_new(int32_t o) {
15246         LDKCoinSelectionSource *res_ptr = MALLOC(sizeof(LDKCoinSelectionSource), "LDKCoinSelectionSource");
15247         *res_ptr = LDKCoinSelectionSource_init(o);
15248         return tag_ptr(res_ptr, true);
15249 }
15250 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) {
15251         void* this_arg_ptr = untag_ptr(this_arg);
15252         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15253         LDKCoinSelectionSource* this_arg_conv = (LDKCoinSelectionSource*)this_arg_ptr;
15254         LDKThirtyTwoBytes claim_id_ref;
15255         CHECK(claim_id->arr_len == 32);
15256         memcpy(claim_id_ref.data, claim_id->elems, 32); FREE(claim_id);
15257         LDKCVec_InputZ must_spend_constr;
15258         must_spend_constr.datalen = must_spend->arr_len;
15259         if (must_spend_constr.datalen > 0)
15260                 must_spend_constr.data = MALLOC(must_spend_constr.datalen * sizeof(LDKInput), "LDKCVec_InputZ Elements");
15261         else
15262                 must_spend_constr.data = NULL;
15263         int64_t* must_spend_vals = must_spend->elems;
15264         for (size_t h = 0; h < must_spend_constr.datalen; h++) {
15265                 int64_t must_spend_conv_7 = must_spend_vals[h];
15266                 LDKInput must_spend_conv_7_conv;
15267                 must_spend_conv_7_conv.inner = untag_ptr(must_spend_conv_7);
15268                 must_spend_conv_7_conv.is_owned = ptr_is_owned(must_spend_conv_7);
15269                 CHECK_INNER_FIELD_ACCESS_OR_NULL(must_spend_conv_7_conv);
15270                 must_spend_conv_7_conv = Input_clone(&must_spend_conv_7_conv);
15271                 must_spend_constr.data[h] = must_spend_conv_7_conv;
15272         }
15273         FREE(must_spend);
15274         LDKCVec_TxOutZ must_pay_to_constr;
15275         must_pay_to_constr.datalen = must_pay_to->arr_len;
15276         if (must_pay_to_constr.datalen > 0)
15277                 must_pay_to_constr.data = MALLOC(must_pay_to_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15278         else
15279                 must_pay_to_constr.data = NULL;
15280         int64_t* must_pay_to_vals = must_pay_to->elems;
15281         for (size_t h = 0; h < must_pay_to_constr.datalen; h++) {
15282                 int64_t must_pay_to_conv_7 = must_pay_to_vals[h];
15283                 void* must_pay_to_conv_7_ptr = untag_ptr(must_pay_to_conv_7);
15284                 CHECK_ACCESS(must_pay_to_conv_7_ptr);
15285                 LDKTxOut must_pay_to_conv_7_conv = *(LDKTxOut*)(must_pay_to_conv_7_ptr);
15286                 must_pay_to_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(must_pay_to_conv_7));
15287                 must_pay_to_constr.data[h] = must_pay_to_conv_7_conv;
15288         }
15289         FREE(must_pay_to);
15290         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
15291         *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);
15292         return tag_ptr(ret_conv, true);
15293 }
15294
15295 int64_t  CS_LDK_CoinSelectionSource_sign_tx(int64_t this_arg, int8_tArray tx) {
15296         void* this_arg_ptr = untag_ptr(this_arg);
15297         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15298         LDKCoinSelectionSource* this_arg_conv = (LDKCoinSelectionSource*)this_arg_ptr;
15299         LDKTransaction tx_ref;
15300         tx_ref.datalen = tx->arr_len;
15301         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
15302         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
15303         tx_ref.data_is_owned = true;
15304         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15305         *ret_conv = (this_arg_conv->sign_tx)(this_arg_conv->this_arg, tx_ref);
15306         return tag_ptr(ret_conv, true);
15307 }
15308
15309 typedef struct LDKWalletSource_JCalls {
15310         atomic_size_t refcnt;
15311         uint32_t instance_ptr;
15312 } LDKWalletSource_JCalls;
15313 static void LDKWalletSource_JCalls_free(void* this_arg) {
15314         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) this_arg;
15315         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15316                 FREE(j_calls);
15317         }
15318 }
15319 LDKCResult_CVec_UtxoZNoneZ list_confirmed_utxos_LDKWalletSource_jcall(const void* this_arg) {
15320         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) this_arg;
15321         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 144);
15322         void* ret_ptr = untag_ptr(ret);
15323         CHECK_ACCESS(ret_ptr);
15324         LDKCResult_CVec_UtxoZNoneZ ret_conv = *(LDKCResult_CVec_UtxoZNoneZ*)(ret_ptr);
15325         FREE(untag_ptr(ret));
15326         return ret_conv;
15327 }
15328 LDKCResult_CVec_u8ZNoneZ get_change_script_LDKWalletSource_jcall(const void* this_arg) {
15329         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) this_arg;
15330         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 145);
15331         void* ret_ptr = untag_ptr(ret);
15332         CHECK_ACCESS(ret_ptr);
15333         LDKCResult_CVec_u8ZNoneZ ret_conv = *(LDKCResult_CVec_u8ZNoneZ*)(ret_ptr);
15334         FREE(untag_ptr(ret));
15335         return ret_conv;
15336 }
15337 LDKCResult_TransactionNoneZ sign_tx_LDKWalletSource_jcall(const void* this_arg, LDKTransaction tx) {
15338         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) this_arg;
15339         LDKTransaction tx_var = tx;
15340         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
15341         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
15342         Transaction_free(tx_var);
15343         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 146, (int64_t)tx_arr);
15344         void* ret_ptr = untag_ptr(ret);
15345         CHECK_ACCESS(ret_ptr);
15346         LDKCResult_TransactionNoneZ ret_conv = *(LDKCResult_TransactionNoneZ*)(ret_ptr);
15347         FREE(untag_ptr(ret));
15348         return ret_conv;
15349 }
15350 static void LDKWalletSource_JCalls_cloned(LDKWalletSource* new_obj) {
15351         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) new_obj->this_arg;
15352         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15353 }
15354 static inline LDKWalletSource LDKWalletSource_init (int64_t o) {
15355         LDKWalletSource_JCalls *calls = MALLOC(sizeof(LDKWalletSource_JCalls), "LDKWalletSource_JCalls");
15356         atomic_init(&calls->refcnt, 1);
15357         calls->instance_ptr = o;
15358
15359         LDKWalletSource ret = {
15360                 .this_arg = (void*) calls,
15361                 .list_confirmed_utxos = list_confirmed_utxos_LDKWalletSource_jcall,
15362                 .get_change_script = get_change_script_LDKWalletSource_jcall,
15363                 .sign_tx = sign_tx_LDKWalletSource_jcall,
15364                 .free = LDKWalletSource_JCalls_free,
15365         };
15366         return ret;
15367 }
15368 uint64_t  CS_LDK_LDKWalletSource_new(int32_t o) {
15369         LDKWalletSource *res_ptr = MALLOC(sizeof(LDKWalletSource), "LDKWalletSource");
15370         *res_ptr = LDKWalletSource_init(o);
15371         return tag_ptr(res_ptr, true);
15372 }
15373 int64_t  CS_LDK_WalletSource_list_confirmed_utxos(int64_t this_arg) {
15374         void* this_arg_ptr = untag_ptr(this_arg);
15375         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15376         LDKWalletSource* this_arg_conv = (LDKWalletSource*)this_arg_ptr;
15377         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
15378         *ret_conv = (this_arg_conv->list_confirmed_utxos)(this_arg_conv->this_arg);
15379         return tag_ptr(ret_conv, true);
15380 }
15381
15382 int64_t  CS_LDK_WalletSource_get_change_script(int64_t this_arg) {
15383         void* this_arg_ptr = untag_ptr(this_arg);
15384         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15385         LDKWalletSource* this_arg_conv = (LDKWalletSource*)this_arg_ptr;
15386         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
15387         *ret_conv = (this_arg_conv->get_change_script)(this_arg_conv->this_arg);
15388         return tag_ptr(ret_conv, true);
15389 }
15390
15391 int64_t  CS_LDK_WalletSource_sign_tx(int64_t this_arg, int8_tArray tx) {
15392         void* this_arg_ptr = untag_ptr(this_arg);
15393         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15394         LDKWalletSource* this_arg_conv = (LDKWalletSource*)this_arg_ptr;
15395         LDKTransaction tx_ref;
15396         tx_ref.datalen = tx->arr_len;
15397         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
15398         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
15399         tx_ref.data_is_owned = true;
15400         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15401         *ret_conv = (this_arg_conv->sign_tx)(this_arg_conv->this_arg, tx_ref);
15402         return tag_ptr(ret_conv, true);
15403 }
15404
15405 uint32_t CS_LDK_LDKGossipSync_ty_from_ptr(int64_t ptr) {
15406         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15407         switch(obj->tag) {
15408                 case LDKGossipSync_P2P: return 0;
15409                 case LDKGossipSync_Rapid: return 1;
15410                 case LDKGossipSync_None: return 2;
15411                 default: abort();
15412         }
15413 }
15414 int64_t CS_LDK_LDKGossipSync_P2P_get_p2p(int64_t ptr) {
15415         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15416         CHECK(obj->tag == LDKGossipSync_P2P);
15417         LDKP2PGossipSync p2p_var = obj->p2p;
15418                         int64_t p2p_ref = 0;
15419                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
15420                         p2p_ref = tag_ptr(p2p_var.inner, false);
15421         return p2p_ref;
15422 }
15423 int64_t CS_LDK_LDKGossipSync_Rapid_get_rapid(int64_t ptr) {
15424         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15425         CHECK(obj->tag == LDKGossipSync_Rapid);
15426         LDKRapidGossipSync rapid_var = obj->rapid;
15427                         int64_t rapid_ref = 0;
15428                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
15429                         rapid_ref = tag_ptr(rapid_var.inner, false);
15430         return rapid_ref;
15431 }
15432 uint32_t CS_LDK_LDKFallback_ty_from_ptr(int64_t ptr) {
15433         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15434         switch(obj->tag) {
15435                 case LDKFallback_SegWitProgram: return 0;
15436                 case LDKFallback_PubKeyHash: return 1;
15437                 case LDKFallback_ScriptHash: return 2;
15438                 default: abort();
15439         }
15440 }
15441 int8_t CS_LDK_LDKFallback_SegWitProgram_get_version(int64_t ptr) {
15442         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15443         CHECK(obj->tag == LDKFallback_SegWitProgram);
15444         uint8_t version_val = obj->seg_wit_program.version._0;
15445         return version_val;
15446 }
15447 int8_tArray CS_LDK_LDKFallback_SegWitProgram_get_program(int64_t ptr) {
15448         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15449         CHECK(obj->tag == LDKFallback_SegWitProgram);
15450         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
15451                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
15452                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
15453         return program_arr;
15454 }
15455 int8_tArray CS_LDK_LDKFallback_PubKeyHash_get_pub_key_hash(int64_t ptr) {
15456         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15457         CHECK(obj->tag == LDKFallback_PubKeyHash);
15458         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
15459         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
15460         return pub_key_hash_arr;
15461 }
15462 int8_tArray CS_LDK_LDKFallback_ScriptHash_get_script_hash(int64_t ptr) {
15463         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15464         CHECK(obj->tag == LDKFallback_ScriptHash);
15465         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
15466         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
15467         return script_hash_arr;
15468 }
15469 jstring  CS_LDK__ldk_get_compiled_version() {
15470         LDKStr ret_str = _ldk_get_compiled_version();
15471         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
15472         Str_free(ret_str);
15473         return ret_conv;
15474 }
15475
15476 jstring  CS_LDK__ldk_c_bindings_get_compiled_version() {
15477         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
15478         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
15479         Str_free(ret_str);
15480         return ret_conv;
15481 }
15482
15483 int8_tArray  CS_LDK_U128_le_bytes(int8_tArray val) {
15484         LDKU128 val_ref;
15485         CHECK(val->arr_len == 16);
15486         memcpy(val_ref.le_bytes, val->elems, 16); FREE(val);
15487         int8_tArray ret_arr = init_int8_tArray(16, __LINE__);
15488         memcpy(ret_arr->elems, U128_le_bytes(val_ref).data, 16);
15489         return ret_arr;
15490 }
15491
15492 int8_tArray  CS_LDK_U128_new(int8_tArray le_bytes) {
15493         LDKSixteenBytes le_bytes_ref;
15494         CHECK(le_bytes->arr_len == 16);
15495         memcpy(le_bytes_ref.data, le_bytes->elems, 16); FREE(le_bytes);
15496         int8_tArray ret_arr = init_int8_tArray(16, __LINE__);
15497         memcpy(ret_arr->elems, U128_new(le_bytes_ref).le_bytes, 16);
15498         return ret_arr;
15499 }
15500
15501 int64_t  CS_LDK_BigEndianScalar_new(int8_tArray big_endian_bytes) {
15502         LDKThirtyTwoBytes big_endian_bytes_ref;
15503         CHECK(big_endian_bytes->arr_len == 32);
15504         memcpy(big_endian_bytes_ref.data, big_endian_bytes->elems, 32); FREE(big_endian_bytes);
15505         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
15506         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
15507         return tag_ptr(ret_ref, true);
15508 }
15509
15510 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
15511         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15512         *ret_copy = Bech32Error_clone(arg);
15513         int64_t ret_ref = tag_ptr(ret_copy, true);
15514         return ret_ref;
15515 }
15516 int64_t  CS_LDK_Bech32Error_clone_ptr(int64_t arg) {
15517         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
15518         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
15519         return ret_conv;
15520 }
15521
15522 int64_t  CS_LDK_Bech32Error_clone(int64_t orig) {
15523         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
15524         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15525         *ret_copy = Bech32Error_clone(orig_conv);
15526         int64_t ret_ref = tag_ptr(ret_copy, true);
15527         return ret_ref;
15528 }
15529
15530 void  CS_LDK_Bech32Error_free(int64_t o) {
15531         if (!ptr_is_owned(o)) return;
15532         void* o_ptr = untag_ptr(o);
15533         CHECK_ACCESS(o_ptr);
15534         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
15535         FREE(untag_ptr(o));
15536         Bech32Error_free(o_conv);
15537 }
15538
15539 void  CS_LDK_Transaction_free(int8_tArray _res) {
15540         LDKTransaction _res_ref;
15541         _res_ref.datalen = _res->arr_len;
15542         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
15543         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15544         _res_ref.data_is_owned = true;
15545         Transaction_free(_res_ref);
15546 }
15547
15548 void  CS_LDK_Witness_free(int8_tArray _res) {
15549         LDKWitness _res_ref;
15550         _res_ref.datalen = _res->arr_len;
15551         _res_ref.data = MALLOC(_res_ref.datalen, "LDKWitness Bytes");
15552         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15553         _res_ref.data_is_owned = true;
15554         Witness_free(_res_ref);
15555 }
15556
15557 void  CS_LDK_TxIn_free(int64_t _res) {
15558         if (!ptr_is_owned(_res)) return;
15559         void* _res_ptr = untag_ptr(_res);
15560         CHECK_ACCESS(_res_ptr);
15561         LDKTxIn _res_conv = *(LDKTxIn*)(_res_ptr);
15562         FREE(untag_ptr(_res));
15563         TxIn_free(_res_conv);
15564 }
15565
15566 int64_t  CS_LDK_TxIn_new(int8_tArray witness, int8_tArray script_sig, int32_t sequence, int8_tArray previous_txid, int32_t previous_vout) {
15567         LDKWitness witness_ref;
15568         witness_ref.datalen = witness->arr_len;
15569         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
15570         memcpy(witness_ref.data, witness->elems, witness_ref.datalen); FREE(witness);
15571         witness_ref.data_is_owned = true;
15572         LDKCVec_u8Z script_sig_ref;
15573         script_sig_ref.datalen = script_sig->arr_len;
15574         script_sig_ref.data = MALLOC(script_sig_ref.datalen, "LDKCVec_u8Z Bytes");
15575         memcpy(script_sig_ref.data, script_sig->elems, script_sig_ref.datalen); FREE(script_sig);
15576         LDKThirtyTwoBytes previous_txid_ref;
15577         CHECK(previous_txid->arr_len == 32);
15578         memcpy(previous_txid_ref.data, previous_txid->elems, 32); FREE(previous_txid);
15579         LDKTxIn* ret_ref = MALLOC(sizeof(LDKTxIn), "LDKTxIn");
15580         *ret_ref = TxIn_new(witness_ref, script_sig_ref, sequence, previous_txid_ref, previous_vout);
15581         return tag_ptr(ret_ref, true);
15582 }
15583
15584 int64_t  CS_LDK_TxOut_new(int8_tArray script_pubkey, int64_t value) {
15585         LDKCVec_u8Z script_pubkey_ref;
15586         script_pubkey_ref.datalen = script_pubkey->arr_len;
15587         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
15588         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
15589         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15590         *ret_ref = TxOut_new(script_pubkey_ref, value);
15591         return tag_ptr(ret_ref, true);
15592 }
15593
15594 void  CS_LDK_TxOut_free(int64_t _res) {
15595         if (!ptr_is_owned(_res)) return;
15596         void* _res_ptr = untag_ptr(_res);
15597         CHECK_ACCESS(_res_ptr);
15598         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
15599         FREE(untag_ptr(_res));
15600         TxOut_free(_res_conv);
15601 }
15602
15603 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
15604         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15605         *ret_ref = TxOut_clone(arg);
15606         return tag_ptr(ret_ref, true);
15607 }
15608 int64_t  CS_LDK_TxOut_clone_ptr(int64_t arg) {
15609         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
15610         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
15611         return ret_conv;
15612 }
15613
15614 int64_t  CS_LDK_TxOut_clone(int64_t orig) {
15615         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
15616         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15617         *ret_ref = TxOut_clone(orig_conv);
15618         return tag_ptr(ret_ref, true);
15619 }
15620
15621 void  CS_LDK_Str_free(jstring _res) {
15622         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
15623         Str_free(dummy);
15624 }
15625
15626 int64_t  CS_LDK_COption_u64Z_some(int64_t o) {
15627         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15628         *ret_copy = COption_u64Z_some(o);
15629         int64_t ret_ref = tag_ptr(ret_copy, true);
15630         return ret_ref;
15631 }
15632
15633 int64_t  CS_LDK_COption_u64Z_none() {
15634         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15635         *ret_copy = COption_u64Z_none();
15636         int64_t ret_ref = tag_ptr(ret_copy, true);
15637         return ret_ref;
15638 }
15639
15640 void  CS_LDK_COption_u64Z_free(int64_t _res) {
15641         if (!ptr_is_owned(_res)) return;
15642         void* _res_ptr = untag_ptr(_res);
15643         CHECK_ACCESS(_res_ptr);
15644         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15645         FREE(untag_ptr(_res));
15646         COption_u64Z_free(_res_conv);
15647 }
15648
15649 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15650         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15651         *ret_copy = COption_u64Z_clone(arg);
15652         int64_t ret_ref = tag_ptr(ret_copy, true);
15653         return ret_ref;
15654 }
15655 int64_t  CS_LDK_COption_u64Z_clone_ptr(int64_t arg) {
15656         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
15657         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
15658         return ret_conv;
15659 }
15660
15661 int64_t  CS_LDK_COption_u64Z_clone(int64_t orig) {
15662         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
15663         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15664         *ret_copy = COption_u64Z_clone(orig_conv);
15665         int64_t ret_ref = tag_ptr(ret_copy, true);
15666         return ret_ref;
15667 }
15668
15669 void  CS_LDK_CVec_BlindedPathZ_free(int64_tArray _res) {
15670         LDKCVec_BlindedPathZ _res_constr;
15671         _res_constr.datalen = _res->arr_len;
15672         if (_res_constr.datalen > 0)
15673                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBlindedPath), "LDKCVec_BlindedPathZ Elements");
15674         else
15675                 _res_constr.data = NULL;
15676         int64_t* _res_vals = _res->elems;
15677         for (size_t n = 0; n < _res_constr.datalen; n++) {
15678                 int64_t _res_conv_13 = _res_vals[n];
15679                 LDKBlindedPath _res_conv_13_conv;
15680                 _res_conv_13_conv.inner = untag_ptr(_res_conv_13);
15681                 _res_conv_13_conv.is_owned = ptr_is_owned(_res_conv_13);
15682                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_13_conv);
15683                 _res_constr.data[n] = _res_conv_13_conv;
15684         }
15685         FREE(_res);
15686         CVec_BlindedPathZ_free(_res_constr);
15687 }
15688
15689 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_ok(int64_t o) {
15690         LDKRefund o_conv;
15691         o_conv.inner = untag_ptr(o);
15692         o_conv.is_owned = ptr_is_owned(o);
15693         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15694         o_conv = Refund_clone(&o_conv);
15695         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
15696         *ret_conv = CResult_RefundBolt12ParseErrorZ_ok(o_conv);
15697         return tag_ptr(ret_conv, true);
15698 }
15699
15700 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_err(int64_t e) {
15701         LDKBolt12ParseError e_conv;
15702         e_conv.inner = untag_ptr(e);
15703         e_conv.is_owned = ptr_is_owned(e);
15704         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15705         e_conv = Bolt12ParseError_clone(&e_conv);
15706         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
15707         *ret_conv = CResult_RefundBolt12ParseErrorZ_err(e_conv);
15708         return tag_ptr(ret_conv, true);
15709 }
15710
15711 jboolean  CS_LDK_CResult_RefundBolt12ParseErrorZ_is_ok(int64_t o) {
15712         LDKCResult_RefundBolt12ParseErrorZ* o_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(o);
15713         jboolean ret_conv = CResult_RefundBolt12ParseErrorZ_is_ok(o_conv);
15714         return ret_conv;
15715 }
15716
15717 void  CS_LDK_CResult_RefundBolt12ParseErrorZ_free(int64_t _res) {
15718         if (!ptr_is_owned(_res)) return;
15719         void* _res_ptr = untag_ptr(_res);
15720         CHECK_ACCESS(_res_ptr);
15721         LDKCResult_RefundBolt12ParseErrorZ _res_conv = *(LDKCResult_RefundBolt12ParseErrorZ*)(_res_ptr);
15722         FREE(untag_ptr(_res));
15723         CResult_RefundBolt12ParseErrorZ_free(_res_conv);
15724 }
15725
15726 static inline uint64_t CResult_RefundBolt12ParseErrorZ_clone_ptr(LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR arg) {
15727         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
15728         *ret_conv = CResult_RefundBolt12ParseErrorZ_clone(arg);
15729         return tag_ptr(ret_conv, true);
15730 }
15731 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_clone_ptr(int64_t arg) {
15732         LDKCResult_RefundBolt12ParseErrorZ* arg_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(arg);
15733         int64_t ret_conv = CResult_RefundBolt12ParseErrorZ_clone_ptr(arg_conv);
15734         return ret_conv;
15735 }
15736
15737 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_clone(int64_t orig) {
15738         LDKCResult_RefundBolt12ParseErrorZ* orig_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(orig);
15739         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
15740         *ret_conv = CResult_RefundBolt12ParseErrorZ_clone(orig_conv);
15741         return tag_ptr(ret_conv, true);
15742 }
15743
15744 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_ok(int64_t o) {
15745         void* o_ptr = untag_ptr(o);
15746         CHECK_ACCESS(o_ptr);
15747         LDKRetry o_conv = *(LDKRetry*)(o_ptr);
15748         o_conv = Retry_clone((LDKRetry*)untag_ptr(o));
15749         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
15750         *ret_conv = CResult_RetryDecodeErrorZ_ok(o_conv);
15751         return tag_ptr(ret_conv, true);
15752 }
15753
15754 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_err(int64_t e) {
15755         void* e_ptr = untag_ptr(e);
15756         CHECK_ACCESS(e_ptr);
15757         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15758         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15759         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
15760         *ret_conv = CResult_RetryDecodeErrorZ_err(e_conv);
15761         return tag_ptr(ret_conv, true);
15762 }
15763
15764 jboolean  CS_LDK_CResult_RetryDecodeErrorZ_is_ok(int64_t o) {
15765         LDKCResult_RetryDecodeErrorZ* o_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(o);
15766         jboolean ret_conv = CResult_RetryDecodeErrorZ_is_ok(o_conv);
15767         return ret_conv;
15768 }
15769
15770 void  CS_LDK_CResult_RetryDecodeErrorZ_free(int64_t _res) {
15771         if (!ptr_is_owned(_res)) return;
15772         void* _res_ptr = untag_ptr(_res);
15773         CHECK_ACCESS(_res_ptr);
15774         LDKCResult_RetryDecodeErrorZ _res_conv = *(LDKCResult_RetryDecodeErrorZ*)(_res_ptr);
15775         FREE(untag_ptr(_res));
15776         CResult_RetryDecodeErrorZ_free(_res_conv);
15777 }
15778
15779 static inline uint64_t CResult_RetryDecodeErrorZ_clone_ptr(LDKCResult_RetryDecodeErrorZ *NONNULL_PTR arg) {
15780         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
15781         *ret_conv = CResult_RetryDecodeErrorZ_clone(arg);
15782         return tag_ptr(ret_conv, true);
15783 }
15784 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_clone_ptr(int64_t arg) {
15785         LDKCResult_RetryDecodeErrorZ* arg_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(arg);
15786         int64_t ret_conv = CResult_RetryDecodeErrorZ_clone_ptr(arg_conv);
15787         return ret_conv;
15788 }
15789
15790 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_clone(int64_t orig) {
15791         LDKCResult_RetryDecodeErrorZ* orig_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(orig);
15792         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
15793         *ret_conv = CResult_RetryDecodeErrorZ_clone(orig_conv);
15794         return tag_ptr(ret_conv, true);
15795 }
15796
15797 int64_t  CS_LDK_CResult_NoneAPIErrorZ_ok() {
15798         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15799         *ret_conv = CResult_NoneAPIErrorZ_ok();
15800         return tag_ptr(ret_conv, true);
15801 }
15802
15803 int64_t  CS_LDK_CResult_NoneAPIErrorZ_err(int64_t e) {
15804         void* e_ptr = untag_ptr(e);
15805         CHECK_ACCESS(e_ptr);
15806         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15807         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
15808         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15809         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15810         return tag_ptr(ret_conv, true);
15811 }
15812
15813 jboolean  CS_LDK_CResult_NoneAPIErrorZ_is_ok(int64_t o) {
15814         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
15815         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15816         return ret_conv;
15817 }
15818
15819 void  CS_LDK_CResult_NoneAPIErrorZ_free(int64_t _res) {
15820         if (!ptr_is_owned(_res)) return;
15821         void* _res_ptr = untag_ptr(_res);
15822         CHECK_ACCESS(_res_ptr);
15823         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15824         FREE(untag_ptr(_res));
15825         CResult_NoneAPIErrorZ_free(_res_conv);
15826 }
15827
15828 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15829         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15830         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15831         return tag_ptr(ret_conv, true);
15832 }
15833 int64_t  CS_LDK_CResult_NoneAPIErrorZ_clone_ptr(int64_t arg) {
15834         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
15835         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15836         return ret_conv;
15837 }
15838
15839 int64_t  CS_LDK_CResult_NoneAPIErrorZ_clone(int64_t orig) {
15840         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
15841         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15842         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15843         return tag_ptr(ret_conv, true);
15844 }
15845
15846 void  CS_LDK_CVec_CResult_NoneAPIErrorZZ_free(int64_tArray _res) {
15847         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15848         _res_constr.datalen = _res->arr_len;
15849         if (_res_constr.datalen > 0)
15850                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15851         else
15852                 _res_constr.data = NULL;
15853         int64_t* _res_vals = _res->elems;
15854         for (size_t w = 0; w < _res_constr.datalen; w++) {
15855                 int64_t _res_conv_22 = _res_vals[w];
15856                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
15857                 CHECK_ACCESS(_res_conv_22_ptr);
15858                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15859                 FREE(untag_ptr(_res_conv_22));
15860                 _res_constr.data[w] = _res_conv_22_conv;
15861         }
15862         FREE(_res);
15863         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15864 }
15865
15866 void  CS_LDK_CVec_APIErrorZ_free(int64_tArray _res) {
15867         LDKCVec_APIErrorZ _res_constr;
15868         _res_constr.datalen = _res->arr_len;
15869         if (_res_constr.datalen > 0)
15870                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15871         else
15872                 _res_constr.data = NULL;
15873         int64_t* _res_vals = _res->elems;
15874         for (size_t k = 0; k < _res_constr.datalen; k++) {
15875                 int64_t _res_conv_10 = _res_vals[k];
15876                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
15877                 CHECK_ACCESS(_res_conv_10_ptr);
15878                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15879                 FREE(untag_ptr(_res_conv_10));
15880                 _res_constr.data[k] = _res_conv_10_conv;
15881         }
15882         FREE(_res);
15883         CVec_APIErrorZ_free(_res_constr);
15884 }
15885
15886 int64_t  CS_LDK_COption_ThirtyTwoBytesZ_some(int8_tArray o) {
15887         LDKThirtyTwoBytes o_ref;
15888         CHECK(o->arr_len == 32);
15889         memcpy(o_ref.data, o->elems, 32); FREE(o);
15890         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
15891         *ret_copy = COption_ThirtyTwoBytesZ_some(o_ref);
15892         int64_t ret_ref = tag_ptr(ret_copy, true);
15893         return ret_ref;
15894 }
15895
15896 int64_t  CS_LDK_COption_ThirtyTwoBytesZ_none() {
15897         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
15898         *ret_copy = COption_ThirtyTwoBytesZ_none();
15899         int64_t ret_ref = tag_ptr(ret_copy, true);
15900         return ret_ref;
15901 }
15902
15903 void  CS_LDK_COption_ThirtyTwoBytesZ_free(int64_t _res) {
15904         if (!ptr_is_owned(_res)) return;
15905         void* _res_ptr = untag_ptr(_res);
15906         CHECK_ACCESS(_res_ptr);
15907         LDKCOption_ThirtyTwoBytesZ _res_conv = *(LDKCOption_ThirtyTwoBytesZ*)(_res_ptr);
15908         FREE(untag_ptr(_res));
15909         COption_ThirtyTwoBytesZ_free(_res_conv);
15910 }
15911
15912 static inline uint64_t COption_ThirtyTwoBytesZ_clone_ptr(LDKCOption_ThirtyTwoBytesZ *NONNULL_PTR arg) {
15913         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
15914         *ret_copy = COption_ThirtyTwoBytesZ_clone(arg);
15915         int64_t ret_ref = tag_ptr(ret_copy, true);
15916         return ret_ref;
15917 }
15918 int64_t  CS_LDK_COption_ThirtyTwoBytesZ_clone_ptr(int64_t arg) {
15919         LDKCOption_ThirtyTwoBytesZ* arg_conv = (LDKCOption_ThirtyTwoBytesZ*)untag_ptr(arg);
15920         int64_t ret_conv = COption_ThirtyTwoBytesZ_clone_ptr(arg_conv);
15921         return ret_conv;
15922 }
15923
15924 int64_t  CS_LDK_COption_ThirtyTwoBytesZ_clone(int64_t orig) {
15925         LDKCOption_ThirtyTwoBytesZ* orig_conv = (LDKCOption_ThirtyTwoBytesZ*)untag_ptr(orig);
15926         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
15927         *ret_copy = COption_ThirtyTwoBytesZ_clone(orig_conv);
15928         int64_t ret_ref = tag_ptr(ret_copy, true);
15929         return ret_ref;
15930 }
15931
15932 void  CS_LDK_CVec_u8Z_free(int8_tArray _res) {
15933         LDKCVec_u8Z _res_ref;
15934         _res_ref.datalen = _res->arr_len;
15935         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15936         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15937         CVec_u8Z_free(_res_ref);
15938 }
15939
15940 int64_t  CS_LDK_COption_CVec_u8ZZ_some(int8_tArray o) {
15941         LDKCVec_u8Z o_ref;
15942         o_ref.datalen = o->arr_len;
15943         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
15944         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15945         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
15946         *ret_copy = COption_CVec_u8ZZ_some(o_ref);
15947         int64_t ret_ref = tag_ptr(ret_copy, true);
15948         return ret_ref;
15949 }
15950
15951 int64_t  CS_LDK_COption_CVec_u8ZZ_none() {
15952         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
15953         *ret_copy = COption_CVec_u8ZZ_none();
15954         int64_t ret_ref = tag_ptr(ret_copy, true);
15955         return ret_ref;
15956 }
15957
15958 void  CS_LDK_COption_CVec_u8ZZ_free(int64_t _res) {
15959         if (!ptr_is_owned(_res)) return;
15960         void* _res_ptr = untag_ptr(_res);
15961         CHECK_ACCESS(_res_ptr);
15962         LDKCOption_CVec_u8ZZ _res_conv = *(LDKCOption_CVec_u8ZZ*)(_res_ptr);
15963         FREE(untag_ptr(_res));
15964         COption_CVec_u8ZZ_free(_res_conv);
15965 }
15966
15967 static inline uint64_t COption_CVec_u8ZZ_clone_ptr(LDKCOption_CVec_u8ZZ *NONNULL_PTR arg) {
15968         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
15969         *ret_copy = COption_CVec_u8ZZ_clone(arg);
15970         int64_t ret_ref = tag_ptr(ret_copy, true);
15971         return ret_ref;
15972 }
15973 int64_t  CS_LDK_COption_CVec_u8ZZ_clone_ptr(int64_t arg) {
15974         LDKCOption_CVec_u8ZZ* arg_conv = (LDKCOption_CVec_u8ZZ*)untag_ptr(arg);
15975         int64_t ret_conv = COption_CVec_u8ZZ_clone_ptr(arg_conv);
15976         return ret_conv;
15977 }
15978
15979 int64_t  CS_LDK_COption_CVec_u8ZZ_clone(int64_t orig) {
15980         LDKCOption_CVec_u8ZZ* orig_conv = (LDKCOption_CVec_u8ZZ*)untag_ptr(orig);
15981         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
15982         *ret_copy = COption_CVec_u8ZZ_clone(orig_conv);
15983         int64_t ret_ref = tag_ptr(ret_copy, true);
15984         return ret_ref;
15985 }
15986
15987 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_ok(int64_t o) {
15988         LDKRecipientOnionFields o_conv;
15989         o_conv.inner = untag_ptr(o);
15990         o_conv.is_owned = ptr_is_owned(o);
15991         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15992         o_conv = RecipientOnionFields_clone(&o_conv);
15993         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
15994         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_ok(o_conv);
15995         return tag_ptr(ret_conv, true);
15996 }
15997
15998 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_err(int64_t e) {
15999         void* e_ptr = untag_ptr(e);
16000         CHECK_ACCESS(e_ptr);
16001         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16002         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16003         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16004         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_err(e_conv);
16005         return tag_ptr(ret_conv, true);
16006 }
16007
16008 jboolean  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(int64_t o) {
16009         LDKCResult_RecipientOnionFieldsDecodeErrorZ* o_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(o);
16010         jboolean ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(o_conv);
16011         return ret_conv;
16012 }
16013
16014 void  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_free(int64_t _res) {
16015         if (!ptr_is_owned(_res)) return;
16016         void* _res_ptr = untag_ptr(_res);
16017         CHECK_ACCESS(_res_ptr);
16018         LDKCResult_RecipientOnionFieldsDecodeErrorZ _res_conv = *(LDKCResult_RecipientOnionFieldsDecodeErrorZ*)(_res_ptr);
16019         FREE(untag_ptr(_res));
16020         CResult_RecipientOnionFieldsDecodeErrorZ_free(_res_conv);
16021 }
16022
16023 static inline uint64_t CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR arg) {
16024         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16025         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone(arg);
16026         return tag_ptr(ret_conv, true);
16027 }
16028 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(int64_t arg) {
16029         LDKCResult_RecipientOnionFieldsDecodeErrorZ* arg_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(arg);
16030         int64_t ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(arg_conv);
16031         return ret_conv;
16032 }
16033
16034 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_clone(int64_t orig) {
16035         LDKCResult_RecipientOnionFieldsDecodeErrorZ* orig_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(orig);
16036         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16037         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone(orig_conv);
16038         return tag_ptr(ret_conv, true);
16039 }
16040
16041 static inline uint64_t C2Tuple_u64CVec_u8ZZ_clone_ptr(LDKC2Tuple_u64CVec_u8ZZ *NONNULL_PTR arg) {
16042         LDKC2Tuple_u64CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKC2Tuple_u64CVec_u8ZZ");
16043         *ret_conv = C2Tuple_u64CVec_u8ZZ_clone(arg);
16044         return tag_ptr(ret_conv, true);
16045 }
16046 int64_t  CS_LDK_C2Tuple_u64CVec_u8ZZ_clone_ptr(int64_t arg) {
16047         LDKC2Tuple_u64CVec_u8ZZ* arg_conv = (LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(arg);
16048         int64_t ret_conv = C2Tuple_u64CVec_u8ZZ_clone_ptr(arg_conv);
16049         return ret_conv;
16050 }
16051
16052 int64_t  CS_LDK_C2Tuple_u64CVec_u8ZZ_clone(int64_t orig) {
16053         LDKC2Tuple_u64CVec_u8ZZ* orig_conv = (LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(orig);
16054         LDKC2Tuple_u64CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKC2Tuple_u64CVec_u8ZZ");
16055         *ret_conv = C2Tuple_u64CVec_u8ZZ_clone(orig_conv);
16056         return tag_ptr(ret_conv, true);
16057 }
16058
16059 int64_t  CS_LDK_C2Tuple_u64CVec_u8ZZ_new(int64_t a, int8_tArray b) {
16060         LDKCVec_u8Z b_ref;
16061         b_ref.datalen = b->arr_len;
16062         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
16063         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
16064         LDKC2Tuple_u64CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKC2Tuple_u64CVec_u8ZZ");
16065         *ret_conv = C2Tuple_u64CVec_u8ZZ_new(a, b_ref);
16066         return tag_ptr(ret_conv, true);
16067 }
16068
16069 void  CS_LDK_C2Tuple_u64CVec_u8ZZ_free(int64_t _res) {
16070         if (!ptr_is_owned(_res)) return;
16071         void* _res_ptr = untag_ptr(_res);
16072         CHECK_ACCESS(_res_ptr);
16073         LDKC2Tuple_u64CVec_u8ZZ _res_conv = *(LDKC2Tuple_u64CVec_u8ZZ*)(_res_ptr);
16074         FREE(untag_ptr(_res));
16075         C2Tuple_u64CVec_u8ZZ_free(_res_conv);
16076 }
16077
16078 void  CS_LDK_CVec_C2Tuple_u64CVec_u8ZZZ_free(int64_tArray _res) {
16079         LDKCVec_C2Tuple_u64CVec_u8ZZZ _res_constr;
16080         _res_constr.datalen = _res->arr_len;
16081         if (_res_constr.datalen > 0)
16082                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKCVec_C2Tuple_u64CVec_u8ZZZ Elements");
16083         else
16084                 _res_constr.data = NULL;
16085         int64_t* _res_vals = _res->elems;
16086         for (size_t x = 0; x < _res_constr.datalen; x++) {
16087                 int64_t _res_conv_23 = _res_vals[x];
16088                 void* _res_conv_23_ptr = untag_ptr(_res_conv_23);
16089                 CHECK_ACCESS(_res_conv_23_ptr);
16090                 LDKC2Tuple_u64CVec_u8ZZ _res_conv_23_conv = *(LDKC2Tuple_u64CVec_u8ZZ*)(_res_conv_23_ptr);
16091                 FREE(untag_ptr(_res_conv_23));
16092                 _res_constr.data[x] = _res_conv_23_conv;
16093         }
16094         FREE(_res);
16095         CVec_C2Tuple_u64CVec_u8ZZZ_free(_res_constr);
16096 }
16097
16098 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_ok(int64_t o) {
16099         LDKRecipientOnionFields o_conv;
16100         o_conv.inner = untag_ptr(o);
16101         o_conv.is_owned = ptr_is_owned(o);
16102         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16103         o_conv = RecipientOnionFields_clone(&o_conv);
16104         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
16105         *ret_conv = CResult_RecipientOnionFieldsNoneZ_ok(o_conv);
16106         return tag_ptr(ret_conv, true);
16107 }
16108
16109 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_err() {
16110         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
16111         *ret_conv = CResult_RecipientOnionFieldsNoneZ_err();
16112         return tag_ptr(ret_conv, true);
16113 }
16114
16115 jboolean  CS_LDK_CResult_RecipientOnionFieldsNoneZ_is_ok(int64_t o) {
16116         LDKCResult_RecipientOnionFieldsNoneZ* o_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(o);
16117         jboolean ret_conv = CResult_RecipientOnionFieldsNoneZ_is_ok(o_conv);
16118         return ret_conv;
16119 }
16120
16121 void  CS_LDK_CResult_RecipientOnionFieldsNoneZ_free(int64_t _res) {
16122         if (!ptr_is_owned(_res)) return;
16123         void* _res_ptr = untag_ptr(_res);
16124         CHECK_ACCESS(_res_ptr);
16125         LDKCResult_RecipientOnionFieldsNoneZ _res_conv = *(LDKCResult_RecipientOnionFieldsNoneZ*)(_res_ptr);
16126         FREE(untag_ptr(_res));
16127         CResult_RecipientOnionFieldsNoneZ_free(_res_conv);
16128 }
16129
16130 static inline uint64_t CResult_RecipientOnionFieldsNoneZ_clone_ptr(LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR arg) {
16131         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
16132         *ret_conv = CResult_RecipientOnionFieldsNoneZ_clone(arg);
16133         return tag_ptr(ret_conv, true);
16134 }
16135 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_clone_ptr(int64_t arg) {
16136         LDKCResult_RecipientOnionFieldsNoneZ* arg_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(arg);
16137         int64_t ret_conv = CResult_RecipientOnionFieldsNoneZ_clone_ptr(arg_conv);
16138         return ret_conv;
16139 }
16140
16141 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_clone(int64_t orig) {
16142         LDKCResult_RecipientOnionFieldsNoneZ* orig_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(orig);
16143         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
16144         *ret_conv = CResult_RecipientOnionFieldsNoneZ_clone(orig_conv);
16145         return tag_ptr(ret_conv, true);
16146 }
16147
16148 void  CS_LDK_CVec_ThirtyTwoBytesZ_free(ptrArray _res) {
16149         LDKCVec_ThirtyTwoBytesZ _res_constr;
16150         _res_constr.datalen = _res->arr_len;
16151         if (_res_constr.datalen > 0)
16152                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
16153         else
16154                 _res_constr.data = NULL;
16155         int8_tArray* _res_vals = (void*) _res->elems;
16156         for (size_t i = 0; i < _res_constr.datalen; i++) {
16157                 int8_tArray _res_conv_8 = _res_vals[i];
16158                 LDKThirtyTwoBytes _res_conv_8_ref;
16159                 CHECK(_res_conv_8->arr_len == 32);
16160                 memcpy(_res_conv_8_ref.data, _res_conv_8->elems, 32); FREE(_res_conv_8);
16161                 _res_constr.data[i] = _res_conv_8_ref;
16162         }
16163         FREE(_res);
16164         CVec_ThirtyTwoBytesZ_free(_res_constr);
16165 }
16166
16167 int64_t  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_some(ptrArray o) {
16168         LDKCVec_ThirtyTwoBytesZ o_constr;
16169         o_constr.datalen = o->arr_len;
16170         if (o_constr.datalen > 0)
16171                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
16172         else
16173                 o_constr.data = NULL;
16174         int8_tArray* o_vals = (void*) o->elems;
16175         for (size_t i = 0; i < o_constr.datalen; i++) {
16176                 int8_tArray o_conv_8 = o_vals[i];
16177                 LDKThirtyTwoBytes o_conv_8_ref;
16178                 CHECK(o_conv_8->arr_len == 32);
16179                 memcpy(o_conv_8_ref.data, o_conv_8->elems, 32); FREE(o_conv_8);
16180                 o_constr.data[i] = o_conv_8_ref;
16181         }
16182         FREE(o);
16183         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
16184         *ret_copy = COption_CVec_ThirtyTwoBytesZZ_some(o_constr);
16185         int64_t ret_ref = tag_ptr(ret_copy, true);
16186         return ret_ref;
16187 }
16188
16189 int64_t  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_none() {
16190         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
16191         *ret_copy = COption_CVec_ThirtyTwoBytesZZ_none();
16192         int64_t ret_ref = tag_ptr(ret_copy, true);
16193         return ret_ref;
16194 }
16195
16196 void  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_free(int64_t _res) {
16197         if (!ptr_is_owned(_res)) return;
16198         void* _res_ptr = untag_ptr(_res);
16199         CHECK_ACCESS(_res_ptr);
16200         LDKCOption_CVec_ThirtyTwoBytesZZ _res_conv = *(LDKCOption_CVec_ThirtyTwoBytesZZ*)(_res_ptr);
16201         FREE(untag_ptr(_res));
16202         COption_CVec_ThirtyTwoBytesZZ_free(_res_conv);
16203 }
16204
16205 static inline uint64_t COption_CVec_ThirtyTwoBytesZZ_clone_ptr(LDKCOption_CVec_ThirtyTwoBytesZZ *NONNULL_PTR arg) {
16206         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
16207         *ret_copy = COption_CVec_ThirtyTwoBytesZZ_clone(arg);
16208         int64_t ret_ref = tag_ptr(ret_copy, true);
16209         return ret_ref;
16210 }
16211 int64_t  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_clone_ptr(int64_t arg) {
16212         LDKCOption_CVec_ThirtyTwoBytesZZ* arg_conv = (LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(arg);
16213         int64_t ret_conv = COption_CVec_ThirtyTwoBytesZZ_clone_ptr(arg_conv);
16214         return ret_conv;
16215 }
16216
16217 int64_t  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_clone(int64_t orig) {
16218         LDKCOption_CVec_ThirtyTwoBytesZZ* orig_conv = (LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(orig);
16219         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
16220         *ret_copy = COption_CVec_ThirtyTwoBytesZZ_clone(orig_conv);
16221         int64_t ret_ref = tag_ptr(ret_copy, true);
16222         return ret_ref;
16223 }
16224
16225 int64_t  CS_LDK_CResult_ThirtyTwoBytesNoneZ_ok(int8_tArray o) {
16226         LDKThirtyTwoBytes o_ref;
16227         CHECK(o->arr_len == 32);
16228         memcpy(o_ref.data, o->elems, 32); FREE(o);
16229         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
16230         *ret_conv = CResult_ThirtyTwoBytesNoneZ_ok(o_ref);
16231         return tag_ptr(ret_conv, true);
16232 }
16233
16234 int64_t  CS_LDK_CResult_ThirtyTwoBytesNoneZ_err() {
16235         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
16236         *ret_conv = CResult_ThirtyTwoBytesNoneZ_err();
16237         return tag_ptr(ret_conv, true);
16238 }
16239
16240 jboolean  CS_LDK_CResult_ThirtyTwoBytesNoneZ_is_ok(int64_t o) {
16241         LDKCResult_ThirtyTwoBytesNoneZ* o_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(o);
16242         jboolean ret_conv = CResult_ThirtyTwoBytesNoneZ_is_ok(o_conv);
16243         return ret_conv;
16244 }
16245
16246 void  CS_LDK_CResult_ThirtyTwoBytesNoneZ_free(int64_t _res) {
16247         if (!ptr_is_owned(_res)) return;
16248         void* _res_ptr = untag_ptr(_res);
16249         CHECK_ACCESS(_res_ptr);
16250         LDKCResult_ThirtyTwoBytesNoneZ _res_conv = *(LDKCResult_ThirtyTwoBytesNoneZ*)(_res_ptr);
16251         FREE(untag_ptr(_res));
16252         CResult_ThirtyTwoBytesNoneZ_free(_res_conv);
16253 }
16254
16255 static inline uint64_t CResult_ThirtyTwoBytesNoneZ_clone_ptr(LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR arg) {
16256         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
16257         *ret_conv = CResult_ThirtyTwoBytesNoneZ_clone(arg);
16258         return tag_ptr(ret_conv, true);
16259 }
16260 int64_t  CS_LDK_CResult_ThirtyTwoBytesNoneZ_clone_ptr(int64_t arg) {
16261         LDKCResult_ThirtyTwoBytesNoneZ* arg_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(arg);
16262         int64_t ret_conv = CResult_ThirtyTwoBytesNoneZ_clone_ptr(arg_conv);
16263         return ret_conv;
16264 }
16265
16266 int64_t  CS_LDK_CResult_ThirtyTwoBytesNoneZ_clone(int64_t orig) {
16267         LDKCResult_ThirtyTwoBytesNoneZ* orig_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(orig);
16268         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
16269         *ret_conv = CResult_ThirtyTwoBytesNoneZ_clone(orig_conv);
16270         return tag_ptr(ret_conv, true);
16271 }
16272
16273 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_ok(int64_t o) {
16274         LDKBlindedPayInfo o_conv;
16275         o_conv.inner = untag_ptr(o);
16276         o_conv.is_owned = ptr_is_owned(o);
16277         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16278         o_conv = BlindedPayInfo_clone(&o_conv);
16279         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
16280         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_ok(o_conv);
16281         return tag_ptr(ret_conv, true);
16282 }
16283
16284 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_err(int64_t e) {
16285         void* e_ptr = untag_ptr(e);
16286         CHECK_ACCESS(e_ptr);
16287         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16288         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16289         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
16290         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_err(e_conv);
16291         return tag_ptr(ret_conv, true);
16292 }
16293
16294 jboolean  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_is_ok(int64_t o) {
16295         LDKCResult_BlindedPayInfoDecodeErrorZ* o_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(o);
16296         jboolean ret_conv = CResult_BlindedPayInfoDecodeErrorZ_is_ok(o_conv);
16297         return ret_conv;
16298 }
16299
16300 void  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_free(int64_t _res) {
16301         if (!ptr_is_owned(_res)) return;
16302         void* _res_ptr = untag_ptr(_res);
16303         CHECK_ACCESS(_res_ptr);
16304         LDKCResult_BlindedPayInfoDecodeErrorZ _res_conv = *(LDKCResult_BlindedPayInfoDecodeErrorZ*)(_res_ptr);
16305         FREE(untag_ptr(_res));
16306         CResult_BlindedPayInfoDecodeErrorZ_free(_res_conv);
16307 }
16308
16309 static inline uint64_t CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR arg) {
16310         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
16311         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone(arg);
16312         return tag_ptr(ret_conv, true);
16313 }
16314 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(int64_t arg) {
16315         LDKCResult_BlindedPayInfoDecodeErrorZ* arg_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(arg);
16316         int64_t ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(arg_conv);
16317         return ret_conv;
16318 }
16319
16320 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_clone(int64_t orig) {
16321         LDKCResult_BlindedPayInfoDecodeErrorZ* orig_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(orig);
16322         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
16323         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone(orig_conv);
16324         return tag_ptr(ret_conv, true);
16325 }
16326
16327 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(int64_t o) {
16328         LDKDelayedPaymentOutputDescriptor o_conv;
16329         o_conv.inner = untag_ptr(o);
16330         o_conv.is_owned = ptr_is_owned(o);
16331         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16332         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
16333         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16334         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16335         return tag_ptr(ret_conv, true);
16336 }
16337
16338 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(int64_t e) {
16339         void* e_ptr = untag_ptr(e);
16340         CHECK_ACCESS(e_ptr);
16341         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16342         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16343         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16344         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16345         return tag_ptr(ret_conv, true);
16346 }
16347
16348 jboolean  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(int64_t o) {
16349         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
16350         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16351         return ret_conv;
16352 }
16353
16354 void  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(int64_t _res) {
16355         if (!ptr_is_owned(_res)) return;
16356         void* _res_ptr = untag_ptr(_res);
16357         CHECK_ACCESS(_res_ptr);
16358         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16359         FREE(untag_ptr(_res));
16360         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16361 }
16362
16363 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16364         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16365         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16366         return tag_ptr(ret_conv, true);
16367 }
16368 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(int64_t arg) {
16369         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
16370         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16371         return ret_conv;
16372 }
16373
16374 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(int64_t orig) {
16375         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
16376         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16377         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16378         return tag_ptr(ret_conv, true);
16379 }
16380
16381 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(int64_t o) {
16382         LDKStaticPaymentOutputDescriptor o_conv;
16383         o_conv.inner = untag_ptr(o);
16384         o_conv.is_owned = ptr_is_owned(o);
16385         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16386         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
16387         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16388         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16389         return tag_ptr(ret_conv, true);
16390 }
16391
16392 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(int64_t e) {
16393         void* e_ptr = untag_ptr(e);
16394         CHECK_ACCESS(e_ptr);
16395         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16396         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16397         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16398         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16399         return tag_ptr(ret_conv, true);
16400 }
16401
16402 jboolean  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(int64_t o) {
16403         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
16404         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16405         return ret_conv;
16406 }
16407
16408 void  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(int64_t _res) {
16409         if (!ptr_is_owned(_res)) return;
16410         void* _res_ptr = untag_ptr(_res);
16411         CHECK_ACCESS(_res_ptr);
16412         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16413         FREE(untag_ptr(_res));
16414         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16415 }
16416
16417 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16418         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16419         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16420         return tag_ptr(ret_conv, true);
16421 }
16422 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(int64_t arg) {
16423         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
16424         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16425         return ret_conv;
16426 }
16427
16428 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(int64_t orig) {
16429         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
16430         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16431         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16432         return tag_ptr(ret_conv, true);
16433 }
16434
16435 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(int64_t o) {
16436         void* o_ptr = untag_ptr(o);
16437         CHECK_ACCESS(o_ptr);
16438         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
16439         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
16440         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16441         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
16442         return tag_ptr(ret_conv, true);
16443 }
16444
16445 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_err(int64_t e) {
16446         void* e_ptr = untag_ptr(e);
16447         CHECK_ACCESS(e_ptr);
16448         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16449         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16450         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16451         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
16452         return tag_ptr(ret_conv, true);
16453 }
16454
16455 jboolean  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(int64_t o) {
16456         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
16457         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16458         return ret_conv;
16459 }
16460
16461 void  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_free(int64_t _res) {
16462         if (!ptr_is_owned(_res)) return;
16463         void* _res_ptr = untag_ptr(_res);
16464         CHECK_ACCESS(_res_ptr);
16465         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
16466         FREE(untag_ptr(_res));
16467         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
16468 }
16469
16470 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16471         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16472         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
16473         return tag_ptr(ret_conv, true);
16474 }
16475 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(int64_t arg) {
16476         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
16477         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16478         return ret_conv;
16479 }
16480
16481 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(int64_t orig) {
16482         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
16483         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16484         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
16485         return tag_ptr(ret_conv, true);
16486 }
16487
16488 void  CS_LDK_CVec_SpendableOutputDescriptorZ_free(int64_tArray _res) {
16489         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16490         _res_constr.datalen = _res->arr_len;
16491         if (_res_constr.datalen > 0)
16492                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16493         else
16494                 _res_constr.data = NULL;
16495         int64_t* _res_vals = _res->elems;
16496         for (size_t b = 0; b < _res_constr.datalen; b++) {
16497                 int64_t _res_conv_27 = _res_vals[b];
16498                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
16499                 CHECK_ACCESS(_res_conv_27_ptr);
16500                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16501                 FREE(untag_ptr(_res_conv_27));
16502                 _res_constr.data[b] = _res_conv_27_conv;
16503         }
16504         FREE(_res);
16505         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16506 }
16507
16508 void  CS_LDK_CVec_TxOutZ_free(int64_tArray _res) {
16509         LDKCVec_TxOutZ _res_constr;
16510         _res_constr.datalen = _res->arr_len;
16511         if (_res_constr.datalen > 0)
16512                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
16513         else
16514                 _res_constr.data = NULL;
16515         int64_t* _res_vals = _res->elems;
16516         for (size_t h = 0; h < _res_constr.datalen; h++) {
16517                 int64_t _res_conv_7 = _res_vals[h];
16518                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
16519                 CHECK_ACCESS(_res_conv_7_ptr);
16520                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
16521                 FREE(untag_ptr(_res_conv_7));
16522                 _res_constr.data[h] = _res_conv_7_conv;
16523         }
16524         FREE(_res);
16525         CVec_TxOutZ_free(_res_constr);
16526 }
16527
16528 int64_t  CS_LDK_COption_u32Z_some(int32_t o) {
16529         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16530         *ret_copy = COption_u32Z_some(o);
16531         int64_t ret_ref = tag_ptr(ret_copy, true);
16532         return ret_ref;
16533 }
16534
16535 int64_t  CS_LDK_COption_u32Z_none() {
16536         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16537         *ret_copy = COption_u32Z_none();
16538         int64_t ret_ref = tag_ptr(ret_copy, true);
16539         return ret_ref;
16540 }
16541
16542 void  CS_LDK_COption_u32Z_free(int64_t _res) {
16543         if (!ptr_is_owned(_res)) return;
16544         void* _res_ptr = untag_ptr(_res);
16545         CHECK_ACCESS(_res_ptr);
16546         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
16547         FREE(untag_ptr(_res));
16548         COption_u32Z_free(_res_conv);
16549 }
16550
16551 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
16552         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16553         *ret_copy = COption_u32Z_clone(arg);
16554         int64_t ret_ref = tag_ptr(ret_copy, true);
16555         return ret_ref;
16556 }
16557 int64_t  CS_LDK_COption_u32Z_clone_ptr(int64_t arg) {
16558         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
16559         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
16560         return ret_conv;
16561 }
16562
16563 int64_t  CS_LDK_COption_u32Z_clone(int64_t orig) {
16564         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
16565         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16566         *ret_copy = COption_u32Z_clone(orig_conv);
16567         int64_t ret_ref = tag_ptr(ret_copy, true);
16568         return ret_ref;
16569 }
16570
16571 static inline uint64_t C2Tuple_CVec_u8ZusizeZ_clone_ptr(LDKC2Tuple_CVec_u8ZusizeZ *NONNULL_PTR arg) {
16572         LDKC2Tuple_CVec_u8ZusizeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_CVec_u8ZusizeZ), "LDKC2Tuple_CVec_u8ZusizeZ");
16573         *ret_conv = C2Tuple_CVec_u8ZusizeZ_clone(arg);
16574         return tag_ptr(ret_conv, true);
16575 }
16576 int64_t  CS_LDK_C2Tuple_CVec_u8ZusizeZ_clone_ptr(int64_t arg) {
16577         LDKC2Tuple_CVec_u8ZusizeZ* arg_conv = (LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(arg);
16578         int64_t ret_conv = C2Tuple_CVec_u8ZusizeZ_clone_ptr(arg_conv);
16579         return ret_conv;
16580 }
16581
16582 int64_t  CS_LDK_C2Tuple_CVec_u8ZusizeZ_clone(int64_t orig) {
16583         LDKC2Tuple_CVec_u8ZusizeZ* orig_conv = (LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(orig);
16584         LDKC2Tuple_CVec_u8ZusizeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_CVec_u8ZusizeZ), "LDKC2Tuple_CVec_u8ZusizeZ");
16585         *ret_conv = C2Tuple_CVec_u8ZusizeZ_clone(orig_conv);
16586         return tag_ptr(ret_conv, true);
16587 }
16588
16589 int64_t  CS_LDK_C2Tuple_CVec_u8ZusizeZ_new(int8_tArray a, int64_t b) {
16590         LDKCVec_u8Z a_ref;
16591         a_ref.datalen = a->arr_len;
16592         a_ref.data = MALLOC(a_ref.datalen, "LDKCVec_u8Z Bytes");
16593         memcpy(a_ref.data, a->elems, a_ref.datalen); FREE(a);
16594         LDKC2Tuple_CVec_u8ZusizeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_CVec_u8ZusizeZ), "LDKC2Tuple_CVec_u8ZusizeZ");
16595         *ret_conv = C2Tuple_CVec_u8ZusizeZ_new(a_ref, b);
16596         return tag_ptr(ret_conv, true);
16597 }
16598
16599 void  CS_LDK_C2Tuple_CVec_u8ZusizeZ_free(int64_t _res) {
16600         if (!ptr_is_owned(_res)) return;
16601         void* _res_ptr = untag_ptr(_res);
16602         CHECK_ACCESS(_res_ptr);
16603         LDKC2Tuple_CVec_u8ZusizeZ _res_conv = *(LDKC2Tuple_CVec_u8ZusizeZ*)(_res_ptr);
16604         FREE(untag_ptr(_res));
16605         C2Tuple_CVec_u8ZusizeZ_free(_res_conv);
16606 }
16607
16608 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_ok(int64_t o) {
16609         void* o_ptr = untag_ptr(o);
16610         CHECK_ACCESS(o_ptr);
16611         LDKC2Tuple_CVec_u8ZusizeZ o_conv = *(LDKC2Tuple_CVec_u8ZusizeZ*)(o_ptr);
16612         o_conv = C2Tuple_CVec_u8ZusizeZ_clone((LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(o));
16613         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
16614         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_ok(o_conv);
16615         return tag_ptr(ret_conv, true);
16616 }
16617
16618 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_err() {
16619         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
16620         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_err();
16621         return tag_ptr(ret_conv, true);
16622 }
16623
16624 jboolean  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_is_ok(int64_t o) {
16625         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* o_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(o);
16626         jboolean ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_is_ok(o_conv);
16627         return ret_conv;
16628 }
16629
16630 void  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_free(int64_t _res) {
16631         if (!ptr_is_owned(_res)) return;
16632         void* _res_ptr = untag_ptr(_res);
16633         CHECK_ACCESS(_res_ptr);
16634         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ _res_conv = *(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)(_res_ptr);
16635         FREE(untag_ptr(_res));
16636         CResult_C2Tuple_CVec_u8ZusizeZNoneZ_free(_res_conv);
16637 }
16638
16639 static inline uint64_t CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone_ptr(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ *NONNULL_PTR arg) {
16640         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
16641         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone(arg);
16642         return tag_ptr(ret_conv, true);
16643 }
16644 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone_ptr(int64_t arg) {
16645         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* arg_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(arg);
16646         int64_t ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone_ptr(arg_conv);
16647         return ret_conv;
16648 }
16649
16650 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone(int64_t orig) {
16651         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* orig_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(orig);
16652         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
16653         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone(orig_conv);
16654         return tag_ptr(ret_conv, true);
16655 }
16656
16657 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_ok(int64_t o) {
16658         LDKChannelDerivationParameters o_conv;
16659         o_conv.inner = untag_ptr(o);
16660         o_conv.is_owned = ptr_is_owned(o);
16661         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16662         o_conv = ChannelDerivationParameters_clone(&o_conv);
16663         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
16664         *ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_ok(o_conv);
16665         return tag_ptr(ret_conv, true);
16666 }
16667
16668 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_err(int64_t e) {
16669         void* e_ptr = untag_ptr(e);
16670         CHECK_ACCESS(e_ptr);
16671         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16672         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16673         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
16674         *ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_err(e_conv);
16675         return tag_ptr(ret_conv, true);
16676 }
16677
16678 jboolean  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_is_ok(int64_t o) {
16679         LDKCResult_ChannelDerivationParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(o);
16680         jboolean ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_is_ok(o_conv);
16681         return ret_conv;
16682 }
16683
16684 void  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_free(int64_t _res) {
16685         if (!ptr_is_owned(_res)) return;
16686         void* _res_ptr = untag_ptr(_res);
16687         CHECK_ACCESS(_res_ptr);
16688         LDKCResult_ChannelDerivationParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelDerivationParametersDecodeErrorZ*)(_res_ptr);
16689         FREE(untag_ptr(_res));
16690         CResult_ChannelDerivationParametersDecodeErrorZ_free(_res_conv);
16691 }
16692
16693 static inline uint64_t CResult_ChannelDerivationParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelDerivationParametersDecodeErrorZ *NONNULL_PTR arg) {
16694         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
16695         *ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_clone(arg);
16696         return tag_ptr(ret_conv, true);
16697 }
16698 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_clone_ptr(int64_t arg) {
16699         LDKCResult_ChannelDerivationParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(arg);
16700         int64_t ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_clone_ptr(arg_conv);
16701         return ret_conv;
16702 }
16703
16704 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_clone(int64_t orig) {
16705         LDKCResult_ChannelDerivationParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(orig);
16706         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
16707         *ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_clone(orig_conv);
16708         return tag_ptr(ret_conv, true);
16709 }
16710
16711 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_ok(int64_t o) {
16712         LDKHTLCDescriptor o_conv;
16713         o_conv.inner = untag_ptr(o);
16714         o_conv.is_owned = ptr_is_owned(o);
16715         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16716         o_conv = HTLCDescriptor_clone(&o_conv);
16717         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
16718         *ret_conv = CResult_HTLCDescriptorDecodeErrorZ_ok(o_conv);
16719         return tag_ptr(ret_conv, true);
16720 }
16721
16722 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_err(int64_t e) {
16723         void* e_ptr = untag_ptr(e);
16724         CHECK_ACCESS(e_ptr);
16725         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16726         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16727         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
16728         *ret_conv = CResult_HTLCDescriptorDecodeErrorZ_err(e_conv);
16729         return tag_ptr(ret_conv, true);
16730 }
16731
16732 jboolean  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_is_ok(int64_t o) {
16733         LDKCResult_HTLCDescriptorDecodeErrorZ* o_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(o);
16734         jboolean ret_conv = CResult_HTLCDescriptorDecodeErrorZ_is_ok(o_conv);
16735         return ret_conv;
16736 }
16737
16738 void  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_free(int64_t _res) {
16739         if (!ptr_is_owned(_res)) return;
16740         void* _res_ptr = untag_ptr(_res);
16741         CHECK_ACCESS(_res_ptr);
16742         LDKCResult_HTLCDescriptorDecodeErrorZ _res_conv = *(LDKCResult_HTLCDescriptorDecodeErrorZ*)(_res_ptr);
16743         FREE(untag_ptr(_res));
16744         CResult_HTLCDescriptorDecodeErrorZ_free(_res_conv);
16745 }
16746
16747 static inline uint64_t CResult_HTLCDescriptorDecodeErrorZ_clone_ptr(LDKCResult_HTLCDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16748         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
16749         *ret_conv = CResult_HTLCDescriptorDecodeErrorZ_clone(arg);
16750         return tag_ptr(ret_conv, true);
16751 }
16752 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_clone_ptr(int64_t arg) {
16753         LDKCResult_HTLCDescriptorDecodeErrorZ* arg_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(arg);
16754         int64_t ret_conv = CResult_HTLCDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16755         return ret_conv;
16756 }
16757
16758 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_clone(int64_t orig) {
16759         LDKCResult_HTLCDescriptorDecodeErrorZ* orig_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(orig);
16760         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
16761         *ret_conv = CResult_HTLCDescriptorDecodeErrorZ_clone(orig_conv);
16762         return tag_ptr(ret_conv, true);
16763 }
16764
16765 int64_t  CS_LDK_CResult_NoneNoneZ_ok() {
16766         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16767         *ret_conv = CResult_NoneNoneZ_ok();
16768         return tag_ptr(ret_conv, true);
16769 }
16770
16771 int64_t  CS_LDK_CResult_NoneNoneZ_err() {
16772         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16773         *ret_conv = CResult_NoneNoneZ_err();
16774         return tag_ptr(ret_conv, true);
16775 }
16776
16777 jboolean  CS_LDK_CResult_NoneNoneZ_is_ok(int64_t o) {
16778         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
16779         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
16780         return ret_conv;
16781 }
16782
16783 void  CS_LDK_CResult_NoneNoneZ_free(int64_t _res) {
16784         if (!ptr_is_owned(_res)) return;
16785         void* _res_ptr = untag_ptr(_res);
16786         CHECK_ACCESS(_res_ptr);
16787         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
16788         FREE(untag_ptr(_res));
16789         CResult_NoneNoneZ_free(_res_conv);
16790 }
16791
16792 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
16793         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16794         *ret_conv = CResult_NoneNoneZ_clone(arg);
16795         return tag_ptr(ret_conv, true);
16796 }
16797 int64_t  CS_LDK_CResult_NoneNoneZ_clone_ptr(int64_t arg) {
16798         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
16799         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
16800         return ret_conv;
16801 }
16802
16803 int64_t  CS_LDK_CResult_NoneNoneZ_clone(int64_t orig) {
16804         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
16805         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16806         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
16807         return tag_ptr(ret_conv, true);
16808 }
16809
16810 void  CS_LDK_CVec_ECDSASignatureZ_free(ptrArray _res) {
16811         LDKCVec_ECDSASignatureZ _res_constr;
16812         _res_constr.datalen = _res->arr_len;
16813         if (_res_constr.datalen > 0)
16814                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
16815         else
16816                 _res_constr.data = NULL;
16817         int8_tArray* _res_vals = (void*) _res->elems;
16818         for (size_t i = 0; i < _res_constr.datalen; i++) {
16819                 int8_tArray _res_conv_8 = _res_vals[i];
16820                 LDKECDSASignature _res_conv_8_ref;
16821                 CHECK(_res_conv_8->arr_len == 64);
16822                 memcpy(_res_conv_8_ref.compact_form, _res_conv_8->elems, 64); FREE(_res_conv_8);
16823                 _res_constr.data[i] = _res_conv_8_ref;
16824         }
16825         FREE(_res);
16826         CVec_ECDSASignatureZ_free(_res_constr);
16827 }
16828
16829 static inline uint64_t C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone_ptr(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ *NONNULL_PTR arg) {
16830         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ), "LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ");
16831         *ret_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(arg);
16832         return tag_ptr(ret_conv, true);
16833 }
16834 int64_t  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone_ptr(int64_t arg) {
16835         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* arg_conv = (LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(arg);
16836         int64_t ret_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone_ptr(arg_conv);
16837         return ret_conv;
16838 }
16839
16840 int64_t  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(int64_t orig) {
16841         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* orig_conv = (LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(orig);
16842         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ), "LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ");
16843         *ret_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(orig_conv);
16844         return tag_ptr(ret_conv, true);
16845 }
16846
16847 int64_t  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_new(int8_tArray a, ptrArray b) {
16848         LDKECDSASignature a_ref;
16849         CHECK(a->arr_len == 64);
16850         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
16851         LDKCVec_ECDSASignatureZ b_constr;
16852         b_constr.datalen = b->arr_len;
16853         if (b_constr.datalen > 0)
16854                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
16855         else
16856                 b_constr.data = NULL;
16857         int8_tArray* b_vals = (void*) b->elems;
16858         for (size_t i = 0; i < b_constr.datalen; i++) {
16859                 int8_tArray b_conv_8 = b_vals[i];
16860                 LDKECDSASignature b_conv_8_ref;
16861                 CHECK(b_conv_8->arr_len == 64);
16862                 memcpy(b_conv_8_ref.compact_form, b_conv_8->elems, 64); FREE(b_conv_8);
16863                 b_constr.data[i] = b_conv_8_ref;
16864         }
16865         FREE(b);
16866         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ), "LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ");
16867         *ret_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_new(a_ref, b_constr);
16868         return tag_ptr(ret_conv, true);
16869 }
16870
16871 void  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_free(int64_t _res) {
16872         if (!ptr_is_owned(_res)) return;
16873         void* _res_ptr = untag_ptr(_res);
16874         CHECK_ACCESS(_res_ptr);
16875         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ _res_conv = *(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)(_res_ptr);
16876         FREE(untag_ptr(_res));
16877         C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_free(_res_conv);
16878 }
16879
16880 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_ok(int64_t o) {
16881         void* o_ptr = untag_ptr(o);
16882         CHECK_ACCESS(o_ptr);
16883         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ o_conv = *(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)(o_ptr);
16884         o_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone((LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(o));
16885         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
16886         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_ok(o_conv);
16887         return tag_ptr(ret_conv, true);
16888 }
16889
16890 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_err() {
16891         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
16892         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_err();
16893         return tag_ptr(ret_conv, true);
16894 }
16895
16896 jboolean  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_is_ok(int64_t o) {
16897         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(o);
16898         jboolean ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_is_ok(o_conv);
16899         return ret_conv;
16900 }
16901
16902 void  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_free(int64_t _res) {
16903         if (!ptr_is_owned(_res)) return;
16904         void* _res_ptr = untag_ptr(_res);
16905         CHECK_ACCESS(_res_ptr);
16906         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)(_res_ptr);
16907         FREE(untag_ptr(_res));
16908         CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_free(_res_conv);
16909 }
16910
16911 static inline uint64_t CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ *NONNULL_PTR arg) {
16912         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
16913         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone(arg);
16914         return tag_ptr(ret_conv, true);
16915 }
16916 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone_ptr(int64_t arg) {
16917         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(arg);
16918         int64_t ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone_ptr(arg_conv);
16919         return ret_conv;
16920 }
16921
16922 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone(int64_t orig) {
16923         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(orig);
16924         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
16925         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone(orig_conv);
16926         return tag_ptr(ret_conv, true);
16927 }
16928
16929 int64_t  CS_LDK_CResult_ECDSASignatureNoneZ_ok(int8_tArray o) {
16930         LDKECDSASignature o_ref;
16931         CHECK(o->arr_len == 64);
16932         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
16933         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
16934         *ret_conv = CResult_ECDSASignatureNoneZ_ok(o_ref);
16935         return tag_ptr(ret_conv, true);
16936 }
16937
16938 int64_t  CS_LDK_CResult_ECDSASignatureNoneZ_err() {
16939         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
16940         *ret_conv = CResult_ECDSASignatureNoneZ_err();
16941         return tag_ptr(ret_conv, true);
16942 }
16943
16944 jboolean  CS_LDK_CResult_ECDSASignatureNoneZ_is_ok(int64_t o) {
16945         LDKCResult_ECDSASignatureNoneZ* o_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(o);
16946         jboolean ret_conv = CResult_ECDSASignatureNoneZ_is_ok(o_conv);
16947         return ret_conv;
16948 }
16949
16950 void  CS_LDK_CResult_ECDSASignatureNoneZ_free(int64_t _res) {
16951         if (!ptr_is_owned(_res)) return;
16952         void* _res_ptr = untag_ptr(_res);
16953         CHECK_ACCESS(_res_ptr);
16954         LDKCResult_ECDSASignatureNoneZ _res_conv = *(LDKCResult_ECDSASignatureNoneZ*)(_res_ptr);
16955         FREE(untag_ptr(_res));
16956         CResult_ECDSASignatureNoneZ_free(_res_conv);
16957 }
16958
16959 static inline uint64_t CResult_ECDSASignatureNoneZ_clone_ptr(LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR arg) {
16960         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
16961         *ret_conv = CResult_ECDSASignatureNoneZ_clone(arg);
16962         return tag_ptr(ret_conv, true);
16963 }
16964 int64_t  CS_LDK_CResult_ECDSASignatureNoneZ_clone_ptr(int64_t arg) {
16965         LDKCResult_ECDSASignatureNoneZ* arg_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(arg);
16966         int64_t ret_conv = CResult_ECDSASignatureNoneZ_clone_ptr(arg_conv);
16967         return ret_conv;
16968 }
16969
16970 int64_t  CS_LDK_CResult_ECDSASignatureNoneZ_clone(int64_t orig) {
16971         LDKCResult_ECDSASignatureNoneZ* orig_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(orig);
16972         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
16973         *ret_conv = CResult_ECDSASignatureNoneZ_clone(orig_conv);
16974         return tag_ptr(ret_conv, true);
16975 }
16976
16977 int64_t  CS_LDK_CResult_PublicKeyNoneZ_ok(int8_tArray o) {
16978         LDKPublicKey o_ref;
16979         CHECK(o->arr_len == 33);
16980         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
16981         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
16982         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
16983         return tag_ptr(ret_conv, true);
16984 }
16985
16986 int64_t  CS_LDK_CResult_PublicKeyNoneZ_err() {
16987         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
16988         *ret_conv = CResult_PublicKeyNoneZ_err();
16989         return tag_ptr(ret_conv, true);
16990 }
16991
16992 jboolean  CS_LDK_CResult_PublicKeyNoneZ_is_ok(int64_t o) {
16993         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
16994         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
16995         return ret_conv;
16996 }
16997
16998 void  CS_LDK_CResult_PublicKeyNoneZ_free(int64_t _res) {
16999         if (!ptr_is_owned(_res)) return;
17000         void* _res_ptr = untag_ptr(_res);
17001         CHECK_ACCESS(_res_ptr);
17002         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
17003         FREE(untag_ptr(_res));
17004         CResult_PublicKeyNoneZ_free(_res_conv);
17005 }
17006
17007 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
17008         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
17009         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
17010         return tag_ptr(ret_conv, true);
17011 }
17012 int64_t  CS_LDK_CResult_PublicKeyNoneZ_clone_ptr(int64_t arg) {
17013         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
17014         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
17015         return ret_conv;
17016 }
17017
17018 int64_t  CS_LDK_CResult_PublicKeyNoneZ_clone(int64_t orig) {
17019         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
17020         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
17021         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
17022         return tag_ptr(ret_conv, true);
17023 }
17024
17025 int64_t  CS_LDK_COption_BigEndianScalarZ_some(int64_t o) {
17026         void* o_ptr = untag_ptr(o);
17027         CHECK_ACCESS(o_ptr);
17028         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
17029         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
17030         LDKCOption_BigEndianScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
17031         *ret_copy = COption_BigEndianScalarZ_some(o_conv);
17032         int64_t ret_ref = tag_ptr(ret_copy, true);
17033         return ret_ref;
17034 }
17035
17036 int64_t  CS_LDK_COption_BigEndianScalarZ_none() {
17037         LDKCOption_BigEndianScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
17038         *ret_copy = COption_BigEndianScalarZ_none();
17039         int64_t ret_ref = tag_ptr(ret_copy, true);
17040         return ret_ref;
17041 }
17042
17043 void  CS_LDK_COption_BigEndianScalarZ_free(int64_t _res) {
17044         if (!ptr_is_owned(_res)) return;
17045         void* _res_ptr = untag_ptr(_res);
17046         CHECK_ACCESS(_res_ptr);
17047         LDKCOption_BigEndianScalarZ _res_conv = *(LDKCOption_BigEndianScalarZ*)(_res_ptr);
17048         FREE(untag_ptr(_res));
17049         COption_BigEndianScalarZ_free(_res_conv);
17050 }
17051
17052 static inline uint64_t COption_BigEndianScalarZ_clone_ptr(LDKCOption_BigEndianScalarZ *NONNULL_PTR arg) {
17053         LDKCOption_BigEndianScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
17054         *ret_copy = COption_BigEndianScalarZ_clone(arg);
17055         int64_t ret_ref = tag_ptr(ret_copy, true);
17056         return ret_ref;
17057 }
17058 int64_t  CS_LDK_COption_BigEndianScalarZ_clone_ptr(int64_t arg) {
17059         LDKCOption_BigEndianScalarZ* arg_conv = (LDKCOption_BigEndianScalarZ*)untag_ptr(arg);
17060         int64_t ret_conv = COption_BigEndianScalarZ_clone_ptr(arg_conv);
17061         return ret_conv;
17062 }
17063
17064 int64_t  CS_LDK_COption_BigEndianScalarZ_clone(int64_t orig) {
17065         LDKCOption_BigEndianScalarZ* orig_conv = (LDKCOption_BigEndianScalarZ*)untag_ptr(orig);
17066         LDKCOption_BigEndianScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
17067         *ret_copy = COption_BigEndianScalarZ_clone(orig_conv);
17068         int64_t ret_ref = tag_ptr(ret_copy, true);
17069         return ret_ref;
17070 }
17071
17072 void  CS_LDK_CVec_U5Z_free(ptrArray _res) {
17073         LDKCVec_U5Z _res_constr;
17074         _res_constr.datalen = _res->arr_len;
17075         if (_res_constr.datalen > 0)
17076                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
17077         else
17078                 _res_constr.data = NULL;
17079         int8_t* _res_vals = (void*) _res->elems;
17080         for (size_t h = 0; h < _res_constr.datalen; h++) {
17081                 int8_t _res_conv_7 = _res_vals[h];
17082                 
17083                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
17084         }
17085         FREE(_res);
17086         CVec_U5Z_free(_res_constr);
17087 }
17088
17089 int64_t  CS_LDK_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
17090         LDKRecoverableSignature o_ref;
17091         CHECK(o->arr_len == 68);
17092         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
17093         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17094         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
17095         return tag_ptr(ret_conv, true);
17096 }
17097
17098 int64_t  CS_LDK_CResult_RecoverableSignatureNoneZ_err() {
17099         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17100         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
17101         return tag_ptr(ret_conv, true);
17102 }
17103
17104 jboolean  CS_LDK_CResult_RecoverableSignatureNoneZ_is_ok(int64_t o) {
17105         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
17106         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
17107         return ret_conv;
17108 }
17109
17110 void  CS_LDK_CResult_RecoverableSignatureNoneZ_free(int64_t _res) {
17111         if (!ptr_is_owned(_res)) return;
17112         void* _res_ptr = untag_ptr(_res);
17113         CHECK_ACCESS(_res_ptr);
17114         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
17115         FREE(untag_ptr(_res));
17116         CResult_RecoverableSignatureNoneZ_free(_res_conv);
17117 }
17118
17119 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
17120         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17121         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
17122         return tag_ptr(ret_conv, true);
17123 }
17124 int64_t  CS_LDK_CResult_RecoverableSignatureNoneZ_clone_ptr(int64_t arg) {
17125         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
17126         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
17127         return ret_conv;
17128 }
17129
17130 int64_t  CS_LDK_CResult_RecoverableSignatureNoneZ_clone(int64_t orig) {
17131         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
17132         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17133         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
17134         return tag_ptr(ret_conv, true);
17135 }
17136
17137 int64_t  CS_LDK_CResult_SchnorrSignatureNoneZ_ok(int8_tArray o) {
17138         LDKSchnorrSignature o_ref;
17139         CHECK(o->arr_len == 64);
17140         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
17141         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
17142         *ret_conv = CResult_SchnorrSignatureNoneZ_ok(o_ref);
17143         return tag_ptr(ret_conv, true);
17144 }
17145
17146 int64_t  CS_LDK_CResult_SchnorrSignatureNoneZ_err() {
17147         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
17148         *ret_conv = CResult_SchnorrSignatureNoneZ_err();
17149         return tag_ptr(ret_conv, true);
17150 }
17151
17152 jboolean  CS_LDK_CResult_SchnorrSignatureNoneZ_is_ok(int64_t o) {
17153         LDKCResult_SchnorrSignatureNoneZ* o_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(o);
17154         jboolean ret_conv = CResult_SchnorrSignatureNoneZ_is_ok(o_conv);
17155         return ret_conv;
17156 }
17157
17158 void  CS_LDK_CResult_SchnorrSignatureNoneZ_free(int64_t _res) {
17159         if (!ptr_is_owned(_res)) return;
17160         void* _res_ptr = untag_ptr(_res);
17161         CHECK_ACCESS(_res_ptr);
17162         LDKCResult_SchnorrSignatureNoneZ _res_conv = *(LDKCResult_SchnorrSignatureNoneZ*)(_res_ptr);
17163         FREE(untag_ptr(_res));
17164         CResult_SchnorrSignatureNoneZ_free(_res_conv);
17165 }
17166
17167 static inline uint64_t CResult_SchnorrSignatureNoneZ_clone_ptr(LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR arg) {
17168         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
17169         *ret_conv = CResult_SchnorrSignatureNoneZ_clone(arg);
17170         return tag_ptr(ret_conv, true);
17171 }
17172 int64_t  CS_LDK_CResult_SchnorrSignatureNoneZ_clone_ptr(int64_t arg) {
17173         LDKCResult_SchnorrSignatureNoneZ* arg_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(arg);
17174         int64_t ret_conv = CResult_SchnorrSignatureNoneZ_clone_ptr(arg_conv);
17175         return ret_conv;
17176 }
17177
17178 int64_t  CS_LDK_CResult_SchnorrSignatureNoneZ_clone(int64_t orig) {
17179         LDKCResult_SchnorrSignatureNoneZ* orig_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(orig);
17180         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
17181         *ret_conv = CResult_SchnorrSignatureNoneZ_clone(orig_conv);
17182         return tag_ptr(ret_conv, true);
17183 }
17184
17185 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(int64_t o) {
17186         void* o_ptr = untag_ptr(o);
17187         CHECK_ACCESS(o_ptr);
17188         LDKWriteableEcdsaChannelSigner o_conv = *(LDKWriteableEcdsaChannelSigner*)(o_ptr);
17189         if (o_conv.free == LDKWriteableEcdsaChannelSigner_JCalls_free) {
17190                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17191                 LDKWriteableEcdsaChannelSigner_JCalls_cloned(&o_conv);
17192         }
17193         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
17194         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o_conv);
17195         return tag_ptr(ret_conv, true);
17196 }
17197
17198 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(int64_t e) {
17199         void* e_ptr = untag_ptr(e);
17200         CHECK_ACCESS(e_ptr);
17201         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17202         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17203         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
17204         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e_conv);
17205         return tag_ptr(ret_conv, true);
17206 }
17207
17208 jboolean  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(int64_t o) {
17209         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* o_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(o);
17210         jboolean ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o_conv);
17211         return ret_conv;
17212 }
17213
17214 void  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(int64_t _res) {
17215         if (!ptr_is_owned(_res)) return;
17216         void* _res_ptr = untag_ptr(_res);
17217         CHECK_ACCESS(_res_ptr);
17218         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(_res_ptr);
17219         FREE(untag_ptr(_res));
17220         CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res_conv);
17221 }
17222
17223 static inline uint64_t CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR arg) {
17224         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
17225         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(arg);
17226         return tag_ptr(ret_conv, true);
17227 }
17228 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(int64_t arg) {
17229         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* arg_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(arg);
17230         int64_t ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(arg_conv);
17231         return ret_conv;
17232 }
17233
17234 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(int64_t orig) {
17235         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* orig_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(orig);
17236         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
17237         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig_conv);
17238         return tag_ptr(ret_conv, true);
17239 }
17240
17241 int64_t  CS_LDK_CResult_CVec_u8ZNoneZ_ok(int8_tArray o) {
17242         LDKCVec_u8Z o_ref;
17243         o_ref.datalen = o->arr_len;
17244         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
17245         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
17246         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
17247         *ret_conv = CResult_CVec_u8ZNoneZ_ok(o_ref);
17248         return tag_ptr(ret_conv, true);
17249 }
17250
17251 int64_t  CS_LDK_CResult_CVec_u8ZNoneZ_err() {
17252         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
17253         *ret_conv = CResult_CVec_u8ZNoneZ_err();
17254         return tag_ptr(ret_conv, true);
17255 }
17256
17257 jboolean  CS_LDK_CResult_CVec_u8ZNoneZ_is_ok(int64_t o) {
17258         LDKCResult_CVec_u8ZNoneZ* o_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(o);
17259         jboolean ret_conv = CResult_CVec_u8ZNoneZ_is_ok(o_conv);
17260         return ret_conv;
17261 }
17262
17263 void  CS_LDK_CResult_CVec_u8ZNoneZ_free(int64_t _res) {
17264         if (!ptr_is_owned(_res)) return;
17265         void* _res_ptr = untag_ptr(_res);
17266         CHECK_ACCESS(_res_ptr);
17267         LDKCResult_CVec_u8ZNoneZ _res_conv = *(LDKCResult_CVec_u8ZNoneZ*)(_res_ptr);
17268         FREE(untag_ptr(_res));
17269         CResult_CVec_u8ZNoneZ_free(_res_conv);
17270 }
17271
17272 static inline uint64_t CResult_CVec_u8ZNoneZ_clone_ptr(LDKCResult_CVec_u8ZNoneZ *NONNULL_PTR arg) {
17273         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
17274         *ret_conv = CResult_CVec_u8ZNoneZ_clone(arg);
17275         return tag_ptr(ret_conv, true);
17276 }
17277 int64_t  CS_LDK_CResult_CVec_u8ZNoneZ_clone_ptr(int64_t arg) {
17278         LDKCResult_CVec_u8ZNoneZ* arg_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(arg);
17279         int64_t ret_conv = CResult_CVec_u8ZNoneZ_clone_ptr(arg_conv);
17280         return ret_conv;
17281 }
17282
17283 int64_t  CS_LDK_CResult_CVec_u8ZNoneZ_clone(int64_t orig) {
17284         LDKCResult_CVec_u8ZNoneZ* orig_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(orig);
17285         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
17286         *ret_conv = CResult_CVec_u8ZNoneZ_clone(orig_conv);
17287         return tag_ptr(ret_conv, true);
17288 }
17289
17290 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_ok(int64_t o) {
17291         LDKShutdownScript o_conv;
17292         o_conv.inner = untag_ptr(o);
17293         o_conv.is_owned = ptr_is_owned(o);
17294         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17295         o_conv = ShutdownScript_clone(&o_conv);
17296         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
17297         *ret_conv = CResult_ShutdownScriptNoneZ_ok(o_conv);
17298         return tag_ptr(ret_conv, true);
17299 }
17300
17301 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_err() {
17302         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
17303         *ret_conv = CResult_ShutdownScriptNoneZ_err();
17304         return tag_ptr(ret_conv, true);
17305 }
17306
17307 jboolean  CS_LDK_CResult_ShutdownScriptNoneZ_is_ok(int64_t o) {
17308         LDKCResult_ShutdownScriptNoneZ* o_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(o);
17309         jboolean ret_conv = CResult_ShutdownScriptNoneZ_is_ok(o_conv);
17310         return ret_conv;
17311 }
17312
17313 void  CS_LDK_CResult_ShutdownScriptNoneZ_free(int64_t _res) {
17314         if (!ptr_is_owned(_res)) return;
17315         void* _res_ptr = untag_ptr(_res);
17316         CHECK_ACCESS(_res_ptr);
17317         LDKCResult_ShutdownScriptNoneZ _res_conv = *(LDKCResult_ShutdownScriptNoneZ*)(_res_ptr);
17318         FREE(untag_ptr(_res));
17319         CResult_ShutdownScriptNoneZ_free(_res_conv);
17320 }
17321
17322 static inline uint64_t CResult_ShutdownScriptNoneZ_clone_ptr(LDKCResult_ShutdownScriptNoneZ *NONNULL_PTR arg) {
17323         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
17324         *ret_conv = CResult_ShutdownScriptNoneZ_clone(arg);
17325         return tag_ptr(ret_conv, true);
17326 }
17327 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_clone_ptr(int64_t arg) {
17328         LDKCResult_ShutdownScriptNoneZ* arg_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(arg);
17329         int64_t ret_conv = CResult_ShutdownScriptNoneZ_clone_ptr(arg_conv);
17330         return ret_conv;
17331 }
17332
17333 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_clone(int64_t orig) {
17334         LDKCResult_ShutdownScriptNoneZ* orig_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(orig);
17335         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
17336         *ret_conv = CResult_ShutdownScriptNoneZ_clone(orig_conv);
17337         return tag_ptr(ret_conv, true);
17338 }
17339
17340 int64_t  CS_LDK_COption_u16Z_some(int16_t o) {
17341         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17342         *ret_copy = COption_u16Z_some(o);
17343         int64_t ret_ref = tag_ptr(ret_copy, true);
17344         return ret_ref;
17345 }
17346
17347 int64_t  CS_LDK_COption_u16Z_none() {
17348         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17349         *ret_copy = COption_u16Z_none();
17350         int64_t ret_ref = tag_ptr(ret_copy, true);
17351         return ret_ref;
17352 }
17353
17354 void  CS_LDK_COption_u16Z_free(int64_t _res) {
17355         if (!ptr_is_owned(_res)) return;
17356         void* _res_ptr = untag_ptr(_res);
17357         CHECK_ACCESS(_res_ptr);
17358         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
17359         FREE(untag_ptr(_res));
17360         COption_u16Z_free(_res_conv);
17361 }
17362
17363 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
17364         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17365         *ret_copy = COption_u16Z_clone(arg);
17366         int64_t ret_ref = tag_ptr(ret_copy, true);
17367         return ret_ref;
17368 }
17369 int64_t  CS_LDK_COption_u16Z_clone_ptr(int64_t arg) {
17370         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
17371         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
17372         return ret_conv;
17373 }
17374
17375 int64_t  CS_LDK_COption_u16Z_clone(int64_t orig) {
17376         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
17377         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17378         *ret_copy = COption_u16Z_clone(orig_conv);
17379         int64_t ret_ref = tag_ptr(ret_copy, true);
17380         return ret_ref;
17381 }
17382
17383 int64_t  CS_LDK_COption_boolZ_some(jboolean o) {
17384         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
17385         *ret_copy = COption_boolZ_some(o);
17386         int64_t ret_ref = tag_ptr(ret_copy, true);
17387         return ret_ref;
17388 }
17389
17390 int64_t  CS_LDK_COption_boolZ_none() {
17391         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
17392         *ret_copy = COption_boolZ_none();
17393         int64_t ret_ref = tag_ptr(ret_copy, true);
17394         return ret_ref;
17395 }
17396
17397 void  CS_LDK_COption_boolZ_free(int64_t _res) {
17398         if (!ptr_is_owned(_res)) return;
17399         void* _res_ptr = untag_ptr(_res);
17400         CHECK_ACCESS(_res_ptr);
17401         LDKCOption_boolZ _res_conv = *(LDKCOption_boolZ*)(_res_ptr);
17402         FREE(untag_ptr(_res));
17403         COption_boolZ_free(_res_conv);
17404 }
17405
17406 static inline uint64_t COption_boolZ_clone_ptr(LDKCOption_boolZ *NONNULL_PTR arg) {
17407         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
17408         *ret_copy = COption_boolZ_clone(arg);
17409         int64_t ret_ref = tag_ptr(ret_copy, true);
17410         return ret_ref;
17411 }
17412 int64_t  CS_LDK_COption_boolZ_clone_ptr(int64_t arg) {
17413         LDKCOption_boolZ* arg_conv = (LDKCOption_boolZ*)untag_ptr(arg);
17414         int64_t ret_conv = COption_boolZ_clone_ptr(arg_conv);
17415         return ret_conv;
17416 }
17417
17418 int64_t  CS_LDK_COption_boolZ_clone(int64_t orig) {
17419         LDKCOption_boolZ* orig_conv = (LDKCOption_boolZ*)untag_ptr(orig);
17420         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
17421         *ret_copy = COption_boolZ_clone(orig_conv);
17422         int64_t ret_ref = tag_ptr(ret_copy, true);
17423         return ret_ref;
17424 }
17425
17426 void  CS_LDK_CVec_CVec_u8ZZ_free(ptrArray _res) {
17427         LDKCVec_CVec_u8ZZ _res_constr;
17428         _res_constr.datalen = _res->arr_len;
17429         if (_res_constr.datalen > 0)
17430                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17431         else
17432                 _res_constr.data = NULL;
17433         int8_tArray* _res_vals = (void*) _res->elems;
17434         for (size_t i = 0; i < _res_constr.datalen; i++) {
17435                 int8_tArray _res_conv_8 = _res_vals[i];
17436                 LDKCVec_u8Z _res_conv_8_ref;
17437                 _res_conv_8_ref.datalen = _res_conv_8->arr_len;
17438                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17439                 memcpy(_res_conv_8_ref.data, _res_conv_8->elems, _res_conv_8_ref.datalen); FREE(_res_conv_8);
17440                 _res_constr.data[i] = _res_conv_8_ref;
17441         }
17442         FREE(_res);
17443         CVec_CVec_u8ZZ_free(_res_constr);
17444 }
17445
17446 int64_t  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
17447         LDKCVec_CVec_u8ZZ o_constr;
17448         o_constr.datalen = o->arr_len;
17449         if (o_constr.datalen > 0)
17450                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17451         else
17452                 o_constr.data = NULL;
17453         int8_tArray* o_vals = (void*) o->elems;
17454         for (size_t i = 0; i < o_constr.datalen; i++) {
17455                 int8_tArray o_conv_8 = o_vals[i];
17456                 LDKCVec_u8Z o_conv_8_ref;
17457                 o_conv_8_ref.datalen = o_conv_8->arr_len;
17458                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17459                 memcpy(o_conv_8_ref.data, o_conv_8->elems, o_conv_8_ref.datalen); FREE(o_conv_8);
17460                 o_constr.data[i] = o_conv_8_ref;
17461         }
17462         FREE(o);
17463         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17464         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
17465         return tag_ptr(ret_conv, true);
17466 }
17467
17468 int64_t  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_err() {
17469         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17470         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
17471         return tag_ptr(ret_conv, true);
17472 }
17473
17474 jboolean  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_is_ok(int64_t o) {
17475         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
17476         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
17477         return ret_conv;
17478 }
17479
17480 void  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_free(int64_t _res) {
17481         if (!ptr_is_owned(_res)) return;
17482         void* _res_ptr = untag_ptr(_res);
17483         CHECK_ACCESS(_res_ptr);
17484         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
17485         FREE(untag_ptr(_res));
17486         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
17487 }
17488
17489 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
17490         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17491         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
17492         return tag_ptr(ret_conv, true);
17493 }
17494 int64_t  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(int64_t arg) {
17495         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
17496         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
17497         return ret_conv;
17498 }
17499
17500 int64_t  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_clone(int64_t orig) {
17501         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
17502         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17503         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
17504         return tag_ptr(ret_conv, true);
17505 }
17506
17507 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_ok(int64_t o) {
17508         LDKInMemorySigner o_conv;
17509         o_conv.inner = untag_ptr(o);
17510         o_conv.is_owned = ptr_is_owned(o);
17511         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17512         o_conv = InMemorySigner_clone(&o_conv);
17513         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17514         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
17515         return tag_ptr(ret_conv, true);
17516 }
17517
17518 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_err(int64_t e) {
17519         void* e_ptr = untag_ptr(e);
17520         CHECK_ACCESS(e_ptr);
17521         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17522         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17523         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17524         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
17525         return tag_ptr(ret_conv, true);
17526 }
17527
17528 jboolean  CS_LDK_CResult_InMemorySignerDecodeErrorZ_is_ok(int64_t o) {
17529         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
17530         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
17531         return ret_conv;
17532 }
17533
17534 void  CS_LDK_CResult_InMemorySignerDecodeErrorZ_free(int64_t _res) {
17535         if (!ptr_is_owned(_res)) return;
17536         void* _res_ptr = untag_ptr(_res);
17537         CHECK_ACCESS(_res_ptr);
17538         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
17539         FREE(untag_ptr(_res));
17540         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
17541 }
17542
17543 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
17544         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17545         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
17546         return tag_ptr(ret_conv, true);
17547 }
17548 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_clone_ptr(int64_t arg) {
17549         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
17550         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
17551         return ret_conv;
17552 }
17553
17554 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_clone(int64_t orig) {
17555         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
17556         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17557         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
17558         return tag_ptr(ret_conv, true);
17559 }
17560
17561 int64_t  CS_LDK_CResult_TransactionNoneZ_ok(int8_tArray o) {
17562         LDKTransaction o_ref;
17563         o_ref.datalen = o->arr_len;
17564         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
17565         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
17566         o_ref.data_is_owned = true;
17567         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17568         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
17569         return tag_ptr(ret_conv, true);
17570 }
17571
17572 int64_t  CS_LDK_CResult_TransactionNoneZ_err() {
17573         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17574         *ret_conv = CResult_TransactionNoneZ_err();
17575         return tag_ptr(ret_conv, true);
17576 }
17577
17578 jboolean  CS_LDK_CResult_TransactionNoneZ_is_ok(int64_t o) {
17579         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
17580         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
17581         return ret_conv;
17582 }
17583
17584 void  CS_LDK_CResult_TransactionNoneZ_free(int64_t _res) {
17585         if (!ptr_is_owned(_res)) return;
17586         void* _res_ptr = untag_ptr(_res);
17587         CHECK_ACCESS(_res_ptr);
17588         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
17589         FREE(untag_ptr(_res));
17590         CResult_TransactionNoneZ_free(_res_conv);
17591 }
17592
17593 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
17594         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17595         *ret_conv = CResult_TransactionNoneZ_clone(arg);
17596         return tag_ptr(ret_conv, true);
17597 }
17598 int64_t  CS_LDK_CResult_TransactionNoneZ_clone_ptr(int64_t arg) {
17599         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
17600         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
17601         return ret_conv;
17602 }
17603
17604 int64_t  CS_LDK_CResult_TransactionNoneZ_clone(int64_t orig) {
17605         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
17606         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17607         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
17608         return tag_ptr(ret_conv, true);
17609 }
17610
17611 int64_t  CS_LDK_COption_WriteableScoreZ_some(int64_t o) {
17612         void* o_ptr = untag_ptr(o);
17613         CHECK_ACCESS(o_ptr);
17614         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
17615         if (o_conv.free == LDKWriteableScore_JCalls_free) {
17616                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17617                 LDKWriteableScore_JCalls_cloned(&o_conv);
17618         }
17619         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17620         *ret_copy = COption_WriteableScoreZ_some(o_conv);
17621         int64_t ret_ref = tag_ptr(ret_copy, true);
17622         return ret_ref;
17623 }
17624
17625 int64_t  CS_LDK_COption_WriteableScoreZ_none() {
17626         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17627         *ret_copy = COption_WriteableScoreZ_none();
17628         int64_t ret_ref = tag_ptr(ret_copy, true);
17629         return ret_ref;
17630 }
17631
17632 void  CS_LDK_COption_WriteableScoreZ_free(int64_t _res) {
17633         if (!ptr_is_owned(_res)) return;
17634         void* _res_ptr = untag_ptr(_res);
17635         CHECK_ACCESS(_res_ptr);
17636         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
17637         FREE(untag_ptr(_res));
17638         COption_WriteableScoreZ_free(_res_conv);
17639 }
17640
17641 int64_t  CS_LDK_CResult_NoneIOErrorZ_ok() {
17642         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
17643         *ret_conv = CResult_NoneIOErrorZ_ok();
17644         return tag_ptr(ret_conv, true);
17645 }
17646
17647 int64_t  CS_LDK_CResult_NoneIOErrorZ_err(int32_t e) {
17648         LDKIOError e_conv = LDKIOError_from_cs(e);
17649         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
17650         *ret_conv = CResult_NoneIOErrorZ_err(e_conv);
17651         return tag_ptr(ret_conv, true);
17652 }
17653
17654 jboolean  CS_LDK_CResult_NoneIOErrorZ_is_ok(int64_t o) {
17655         LDKCResult_NoneIOErrorZ* o_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(o);
17656         jboolean ret_conv = CResult_NoneIOErrorZ_is_ok(o_conv);
17657         return ret_conv;
17658 }
17659
17660 void  CS_LDK_CResult_NoneIOErrorZ_free(int64_t _res) {
17661         if (!ptr_is_owned(_res)) return;
17662         void* _res_ptr = untag_ptr(_res);
17663         CHECK_ACCESS(_res_ptr);
17664         LDKCResult_NoneIOErrorZ _res_conv = *(LDKCResult_NoneIOErrorZ*)(_res_ptr);
17665         FREE(untag_ptr(_res));
17666         CResult_NoneIOErrorZ_free(_res_conv);
17667 }
17668
17669 static inline uint64_t CResult_NoneIOErrorZ_clone_ptr(LDKCResult_NoneIOErrorZ *NONNULL_PTR arg) {
17670         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
17671         *ret_conv = CResult_NoneIOErrorZ_clone(arg);
17672         return tag_ptr(ret_conv, true);
17673 }
17674 int64_t  CS_LDK_CResult_NoneIOErrorZ_clone_ptr(int64_t arg) {
17675         LDKCResult_NoneIOErrorZ* arg_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(arg);
17676         int64_t ret_conv = CResult_NoneIOErrorZ_clone_ptr(arg_conv);
17677         return ret_conv;
17678 }
17679
17680 int64_t  CS_LDK_CResult_NoneIOErrorZ_clone(int64_t orig) {
17681         LDKCResult_NoneIOErrorZ* orig_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(orig);
17682         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
17683         *ret_conv = CResult_NoneIOErrorZ_clone(orig_conv);
17684         return tag_ptr(ret_conv, true);
17685 }
17686
17687 void  CS_LDK_CVec_ChannelDetailsZ_free(int64_tArray _res) {
17688         LDKCVec_ChannelDetailsZ _res_constr;
17689         _res_constr.datalen = _res->arr_len;
17690         if (_res_constr.datalen > 0)
17691                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17692         else
17693                 _res_constr.data = NULL;
17694         int64_t* _res_vals = _res->elems;
17695         for (size_t q = 0; q < _res_constr.datalen; q++) {
17696                 int64_t _res_conv_16 = _res_vals[q];
17697                 LDKChannelDetails _res_conv_16_conv;
17698                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17699                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17700                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17701                 _res_constr.data[q] = _res_conv_16_conv;
17702         }
17703         FREE(_res);
17704         CVec_ChannelDetailsZ_free(_res_constr);
17705 }
17706
17707 int64_t  CS_LDK_CResult_RouteLightningErrorZ_ok(int64_t o) {
17708         LDKRoute o_conv;
17709         o_conv.inner = untag_ptr(o);
17710         o_conv.is_owned = ptr_is_owned(o);
17711         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17712         o_conv = Route_clone(&o_conv);
17713         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17714         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17715         return tag_ptr(ret_conv, true);
17716 }
17717
17718 int64_t  CS_LDK_CResult_RouteLightningErrorZ_err(int64_t e) {
17719         LDKLightningError e_conv;
17720         e_conv.inner = untag_ptr(e);
17721         e_conv.is_owned = ptr_is_owned(e);
17722         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17723         e_conv = LightningError_clone(&e_conv);
17724         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17725         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17726         return tag_ptr(ret_conv, true);
17727 }
17728
17729 jboolean  CS_LDK_CResult_RouteLightningErrorZ_is_ok(int64_t o) {
17730         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17731         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17732         return ret_conv;
17733 }
17734
17735 void  CS_LDK_CResult_RouteLightningErrorZ_free(int64_t _res) {
17736         if (!ptr_is_owned(_res)) return;
17737         void* _res_ptr = untag_ptr(_res);
17738         CHECK_ACCESS(_res_ptr);
17739         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17740         FREE(untag_ptr(_res));
17741         CResult_RouteLightningErrorZ_free(_res_conv);
17742 }
17743
17744 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17745         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17746         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17747         return tag_ptr(ret_conv, true);
17748 }
17749 int64_t  CS_LDK_CResult_RouteLightningErrorZ_clone_ptr(int64_t arg) {
17750         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17751         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17752         return ret_conv;
17753 }
17754
17755 int64_t  CS_LDK_CResult_RouteLightningErrorZ_clone(int64_t orig) {
17756         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17757         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17758         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17759         return tag_ptr(ret_conv, true);
17760 }
17761
17762 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_ok(int64_t o) {
17763         LDKInFlightHtlcs o_conv;
17764         o_conv.inner = untag_ptr(o);
17765         o_conv.is_owned = ptr_is_owned(o);
17766         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17767         o_conv = InFlightHtlcs_clone(&o_conv);
17768         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17769         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
17770         return tag_ptr(ret_conv, true);
17771 }
17772
17773 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_err(int64_t e) {
17774         void* e_ptr = untag_ptr(e);
17775         CHECK_ACCESS(e_ptr);
17776         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17777         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17778         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17779         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
17780         return tag_ptr(ret_conv, true);
17781 }
17782
17783 jboolean  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_is_ok(int64_t o) {
17784         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
17785         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
17786         return ret_conv;
17787 }
17788
17789 void  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_free(int64_t _res) {
17790         if (!ptr_is_owned(_res)) return;
17791         void* _res_ptr = untag_ptr(_res);
17792         CHECK_ACCESS(_res_ptr);
17793         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
17794         FREE(untag_ptr(_res));
17795         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
17796 }
17797
17798 static inline uint64_t CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR arg) {
17799         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17800         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(arg);
17801         return tag_ptr(ret_conv, true);
17802 }
17803 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(int64_t arg) {
17804         LDKCResult_InFlightHtlcsDecodeErrorZ* arg_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(arg);
17805         int64_t ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(arg_conv);
17806         return ret_conv;
17807 }
17808
17809 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_clone(int64_t orig) {
17810         LDKCResult_InFlightHtlcsDecodeErrorZ* orig_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(orig);
17811         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17812         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(orig_conv);
17813         return tag_ptr(ret_conv, true);
17814 }
17815
17816 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_ok(int64_t o) {
17817         LDKRouteHop o_conv;
17818         o_conv.inner = untag_ptr(o);
17819         o_conv.is_owned = ptr_is_owned(o);
17820         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17821         o_conv = RouteHop_clone(&o_conv);
17822         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17823         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
17824         return tag_ptr(ret_conv, true);
17825 }
17826
17827 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_err(int64_t e) {
17828         void* e_ptr = untag_ptr(e);
17829         CHECK_ACCESS(e_ptr);
17830         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17831         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17832         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17833         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
17834         return tag_ptr(ret_conv, true);
17835 }
17836
17837 jboolean  CS_LDK_CResult_RouteHopDecodeErrorZ_is_ok(int64_t o) {
17838         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
17839         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
17840         return ret_conv;
17841 }
17842
17843 void  CS_LDK_CResult_RouteHopDecodeErrorZ_free(int64_t _res) {
17844         if (!ptr_is_owned(_res)) return;
17845         void* _res_ptr = untag_ptr(_res);
17846         CHECK_ACCESS(_res_ptr);
17847         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
17848         FREE(untag_ptr(_res));
17849         CResult_RouteHopDecodeErrorZ_free(_res_conv);
17850 }
17851
17852 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
17853         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17854         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
17855         return tag_ptr(ret_conv, true);
17856 }
17857 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_clone_ptr(int64_t arg) {
17858         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
17859         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
17860         return ret_conv;
17861 }
17862
17863 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_clone(int64_t orig) {
17864         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
17865         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17866         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
17867         return tag_ptr(ret_conv, true);
17868 }
17869
17870 void  CS_LDK_CVec_BlindedHopZ_free(int64_tArray _res) {
17871         LDKCVec_BlindedHopZ _res_constr;
17872         _res_constr.datalen = _res->arr_len;
17873         if (_res_constr.datalen > 0)
17874                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
17875         else
17876                 _res_constr.data = NULL;
17877         int64_t* _res_vals = _res->elems;
17878         for (size_t m = 0; m < _res_constr.datalen; m++) {
17879                 int64_t _res_conv_12 = _res_vals[m];
17880                 LDKBlindedHop _res_conv_12_conv;
17881                 _res_conv_12_conv.inner = untag_ptr(_res_conv_12);
17882                 _res_conv_12_conv.is_owned = ptr_is_owned(_res_conv_12);
17883                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv);
17884                 _res_constr.data[m] = _res_conv_12_conv;
17885         }
17886         FREE(_res);
17887         CVec_BlindedHopZ_free(_res_constr);
17888 }
17889
17890 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_ok(int64_t o) {
17891         LDKBlindedTail o_conv;
17892         o_conv.inner = untag_ptr(o);
17893         o_conv.is_owned = ptr_is_owned(o);
17894         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17895         o_conv = BlindedTail_clone(&o_conv);
17896         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17897         *ret_conv = CResult_BlindedTailDecodeErrorZ_ok(o_conv);
17898         return tag_ptr(ret_conv, true);
17899 }
17900
17901 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_err(int64_t e) {
17902         void* e_ptr = untag_ptr(e);
17903         CHECK_ACCESS(e_ptr);
17904         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17905         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17906         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17907         *ret_conv = CResult_BlindedTailDecodeErrorZ_err(e_conv);
17908         return tag_ptr(ret_conv, true);
17909 }
17910
17911 jboolean  CS_LDK_CResult_BlindedTailDecodeErrorZ_is_ok(int64_t o) {
17912         LDKCResult_BlindedTailDecodeErrorZ* o_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(o);
17913         jboolean ret_conv = CResult_BlindedTailDecodeErrorZ_is_ok(o_conv);
17914         return ret_conv;
17915 }
17916
17917 void  CS_LDK_CResult_BlindedTailDecodeErrorZ_free(int64_t _res) {
17918         if (!ptr_is_owned(_res)) return;
17919         void* _res_ptr = untag_ptr(_res);
17920         CHECK_ACCESS(_res_ptr);
17921         LDKCResult_BlindedTailDecodeErrorZ _res_conv = *(LDKCResult_BlindedTailDecodeErrorZ*)(_res_ptr);
17922         FREE(untag_ptr(_res));
17923         CResult_BlindedTailDecodeErrorZ_free(_res_conv);
17924 }
17925
17926 static inline uint64_t CResult_BlindedTailDecodeErrorZ_clone_ptr(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR arg) {
17927         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17928         *ret_conv = CResult_BlindedTailDecodeErrorZ_clone(arg);
17929         return tag_ptr(ret_conv, true);
17930 }
17931 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_clone_ptr(int64_t arg) {
17932         LDKCResult_BlindedTailDecodeErrorZ* arg_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(arg);
17933         int64_t ret_conv = CResult_BlindedTailDecodeErrorZ_clone_ptr(arg_conv);
17934         return ret_conv;
17935 }
17936
17937 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_clone(int64_t orig) {
17938         LDKCResult_BlindedTailDecodeErrorZ* orig_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(orig);
17939         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17940         *ret_conv = CResult_BlindedTailDecodeErrorZ_clone(orig_conv);
17941         return tag_ptr(ret_conv, true);
17942 }
17943
17944 void  CS_LDK_CVec_RouteHopZ_free(int64_tArray _res) {
17945         LDKCVec_RouteHopZ _res_constr;
17946         _res_constr.datalen = _res->arr_len;
17947         if (_res_constr.datalen > 0)
17948                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17949         else
17950                 _res_constr.data = NULL;
17951         int64_t* _res_vals = _res->elems;
17952         for (size_t k = 0; k < _res_constr.datalen; k++) {
17953                 int64_t _res_conv_10 = _res_vals[k];
17954                 LDKRouteHop _res_conv_10_conv;
17955                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
17956                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
17957                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
17958                 _res_constr.data[k] = _res_conv_10_conv;
17959         }
17960         FREE(_res);
17961         CVec_RouteHopZ_free(_res_constr);
17962 }
17963
17964 void  CS_LDK_CVec_PathZ_free(int64_tArray _res) {
17965         LDKCVec_PathZ _res_constr;
17966         _res_constr.datalen = _res->arr_len;
17967         if (_res_constr.datalen > 0)
17968                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
17969         else
17970                 _res_constr.data = NULL;
17971         int64_t* _res_vals = _res->elems;
17972         for (size_t g = 0; g < _res_constr.datalen; g++) {
17973                 int64_t _res_conv_6 = _res_vals[g];
17974                 LDKPath _res_conv_6_conv;
17975                 _res_conv_6_conv.inner = untag_ptr(_res_conv_6);
17976                 _res_conv_6_conv.is_owned = ptr_is_owned(_res_conv_6);
17977                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_6_conv);
17978                 _res_constr.data[g] = _res_conv_6_conv;
17979         }
17980         FREE(_res);
17981         CVec_PathZ_free(_res_constr);
17982 }
17983
17984 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_ok(int64_t o) {
17985         LDKRoute o_conv;
17986         o_conv.inner = untag_ptr(o);
17987         o_conv.is_owned = ptr_is_owned(o);
17988         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17989         o_conv = Route_clone(&o_conv);
17990         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17991         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
17992         return tag_ptr(ret_conv, true);
17993 }
17994
17995 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_err(int64_t e) {
17996         void* e_ptr = untag_ptr(e);
17997         CHECK_ACCESS(e_ptr);
17998         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17999         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18000         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
18001         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
18002         return tag_ptr(ret_conv, true);
18003 }
18004
18005 jboolean  CS_LDK_CResult_RouteDecodeErrorZ_is_ok(int64_t o) {
18006         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
18007         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
18008         return ret_conv;
18009 }
18010
18011 void  CS_LDK_CResult_RouteDecodeErrorZ_free(int64_t _res) {
18012         if (!ptr_is_owned(_res)) return;
18013         void* _res_ptr = untag_ptr(_res);
18014         CHECK_ACCESS(_res_ptr);
18015         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
18016         FREE(untag_ptr(_res));
18017         CResult_RouteDecodeErrorZ_free(_res_conv);
18018 }
18019
18020 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
18021         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
18022         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
18023         return tag_ptr(ret_conv, true);
18024 }
18025 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_clone_ptr(int64_t arg) {
18026         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
18027         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
18028         return ret_conv;
18029 }
18030
18031 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_clone(int64_t orig) {
18032         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
18033         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
18034         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
18035         return tag_ptr(ret_conv, true);
18036 }
18037
18038 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_ok(int64_t o) {
18039         LDKRouteParameters o_conv;
18040         o_conv.inner = untag_ptr(o);
18041         o_conv.is_owned = ptr_is_owned(o);
18042         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18043         o_conv = RouteParameters_clone(&o_conv);
18044         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
18045         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
18046         return tag_ptr(ret_conv, true);
18047 }
18048
18049 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_err(int64_t e) {
18050         void* e_ptr = untag_ptr(e);
18051         CHECK_ACCESS(e_ptr);
18052         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18053         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18054         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
18055         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
18056         return tag_ptr(ret_conv, true);
18057 }
18058
18059 jboolean  CS_LDK_CResult_RouteParametersDecodeErrorZ_is_ok(int64_t o) {
18060         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
18061         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
18062         return ret_conv;
18063 }
18064
18065 void  CS_LDK_CResult_RouteParametersDecodeErrorZ_free(int64_t _res) {
18066         if (!ptr_is_owned(_res)) return;
18067         void* _res_ptr = untag_ptr(_res);
18068         CHECK_ACCESS(_res_ptr);
18069         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
18070         FREE(untag_ptr(_res));
18071         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
18072 }
18073
18074 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
18075         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
18076         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
18077         return tag_ptr(ret_conv, true);
18078 }
18079 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_clone_ptr(int64_t arg) {
18080         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
18081         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
18082         return ret_conv;
18083 }
18084
18085 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_clone(int64_t orig) {
18086         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
18087         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
18088         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
18089         return tag_ptr(ret_conv, true);
18090 }
18091
18092 void  CS_LDK_CVec_u64Z_free(int64_tArray _res) {
18093         LDKCVec_u64Z _res_constr;
18094         _res_constr.datalen = _res->arr_len;
18095         if (_res_constr.datalen > 0)
18096                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18097         else
18098                 _res_constr.data = NULL;
18099         int64_t* _res_vals = _res->elems;
18100         for (size_t g = 0; g < _res_constr.datalen; g++) {
18101                 int64_t _res_conv_6 = _res_vals[g];
18102                 _res_constr.data[g] = _res_conv_6;
18103         }
18104         FREE(_res);
18105         CVec_u64Z_free(_res_constr);
18106 }
18107
18108 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_ok(int64_t o) {
18109         LDKPaymentParameters o_conv;
18110         o_conv.inner = untag_ptr(o);
18111         o_conv.is_owned = ptr_is_owned(o);
18112         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18113         o_conv = PaymentParameters_clone(&o_conv);
18114         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
18115         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
18116         return tag_ptr(ret_conv, true);
18117 }
18118
18119 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_err(int64_t e) {
18120         void* e_ptr = untag_ptr(e);
18121         CHECK_ACCESS(e_ptr);
18122         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18123         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18124         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
18125         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
18126         return tag_ptr(ret_conv, true);
18127 }
18128
18129 jboolean  CS_LDK_CResult_PaymentParametersDecodeErrorZ_is_ok(int64_t o) {
18130         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
18131         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
18132         return ret_conv;
18133 }
18134
18135 void  CS_LDK_CResult_PaymentParametersDecodeErrorZ_free(int64_t _res) {
18136         if (!ptr_is_owned(_res)) return;
18137         void* _res_ptr = untag_ptr(_res);
18138         CHECK_ACCESS(_res_ptr);
18139         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
18140         FREE(untag_ptr(_res));
18141         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
18142 }
18143
18144 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
18145         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
18146         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
18147         return tag_ptr(ret_conv, true);
18148 }
18149 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_clone_ptr(int64_t arg) {
18150         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
18151         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
18152         return ret_conv;
18153 }
18154
18155 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_clone(int64_t orig) {
18156         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
18157         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
18158         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
18159         return tag_ptr(ret_conv, true);
18160 }
18161
18162 static inline uint64_t C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR arg) {
18163         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
18164         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(arg);
18165         return tag_ptr(ret_conv, true);
18166 }
18167 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(int64_t arg) {
18168         LDKC2Tuple_BlindedPayInfoBlindedPathZ* arg_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(arg);
18169         int64_t ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(arg_conv);
18170         return ret_conv;
18171 }
18172
18173 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_clone(int64_t orig) {
18174         LDKC2Tuple_BlindedPayInfoBlindedPathZ* orig_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(orig);
18175         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
18176         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig_conv);
18177         return tag_ptr(ret_conv, true);
18178 }
18179
18180 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_new(int64_t a, int64_t b) {
18181         LDKBlindedPayInfo a_conv;
18182         a_conv.inner = untag_ptr(a);
18183         a_conv.is_owned = ptr_is_owned(a);
18184         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18185         a_conv = BlindedPayInfo_clone(&a_conv);
18186         LDKBlindedPath b_conv;
18187         b_conv.inner = untag_ptr(b);
18188         b_conv.is_owned = ptr_is_owned(b);
18189         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18190         b_conv = BlindedPath_clone(&b_conv);
18191         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
18192         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_new(a_conv, b_conv);
18193         return tag_ptr(ret_conv, true);
18194 }
18195
18196 void  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_free(int64_t _res) {
18197         if (!ptr_is_owned(_res)) return;
18198         void* _res_ptr = untag_ptr(_res);
18199         CHECK_ACCESS(_res_ptr);
18200         LDKC2Tuple_BlindedPayInfoBlindedPathZ _res_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(_res_ptr);
18201         FREE(untag_ptr(_res));
18202         C2Tuple_BlindedPayInfoBlindedPathZ_free(_res_conv);
18203 }
18204
18205 void  CS_LDK_CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(int64_tArray _res) {
18206         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ _res_constr;
18207         _res_constr.datalen = _res->arr_len;
18208         if (_res_constr.datalen > 0)
18209                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
18210         else
18211                 _res_constr.data = NULL;
18212         int64_t* _res_vals = _res->elems;
18213         for (size_t l = 0; l < _res_constr.datalen; l++) {
18214                 int64_t _res_conv_37 = _res_vals[l];
18215                 void* _res_conv_37_ptr = untag_ptr(_res_conv_37);
18216                 CHECK_ACCESS(_res_conv_37_ptr);
18217                 LDKC2Tuple_BlindedPayInfoBlindedPathZ _res_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(_res_conv_37_ptr);
18218                 FREE(untag_ptr(_res_conv_37));
18219                 _res_constr.data[l] = _res_conv_37_conv;
18220         }
18221         FREE(_res);
18222         CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res_constr);
18223 }
18224
18225 void  CS_LDK_CVec_RouteHintZ_free(int64_tArray _res) {
18226         LDKCVec_RouteHintZ _res_constr;
18227         _res_constr.datalen = _res->arr_len;
18228         if (_res_constr.datalen > 0)
18229                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
18230         else
18231                 _res_constr.data = NULL;
18232         int64_t* _res_vals = _res->elems;
18233         for (size_t l = 0; l < _res_constr.datalen; l++) {
18234                 int64_t _res_conv_11 = _res_vals[l];
18235                 LDKRouteHint _res_conv_11_conv;
18236                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
18237                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
18238                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
18239                 _res_constr.data[l] = _res_conv_11_conv;
18240         }
18241         FREE(_res);
18242         CVec_RouteHintZ_free(_res_constr);
18243 }
18244
18245 void  CS_LDK_CVec_RouteHintHopZ_free(int64_tArray _res) {
18246         LDKCVec_RouteHintHopZ _res_constr;
18247         _res_constr.datalen = _res->arr_len;
18248         if (_res_constr.datalen > 0)
18249                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
18250         else
18251                 _res_constr.data = NULL;
18252         int64_t* _res_vals = _res->elems;
18253         for (size_t o = 0; o < _res_constr.datalen; o++) {
18254                 int64_t _res_conv_14 = _res_vals[o];
18255                 LDKRouteHintHop _res_conv_14_conv;
18256                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
18257                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
18258                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
18259                 _res_constr.data[o] = _res_conv_14_conv;
18260         }
18261         FREE(_res);
18262         CVec_RouteHintHopZ_free(_res_constr);
18263 }
18264
18265 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_ok(int64_t o) {
18266         LDKRouteHint o_conv;
18267         o_conv.inner = untag_ptr(o);
18268         o_conv.is_owned = ptr_is_owned(o);
18269         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18270         o_conv = RouteHint_clone(&o_conv);
18271         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18272         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
18273         return tag_ptr(ret_conv, true);
18274 }
18275
18276 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_err(int64_t e) {
18277         void* e_ptr = untag_ptr(e);
18278         CHECK_ACCESS(e_ptr);
18279         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18280         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18281         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18282         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
18283         return tag_ptr(ret_conv, true);
18284 }
18285
18286 jboolean  CS_LDK_CResult_RouteHintDecodeErrorZ_is_ok(int64_t o) {
18287         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
18288         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
18289         return ret_conv;
18290 }
18291
18292 void  CS_LDK_CResult_RouteHintDecodeErrorZ_free(int64_t _res) {
18293         if (!ptr_is_owned(_res)) return;
18294         void* _res_ptr = untag_ptr(_res);
18295         CHECK_ACCESS(_res_ptr);
18296         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
18297         FREE(untag_ptr(_res));
18298         CResult_RouteHintDecodeErrorZ_free(_res_conv);
18299 }
18300
18301 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
18302         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18303         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
18304         return tag_ptr(ret_conv, true);
18305 }
18306 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_clone_ptr(int64_t arg) {
18307         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
18308         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
18309         return ret_conv;
18310 }
18311
18312 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_clone(int64_t orig) {
18313         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
18314         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18315         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
18316         return tag_ptr(ret_conv, true);
18317 }
18318
18319 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_ok(int64_t o) {
18320         LDKRouteHintHop o_conv;
18321         o_conv.inner = untag_ptr(o);
18322         o_conv.is_owned = ptr_is_owned(o);
18323         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18324         o_conv = RouteHintHop_clone(&o_conv);
18325         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18326         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
18327         return tag_ptr(ret_conv, true);
18328 }
18329
18330 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_err(int64_t e) {
18331         void* e_ptr = untag_ptr(e);
18332         CHECK_ACCESS(e_ptr);
18333         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18334         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18335         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18336         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
18337         return tag_ptr(ret_conv, true);
18338 }
18339
18340 jboolean  CS_LDK_CResult_RouteHintHopDecodeErrorZ_is_ok(int64_t o) {
18341         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
18342         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
18343         return ret_conv;
18344 }
18345
18346 void  CS_LDK_CResult_RouteHintHopDecodeErrorZ_free(int64_t _res) {
18347         if (!ptr_is_owned(_res)) return;
18348         void* _res_ptr = untag_ptr(_res);
18349         CHECK_ACCESS(_res_ptr);
18350         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
18351         FREE(untag_ptr(_res));
18352         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
18353 }
18354
18355 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
18356         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18357         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
18358         return tag_ptr(ret_conv, true);
18359 }
18360 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_clone_ptr(int64_t arg) {
18361         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
18362         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
18363         return ret_conv;
18364 }
18365
18366 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_clone(int64_t orig) {
18367         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
18368         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18369         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
18370         return tag_ptr(ret_conv, true);
18371 }
18372
18373 void  CS_LDK_CVec_PublicKeyZ_free(ptrArray _res) {
18374         LDKCVec_PublicKeyZ _res_constr;
18375         _res_constr.datalen = _res->arr_len;
18376         if (_res_constr.datalen > 0)
18377                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
18378         else
18379                 _res_constr.data = NULL;
18380         int8_tArray* _res_vals = (void*) _res->elems;
18381         for (size_t i = 0; i < _res_constr.datalen; i++) {
18382                 int8_tArray _res_conv_8 = _res_vals[i];
18383                 LDKPublicKey _res_conv_8_ref;
18384                 CHECK(_res_conv_8->arr_len == 33);
18385                 memcpy(_res_conv_8_ref.compressed_form, _res_conv_8->elems, 33); FREE(_res_conv_8);
18386                 _res_constr.data[i] = _res_conv_8_ref;
18387         }
18388         FREE(_res);
18389         CVec_PublicKeyZ_free(_res_constr);
18390 }
18391
18392 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_ok(int64_t o) {
18393         LDKFixedPenaltyScorer o_conv;
18394         o_conv.inner = untag_ptr(o);
18395         o_conv.is_owned = ptr_is_owned(o);
18396         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18397         o_conv = FixedPenaltyScorer_clone(&o_conv);
18398         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18399         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
18400         return tag_ptr(ret_conv, true);
18401 }
18402
18403 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_err(int64_t e) {
18404         void* e_ptr = untag_ptr(e);
18405         CHECK_ACCESS(e_ptr);
18406         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18407         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18408         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18409         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
18410         return tag_ptr(ret_conv, true);
18411 }
18412
18413 jboolean  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(int64_t o) {
18414         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
18415         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
18416         return ret_conv;
18417 }
18418
18419 void  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_free(int64_t _res) {
18420         if (!ptr_is_owned(_res)) return;
18421         void* _res_ptr = untag_ptr(_res);
18422         CHECK_ACCESS(_res_ptr);
18423         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
18424         FREE(untag_ptr(_res));
18425         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
18426 }
18427
18428 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
18429         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18430         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
18431         return tag_ptr(ret_conv, true);
18432 }
18433 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(int64_t arg) {
18434         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
18435         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
18436         return ret_conv;
18437 }
18438
18439 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_clone(int64_t orig) {
18440         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
18441         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18442         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
18443         return tag_ptr(ret_conv, true);
18444 }
18445
18446 void  CS_LDK_CVec_NodeIdZ_free(int64_tArray _res) {
18447         LDKCVec_NodeIdZ _res_constr;
18448         _res_constr.datalen = _res->arr_len;
18449         if (_res_constr.datalen > 0)
18450                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
18451         else
18452                 _res_constr.data = NULL;
18453         int64_t* _res_vals = _res->elems;
18454         for (size_t i = 0; i < _res_constr.datalen; i++) {
18455                 int64_t _res_conv_8 = _res_vals[i];
18456                 LDKNodeId _res_conv_8_conv;
18457                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
18458                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
18459                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
18460                 _res_constr.data[i] = _res_conv_8_conv;
18461         }
18462         FREE(_res);
18463         CVec_NodeIdZ_free(_res_constr);
18464 }
18465
18466 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
18467         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18468         *ret_conv = C2Tuple_u64u64Z_clone(arg);
18469         return tag_ptr(ret_conv, true);
18470 }
18471 int64_t  CS_LDK_C2Tuple_u64u64Z_clone_ptr(int64_t arg) {
18472         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
18473         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
18474         return ret_conv;
18475 }
18476
18477 int64_t  CS_LDK_C2Tuple_u64u64Z_clone(int64_t orig) {
18478         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
18479         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18480         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
18481         return tag_ptr(ret_conv, true);
18482 }
18483
18484 int64_t  CS_LDK_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
18485         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18486         *ret_conv = C2Tuple_u64u64Z_new(a, b);
18487         return tag_ptr(ret_conv, true);
18488 }
18489
18490 void  CS_LDK_C2Tuple_u64u64Z_free(int64_t _res) {
18491         if (!ptr_is_owned(_res)) return;
18492         void* _res_ptr = untag_ptr(_res);
18493         CHECK_ACCESS(_res_ptr);
18494         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
18495         FREE(untag_ptr(_res));
18496         C2Tuple_u64u64Z_free(_res_conv);
18497 }
18498
18499 int64_t  CS_LDK_COption_C2Tuple_u64u64ZZ_some(int64_t o) {
18500         void* o_ptr = untag_ptr(o);
18501         CHECK_ACCESS(o_ptr);
18502         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
18503         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
18504         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18505         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
18506         int64_t ret_ref = tag_ptr(ret_copy, true);
18507         return ret_ref;
18508 }
18509
18510 int64_t  CS_LDK_COption_C2Tuple_u64u64ZZ_none() {
18511         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18512         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
18513         int64_t ret_ref = tag_ptr(ret_copy, true);
18514         return ret_ref;
18515 }
18516
18517 void  CS_LDK_COption_C2Tuple_u64u64ZZ_free(int64_t _res) {
18518         if (!ptr_is_owned(_res)) return;
18519         void* _res_ptr = untag_ptr(_res);
18520         CHECK_ACCESS(_res_ptr);
18521         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
18522         FREE(untag_ptr(_res));
18523         COption_C2Tuple_u64u64ZZ_free(_res_conv);
18524 }
18525
18526 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
18527         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18528         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
18529         int64_t ret_ref = tag_ptr(ret_copy, true);
18530         return ret_ref;
18531 }
18532 int64_t  CS_LDK_COption_C2Tuple_u64u64ZZ_clone_ptr(int64_t arg) {
18533         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
18534         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
18535         return ret_conv;
18536 }
18537
18538 int64_t  CS_LDK_COption_C2Tuple_u64u64ZZ_clone(int64_t orig) {
18539         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
18540         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18541         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
18542         int64_t ret_ref = tag_ptr(ret_copy, true);
18543         return ret_ref;
18544 }
18545
18546 int64_t  CS_LDK_C2Tuple_Z_new(int16_tArray a, int16_tArray b) {
18547         LDKThirtyTwoU16s a_ref;
18548         CHECK(a->arr_len == 32);
18549         memcpy(a_ref.data, a->elems, 32 * 2); FREE(a);
18550         LDKThirtyTwoU16s b_ref;
18551         CHECK(b->arr_len == 32);
18552         memcpy(b_ref.data, b->elems, 32 * 2); FREE(b);
18553         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18554         *ret_conv = C2Tuple_Z_new(a_ref, b_ref);
18555         return tag_ptr(ret_conv, true);
18556 }
18557
18558 void  CS_LDK_C2Tuple_Z_free(int64_t _res) {
18559         if (!ptr_is_owned(_res)) return;
18560         void* _res_ptr = untag_ptr(_res);
18561         CHECK_ACCESS(_res_ptr);
18562         LDKC2Tuple_Z _res_conv = *(LDKC2Tuple_Z*)(_res_ptr);
18563         FREE(untag_ptr(_res));
18564         C2Tuple_Z_free(_res_conv);
18565 }
18566
18567 int64_t  CS_LDK_C2Tuple__u1632_u1632Z_new(int16_tArray a, int16_tArray b) {
18568         LDKThirtyTwoU16s a_ref;
18569         CHECK(a->arr_len == 32);
18570         memcpy(a_ref.data, a->elems, 32 * 2); FREE(a);
18571         LDKThirtyTwoU16s b_ref;
18572         CHECK(b->arr_len == 32);
18573         memcpy(b_ref.data, b->elems, 32 * 2); FREE(b);
18574         LDKC2Tuple__u1632_u1632Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u1632_u1632Z), "LDKC2Tuple__u1632_u1632Z");
18575         *ret_conv = C2Tuple__u1632_u1632Z_new(a_ref, b_ref);
18576         return tag_ptr(ret_conv, true);
18577 }
18578
18579 void  CS_LDK_C2Tuple__u1632_u1632Z_free(int64_t _res) {
18580         if (!ptr_is_owned(_res)) return;
18581         void* _res_ptr = untag_ptr(_res);
18582         CHECK_ACCESS(_res_ptr);
18583         LDKC2Tuple__u1632_u1632Z _res_conv = *(LDKC2Tuple__u1632_u1632Z*)(_res_ptr);
18584         FREE(untag_ptr(_res));
18585         C2Tuple__u1632_u1632Z_free(_res_conv);
18586 }
18587
18588 int64_t  CS_LDK_COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_some(int64_t o) {
18589         void* o_ptr = untag_ptr(o);
18590         CHECK_ACCESS(o_ptr);
18591         LDKC2Tuple__u1632_u1632Z o_conv = *(LDKC2Tuple__u1632_u1632Z*)(o_ptr);
18592         // WARNING: we may need a move here but no clone is available for LDKC2Tuple__u1632_u1632Z
18593         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ), "LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ");
18594         *ret_copy = COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_some(o_conv);
18595         int64_t ret_ref = tag_ptr(ret_copy, true);
18596         return ret_ref;
18597 }
18598
18599 int64_t  CS_LDK_COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_none() {
18600         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ), "LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ");
18601         *ret_copy = COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_none();
18602         int64_t ret_ref = tag_ptr(ret_copy, true);
18603         return ret_ref;
18604 }
18605
18606 void  CS_LDK_COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_free(int64_t _res) {
18607         if (!ptr_is_owned(_res)) return;
18608         void* _res_ptr = untag_ptr(_res);
18609         CHECK_ACCESS(_res_ptr);
18610         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ _res_conv = *(LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ*)(_res_ptr);
18611         FREE(untag_ptr(_res));
18612         COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_free(_res_conv);
18613 }
18614
18615 int64_t  CS_LDK_COption_f64Z_some(double o) {
18616         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
18617         *ret_copy = COption_f64Z_some(o);
18618         int64_t ret_ref = tag_ptr(ret_copy, true);
18619         return ret_ref;
18620 }
18621
18622 int64_t  CS_LDK_COption_f64Z_none() {
18623         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
18624         *ret_copy = COption_f64Z_none();
18625         int64_t ret_ref = tag_ptr(ret_copy, true);
18626         return ret_ref;
18627 }
18628
18629 void  CS_LDK_COption_f64Z_free(int64_t _res) {
18630         if (!ptr_is_owned(_res)) return;
18631         void* _res_ptr = untag_ptr(_res);
18632         CHECK_ACCESS(_res_ptr);
18633         LDKCOption_f64Z _res_conv = *(LDKCOption_f64Z*)(_res_ptr);
18634         FREE(untag_ptr(_res));
18635         COption_f64Z_free(_res_conv);
18636 }
18637
18638 static inline uint64_t COption_f64Z_clone_ptr(LDKCOption_f64Z *NONNULL_PTR arg) {
18639         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
18640         *ret_copy = COption_f64Z_clone(arg);
18641         int64_t ret_ref = tag_ptr(ret_copy, true);
18642         return ret_ref;
18643 }
18644 int64_t  CS_LDK_COption_f64Z_clone_ptr(int64_t arg) {
18645         LDKCOption_f64Z* arg_conv = (LDKCOption_f64Z*)untag_ptr(arg);
18646         int64_t ret_conv = COption_f64Z_clone_ptr(arg_conv);
18647         return ret_conv;
18648 }
18649
18650 int64_t  CS_LDK_COption_f64Z_clone(int64_t orig) {
18651         LDKCOption_f64Z* orig_conv = (LDKCOption_f64Z*)untag_ptr(orig);
18652         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
18653         *ret_copy = COption_f64Z_clone(orig_conv);
18654         int64_t ret_ref = tag_ptr(ret_copy, true);
18655         return ret_ref;
18656 }
18657
18658 int64_t  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_ok(int64_t o) {
18659         LDKProbabilisticScorer o_conv;
18660         o_conv.inner = untag_ptr(o);
18661         o_conv.is_owned = ptr_is_owned(o);
18662         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18663         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
18664         
18665         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18666         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
18667         return tag_ptr(ret_conv, true);
18668 }
18669
18670 int64_t  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_err(int64_t e) {
18671         void* e_ptr = untag_ptr(e);
18672         CHECK_ACCESS(e_ptr);
18673         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18674         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18675         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18676         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18677         return tag_ptr(ret_conv, true);
18678 }
18679
18680 jboolean  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(int64_t o) {
18681         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18682         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18683         return ret_conv;
18684 }
18685
18686 void  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_free(int64_t _res) {
18687         if (!ptr_is_owned(_res)) return;
18688         void* _res_ptr = untag_ptr(_res);
18689         CHECK_ACCESS(_res_ptr);
18690         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18691         FREE(untag_ptr(_res));
18692         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18693 }
18694
18695 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
18696         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18697         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
18698         return tag_ptr(ret_conv, true);
18699 }
18700 int64_t  CS_LDK_C2Tuple_usizeTransactionZ_clone_ptr(int64_t arg) {
18701         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
18702         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
18703         return ret_conv;
18704 }
18705
18706 int64_t  CS_LDK_C2Tuple_usizeTransactionZ_clone(int64_t orig) {
18707         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
18708         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18709         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
18710         return tag_ptr(ret_conv, true);
18711 }
18712
18713 int64_t  CS_LDK_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
18714         LDKTransaction b_ref;
18715         b_ref.datalen = b->arr_len;
18716         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
18717         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
18718         b_ref.data_is_owned = true;
18719         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18720         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
18721         return tag_ptr(ret_conv, true);
18722 }
18723
18724 void  CS_LDK_C2Tuple_usizeTransactionZ_free(int64_t _res) {
18725         if (!ptr_is_owned(_res)) return;
18726         void* _res_ptr = untag_ptr(_res);
18727         CHECK_ACCESS(_res_ptr);
18728         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
18729         FREE(untag_ptr(_res));
18730         C2Tuple_usizeTransactionZ_free(_res_conv);
18731 }
18732
18733 void  CS_LDK_CVec_C2Tuple_usizeTransactionZZ_free(int64_tArray _res) {
18734         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
18735         _res_constr.datalen = _res->arr_len;
18736         if (_res_constr.datalen > 0)
18737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18738         else
18739                 _res_constr.data = NULL;
18740         int64_t* _res_vals = _res->elems;
18741         for (size_t c = 0; c < _res_constr.datalen; c++) {
18742                 int64_t _res_conv_28 = _res_vals[c];
18743                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
18744                 CHECK_ACCESS(_res_conv_28_ptr);
18745                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
18746                 FREE(untag_ptr(_res_conv_28));
18747                 _res_constr.data[c] = _res_conv_28_conv;
18748         }
18749         FREE(_res);
18750         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
18751 }
18752
18753 static inline uint64_t C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ *NONNULL_PTR arg) {
18754         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
18755         *ret_conv = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone(arg);
18756         return tag_ptr(ret_conv, true);
18757 }
18758 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone_ptr(int64_t arg) {
18759         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)untag_ptr(arg);
18760         int64_t ret_conv = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone_ptr(arg_conv);
18761         return ret_conv;
18762 }
18763
18764 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone(int64_t orig) {
18765         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)untag_ptr(orig);
18766         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
18767         *ret_conv = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone(orig_conv);
18768         return tag_ptr(ret_conv, true);
18769 }
18770
18771 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_new(int8_tArray a, int64_t b) {
18772         LDKThirtyTwoBytes a_ref;
18773         CHECK(a->arr_len == 32);
18774         memcpy(a_ref.data, a->elems, 32); FREE(a);
18775         void* b_ptr = untag_ptr(b);
18776         CHECK_ACCESS(b_ptr);
18777         LDKCOption_ThirtyTwoBytesZ b_conv = *(LDKCOption_ThirtyTwoBytesZ*)(b_ptr);
18778         b_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(b));
18779         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
18780         *ret_conv = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_new(a_ref, b_conv);
18781         return tag_ptr(ret_conv, true);
18782 }
18783
18784 void  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_free(int64_t _res) {
18785         if (!ptr_is_owned(_res)) return;
18786         void* _res_ptr = untag_ptr(_res);
18787         CHECK_ACCESS(_res_ptr);
18788         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)(_res_ptr);
18789         FREE(untag_ptr(_res));
18790         C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_free(_res_conv);
18791 }
18792
18793 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ_free(int64_tArray _res) {
18794         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ _res_constr;
18795         _res_constr.datalen = _res->arr_len;
18796         if (_res_constr.datalen > 0)
18797                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ Elements");
18798         else
18799                 _res_constr.data = NULL;
18800         int64_t* _res_vals = _res->elems;
18801         for (size_t x = 0; x < _res_constr.datalen; x++) {
18802                 int64_t _res_conv_49 = _res_vals[x];
18803                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18804                 CHECK_ACCESS(_res_conv_49_ptr);
18805                 LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ _res_conv_49_conv = *(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)(_res_conv_49_ptr);
18806                 FREE(untag_ptr(_res_conv_49));
18807                 _res_constr.data[x] = _res_conv_49_conv;
18808         }
18809         FREE(_res);
18810         CVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ_free(_res_constr);
18811 }
18812
18813 int64_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_ok(int32_t o) {
18814         LDKChannelMonitorUpdateStatus o_conv = LDKChannelMonitorUpdateStatus_from_cs(o);
18815         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
18816         *ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_ok(o_conv);
18817         return tag_ptr(ret_conv, true);
18818 }
18819
18820 int64_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_err() {
18821         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
18822         *ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_err();
18823         return tag_ptr(ret_conv, true);
18824 }
18825
18826 jboolean  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_is_ok(int64_t o) {
18827         LDKCResult_ChannelMonitorUpdateStatusNoneZ* o_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(o);
18828         jboolean ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_is_ok(o_conv);
18829         return ret_conv;
18830 }
18831
18832 void  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_free(int64_t _res) {
18833         if (!ptr_is_owned(_res)) return;
18834         void* _res_ptr = untag_ptr(_res);
18835         CHECK_ACCESS(_res_ptr);
18836         LDKCResult_ChannelMonitorUpdateStatusNoneZ _res_conv = *(LDKCResult_ChannelMonitorUpdateStatusNoneZ*)(_res_ptr);
18837         FREE(untag_ptr(_res));
18838         CResult_ChannelMonitorUpdateStatusNoneZ_free(_res_conv);
18839 }
18840
18841 static inline uint64_t CResult_ChannelMonitorUpdateStatusNoneZ_clone_ptr(LDKCResult_ChannelMonitorUpdateStatusNoneZ *NONNULL_PTR arg) {
18842         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
18843         *ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_clone(arg);
18844         return tag_ptr(ret_conv, true);
18845 }
18846 int64_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_clone_ptr(int64_t arg) {
18847         LDKCResult_ChannelMonitorUpdateStatusNoneZ* arg_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(arg);
18848         int64_t ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_clone_ptr(arg_conv);
18849         return ret_conv;
18850 }
18851
18852 int64_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_clone(int64_t orig) {
18853         LDKCResult_ChannelMonitorUpdateStatusNoneZ* orig_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(orig);
18854         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
18855         *ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_clone(orig_conv);
18856         return tag_ptr(ret_conv, true);
18857 }
18858
18859 void  CS_LDK_CVec_MonitorEventZ_free(int64_tArray _res) {
18860         LDKCVec_MonitorEventZ _res_constr;
18861         _res_constr.datalen = _res->arr_len;
18862         if (_res_constr.datalen > 0)
18863                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18864         else
18865                 _res_constr.data = NULL;
18866         int64_t* _res_vals = _res->elems;
18867         for (size_t o = 0; o < _res_constr.datalen; o++) {
18868                 int64_t _res_conv_14 = _res_vals[o];
18869                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
18870                 CHECK_ACCESS(_res_conv_14_ptr);
18871                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
18872                 FREE(untag_ptr(_res_conv_14));
18873                 _res_constr.data[o] = _res_conv_14_conv;
18874         }
18875         FREE(_res);
18876         CVec_MonitorEventZ_free(_res_constr);
18877 }
18878
18879 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
18880         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18881         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
18882         return tag_ptr(ret_conv, true);
18883 }
18884 int64_t  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(int64_t arg) {
18885         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
18886         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
18887         return ret_conv;
18888 }
18889
18890 int64_t  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(int64_t orig) {
18891         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
18892         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18893         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
18894         return tag_ptr(ret_conv, true);
18895 }
18896
18897 int64_t  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(int64_t a, int64_tArray b, int8_tArray c) {
18898         LDKOutPoint a_conv;
18899         a_conv.inner = untag_ptr(a);
18900         a_conv.is_owned = ptr_is_owned(a);
18901         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18902         a_conv = OutPoint_clone(&a_conv);
18903         LDKCVec_MonitorEventZ b_constr;
18904         b_constr.datalen = b->arr_len;
18905         if (b_constr.datalen > 0)
18906                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18907         else
18908                 b_constr.data = NULL;
18909         int64_t* b_vals = b->elems;
18910         for (size_t o = 0; o < b_constr.datalen; o++) {
18911                 int64_t b_conv_14 = b_vals[o];
18912                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
18913                 CHECK_ACCESS(b_conv_14_ptr);
18914                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
18915                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
18916                 b_constr.data[o] = b_conv_14_conv;
18917         }
18918         FREE(b);
18919         LDKPublicKey c_ref;
18920         CHECK(c->arr_len == 33);
18921         memcpy(c_ref.compressed_form, c->elems, 33); FREE(c);
18922         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18923         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
18924         return tag_ptr(ret_conv, true);
18925 }
18926
18927 void  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(int64_t _res) {
18928         if (!ptr_is_owned(_res)) return;
18929         void* _res_ptr = untag_ptr(_res);
18930         CHECK_ACCESS(_res_ptr);
18931         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
18932         FREE(untag_ptr(_res));
18933         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
18934 }
18935
18936 void  CS_LDK_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(int64_tArray _res) {
18937         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
18938         _res_constr.datalen = _res->arr_len;
18939         if (_res_constr.datalen > 0)
18940                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
18941         else
18942                 _res_constr.data = NULL;
18943         int64_t* _res_vals = _res->elems;
18944         for (size_t x = 0; x < _res_constr.datalen; x++) {
18945                 int64_t _res_conv_49 = _res_vals[x];
18946                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18947                 CHECK_ACCESS(_res_conv_49_ptr);
18948                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
18949                 FREE(untag_ptr(_res_conv_49));
18950                 _res_constr.data[x] = _res_conv_49_conv;
18951         }
18952         FREE(_res);
18953         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
18954 }
18955
18956 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_ok(int64_t o) {
18957         LDKInitFeatures o_conv;
18958         o_conv.inner = untag_ptr(o);
18959         o_conv.is_owned = ptr_is_owned(o);
18960         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18961         o_conv = InitFeatures_clone(&o_conv);
18962         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18963         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18964         return tag_ptr(ret_conv, true);
18965 }
18966
18967 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_err(int64_t e) {
18968         void* e_ptr = untag_ptr(e);
18969         CHECK_ACCESS(e_ptr);
18970         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18971         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18972         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18973         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18974         return tag_ptr(ret_conv, true);
18975 }
18976
18977 jboolean  CS_LDK_CResult_InitFeaturesDecodeErrorZ_is_ok(int64_t o) {
18978         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18979         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18980         return ret_conv;
18981 }
18982
18983 void  CS_LDK_CResult_InitFeaturesDecodeErrorZ_free(int64_t _res) {
18984         if (!ptr_is_owned(_res)) return;
18985         void* _res_ptr = untag_ptr(_res);
18986         CHECK_ACCESS(_res_ptr);
18987         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18988         FREE(untag_ptr(_res));
18989         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18990 }
18991
18992 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18993         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18994         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18995         return tag_ptr(ret_conv, true);
18996 }
18997 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
18998         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18999         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19000         return ret_conv;
19001 }
19002
19003 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_clone(int64_t orig) {
19004         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
19005         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
19006         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
19007         return tag_ptr(ret_conv, true);
19008 }
19009
19010 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_ok(int64_t o) {
19011         LDKChannelFeatures o_conv;
19012         o_conv.inner = untag_ptr(o);
19013         o_conv.is_owned = ptr_is_owned(o);
19014         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19015         o_conv = ChannelFeatures_clone(&o_conv);
19016         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19017         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
19018         return tag_ptr(ret_conv, true);
19019 }
19020
19021 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_err(int64_t e) {
19022         void* e_ptr = untag_ptr(e);
19023         CHECK_ACCESS(e_ptr);
19024         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19025         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19026         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19027         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
19028         return tag_ptr(ret_conv, true);
19029 }
19030
19031 jboolean  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_is_ok(int64_t o) {
19032         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
19033         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
19034         return ret_conv;
19035 }
19036
19037 void  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_free(int64_t _res) {
19038         if (!ptr_is_owned(_res)) return;
19039         void* _res_ptr = untag_ptr(_res);
19040         CHECK_ACCESS(_res_ptr);
19041         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
19042         FREE(untag_ptr(_res));
19043         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
19044 }
19045
19046 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19047         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19048         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
19049         return tag_ptr(ret_conv, true);
19050 }
19051 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19052         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
19053         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19054         return ret_conv;
19055 }
19056
19057 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_clone(int64_t orig) {
19058         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
19059         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19060         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
19061         return tag_ptr(ret_conv, true);
19062 }
19063
19064 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_ok(int64_t o) {
19065         LDKNodeFeatures o_conv;
19066         o_conv.inner = untag_ptr(o);
19067         o_conv.is_owned = ptr_is_owned(o);
19068         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19069         o_conv = NodeFeatures_clone(&o_conv);
19070         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19071         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
19072         return tag_ptr(ret_conv, true);
19073 }
19074
19075 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_err(int64_t e) {
19076         void* e_ptr = untag_ptr(e);
19077         CHECK_ACCESS(e_ptr);
19078         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19079         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19080         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19081         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
19082         return tag_ptr(ret_conv, true);
19083 }
19084
19085 jboolean  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_is_ok(int64_t o) {
19086         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
19087         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
19088         return ret_conv;
19089 }
19090
19091 void  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_free(int64_t _res) {
19092         if (!ptr_is_owned(_res)) return;
19093         void* _res_ptr = untag_ptr(_res);
19094         CHECK_ACCESS(_res_ptr);
19095         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
19096         FREE(untag_ptr(_res));
19097         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
19098 }
19099
19100 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19101         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19102         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
19103         return tag_ptr(ret_conv, true);
19104 }
19105 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19106         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
19107         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19108         return ret_conv;
19109 }
19110
19111 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_clone(int64_t orig) {
19112         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
19113         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19114         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
19115         return tag_ptr(ret_conv, true);
19116 }
19117
19118 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(int64_t o) {
19119         LDKBolt11InvoiceFeatures o_conv;
19120         o_conv.inner = untag_ptr(o);
19121         o_conv.is_owned = ptr_is_owned(o);
19122         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19123         o_conv = Bolt11InvoiceFeatures_clone(&o_conv);
19124         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
19125         *ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(o_conv);
19126         return tag_ptr(ret_conv, true);
19127 }
19128
19129 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(int64_t e) {
19130         void* e_ptr = untag_ptr(e);
19131         CHECK_ACCESS(e_ptr);
19132         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19133         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19134         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
19135         *ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(e_conv);
19136         return tag_ptr(ret_conv, true);
19137 }
19138
19139 jboolean  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(int64_t o) {
19140         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
19141         jboolean ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
19142         return ret_conv;
19143 }
19144
19145 void  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(int64_t _res) {
19146         if (!ptr_is_owned(_res)) return;
19147         void* _res_ptr = untag_ptr(_res);
19148         CHECK_ACCESS(_res_ptr);
19149         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
19150         FREE(untag_ptr(_res));
19151         CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(_res_conv);
19152 }
19153
19154 static inline uint64_t CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19155         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
19156         *ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(arg);
19157         return tag_ptr(ret_conv, true);
19158 }
19159 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19160         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
19161         int64_t ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19162         return ret_conv;
19163 }
19164
19165 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(int64_t orig) {
19166         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
19167         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
19168         *ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
19169         return tag_ptr(ret_conv, true);
19170 }
19171
19172 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(int64_t o) {
19173         LDKBolt12InvoiceFeatures o_conv;
19174         o_conv.inner = untag_ptr(o);
19175         o_conv.is_owned = ptr_is_owned(o);
19176         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19177         o_conv = Bolt12InvoiceFeatures_clone(&o_conv);
19178         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
19179         *ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(o_conv);
19180         return tag_ptr(ret_conv, true);
19181 }
19182
19183 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(int64_t e) {
19184         void* e_ptr = untag_ptr(e);
19185         CHECK_ACCESS(e_ptr);
19186         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19187         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19188         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
19189         *ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(e_conv);
19190         return tag_ptr(ret_conv, true);
19191 }
19192
19193 jboolean  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(int64_t o) {
19194         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
19195         jboolean ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
19196         return ret_conv;
19197 }
19198
19199 void  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(int64_t _res) {
19200         if (!ptr_is_owned(_res)) return;
19201         void* _res_ptr = untag_ptr(_res);
19202         CHECK_ACCESS(_res_ptr);
19203         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
19204         FREE(untag_ptr(_res));
19205         CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(_res_conv);
19206 }
19207
19208 static inline uint64_t CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19209         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
19210         *ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(arg);
19211         return tag_ptr(ret_conv, true);
19212 }
19213 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19214         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
19215         int64_t ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19216         return ret_conv;
19217 }
19218
19219 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(int64_t orig) {
19220         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
19221         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
19222         *ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
19223         return tag_ptr(ret_conv, true);
19224 }
19225
19226 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_ok(int64_t o) {
19227         LDKBlindedHopFeatures o_conv;
19228         o_conv.inner = untag_ptr(o);
19229         o_conv.is_owned = ptr_is_owned(o);
19230         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19231         o_conv = BlindedHopFeatures_clone(&o_conv);
19232         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19233         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_ok(o_conv);
19234         return tag_ptr(ret_conv, true);
19235 }
19236
19237 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_err(int64_t e) {
19238         void* e_ptr = untag_ptr(e);
19239         CHECK_ACCESS(e_ptr);
19240         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19241         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19242         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19243         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_err(e_conv);
19244         return tag_ptr(ret_conv, true);
19245 }
19246
19247 jboolean  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(int64_t o) {
19248         LDKCResult_BlindedHopFeaturesDecodeErrorZ* o_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(o);
19249         jboolean ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o_conv);
19250         return ret_conv;
19251 }
19252
19253 void  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_free(int64_t _res) {
19254         if (!ptr_is_owned(_res)) return;
19255         void* _res_ptr = untag_ptr(_res);
19256         CHECK_ACCESS(_res_ptr);
19257         LDKCResult_BlindedHopFeaturesDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopFeaturesDecodeErrorZ*)(_res_ptr);
19258         FREE(untag_ptr(_res));
19259         CResult_BlindedHopFeaturesDecodeErrorZ_free(_res_conv);
19260 }
19261
19262 static inline uint64_t CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19263         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19264         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(arg);
19265         return tag_ptr(ret_conv, true);
19266 }
19267 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19268         LDKCResult_BlindedHopFeaturesDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(arg);
19269         int64_t ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19270         return ret_conv;
19271 }
19272
19273 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_clone(int64_t orig) {
19274         LDKCResult_BlindedHopFeaturesDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(orig);
19275         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19276         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig_conv);
19277         return tag_ptr(ret_conv, true);
19278 }
19279
19280 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(int64_t o) {
19281         LDKChannelTypeFeatures o_conv;
19282         o_conv.inner = untag_ptr(o);
19283         o_conv.is_owned = ptr_is_owned(o);
19284         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19285         o_conv = ChannelTypeFeatures_clone(&o_conv);
19286         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19287         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
19288         return tag_ptr(ret_conv, true);
19289 }
19290
19291 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_err(int64_t e) {
19292         void* e_ptr = untag_ptr(e);
19293         CHECK_ACCESS(e_ptr);
19294         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19295         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19296         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19297         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
19298         return tag_ptr(ret_conv, true);
19299 }
19300
19301 jboolean  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(int64_t o) {
19302         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
19303         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
19304         return ret_conv;
19305 }
19306
19307 void  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_free(int64_t _res) {
19308         if (!ptr_is_owned(_res)) return;
19309         void* _res_ptr = untag_ptr(_res);
19310         CHECK_ACCESS(_res_ptr);
19311         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
19312         FREE(untag_ptr(_res));
19313         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
19314 }
19315
19316 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19317         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19318         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
19319         return tag_ptr(ret_conv, true);
19320 }
19321 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19322         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
19323         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19324         return ret_conv;
19325 }
19326
19327 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(int64_t orig) {
19328         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
19329         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19330         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
19331         return tag_ptr(ret_conv, true);
19332 }
19333
19334 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_ok(int64_t o) {
19335         LDKOffer o_conv;
19336         o_conv.inner = untag_ptr(o);
19337         o_conv.is_owned = ptr_is_owned(o);
19338         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19339         o_conv = Offer_clone(&o_conv);
19340         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
19341         *ret_conv = CResult_OfferBolt12ParseErrorZ_ok(o_conv);
19342         return tag_ptr(ret_conv, true);
19343 }
19344
19345 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_err(int64_t e) {
19346         LDKBolt12ParseError e_conv;
19347         e_conv.inner = untag_ptr(e);
19348         e_conv.is_owned = ptr_is_owned(e);
19349         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19350         e_conv = Bolt12ParseError_clone(&e_conv);
19351         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
19352         *ret_conv = CResult_OfferBolt12ParseErrorZ_err(e_conv);
19353         return tag_ptr(ret_conv, true);
19354 }
19355
19356 jboolean  CS_LDK_CResult_OfferBolt12ParseErrorZ_is_ok(int64_t o) {
19357         LDKCResult_OfferBolt12ParseErrorZ* o_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(o);
19358         jboolean ret_conv = CResult_OfferBolt12ParseErrorZ_is_ok(o_conv);
19359         return ret_conv;
19360 }
19361
19362 void  CS_LDK_CResult_OfferBolt12ParseErrorZ_free(int64_t _res) {
19363         if (!ptr_is_owned(_res)) return;
19364         void* _res_ptr = untag_ptr(_res);
19365         CHECK_ACCESS(_res_ptr);
19366         LDKCResult_OfferBolt12ParseErrorZ _res_conv = *(LDKCResult_OfferBolt12ParseErrorZ*)(_res_ptr);
19367         FREE(untag_ptr(_res));
19368         CResult_OfferBolt12ParseErrorZ_free(_res_conv);
19369 }
19370
19371 static inline uint64_t CResult_OfferBolt12ParseErrorZ_clone_ptr(LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR arg) {
19372         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
19373         *ret_conv = CResult_OfferBolt12ParseErrorZ_clone(arg);
19374         return tag_ptr(ret_conv, true);
19375 }
19376 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_clone_ptr(int64_t arg) {
19377         LDKCResult_OfferBolt12ParseErrorZ* arg_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(arg);
19378         int64_t ret_conv = CResult_OfferBolt12ParseErrorZ_clone_ptr(arg_conv);
19379         return ret_conv;
19380 }
19381
19382 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_clone(int64_t orig) {
19383         LDKCResult_OfferBolt12ParseErrorZ* orig_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(orig);
19384         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
19385         *ret_conv = CResult_OfferBolt12ParseErrorZ_clone(orig_conv);
19386         return tag_ptr(ret_conv, true);
19387 }
19388
19389 int64_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_ok(int8_tArray o) {
19390         LDKPublicKey o_ref;
19391         CHECK(o->arr_len == 33);
19392         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
19393         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
19394         *ret_conv = CResult_PublicKeySecp256k1ErrorZ_ok(o_ref);
19395         return tag_ptr(ret_conv, true);
19396 }
19397
19398 int64_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_err(int32_t e) {
19399         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_cs(e);
19400         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
19401         *ret_conv = CResult_PublicKeySecp256k1ErrorZ_err(e_conv);
19402         return tag_ptr(ret_conv, true);
19403 }
19404
19405 jboolean  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_is_ok(int64_t o) {
19406         LDKCResult_PublicKeySecp256k1ErrorZ* o_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(o);
19407         jboolean ret_conv = CResult_PublicKeySecp256k1ErrorZ_is_ok(o_conv);
19408         return ret_conv;
19409 }
19410
19411 void  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_free(int64_t _res) {
19412         if (!ptr_is_owned(_res)) return;
19413         void* _res_ptr = untag_ptr(_res);
19414         CHECK_ACCESS(_res_ptr);
19415         LDKCResult_PublicKeySecp256k1ErrorZ _res_conv = *(LDKCResult_PublicKeySecp256k1ErrorZ*)(_res_ptr);
19416         FREE(untag_ptr(_res));
19417         CResult_PublicKeySecp256k1ErrorZ_free(_res_conv);
19418 }
19419
19420 static inline uint64_t CResult_PublicKeySecp256k1ErrorZ_clone_ptr(LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR arg) {
19421         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
19422         *ret_conv = CResult_PublicKeySecp256k1ErrorZ_clone(arg);
19423         return tag_ptr(ret_conv, true);
19424 }
19425 int64_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_clone_ptr(int64_t arg) {
19426         LDKCResult_PublicKeySecp256k1ErrorZ* arg_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(arg);
19427         int64_t ret_conv = CResult_PublicKeySecp256k1ErrorZ_clone_ptr(arg_conv);
19428         return ret_conv;
19429 }
19430
19431 int64_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_clone(int64_t orig) {
19432         LDKCResult_PublicKeySecp256k1ErrorZ* orig_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(orig);
19433         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
19434         *ret_conv = CResult_PublicKeySecp256k1ErrorZ_clone(orig_conv);
19435         return tag_ptr(ret_conv, true);
19436 }
19437
19438 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_ok(int64_t o) {
19439         LDKNodeId o_conv;
19440         o_conv.inner = untag_ptr(o);
19441         o_conv.is_owned = ptr_is_owned(o);
19442         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19443         o_conv = NodeId_clone(&o_conv);
19444         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19445         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
19446         return tag_ptr(ret_conv, true);
19447 }
19448
19449 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_err(int64_t e) {
19450         void* e_ptr = untag_ptr(e);
19451         CHECK_ACCESS(e_ptr);
19452         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19453         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19454         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19455         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
19456         return tag_ptr(ret_conv, true);
19457 }
19458
19459 jboolean  CS_LDK_CResult_NodeIdDecodeErrorZ_is_ok(int64_t o) {
19460         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
19461         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
19462         return ret_conv;
19463 }
19464
19465 void  CS_LDK_CResult_NodeIdDecodeErrorZ_free(int64_t _res) {
19466         if (!ptr_is_owned(_res)) return;
19467         void* _res_ptr = untag_ptr(_res);
19468         CHECK_ACCESS(_res_ptr);
19469         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
19470         FREE(untag_ptr(_res));
19471         CResult_NodeIdDecodeErrorZ_free(_res_conv);
19472 }
19473
19474 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
19475         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19476         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
19477         return tag_ptr(ret_conv, true);
19478 }
19479 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_clone_ptr(int64_t arg) {
19480         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
19481         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
19482         return ret_conv;
19483 }
19484
19485 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_clone(int64_t orig) {
19486         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
19487         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19488         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
19489         return tag_ptr(ret_conv, true);
19490 }
19491
19492 int64_t  CS_LDK_COption_NetworkUpdateZ_some(int64_t o) {
19493         void* o_ptr = untag_ptr(o);
19494         CHECK_ACCESS(o_ptr);
19495         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
19496         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
19497         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19498         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
19499         int64_t ret_ref = tag_ptr(ret_copy, true);
19500         return ret_ref;
19501 }
19502
19503 int64_t  CS_LDK_COption_NetworkUpdateZ_none() {
19504         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19505         *ret_copy = COption_NetworkUpdateZ_none();
19506         int64_t ret_ref = tag_ptr(ret_copy, true);
19507         return ret_ref;
19508 }
19509
19510 void  CS_LDK_COption_NetworkUpdateZ_free(int64_t _res) {
19511         if (!ptr_is_owned(_res)) return;
19512         void* _res_ptr = untag_ptr(_res);
19513         CHECK_ACCESS(_res_ptr);
19514         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
19515         FREE(untag_ptr(_res));
19516         COption_NetworkUpdateZ_free(_res_conv);
19517 }
19518
19519 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
19520         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19521         *ret_copy = COption_NetworkUpdateZ_clone(arg);
19522         int64_t ret_ref = tag_ptr(ret_copy, true);
19523         return ret_ref;
19524 }
19525 int64_t  CS_LDK_COption_NetworkUpdateZ_clone_ptr(int64_t arg) {
19526         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
19527         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
19528         return ret_conv;
19529 }
19530
19531 int64_t  CS_LDK_COption_NetworkUpdateZ_clone(int64_t orig) {
19532         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
19533         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19534         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
19535         int64_t ret_ref = tag_ptr(ret_copy, true);
19536         return ret_ref;
19537 }
19538
19539 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(int64_t o) {
19540         void* o_ptr = untag_ptr(o);
19541         CHECK_ACCESS(o_ptr);
19542         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
19543         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
19544         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19545         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
19546         return tag_ptr(ret_conv, true);
19547 }
19548
19549 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_err(int64_t e) {
19550         void* e_ptr = untag_ptr(e);
19551         CHECK_ACCESS(e_ptr);
19552         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19553         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19554         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19555         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
19556         return tag_ptr(ret_conv, true);
19557 }
19558
19559 jboolean  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(int64_t o) {
19560         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
19561         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
19562         return ret_conv;
19563 }
19564
19565 void  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_free(int64_t _res) {
19566         if (!ptr_is_owned(_res)) return;
19567         void* _res_ptr = untag_ptr(_res);
19568         CHECK_ACCESS(_res_ptr);
19569         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
19570         FREE(untag_ptr(_res));
19571         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
19572 }
19573
19574 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
19575         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19576         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
19577         return tag_ptr(ret_conv, true);
19578 }
19579 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(int64_t arg) {
19580         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
19581         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
19582         return ret_conv;
19583 }
19584
19585 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(int64_t orig) {
19586         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
19587         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19588         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
19589         return tag_ptr(ret_conv, true);
19590 }
19591
19592 int64_t  CS_LDK_COption_UtxoLookupZ_some(int64_t o) {
19593         void* o_ptr = untag_ptr(o);
19594         CHECK_ACCESS(o_ptr);
19595         LDKUtxoLookup o_conv = *(LDKUtxoLookup*)(o_ptr);
19596         if (o_conv.free == LDKUtxoLookup_JCalls_free) {
19597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19598                 LDKUtxoLookup_JCalls_cloned(&o_conv);
19599         }
19600         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19601         *ret_copy = COption_UtxoLookupZ_some(o_conv);
19602         int64_t ret_ref = tag_ptr(ret_copy, true);
19603         return ret_ref;
19604 }
19605
19606 int64_t  CS_LDK_COption_UtxoLookupZ_none() {
19607         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19608         *ret_copy = COption_UtxoLookupZ_none();
19609         int64_t ret_ref = tag_ptr(ret_copy, true);
19610         return ret_ref;
19611 }
19612
19613 void  CS_LDK_COption_UtxoLookupZ_free(int64_t _res) {
19614         if (!ptr_is_owned(_res)) return;
19615         void* _res_ptr = untag_ptr(_res);
19616         CHECK_ACCESS(_res_ptr);
19617         LDKCOption_UtxoLookupZ _res_conv = *(LDKCOption_UtxoLookupZ*)(_res_ptr);
19618         FREE(untag_ptr(_res));
19619         COption_UtxoLookupZ_free(_res_conv);
19620 }
19621
19622 int64_t  CS_LDK_CResult_NoneLightningErrorZ_ok() {
19623         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19624         *ret_conv = CResult_NoneLightningErrorZ_ok();
19625         return tag_ptr(ret_conv, true);
19626 }
19627
19628 int64_t  CS_LDK_CResult_NoneLightningErrorZ_err(int64_t e) {
19629         LDKLightningError e_conv;
19630         e_conv.inner = untag_ptr(e);
19631         e_conv.is_owned = ptr_is_owned(e);
19632         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19633         e_conv = LightningError_clone(&e_conv);
19634         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19635         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
19636         return tag_ptr(ret_conv, true);
19637 }
19638
19639 jboolean  CS_LDK_CResult_NoneLightningErrorZ_is_ok(int64_t o) {
19640         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
19641         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
19642         return ret_conv;
19643 }
19644
19645 void  CS_LDK_CResult_NoneLightningErrorZ_free(int64_t _res) {
19646         if (!ptr_is_owned(_res)) return;
19647         void* _res_ptr = untag_ptr(_res);
19648         CHECK_ACCESS(_res_ptr);
19649         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
19650         FREE(untag_ptr(_res));
19651         CResult_NoneLightningErrorZ_free(_res_conv);
19652 }
19653
19654 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
19655         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19656         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
19657         return tag_ptr(ret_conv, true);
19658 }
19659 int64_t  CS_LDK_CResult_NoneLightningErrorZ_clone_ptr(int64_t arg) {
19660         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
19661         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
19662         return ret_conv;
19663 }
19664
19665 int64_t  CS_LDK_CResult_NoneLightningErrorZ_clone(int64_t orig) {
19666         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
19667         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19668         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
19669         return tag_ptr(ret_conv, true);
19670 }
19671
19672 int64_t  CS_LDK_CResult_boolLightningErrorZ_ok(jboolean o) {
19673         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19674         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19675         return tag_ptr(ret_conv, true);
19676 }
19677
19678 int64_t  CS_LDK_CResult_boolLightningErrorZ_err(int64_t e) {
19679         LDKLightningError e_conv;
19680         e_conv.inner = untag_ptr(e);
19681         e_conv.is_owned = ptr_is_owned(e);
19682         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19683         e_conv = LightningError_clone(&e_conv);
19684         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19685         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19686         return tag_ptr(ret_conv, true);
19687 }
19688
19689 jboolean  CS_LDK_CResult_boolLightningErrorZ_is_ok(int64_t o) {
19690         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
19691         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
19692         return ret_conv;
19693 }
19694
19695 void  CS_LDK_CResult_boolLightningErrorZ_free(int64_t _res) {
19696         if (!ptr_is_owned(_res)) return;
19697         void* _res_ptr = untag_ptr(_res);
19698         CHECK_ACCESS(_res_ptr);
19699         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19700         FREE(untag_ptr(_res));
19701         CResult_boolLightningErrorZ_free(_res_conv);
19702 }
19703
19704 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19705         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19706         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19707         return tag_ptr(ret_conv, true);
19708 }
19709 int64_t  CS_LDK_CResult_boolLightningErrorZ_clone_ptr(int64_t arg) {
19710         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
19711         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19712         return ret_conv;
19713 }
19714
19715 int64_t  CS_LDK_CResult_boolLightningErrorZ_clone(int64_t orig) {
19716         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
19717         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19718         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19719         return tag_ptr(ret_conv, true);
19720 }
19721
19722 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19723         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19724         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19725         return tag_ptr(ret_conv, true);
19726 }
19727 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(int64_t arg) {
19728         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
19729         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19730         return ret_conv;
19731 }
19732
19733 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(int64_t orig) {
19734         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
19735         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19736         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19737         return tag_ptr(ret_conv, true);
19738 }
19739
19740 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(int64_t a, int64_t b, int64_t c) {
19741         LDKChannelAnnouncement a_conv;
19742         a_conv.inner = untag_ptr(a);
19743         a_conv.is_owned = ptr_is_owned(a);
19744         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19745         a_conv = ChannelAnnouncement_clone(&a_conv);
19746         LDKChannelUpdate b_conv;
19747         b_conv.inner = untag_ptr(b);
19748         b_conv.is_owned = ptr_is_owned(b);
19749         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19750         b_conv = ChannelUpdate_clone(&b_conv);
19751         LDKChannelUpdate c_conv;
19752         c_conv.inner = untag_ptr(c);
19753         c_conv.is_owned = ptr_is_owned(c);
19754         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19755         c_conv = ChannelUpdate_clone(&c_conv);
19756         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19757         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19758         return tag_ptr(ret_conv, true);
19759 }
19760
19761 void  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(int64_t _res) {
19762         if (!ptr_is_owned(_res)) return;
19763         void* _res_ptr = untag_ptr(_res);
19764         CHECK_ACCESS(_res_ptr);
19765         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19766         FREE(untag_ptr(_res));
19767         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19768 }
19769
19770 int64_t  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(int64_t o) {
19771         void* o_ptr = untag_ptr(o);
19772         CHECK_ACCESS(o_ptr);
19773         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
19774         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
19775         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19776         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
19777         int64_t ret_ref = tag_ptr(ret_copy, true);
19778         return ret_ref;
19779 }
19780
19781 int64_t  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none() {
19782         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19783         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
19784         int64_t ret_ref = tag_ptr(ret_copy, true);
19785         return ret_ref;
19786 }
19787
19788 void  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(int64_t _res) {
19789         if (!ptr_is_owned(_res)) return;
19790         void* _res_ptr = untag_ptr(_res);
19791         CHECK_ACCESS(_res_ptr);
19792         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
19793         FREE(untag_ptr(_res));
19794         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
19795 }
19796
19797 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
19798         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19799         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
19800         int64_t ret_ref = tag_ptr(ret_copy, true);
19801         return ret_ref;
19802 }
19803 int64_t  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(int64_t arg) {
19804         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
19805         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
19806         return ret_conv;
19807 }
19808
19809 int64_t  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(int64_t orig) {
19810         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
19811         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19812         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
19813         int64_t ret_ref = tag_ptr(ret_copy, true);
19814         return ret_ref;
19815 }
19816
19817 void  CS_LDK_CVec_MessageSendEventZ_free(int64_tArray _res) {
19818         LDKCVec_MessageSendEventZ _res_constr;
19819         _res_constr.datalen = _res->arr_len;
19820         if (_res_constr.datalen > 0)
19821                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
19822         else
19823                 _res_constr.data = NULL;
19824         int64_t* _res_vals = _res->elems;
19825         for (size_t s = 0; s < _res_constr.datalen; s++) {
19826                 int64_t _res_conv_18 = _res_vals[s];
19827                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
19828                 CHECK_ACCESS(_res_conv_18_ptr);
19829                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
19830                 FREE(untag_ptr(_res_conv_18));
19831                 _res_constr.data[s] = _res_conv_18_conv;
19832         }
19833         FREE(_res);
19834         CVec_MessageSendEventZ_free(_res_constr);
19835 }
19836
19837 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_ok(int64_t o) {
19838         LDKChannelUpdateInfo o_conv;
19839         o_conv.inner = untag_ptr(o);
19840         o_conv.is_owned = ptr_is_owned(o);
19841         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19842         o_conv = ChannelUpdateInfo_clone(&o_conv);
19843         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19844         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
19845         return tag_ptr(ret_conv, true);
19846 }
19847
19848 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_err(int64_t e) {
19849         void* e_ptr = untag_ptr(e);
19850         CHECK_ACCESS(e_ptr);
19851         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19852         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19853         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19854         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
19855         return tag_ptr(ret_conv, true);
19856 }
19857
19858 jboolean  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(int64_t o) {
19859         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
19860         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
19861         return ret_conv;
19862 }
19863
19864 void  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_free(int64_t _res) {
19865         if (!ptr_is_owned(_res)) return;
19866         void* _res_ptr = untag_ptr(_res);
19867         CHECK_ACCESS(_res_ptr);
19868         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
19869         FREE(untag_ptr(_res));
19870         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
19871 }
19872
19873 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
19874         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19875         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
19876         return tag_ptr(ret_conv, true);
19877 }
19878 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(int64_t arg) {
19879         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
19880         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
19881         return ret_conv;
19882 }
19883
19884 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_clone(int64_t orig) {
19885         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
19886         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19887         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
19888         return tag_ptr(ret_conv, true);
19889 }
19890
19891 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_ok(int64_t o) {
19892         LDKChannelInfo o_conv;
19893         o_conv.inner = untag_ptr(o);
19894         o_conv.is_owned = ptr_is_owned(o);
19895         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19896         o_conv = ChannelInfo_clone(&o_conv);
19897         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19898         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
19899         return tag_ptr(ret_conv, true);
19900 }
19901
19902 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_err(int64_t e) {
19903         void* e_ptr = untag_ptr(e);
19904         CHECK_ACCESS(e_ptr);
19905         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19906         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19907         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19908         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
19909         return tag_ptr(ret_conv, true);
19910 }
19911
19912 jboolean  CS_LDK_CResult_ChannelInfoDecodeErrorZ_is_ok(int64_t o) {
19913         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
19914         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
19915         return ret_conv;
19916 }
19917
19918 void  CS_LDK_CResult_ChannelInfoDecodeErrorZ_free(int64_t _res) {
19919         if (!ptr_is_owned(_res)) return;
19920         void* _res_ptr = untag_ptr(_res);
19921         CHECK_ACCESS(_res_ptr);
19922         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
19923         FREE(untag_ptr(_res));
19924         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
19925 }
19926
19927 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
19928         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19929         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
19930         return tag_ptr(ret_conv, true);
19931 }
19932 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_clone_ptr(int64_t arg) {
19933         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
19934         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
19935         return ret_conv;
19936 }
19937
19938 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_clone(int64_t orig) {
19939         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
19940         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19941         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
19942         return tag_ptr(ret_conv, true);
19943 }
19944
19945 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_ok(int64_t o) {
19946         LDKRoutingFees o_conv;
19947         o_conv.inner = untag_ptr(o);
19948         o_conv.is_owned = ptr_is_owned(o);
19949         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19950         o_conv = RoutingFees_clone(&o_conv);
19951         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19952         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
19953         return tag_ptr(ret_conv, true);
19954 }
19955
19956 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_err(int64_t e) {
19957         void* e_ptr = untag_ptr(e);
19958         CHECK_ACCESS(e_ptr);
19959         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19960         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19961         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19962         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
19963         return tag_ptr(ret_conv, true);
19964 }
19965
19966 jboolean  CS_LDK_CResult_RoutingFeesDecodeErrorZ_is_ok(int64_t o) {
19967         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
19968         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
19969         return ret_conv;
19970 }
19971
19972 void  CS_LDK_CResult_RoutingFeesDecodeErrorZ_free(int64_t _res) {
19973         if (!ptr_is_owned(_res)) return;
19974         void* _res_ptr = untag_ptr(_res);
19975         CHECK_ACCESS(_res_ptr);
19976         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
19977         FREE(untag_ptr(_res));
19978         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
19979 }
19980
19981 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
19982         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19983         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
19984         return tag_ptr(ret_conv, true);
19985 }
19986 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_clone_ptr(int64_t arg) {
19987         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
19988         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
19989         return ret_conv;
19990 }
19991
19992 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_clone(int64_t orig) {
19993         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
19994         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19995         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
19996         return tag_ptr(ret_conv, true);
19997 }
19998
19999 void  CS_LDK_CVec_SocketAddressZ_free(int64_tArray _res) {
20000         LDKCVec_SocketAddressZ _res_constr;
20001         _res_constr.datalen = _res->arr_len;
20002         if (_res_constr.datalen > 0)
20003                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSocketAddress), "LDKCVec_SocketAddressZ Elements");
20004         else
20005                 _res_constr.data = NULL;
20006         int64_t* _res_vals = _res->elems;
20007         for (size_t p = 0; p < _res_constr.datalen; p++) {
20008                 int64_t _res_conv_15 = _res_vals[p];
20009                 void* _res_conv_15_ptr = untag_ptr(_res_conv_15);
20010                 CHECK_ACCESS(_res_conv_15_ptr);
20011                 LDKSocketAddress _res_conv_15_conv = *(LDKSocketAddress*)(_res_conv_15_ptr);
20012                 FREE(untag_ptr(_res_conv_15));
20013                 _res_constr.data[p] = _res_conv_15_conv;
20014         }
20015         FREE(_res);
20016         CVec_SocketAddressZ_free(_res_constr);
20017 }
20018
20019 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(int64_t o) {
20020         LDKNodeAnnouncementInfo o_conv;
20021         o_conv.inner = untag_ptr(o);
20022         o_conv.is_owned = ptr_is_owned(o);
20023         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20024         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20025         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20026         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20027         return tag_ptr(ret_conv, true);
20028 }
20029
20030 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_err(int64_t e) {
20031         void* e_ptr = untag_ptr(e);
20032         CHECK_ACCESS(e_ptr);
20033         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20034         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20035         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20036         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20037         return tag_ptr(ret_conv, true);
20038 }
20039
20040 jboolean  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(int64_t o) {
20041         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
20042         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20043         return ret_conv;
20044 }
20045
20046 void  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_free(int64_t _res) {
20047         if (!ptr_is_owned(_res)) return;
20048         void* _res_ptr = untag_ptr(_res);
20049         CHECK_ACCESS(_res_ptr);
20050         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20051         FREE(untag_ptr(_res));
20052         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20053 }
20054
20055 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20056         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20057         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20058         return tag_ptr(ret_conv, true);
20059 }
20060 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(int64_t arg) {
20061         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
20062         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20063         return ret_conv;
20064 }
20065
20066 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(int64_t orig) {
20067         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
20068         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20069         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20070         return tag_ptr(ret_conv, true);
20071 }
20072
20073 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_ok(int64_t o) {
20074         LDKNodeAlias o_conv;
20075         o_conv.inner = untag_ptr(o);
20076         o_conv.is_owned = ptr_is_owned(o);
20077         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20078         o_conv = NodeAlias_clone(&o_conv);
20079         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20080         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
20081         return tag_ptr(ret_conv, true);
20082 }
20083
20084 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_err(int64_t e) {
20085         void* e_ptr = untag_ptr(e);
20086         CHECK_ACCESS(e_ptr);
20087         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20088         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20089         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20090         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
20091         return tag_ptr(ret_conv, true);
20092 }
20093
20094 jboolean  CS_LDK_CResult_NodeAliasDecodeErrorZ_is_ok(int64_t o) {
20095         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
20096         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
20097         return ret_conv;
20098 }
20099
20100 void  CS_LDK_CResult_NodeAliasDecodeErrorZ_free(int64_t _res) {
20101         if (!ptr_is_owned(_res)) return;
20102         void* _res_ptr = untag_ptr(_res);
20103         CHECK_ACCESS(_res_ptr);
20104         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
20105         FREE(untag_ptr(_res));
20106         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
20107 }
20108
20109 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
20110         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20111         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
20112         return tag_ptr(ret_conv, true);
20113 }
20114 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_clone_ptr(int64_t arg) {
20115         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
20116         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
20117         return ret_conv;
20118 }
20119
20120 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_clone(int64_t orig) {
20121         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
20122         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20123         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
20124         return tag_ptr(ret_conv, true);
20125 }
20126
20127 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_ok(int64_t o) {
20128         LDKNodeInfo o_conv;
20129         o_conv.inner = untag_ptr(o);
20130         o_conv.is_owned = ptr_is_owned(o);
20131         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20132         o_conv = NodeInfo_clone(&o_conv);
20133         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20134         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20135         return tag_ptr(ret_conv, true);
20136 }
20137
20138 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_err(int64_t e) {
20139         void* e_ptr = untag_ptr(e);
20140         CHECK_ACCESS(e_ptr);
20141         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20142         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20143         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20144         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20145         return tag_ptr(ret_conv, true);
20146 }
20147
20148 jboolean  CS_LDK_CResult_NodeInfoDecodeErrorZ_is_ok(int64_t o) {
20149         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
20150         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20151         return ret_conv;
20152 }
20153
20154 void  CS_LDK_CResult_NodeInfoDecodeErrorZ_free(int64_t _res) {
20155         if (!ptr_is_owned(_res)) return;
20156         void* _res_ptr = untag_ptr(_res);
20157         CHECK_ACCESS(_res_ptr);
20158         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20159         FREE(untag_ptr(_res));
20160         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20161 }
20162
20163 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20164         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20165         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20166         return tag_ptr(ret_conv, true);
20167 }
20168 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_clone_ptr(int64_t arg) {
20169         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
20170         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20171         return ret_conv;
20172 }
20173
20174 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_clone(int64_t orig) {
20175         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
20176         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20177         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20178         return tag_ptr(ret_conv, true);
20179 }
20180
20181 int64_t  CS_LDK_CResult_NetworkGraphDecodeErrorZ_ok(int64_t o) {
20182         LDKNetworkGraph o_conv;
20183         o_conv.inner = untag_ptr(o);
20184         o_conv.is_owned = ptr_is_owned(o);
20185         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20186         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
20187         
20188         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20189         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20190         return tag_ptr(ret_conv, true);
20191 }
20192
20193 int64_t  CS_LDK_CResult_NetworkGraphDecodeErrorZ_err(int64_t e) {
20194         void* e_ptr = untag_ptr(e);
20195         CHECK_ACCESS(e_ptr);
20196         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20197         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20198         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20199         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20200         return tag_ptr(ret_conv, true);
20201 }
20202
20203 jboolean  CS_LDK_CResult_NetworkGraphDecodeErrorZ_is_ok(int64_t o) {
20204         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
20205         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20206         return ret_conv;
20207 }
20208
20209 void  CS_LDK_CResult_NetworkGraphDecodeErrorZ_free(int64_t _res) {
20210         if (!ptr_is_owned(_res)) return;
20211         void* _res_ptr = untag_ptr(_res);
20212         CHECK_ACCESS(_res_ptr);
20213         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20214         FREE(untag_ptr(_res));
20215         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20216 }
20217
20218 int64_t  CS_LDK_COption_CVec_SocketAddressZZ_some(int64_tArray o) {
20219         LDKCVec_SocketAddressZ o_constr;
20220         o_constr.datalen = o->arr_len;
20221         if (o_constr.datalen > 0)
20222                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSocketAddress), "LDKCVec_SocketAddressZ Elements");
20223         else
20224                 o_constr.data = NULL;
20225         int64_t* o_vals = o->elems;
20226         for (size_t p = 0; p < o_constr.datalen; p++) {
20227                 int64_t o_conv_15 = o_vals[p];
20228                 void* o_conv_15_ptr = untag_ptr(o_conv_15);
20229                 CHECK_ACCESS(o_conv_15_ptr);
20230                 LDKSocketAddress o_conv_15_conv = *(LDKSocketAddress*)(o_conv_15_ptr);
20231                 o_conv_15_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(o_conv_15));
20232                 o_constr.data[p] = o_conv_15_conv;
20233         }
20234         FREE(o);
20235         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
20236         *ret_copy = COption_CVec_SocketAddressZZ_some(o_constr);
20237         int64_t ret_ref = tag_ptr(ret_copy, true);
20238         return ret_ref;
20239 }
20240
20241 int64_t  CS_LDK_COption_CVec_SocketAddressZZ_none() {
20242         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
20243         *ret_copy = COption_CVec_SocketAddressZZ_none();
20244         int64_t ret_ref = tag_ptr(ret_copy, true);
20245         return ret_ref;
20246 }
20247
20248 void  CS_LDK_COption_CVec_SocketAddressZZ_free(int64_t _res) {
20249         if (!ptr_is_owned(_res)) return;
20250         void* _res_ptr = untag_ptr(_res);
20251         CHECK_ACCESS(_res_ptr);
20252         LDKCOption_CVec_SocketAddressZZ _res_conv = *(LDKCOption_CVec_SocketAddressZZ*)(_res_ptr);
20253         FREE(untag_ptr(_res));
20254         COption_CVec_SocketAddressZZ_free(_res_conv);
20255 }
20256
20257 static inline uint64_t COption_CVec_SocketAddressZZ_clone_ptr(LDKCOption_CVec_SocketAddressZZ *NONNULL_PTR arg) {
20258         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
20259         *ret_copy = COption_CVec_SocketAddressZZ_clone(arg);
20260         int64_t ret_ref = tag_ptr(ret_copy, true);
20261         return ret_ref;
20262 }
20263 int64_t  CS_LDK_COption_CVec_SocketAddressZZ_clone_ptr(int64_t arg) {
20264         LDKCOption_CVec_SocketAddressZZ* arg_conv = (LDKCOption_CVec_SocketAddressZZ*)untag_ptr(arg);
20265         int64_t ret_conv = COption_CVec_SocketAddressZZ_clone_ptr(arg_conv);
20266         return ret_conv;
20267 }
20268
20269 int64_t  CS_LDK_COption_CVec_SocketAddressZZ_clone(int64_t orig) {
20270         LDKCOption_CVec_SocketAddressZZ* orig_conv = (LDKCOption_CVec_SocketAddressZZ*)untag_ptr(orig);
20271         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
20272         *ret_copy = COption_CVec_SocketAddressZZ_clone(orig_conv);
20273         int64_t ret_ref = tag_ptr(ret_copy, true);
20274         return ret_ref;
20275 }
20276
20277 void  CS_LDK_CVec_HTLCOutputInCommitmentZ_free(int64_tArray _res) {
20278         LDKCVec_HTLCOutputInCommitmentZ _res_constr;
20279         _res_constr.datalen = _res->arr_len;
20280         if (_res_constr.datalen > 0)
20281                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
20282         else
20283                 _res_constr.data = NULL;
20284         int64_t* _res_vals = _res->elems;
20285         for (size_t y = 0; y < _res_constr.datalen; y++) {
20286                 int64_t _res_conv_24 = _res_vals[y];
20287                 LDKHTLCOutputInCommitment _res_conv_24_conv;
20288                 _res_conv_24_conv.inner = untag_ptr(_res_conv_24);
20289                 _res_conv_24_conv.is_owned = ptr_is_owned(_res_conv_24);
20290                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_24_conv);
20291                 _res_constr.data[y] = _res_conv_24_conv;
20292         }
20293         FREE(_res);
20294         CVec_HTLCOutputInCommitmentZ_free(_res_constr);
20295 }
20296
20297 void  CS_LDK_CVec_HTLCDescriptorZ_free(int64_tArray _res) {
20298         LDKCVec_HTLCDescriptorZ _res_constr;
20299         _res_constr.datalen = _res->arr_len;
20300         if (_res_constr.datalen > 0)
20301                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKHTLCDescriptor), "LDKCVec_HTLCDescriptorZ Elements");
20302         else
20303                 _res_constr.data = NULL;
20304         int64_t* _res_vals = _res->elems;
20305         for (size_t q = 0; q < _res_constr.datalen; q++) {
20306                 int64_t _res_conv_16 = _res_vals[q];
20307                 LDKHTLCDescriptor _res_conv_16_conv;
20308                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
20309                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
20310                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20311                 _res_constr.data[q] = _res_conv_16_conv;
20312         }
20313         FREE(_res);
20314         CVec_HTLCDescriptorZ_free(_res_constr);
20315 }
20316
20317 void  CS_LDK_CVec_UtxoZ_free(int64_tArray _res) {
20318         LDKCVec_UtxoZ _res_constr;
20319         _res_constr.datalen = _res->arr_len;
20320         if (_res_constr.datalen > 0)
20321                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUtxo), "LDKCVec_UtxoZ Elements");
20322         else
20323                 _res_constr.data = NULL;
20324         int64_t* _res_vals = _res->elems;
20325         for (size_t g = 0; g < _res_constr.datalen; g++) {
20326                 int64_t _res_conv_6 = _res_vals[g];
20327                 LDKUtxo _res_conv_6_conv;
20328                 _res_conv_6_conv.inner = untag_ptr(_res_conv_6);
20329                 _res_conv_6_conv.is_owned = ptr_is_owned(_res_conv_6);
20330                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_6_conv);
20331                 _res_constr.data[g] = _res_conv_6_conv;
20332         }
20333         FREE(_res);
20334         CVec_UtxoZ_free(_res_constr);
20335 }
20336
20337 int64_t  CS_LDK_COption_TxOutZ_some(int64_t o) {
20338         void* o_ptr = untag_ptr(o);
20339         CHECK_ACCESS(o_ptr);
20340         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
20341         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
20342         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
20343         *ret_copy = COption_TxOutZ_some(o_conv);
20344         int64_t ret_ref = tag_ptr(ret_copy, true);
20345         return ret_ref;
20346 }
20347
20348 int64_t  CS_LDK_COption_TxOutZ_none() {
20349         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
20350         *ret_copy = COption_TxOutZ_none();
20351         int64_t ret_ref = tag_ptr(ret_copy, true);
20352         return ret_ref;
20353 }
20354
20355 void  CS_LDK_COption_TxOutZ_free(int64_t _res) {
20356         if (!ptr_is_owned(_res)) return;
20357         void* _res_ptr = untag_ptr(_res);
20358         CHECK_ACCESS(_res_ptr);
20359         LDKCOption_TxOutZ _res_conv = *(LDKCOption_TxOutZ*)(_res_ptr);
20360         FREE(untag_ptr(_res));
20361         COption_TxOutZ_free(_res_conv);
20362 }
20363
20364 static inline uint64_t COption_TxOutZ_clone_ptr(LDKCOption_TxOutZ *NONNULL_PTR arg) {
20365         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
20366         *ret_copy = COption_TxOutZ_clone(arg);
20367         int64_t ret_ref = tag_ptr(ret_copy, true);
20368         return ret_ref;
20369 }
20370 int64_t  CS_LDK_COption_TxOutZ_clone_ptr(int64_t arg) {
20371         LDKCOption_TxOutZ* arg_conv = (LDKCOption_TxOutZ*)untag_ptr(arg);
20372         int64_t ret_conv = COption_TxOutZ_clone_ptr(arg_conv);
20373         return ret_conv;
20374 }
20375
20376 int64_t  CS_LDK_COption_TxOutZ_clone(int64_t orig) {
20377         LDKCOption_TxOutZ* orig_conv = (LDKCOption_TxOutZ*)untag_ptr(orig);
20378         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
20379         *ret_copy = COption_TxOutZ_clone(orig_conv);
20380         int64_t ret_ref = tag_ptr(ret_copy, true);
20381         return ret_ref;
20382 }
20383
20384 void  CS_LDK_CVec_InputZ_free(int64_tArray _res) {
20385         LDKCVec_InputZ _res_constr;
20386         _res_constr.datalen = _res->arr_len;
20387         if (_res_constr.datalen > 0)
20388                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKInput), "LDKCVec_InputZ Elements");
20389         else
20390                 _res_constr.data = NULL;
20391         int64_t* _res_vals = _res->elems;
20392         for (size_t h = 0; h < _res_constr.datalen; h++) {
20393                 int64_t _res_conv_7 = _res_vals[h];
20394                 LDKInput _res_conv_7_conv;
20395                 _res_conv_7_conv.inner = untag_ptr(_res_conv_7);
20396                 _res_conv_7_conv.is_owned = ptr_is_owned(_res_conv_7);
20397                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_7_conv);
20398                 _res_constr.data[h] = _res_conv_7_conv;
20399         }
20400         FREE(_res);
20401         CVec_InputZ_free(_res_constr);
20402 }
20403
20404 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_ok(int64_t o) {
20405         LDKCoinSelection o_conv;
20406         o_conv.inner = untag_ptr(o);
20407         o_conv.is_owned = ptr_is_owned(o);
20408         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20409         o_conv = CoinSelection_clone(&o_conv);
20410         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
20411         *ret_conv = CResult_CoinSelectionNoneZ_ok(o_conv);
20412         return tag_ptr(ret_conv, true);
20413 }
20414
20415 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_err() {
20416         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
20417         *ret_conv = CResult_CoinSelectionNoneZ_err();
20418         return tag_ptr(ret_conv, true);
20419 }
20420
20421 jboolean  CS_LDK_CResult_CoinSelectionNoneZ_is_ok(int64_t o) {
20422         LDKCResult_CoinSelectionNoneZ* o_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(o);
20423         jboolean ret_conv = CResult_CoinSelectionNoneZ_is_ok(o_conv);
20424         return ret_conv;
20425 }
20426
20427 void  CS_LDK_CResult_CoinSelectionNoneZ_free(int64_t _res) {
20428         if (!ptr_is_owned(_res)) return;
20429         void* _res_ptr = untag_ptr(_res);
20430         CHECK_ACCESS(_res_ptr);
20431         LDKCResult_CoinSelectionNoneZ _res_conv = *(LDKCResult_CoinSelectionNoneZ*)(_res_ptr);
20432         FREE(untag_ptr(_res));
20433         CResult_CoinSelectionNoneZ_free(_res_conv);
20434 }
20435
20436 static inline uint64_t CResult_CoinSelectionNoneZ_clone_ptr(LDKCResult_CoinSelectionNoneZ *NONNULL_PTR arg) {
20437         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
20438         *ret_conv = CResult_CoinSelectionNoneZ_clone(arg);
20439         return tag_ptr(ret_conv, true);
20440 }
20441 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_clone_ptr(int64_t arg) {
20442         LDKCResult_CoinSelectionNoneZ* arg_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(arg);
20443         int64_t ret_conv = CResult_CoinSelectionNoneZ_clone_ptr(arg_conv);
20444         return ret_conv;
20445 }
20446
20447 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_clone(int64_t orig) {
20448         LDKCResult_CoinSelectionNoneZ* orig_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(orig);
20449         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
20450         *ret_conv = CResult_CoinSelectionNoneZ_clone(orig_conv);
20451         return tag_ptr(ret_conv, true);
20452 }
20453
20454 int64_t  CS_LDK_CResult_CVec_UtxoZNoneZ_ok(int64_tArray o) {
20455         LDKCVec_UtxoZ o_constr;
20456         o_constr.datalen = o->arr_len;
20457         if (o_constr.datalen > 0)
20458                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKUtxo), "LDKCVec_UtxoZ Elements");
20459         else
20460                 o_constr.data = NULL;
20461         int64_t* o_vals = o->elems;
20462         for (size_t g = 0; g < o_constr.datalen; g++) {
20463                 int64_t o_conv_6 = o_vals[g];
20464                 LDKUtxo o_conv_6_conv;
20465                 o_conv_6_conv.inner = untag_ptr(o_conv_6);
20466                 o_conv_6_conv.is_owned = ptr_is_owned(o_conv_6);
20467                 CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv_6_conv);
20468                 o_conv_6_conv = Utxo_clone(&o_conv_6_conv);
20469                 o_constr.data[g] = o_conv_6_conv;
20470         }
20471         FREE(o);
20472         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
20473         *ret_conv = CResult_CVec_UtxoZNoneZ_ok(o_constr);
20474         return tag_ptr(ret_conv, true);
20475 }
20476
20477 int64_t  CS_LDK_CResult_CVec_UtxoZNoneZ_err() {
20478         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
20479         *ret_conv = CResult_CVec_UtxoZNoneZ_err();
20480         return tag_ptr(ret_conv, true);
20481 }
20482
20483 jboolean  CS_LDK_CResult_CVec_UtxoZNoneZ_is_ok(int64_t o) {
20484         LDKCResult_CVec_UtxoZNoneZ* o_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(o);
20485         jboolean ret_conv = CResult_CVec_UtxoZNoneZ_is_ok(o_conv);
20486         return ret_conv;
20487 }
20488
20489 void  CS_LDK_CResult_CVec_UtxoZNoneZ_free(int64_t _res) {
20490         if (!ptr_is_owned(_res)) return;
20491         void* _res_ptr = untag_ptr(_res);
20492         CHECK_ACCESS(_res_ptr);
20493         LDKCResult_CVec_UtxoZNoneZ _res_conv = *(LDKCResult_CVec_UtxoZNoneZ*)(_res_ptr);
20494         FREE(untag_ptr(_res));
20495         CResult_CVec_UtxoZNoneZ_free(_res_conv);
20496 }
20497
20498 static inline uint64_t CResult_CVec_UtxoZNoneZ_clone_ptr(LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR arg) {
20499         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
20500         *ret_conv = CResult_CVec_UtxoZNoneZ_clone(arg);
20501         return tag_ptr(ret_conv, true);
20502 }
20503 int64_t  CS_LDK_CResult_CVec_UtxoZNoneZ_clone_ptr(int64_t arg) {
20504         LDKCResult_CVec_UtxoZNoneZ* arg_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(arg);
20505         int64_t ret_conv = CResult_CVec_UtxoZNoneZ_clone_ptr(arg_conv);
20506         return ret_conv;
20507 }
20508
20509 int64_t  CS_LDK_CResult_CVec_UtxoZNoneZ_clone(int64_t orig) {
20510         LDKCResult_CVec_UtxoZNoneZ* orig_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(orig);
20511         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
20512         *ret_conv = CResult_CVec_UtxoZNoneZ_clone(orig_conv);
20513         return tag_ptr(ret_conv, true);
20514 }
20515
20516 static inline uint64_t C2Tuple_u64u16Z_clone_ptr(LDKC2Tuple_u64u16Z *NONNULL_PTR arg) {
20517         LDKC2Tuple_u64u16Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u16Z), "LDKC2Tuple_u64u16Z");
20518         *ret_conv = C2Tuple_u64u16Z_clone(arg);
20519         return tag_ptr(ret_conv, true);
20520 }
20521 int64_t  CS_LDK_C2Tuple_u64u16Z_clone_ptr(int64_t arg) {
20522         LDKC2Tuple_u64u16Z* arg_conv = (LDKC2Tuple_u64u16Z*)untag_ptr(arg);
20523         int64_t ret_conv = C2Tuple_u64u16Z_clone_ptr(arg_conv);
20524         return ret_conv;
20525 }
20526
20527 int64_t  CS_LDK_C2Tuple_u64u16Z_clone(int64_t orig) {
20528         LDKC2Tuple_u64u16Z* orig_conv = (LDKC2Tuple_u64u16Z*)untag_ptr(orig);
20529         LDKC2Tuple_u64u16Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u16Z), "LDKC2Tuple_u64u16Z");
20530         *ret_conv = C2Tuple_u64u16Z_clone(orig_conv);
20531         return tag_ptr(ret_conv, true);
20532 }
20533
20534 int64_t  CS_LDK_C2Tuple_u64u16Z_new(int64_t a, int16_t b) {
20535         LDKC2Tuple_u64u16Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u16Z), "LDKC2Tuple_u64u16Z");
20536         *ret_conv = C2Tuple_u64u16Z_new(a, b);
20537         return tag_ptr(ret_conv, true);
20538 }
20539
20540 void  CS_LDK_C2Tuple_u64u16Z_free(int64_t _res) {
20541         if (!ptr_is_owned(_res)) return;
20542         void* _res_ptr = untag_ptr(_res);
20543         CHECK_ACCESS(_res_ptr);
20544         LDKC2Tuple_u64u16Z _res_conv = *(LDKC2Tuple_u64u16Z*)(_res_ptr);
20545         FREE(untag_ptr(_res));
20546         C2Tuple_u64u16Z_free(_res_conv);
20547 }
20548
20549 int64_t  CS_LDK_COption_C2Tuple_u64u16ZZ_some(int64_t o) {
20550         void* o_ptr = untag_ptr(o);
20551         CHECK_ACCESS(o_ptr);
20552         LDKC2Tuple_u64u16Z o_conv = *(LDKC2Tuple_u64u16Z*)(o_ptr);
20553         o_conv = C2Tuple_u64u16Z_clone((LDKC2Tuple_u64u16Z*)untag_ptr(o));
20554         LDKCOption_C2Tuple_u64u16ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u16ZZ), "LDKCOption_C2Tuple_u64u16ZZ");
20555         *ret_copy = COption_C2Tuple_u64u16ZZ_some(o_conv);
20556         int64_t ret_ref = tag_ptr(ret_copy, true);
20557         return ret_ref;
20558 }
20559
20560 int64_t  CS_LDK_COption_C2Tuple_u64u16ZZ_none() {
20561         LDKCOption_C2Tuple_u64u16ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u16ZZ), "LDKCOption_C2Tuple_u64u16ZZ");
20562         *ret_copy = COption_C2Tuple_u64u16ZZ_none();
20563         int64_t ret_ref = tag_ptr(ret_copy, true);
20564         return ret_ref;
20565 }
20566
20567 void  CS_LDK_COption_C2Tuple_u64u16ZZ_free(int64_t _res) {
20568         if (!ptr_is_owned(_res)) return;
20569         void* _res_ptr = untag_ptr(_res);
20570         CHECK_ACCESS(_res_ptr);
20571         LDKCOption_C2Tuple_u64u16ZZ _res_conv = *(LDKCOption_C2Tuple_u64u16ZZ*)(_res_ptr);
20572         FREE(untag_ptr(_res));
20573         COption_C2Tuple_u64u16ZZ_free(_res_conv);
20574 }
20575
20576 static inline uint64_t COption_C2Tuple_u64u16ZZ_clone_ptr(LDKCOption_C2Tuple_u64u16ZZ *NONNULL_PTR arg) {
20577         LDKCOption_C2Tuple_u64u16ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u16ZZ), "LDKCOption_C2Tuple_u64u16ZZ");
20578         *ret_copy = COption_C2Tuple_u64u16ZZ_clone(arg);
20579         int64_t ret_ref = tag_ptr(ret_copy, true);
20580         return ret_ref;
20581 }
20582 int64_t  CS_LDK_COption_C2Tuple_u64u16ZZ_clone_ptr(int64_t arg) {
20583         LDKCOption_C2Tuple_u64u16ZZ* arg_conv = (LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(arg);
20584         int64_t ret_conv = COption_C2Tuple_u64u16ZZ_clone_ptr(arg_conv);
20585         return ret_conv;
20586 }
20587
20588 int64_t  CS_LDK_COption_C2Tuple_u64u16ZZ_clone(int64_t orig) {
20589         LDKCOption_C2Tuple_u64u16ZZ* orig_conv = (LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(orig);
20590         LDKCOption_C2Tuple_u64u16ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u16ZZ), "LDKCOption_C2Tuple_u64u16ZZ");
20591         *ret_copy = COption_C2Tuple_u64u16ZZ_clone(orig_conv);
20592         int64_t ret_ref = tag_ptr(ret_copy, true);
20593         return ret_ref;
20594 }
20595
20596 int64_t  CS_LDK_COption_ChannelShutdownStateZ_some(int32_t o) {
20597         LDKChannelShutdownState o_conv = LDKChannelShutdownState_from_cs(o);
20598         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
20599         *ret_copy = COption_ChannelShutdownStateZ_some(o_conv);
20600         int64_t ret_ref = tag_ptr(ret_copy, true);
20601         return ret_ref;
20602 }
20603
20604 int64_t  CS_LDK_COption_ChannelShutdownStateZ_none() {
20605         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
20606         *ret_copy = COption_ChannelShutdownStateZ_none();
20607         int64_t ret_ref = tag_ptr(ret_copy, true);
20608         return ret_ref;
20609 }
20610
20611 void  CS_LDK_COption_ChannelShutdownStateZ_free(int64_t _res) {
20612         if (!ptr_is_owned(_res)) return;
20613         void* _res_ptr = untag_ptr(_res);
20614         CHECK_ACCESS(_res_ptr);
20615         LDKCOption_ChannelShutdownStateZ _res_conv = *(LDKCOption_ChannelShutdownStateZ*)(_res_ptr);
20616         FREE(untag_ptr(_res));
20617         COption_ChannelShutdownStateZ_free(_res_conv);
20618 }
20619
20620 static inline uint64_t COption_ChannelShutdownStateZ_clone_ptr(LDKCOption_ChannelShutdownStateZ *NONNULL_PTR arg) {
20621         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
20622         *ret_copy = COption_ChannelShutdownStateZ_clone(arg);
20623         int64_t ret_ref = tag_ptr(ret_copy, true);
20624         return ret_ref;
20625 }
20626 int64_t  CS_LDK_COption_ChannelShutdownStateZ_clone_ptr(int64_t arg) {
20627         LDKCOption_ChannelShutdownStateZ* arg_conv = (LDKCOption_ChannelShutdownStateZ*)untag_ptr(arg);
20628         int64_t ret_conv = COption_ChannelShutdownStateZ_clone_ptr(arg_conv);
20629         return ret_conv;
20630 }
20631
20632 int64_t  CS_LDK_COption_ChannelShutdownStateZ_clone(int64_t orig) {
20633         LDKCOption_ChannelShutdownStateZ* orig_conv = (LDKCOption_ChannelShutdownStateZ*)untag_ptr(orig);
20634         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
20635         *ret_copy = COption_ChannelShutdownStateZ_clone(orig_conv);
20636         int64_t ret_ref = tag_ptr(ret_copy, true);
20637         return ret_ref;
20638 }
20639
20640 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_ok(int8_tArray o) {
20641         LDKThirtyTwoBytes o_ref;
20642         CHECK(o->arr_len == 32);
20643         memcpy(o_ref.data, o->elems, 32); FREE(o);
20644         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
20645         *ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_ok(o_ref);
20646         return tag_ptr(ret_conv, true);
20647 }
20648
20649 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_err(int64_t e) {
20650         void* e_ptr = untag_ptr(e);
20651         CHECK_ACCESS(e_ptr);
20652         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20653         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20654         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
20655         *ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_err(e_conv);
20656         return tag_ptr(ret_conv, true);
20657 }
20658
20659 jboolean  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_is_ok(int64_t o) {
20660         LDKCResult_ThirtyTwoBytesAPIErrorZ* o_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(o);
20661         jboolean ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_is_ok(o_conv);
20662         return ret_conv;
20663 }
20664
20665 void  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_free(int64_t _res) {
20666         if (!ptr_is_owned(_res)) return;
20667         void* _res_ptr = untag_ptr(_res);
20668         CHECK_ACCESS(_res_ptr);
20669         LDKCResult_ThirtyTwoBytesAPIErrorZ _res_conv = *(LDKCResult_ThirtyTwoBytesAPIErrorZ*)(_res_ptr);
20670         FREE(untag_ptr(_res));
20671         CResult_ThirtyTwoBytesAPIErrorZ_free(_res_conv);
20672 }
20673
20674 static inline uint64_t CResult_ThirtyTwoBytesAPIErrorZ_clone_ptr(LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR arg) {
20675         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
20676         *ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_clone(arg);
20677         return tag_ptr(ret_conv, true);
20678 }
20679 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_clone_ptr(int64_t arg) {
20680         LDKCResult_ThirtyTwoBytesAPIErrorZ* arg_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(arg);
20681         int64_t ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_clone_ptr(arg_conv);
20682         return ret_conv;
20683 }
20684
20685 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_clone(int64_t orig) {
20686         LDKCResult_ThirtyTwoBytesAPIErrorZ* orig_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(orig);
20687         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
20688         *ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_clone(orig_conv);
20689         return tag_ptr(ret_conv, true);
20690 }
20691
20692 void  CS_LDK_CVec_RecentPaymentDetailsZ_free(int64_tArray _res) {
20693         LDKCVec_RecentPaymentDetailsZ _res_constr;
20694         _res_constr.datalen = _res->arr_len;
20695         if (_res_constr.datalen > 0)
20696                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRecentPaymentDetails), "LDKCVec_RecentPaymentDetailsZ Elements");
20697         else
20698                 _res_constr.data = NULL;
20699         int64_t* _res_vals = _res->elems;
20700         for (size_t w = 0; w < _res_constr.datalen; w++) {
20701                 int64_t _res_conv_22 = _res_vals[w];
20702                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
20703                 CHECK_ACCESS(_res_conv_22_ptr);
20704                 LDKRecentPaymentDetails _res_conv_22_conv = *(LDKRecentPaymentDetails*)(_res_conv_22_ptr);
20705                 FREE(untag_ptr(_res_conv_22));
20706                 _res_constr.data[w] = _res_conv_22_conv;
20707         }
20708         FREE(_res);
20709         CVec_RecentPaymentDetailsZ_free(_res_constr);
20710 }
20711
20712 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_ok() {
20713         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20714         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
20715         return tag_ptr(ret_conv, true);
20716 }
20717
20718 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_err(int64_t e) {
20719         void* e_ptr = untag_ptr(e);
20720         CHECK_ACCESS(e_ptr);
20721         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20722         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20723         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20724         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
20725         return tag_ptr(ret_conv, true);
20726 }
20727
20728 jboolean  CS_LDK_CResult_NonePaymentSendFailureZ_is_ok(int64_t o) {
20729         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
20730         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
20731         return ret_conv;
20732 }
20733
20734 void  CS_LDK_CResult_NonePaymentSendFailureZ_free(int64_t _res) {
20735         if (!ptr_is_owned(_res)) return;
20736         void* _res_ptr = untag_ptr(_res);
20737         CHECK_ACCESS(_res_ptr);
20738         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
20739         FREE(untag_ptr(_res));
20740         CResult_NonePaymentSendFailureZ_free(_res_conv);
20741 }
20742
20743 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
20744         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20745         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
20746         return tag_ptr(ret_conv, true);
20747 }
20748 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_clone_ptr(int64_t arg) {
20749         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
20750         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
20751         return ret_conv;
20752 }
20753
20754 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_clone(int64_t orig) {
20755         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
20756         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20757         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
20758         return tag_ptr(ret_conv, true);
20759 }
20760
20761 int64_t  CS_LDK_CResult_NoneRetryableSendFailureZ_ok() {
20762         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20763         *ret_conv = CResult_NoneRetryableSendFailureZ_ok();
20764         return tag_ptr(ret_conv, true);
20765 }
20766
20767 int64_t  CS_LDK_CResult_NoneRetryableSendFailureZ_err(int32_t e) {
20768         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_cs(e);
20769         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20770         *ret_conv = CResult_NoneRetryableSendFailureZ_err(e_conv);
20771         return tag_ptr(ret_conv, true);
20772 }
20773
20774 jboolean  CS_LDK_CResult_NoneRetryableSendFailureZ_is_ok(int64_t o) {
20775         LDKCResult_NoneRetryableSendFailureZ* o_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(o);
20776         jboolean ret_conv = CResult_NoneRetryableSendFailureZ_is_ok(o_conv);
20777         return ret_conv;
20778 }
20779
20780 void  CS_LDK_CResult_NoneRetryableSendFailureZ_free(int64_t _res) {
20781         if (!ptr_is_owned(_res)) return;
20782         void* _res_ptr = untag_ptr(_res);
20783         CHECK_ACCESS(_res_ptr);
20784         LDKCResult_NoneRetryableSendFailureZ _res_conv = *(LDKCResult_NoneRetryableSendFailureZ*)(_res_ptr);
20785         FREE(untag_ptr(_res));
20786         CResult_NoneRetryableSendFailureZ_free(_res_conv);
20787 }
20788
20789 static inline uint64_t CResult_NoneRetryableSendFailureZ_clone_ptr(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR arg) {
20790         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20791         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(arg);
20792         return tag_ptr(ret_conv, true);
20793 }
20794 int64_t  CS_LDK_CResult_NoneRetryableSendFailureZ_clone_ptr(int64_t arg) {
20795         LDKCResult_NoneRetryableSendFailureZ* arg_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(arg);
20796         int64_t ret_conv = CResult_NoneRetryableSendFailureZ_clone_ptr(arg_conv);
20797         return ret_conv;
20798 }
20799
20800 int64_t  CS_LDK_CResult_NoneRetryableSendFailureZ_clone(int64_t orig) {
20801         LDKCResult_NoneRetryableSendFailureZ* orig_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(orig);
20802         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20803         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(orig_conv);
20804         return tag_ptr(ret_conv, true);
20805 }
20806
20807 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_ok(int8_tArray o) {
20808         LDKThirtyTwoBytes o_ref;
20809         CHECK(o->arr_len == 32);
20810         memcpy(o_ref.data, o->elems, 32); FREE(o);
20811         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
20812         *ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_ok(o_ref);
20813         return tag_ptr(ret_conv, true);
20814 }
20815
20816 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_err(int64_t e) {
20817         void* e_ptr = untag_ptr(e);
20818         CHECK_ACCESS(e_ptr);
20819         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20820         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20821         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
20822         *ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_err(e_conv);
20823         return tag_ptr(ret_conv, true);
20824 }
20825
20826 jboolean  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_is_ok(int64_t o) {
20827         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* o_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(o);
20828         jboolean ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_is_ok(o_conv);
20829         return ret_conv;
20830 }
20831
20832 void  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_free(int64_t _res) {
20833         if (!ptr_is_owned(_res)) return;
20834         void* _res_ptr = untag_ptr(_res);
20835         CHECK_ACCESS(_res_ptr);
20836         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ _res_conv = *(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)(_res_ptr);
20837         FREE(untag_ptr(_res));
20838         CResult_ThirtyTwoBytesPaymentSendFailureZ_free(_res_conv);
20839 }
20840
20841 static inline uint64_t CResult_ThirtyTwoBytesPaymentSendFailureZ_clone_ptr(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ *NONNULL_PTR arg) {
20842         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
20843         *ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_clone(arg);
20844         return tag_ptr(ret_conv, true);
20845 }
20846 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_clone_ptr(int64_t arg) {
20847         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* arg_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(arg);
20848         int64_t ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_clone_ptr(arg_conv);
20849         return ret_conv;
20850 }
20851
20852 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_clone(int64_t orig) {
20853         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* orig_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(orig);
20854         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
20855         *ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_clone(orig_conv);
20856         return tag_ptr(ret_conv, true);
20857 }
20858
20859 int64_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_ok(int8_tArray o) {
20860         LDKThirtyTwoBytes o_ref;
20861         CHECK(o->arr_len == 32);
20862         memcpy(o_ref.data, o->elems, 32); FREE(o);
20863         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
20864         *ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_ok(o_ref);
20865         return tag_ptr(ret_conv, true);
20866 }
20867
20868 int64_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_err(int32_t e) {
20869         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_cs(e);
20870         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
20871         *ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_err(e_conv);
20872         return tag_ptr(ret_conv, true);
20873 }
20874
20875 jboolean  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_is_ok(int64_t o) {
20876         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* o_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(o);
20877         jboolean ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_is_ok(o_conv);
20878         return ret_conv;
20879 }
20880
20881 void  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_free(int64_t _res) {
20882         if (!ptr_is_owned(_res)) return;
20883         void* _res_ptr = untag_ptr(_res);
20884         CHECK_ACCESS(_res_ptr);
20885         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ _res_conv = *(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)(_res_ptr);
20886         FREE(untag_ptr(_res));
20887         CResult_ThirtyTwoBytesRetryableSendFailureZ_free(_res_conv);
20888 }
20889
20890 static inline uint64_t CResult_ThirtyTwoBytesRetryableSendFailureZ_clone_ptr(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ *NONNULL_PTR arg) {
20891         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
20892         *ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_clone(arg);
20893         return tag_ptr(ret_conv, true);
20894 }
20895 int64_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_clone_ptr(int64_t arg) {
20896         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* arg_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(arg);
20897         int64_t ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_clone_ptr(arg_conv);
20898         return ret_conv;
20899 }
20900
20901 int64_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_clone(int64_t orig) {
20902         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* orig_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(orig);
20903         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
20904         *ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_clone(orig_conv);
20905         return tag_ptr(ret_conv, true);
20906 }
20907
20908 static inline uint64_t C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ *NONNULL_PTR arg) {
20909         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
20910         *ret_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(arg);
20911         return tag_ptr(ret_conv, true);
20912 }
20913 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone_ptr(int64_t arg) {
20914         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(arg);
20915         int64_t ret_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone_ptr(arg_conv);
20916         return ret_conv;
20917 }
20918
20919 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(int64_t orig) {
20920         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(orig);
20921         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
20922         *ret_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(orig_conv);
20923         return tag_ptr(ret_conv, true);
20924 }
20925
20926 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_new(int8_tArray a, int8_tArray b) {
20927         LDKThirtyTwoBytes a_ref;
20928         CHECK(a->arr_len == 32);
20929         memcpy(a_ref.data, a->elems, 32); FREE(a);
20930         LDKThirtyTwoBytes b_ref;
20931         CHECK(b->arr_len == 32);
20932         memcpy(b_ref.data, b->elems, 32); FREE(b);
20933         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
20934         *ret_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_new(a_ref, b_ref);
20935         return tag_ptr(ret_conv, true);
20936 }
20937
20938 void  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_free(int64_t _res) {
20939         if (!ptr_is_owned(_res)) return;
20940         void* _res_ptr = untag_ptr(_res);
20941         CHECK_ACCESS(_res_ptr);
20942         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(_res_ptr);
20943         FREE(untag_ptr(_res));
20944         C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_free(_res_conv);
20945 }
20946
20947 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_ok(int64_t o) {
20948         void* o_ptr = untag_ptr(o);
20949         CHECK_ACCESS(o_ptr);
20950         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(o_ptr);
20951         o_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone((LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(o));
20952         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
20953         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_ok(o_conv);
20954         return tag_ptr(ret_conv, true);
20955 }
20956
20957 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_err(int64_t e) {
20958         void* e_ptr = untag_ptr(e);
20959         CHECK_ACCESS(e_ptr);
20960         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20961         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20962         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
20963         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_err(e_conv);
20964         return tag_ptr(ret_conv, true);
20965 }
20966
20967 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_is_ok(int64_t o) {
20968         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(o);
20969         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_is_ok(o_conv);
20970         return ret_conv;
20971 }
20972
20973 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_free(int64_t _res) {
20974         if (!ptr_is_owned(_res)) return;
20975         void* _res_ptr = untag_ptr(_res);
20976         CHECK_ACCESS(_res_ptr);
20977         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)(_res_ptr);
20978         FREE(untag_ptr(_res));
20979         CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_free(_res_conv);
20980 }
20981
20982 static inline uint64_t CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ *NONNULL_PTR arg) {
20983         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
20984         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone(arg);
20985         return tag_ptr(ret_conv, true);
20986 }
20987 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone_ptr(int64_t arg) {
20988         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(arg);
20989         int64_t ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone_ptr(arg_conv);
20990         return ret_conv;
20991 }
20992
20993 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone(int64_t orig) {
20994         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(orig);
20995         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
20996         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone(orig_conv);
20997         return tag_ptr(ret_conv, true);
20998 }
20999
21000 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_free(int64_tArray _res) {
21001         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ _res_constr;
21002         _res_constr.datalen = _res->arr_len;
21003         if (_res_constr.datalen > 0)
21004                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ Elements");
21005         else
21006                 _res_constr.data = NULL;
21007         int64_t* _res_vals = _res->elems;
21008         for (size_t o = 0; o < _res_constr.datalen; o++) {
21009                 int64_t _res_conv_40 = _res_vals[o];
21010                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
21011                 CHECK_ACCESS(_res_conv_40_ptr);
21012                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ _res_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(_res_conv_40_ptr);
21013                 FREE(untag_ptr(_res_conv_40));
21014                 _res_constr.data[o] = _res_conv_40_conv;
21015         }
21016         FREE(_res);
21017         CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_free(_res_constr);
21018 }
21019
21020 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_ok(int64_tArray o) {
21021         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ o_constr;
21022         o_constr.datalen = o->arr_len;
21023         if (o_constr.datalen > 0)
21024                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ Elements");
21025         else
21026                 o_constr.data = NULL;
21027         int64_t* o_vals = o->elems;
21028         for (size_t o = 0; o < o_constr.datalen; o++) {
21029                 int64_t o_conv_40 = o_vals[o];
21030                 void* o_conv_40_ptr = untag_ptr(o_conv_40);
21031                 CHECK_ACCESS(o_conv_40_ptr);
21032                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(o_conv_40_ptr);
21033                 o_conv_40_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone((LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(o_conv_40));
21034                 o_constr.data[o] = o_conv_40_conv;
21035         }
21036         FREE(o);
21037         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
21038         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_ok(o_constr);
21039         return tag_ptr(ret_conv, true);
21040 }
21041
21042 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_err(int64_t e) {
21043         void* e_ptr = untag_ptr(e);
21044         CHECK_ACCESS(e_ptr);
21045         LDKProbeSendFailure e_conv = *(LDKProbeSendFailure*)(e_ptr);
21046         e_conv = ProbeSendFailure_clone((LDKProbeSendFailure*)untag_ptr(e));
21047         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
21048         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_err(e_conv);
21049         return tag_ptr(ret_conv, true);
21050 }
21051
21052 jboolean  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_is_ok(int64_t o) {
21053         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* o_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(o);
21054         jboolean ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_is_ok(o_conv);
21055         return ret_conv;
21056 }
21057
21058 void  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_free(int64_t _res) {
21059         if (!ptr_is_owned(_res)) return;
21060         void* _res_ptr = untag_ptr(_res);
21061         CHECK_ACCESS(_res_ptr);
21062         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ _res_conv = *(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)(_res_ptr);
21063         FREE(untag_ptr(_res));
21064         CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_free(_res_conv);
21065 }
21066
21067 static inline uint64_t CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone_ptr(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ *NONNULL_PTR arg) {
21068         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
21069         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone(arg);
21070         return tag_ptr(ret_conv, true);
21071 }
21072 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone_ptr(int64_t arg) {
21073         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* arg_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(arg);
21074         int64_t ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone_ptr(arg_conv);
21075         return ret_conv;
21076 }
21077
21078 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone(int64_t orig) {
21079         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* orig_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(orig);
21080         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
21081         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone(orig_conv);
21082         return tag_ptr(ret_conv, true);
21083 }
21084
21085 static inline uint64_t C2Tuple_ThirtyTwoBytesPublicKeyZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ *NONNULL_PTR arg) {
21086         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKC2Tuple_ThirtyTwoBytesPublicKeyZ");
21087         *ret_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(arg);
21088         return tag_ptr(ret_conv, true);
21089 }
21090 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_clone_ptr(int64_t arg) {
21091         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(arg);
21092         int64_t ret_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone_ptr(arg_conv);
21093         return ret_conv;
21094 }
21095
21096 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(int64_t orig) {
21097         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(orig);
21098         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKC2Tuple_ThirtyTwoBytesPublicKeyZ");
21099         *ret_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(orig_conv);
21100         return tag_ptr(ret_conv, true);
21101 }
21102
21103 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_new(int8_tArray a, int8_tArray b) {
21104         LDKThirtyTwoBytes a_ref;
21105         CHECK(a->arr_len == 32);
21106         memcpy(a_ref.data, a->elems, 32); FREE(a);
21107         LDKPublicKey b_ref;
21108         CHECK(b->arr_len == 33);
21109         memcpy(b_ref.compressed_form, b->elems, 33); FREE(b);
21110         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKC2Tuple_ThirtyTwoBytesPublicKeyZ");
21111         *ret_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_new(a_ref, b_ref);
21112         return tag_ptr(ret_conv, true);
21113 }
21114
21115 void  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_free(int64_t _res) {
21116         if (!ptr_is_owned(_res)) return;
21117         void* _res_ptr = untag_ptr(_res);
21118         CHECK_ACCESS(_res_ptr);
21119         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)(_res_ptr);
21120         FREE(untag_ptr(_res));
21121         C2Tuple_ThirtyTwoBytesPublicKeyZ_free(_res_conv);
21122 }
21123
21124 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_free(int64_tArray _res) {
21125         LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ _res_constr;
21126         _res_constr.datalen = _res->arr_len;
21127         if (_res_constr.datalen > 0)
21128                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ Elements");
21129         else
21130                 _res_constr.data = NULL;
21131         int64_t* _res_vals = _res->elems;
21132         for (size_t j = 0; j < _res_constr.datalen; j++) {
21133                 int64_t _res_conv_35 = _res_vals[j];
21134                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
21135                 CHECK_ACCESS(_res_conv_35_ptr);
21136                 LDKC2Tuple_ThirtyTwoBytesPublicKeyZ _res_conv_35_conv = *(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)(_res_conv_35_ptr);
21137                 FREE(untag_ptr(_res_conv_35));
21138                 _res_constr.data[j] = _res_conv_35_conv;
21139         }
21140         FREE(_res);
21141         CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_free(_res_constr);
21142 }
21143
21144 int64_t  CS_LDK_COption_StrZ_some(jstring o) {
21145         LDKStr o_conv = str_ref_to_owned_c(o);
21146         LDKCOption_StrZ *ret_copy = MALLOC(sizeof(LDKCOption_StrZ), "LDKCOption_StrZ");
21147         *ret_copy = COption_StrZ_some(o_conv);
21148         int64_t ret_ref = tag_ptr(ret_copy, true);
21149         return ret_ref;
21150 }
21151
21152 int64_t  CS_LDK_COption_StrZ_none() {
21153         LDKCOption_StrZ *ret_copy = MALLOC(sizeof(LDKCOption_StrZ), "LDKCOption_StrZ");
21154         *ret_copy = COption_StrZ_none();
21155         int64_t ret_ref = tag_ptr(ret_copy, true);
21156         return ret_ref;
21157 }
21158
21159 void  CS_LDK_COption_StrZ_free(int64_t _res) {
21160         if (!ptr_is_owned(_res)) return;
21161         void* _res_ptr = untag_ptr(_res);
21162         CHECK_ACCESS(_res_ptr);
21163         LDKCOption_StrZ _res_conv = *(LDKCOption_StrZ*)(_res_ptr);
21164         FREE(untag_ptr(_res));
21165         COption_StrZ_free(_res_conv);
21166 }
21167
21168 static inline uint64_t COption_StrZ_clone_ptr(LDKCOption_StrZ *NONNULL_PTR arg) {
21169         LDKCOption_StrZ *ret_copy = MALLOC(sizeof(LDKCOption_StrZ), "LDKCOption_StrZ");
21170         *ret_copy = COption_StrZ_clone(arg);
21171         int64_t ret_ref = tag_ptr(ret_copy, true);
21172         return ret_ref;
21173 }
21174 int64_t  CS_LDK_COption_StrZ_clone_ptr(int64_t arg) {
21175         LDKCOption_StrZ* arg_conv = (LDKCOption_StrZ*)untag_ptr(arg);
21176         int64_t ret_conv = COption_StrZ_clone_ptr(arg_conv);
21177         return ret_conv;
21178 }
21179
21180 int64_t  CS_LDK_COption_StrZ_clone(int64_t orig) {
21181         LDKCOption_StrZ* orig_conv = (LDKCOption_StrZ*)untag_ptr(orig);
21182         LDKCOption_StrZ *ret_copy = MALLOC(sizeof(LDKCOption_StrZ), "LDKCOption_StrZ");
21183         *ret_copy = COption_StrZ_clone(orig_conv);
21184         int64_t ret_ref = tag_ptr(ret_copy, true);
21185         return ret_ref;
21186 }
21187
21188 int64_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_ok() {
21189         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
21190         *ret_conv = CResult_NoneBolt12SemanticErrorZ_ok();
21191         return tag_ptr(ret_conv, true);
21192 }
21193
21194 int64_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_err(int32_t e) {
21195         LDKBolt12SemanticError e_conv = LDKBolt12SemanticError_from_cs(e);
21196         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
21197         *ret_conv = CResult_NoneBolt12SemanticErrorZ_err(e_conv);
21198         return tag_ptr(ret_conv, true);
21199 }
21200
21201 jboolean  CS_LDK_CResult_NoneBolt12SemanticErrorZ_is_ok(int64_t o) {
21202         LDKCResult_NoneBolt12SemanticErrorZ* o_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(o);
21203         jboolean ret_conv = CResult_NoneBolt12SemanticErrorZ_is_ok(o_conv);
21204         return ret_conv;
21205 }
21206
21207 void  CS_LDK_CResult_NoneBolt12SemanticErrorZ_free(int64_t _res) {
21208         if (!ptr_is_owned(_res)) return;
21209         void* _res_ptr = untag_ptr(_res);
21210         CHECK_ACCESS(_res_ptr);
21211         LDKCResult_NoneBolt12SemanticErrorZ _res_conv = *(LDKCResult_NoneBolt12SemanticErrorZ*)(_res_ptr);
21212         FREE(untag_ptr(_res));
21213         CResult_NoneBolt12SemanticErrorZ_free(_res_conv);
21214 }
21215
21216 static inline uint64_t CResult_NoneBolt12SemanticErrorZ_clone_ptr(LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR arg) {
21217         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
21218         *ret_conv = CResult_NoneBolt12SemanticErrorZ_clone(arg);
21219         return tag_ptr(ret_conv, true);
21220 }
21221 int64_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_clone_ptr(int64_t arg) {
21222         LDKCResult_NoneBolt12SemanticErrorZ* arg_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(arg);
21223         int64_t ret_conv = CResult_NoneBolt12SemanticErrorZ_clone_ptr(arg_conv);
21224         return ret_conv;
21225 }
21226
21227 int64_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_clone(int64_t orig) {
21228         LDKCResult_NoneBolt12SemanticErrorZ* orig_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(orig);
21229         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
21230         *ret_conv = CResult_NoneBolt12SemanticErrorZ_clone(orig_conv);
21231         return tag_ptr(ret_conv, true);
21232 }
21233
21234 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_ok(int64_t o) {
21235         void* o_ptr = untag_ptr(o);
21236         CHECK_ACCESS(o_ptr);
21237         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(o_ptr);
21238         o_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone((LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(o));
21239         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
21240         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_ok(o_conv);
21241         return tag_ptr(ret_conv, true);
21242 }
21243
21244 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_err() {
21245         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
21246         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_err();
21247         return tag_ptr(ret_conv, true);
21248 }
21249
21250 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_is_ok(int64_t o) {
21251         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(o);
21252         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_is_ok(o_conv);
21253         return ret_conv;
21254 }
21255
21256 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_free(int64_t _res) {
21257         if (!ptr_is_owned(_res)) return;
21258         void* _res_ptr = untag_ptr(_res);
21259         CHECK_ACCESS(_res_ptr);
21260         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)(_res_ptr);
21261         FREE(untag_ptr(_res));
21262         CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_free(_res_conv);
21263 }
21264
21265 static inline uint64_t CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone_ptr(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR arg) {
21266         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
21267         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(arg);
21268         return tag_ptr(ret_conv, true);
21269 }
21270 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone_ptr(int64_t arg) {
21271         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* arg_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(arg);
21272         int64_t ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone_ptr(arg_conv);
21273         return ret_conv;
21274 }
21275
21276 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(int64_t orig) {
21277         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* orig_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(orig);
21278         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
21279         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(orig_conv);
21280         return tag_ptr(ret_conv, true);
21281 }
21282
21283 int64_t  CS_LDK_COption_OffersMessageZ_some(int64_t o) {
21284         void* o_ptr = untag_ptr(o);
21285         CHECK_ACCESS(o_ptr);
21286         LDKOffersMessage o_conv = *(LDKOffersMessage*)(o_ptr);
21287         o_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(o));
21288         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
21289         *ret_copy = COption_OffersMessageZ_some(o_conv);
21290         int64_t ret_ref = tag_ptr(ret_copy, true);
21291         return ret_ref;
21292 }
21293
21294 int64_t  CS_LDK_COption_OffersMessageZ_none() {
21295         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
21296         *ret_copy = COption_OffersMessageZ_none();
21297         int64_t ret_ref = tag_ptr(ret_copy, true);
21298         return ret_ref;
21299 }
21300
21301 void  CS_LDK_COption_OffersMessageZ_free(int64_t _res) {
21302         if (!ptr_is_owned(_res)) return;
21303         void* _res_ptr = untag_ptr(_res);
21304         CHECK_ACCESS(_res_ptr);
21305         LDKCOption_OffersMessageZ _res_conv = *(LDKCOption_OffersMessageZ*)(_res_ptr);
21306         FREE(untag_ptr(_res));
21307         COption_OffersMessageZ_free(_res_conv);
21308 }
21309
21310 static inline uint64_t COption_OffersMessageZ_clone_ptr(LDKCOption_OffersMessageZ *NONNULL_PTR arg) {
21311         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
21312         *ret_copy = COption_OffersMessageZ_clone(arg);
21313         int64_t ret_ref = tag_ptr(ret_copy, true);
21314         return ret_ref;
21315 }
21316 int64_t  CS_LDK_COption_OffersMessageZ_clone_ptr(int64_t arg) {
21317         LDKCOption_OffersMessageZ* arg_conv = (LDKCOption_OffersMessageZ*)untag_ptr(arg);
21318         int64_t ret_conv = COption_OffersMessageZ_clone_ptr(arg_conv);
21319         return ret_conv;
21320 }
21321
21322 int64_t  CS_LDK_COption_OffersMessageZ_clone(int64_t orig) {
21323         LDKCOption_OffersMessageZ* orig_conv = (LDKCOption_OffersMessageZ*)untag_ptr(orig);
21324         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
21325         *ret_copy = COption_OffersMessageZ_clone(orig_conv);
21326         int64_t ret_ref = tag_ptr(ret_copy, true);
21327         return ret_ref;
21328 }
21329
21330 static inline uint64_t C3Tuple_OffersMessageDestinationBlindedPathZ_clone_ptr(LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR arg) {
21331         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKC3Tuple_OffersMessageDestinationBlindedPathZ");
21332         *ret_conv = C3Tuple_OffersMessageDestinationBlindedPathZ_clone(arg);
21333         return tag_ptr(ret_conv, true);
21334 }
21335 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_clone_ptr(int64_t arg) {
21336         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* arg_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(arg);
21337         int64_t ret_conv = C3Tuple_OffersMessageDestinationBlindedPathZ_clone_ptr(arg_conv);
21338         return ret_conv;
21339 }
21340
21341 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_clone(int64_t orig) {
21342         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* orig_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(orig);
21343         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKC3Tuple_OffersMessageDestinationBlindedPathZ");
21344         *ret_conv = C3Tuple_OffersMessageDestinationBlindedPathZ_clone(orig_conv);
21345         return tag_ptr(ret_conv, true);
21346 }
21347
21348 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_new(int64_t a, int64_t b, int64_t c) {
21349         void* a_ptr = untag_ptr(a);
21350         CHECK_ACCESS(a_ptr);
21351         LDKOffersMessage a_conv = *(LDKOffersMessage*)(a_ptr);
21352         a_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(a));
21353         void* b_ptr = untag_ptr(b);
21354         CHECK_ACCESS(b_ptr);
21355         LDKDestination b_conv = *(LDKDestination*)(b_ptr);
21356         b_conv = Destination_clone((LDKDestination*)untag_ptr(b));
21357         LDKBlindedPath c_conv;
21358         c_conv.inner = untag_ptr(c);
21359         c_conv.is_owned = ptr_is_owned(c);
21360         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
21361         c_conv = BlindedPath_clone(&c_conv);
21362         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKC3Tuple_OffersMessageDestinationBlindedPathZ");
21363         *ret_conv = C3Tuple_OffersMessageDestinationBlindedPathZ_new(a_conv, b_conv, c_conv);
21364         return tag_ptr(ret_conv, true);
21365 }
21366
21367 void  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_free(int64_t _res) {
21368         if (!ptr_is_owned(_res)) return;
21369         void* _res_ptr = untag_ptr(_res);
21370         CHECK_ACCESS(_res_ptr);
21371         LDKC3Tuple_OffersMessageDestinationBlindedPathZ _res_conv = *(LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)(_res_ptr);
21372         FREE(untag_ptr(_res));
21373         C3Tuple_OffersMessageDestinationBlindedPathZ_free(_res_conv);
21374 }
21375
21376 void  CS_LDK_CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(int64_tArray _res) {
21377         LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ _res_constr;
21378         _res_constr.datalen = _res->arr_len;
21379         if (_res_constr.datalen > 0)
21380                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ Elements");
21381         else
21382                 _res_constr.data = NULL;
21383         int64_t* _res_vals = _res->elems;
21384         for (size_t x = 0; x < _res_constr.datalen; x++) {
21385                 int64_t _res_conv_49 = _res_vals[x];
21386                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
21387                 CHECK_ACCESS(_res_conv_49_ptr);
21388                 LDKC3Tuple_OffersMessageDestinationBlindedPathZ _res_conv_49_conv = *(LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)(_res_conv_49_ptr);
21389                 FREE(untag_ptr(_res_conv_49));
21390                 _res_constr.data[x] = _res_conv_49_conv;
21391         }
21392         FREE(_res);
21393         CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(_res_constr);
21394 }
21395
21396 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(int64_t o) {
21397         LDKCounterpartyForwardingInfo o_conv;
21398         o_conv.inner = untag_ptr(o);
21399         o_conv.is_owned = ptr_is_owned(o);
21400         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21401         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
21402         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21403         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
21404         return tag_ptr(ret_conv, true);
21405 }
21406
21407 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(int64_t e) {
21408         void* e_ptr = untag_ptr(e);
21409         CHECK_ACCESS(e_ptr);
21410         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21411         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21412         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21413         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
21414         return tag_ptr(ret_conv, true);
21415 }
21416
21417 jboolean  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(int64_t o) {
21418         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
21419         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
21420         return ret_conv;
21421 }
21422
21423 void  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(int64_t _res) {
21424         if (!ptr_is_owned(_res)) return;
21425         void* _res_ptr = untag_ptr(_res);
21426         CHECK_ACCESS(_res_ptr);
21427         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
21428         FREE(untag_ptr(_res));
21429         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
21430 }
21431
21432 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
21433         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21434         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
21435         return tag_ptr(ret_conv, true);
21436 }
21437 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(int64_t arg) {
21438         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
21439         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
21440         return ret_conv;
21441 }
21442
21443 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(int64_t orig) {
21444         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
21445         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21446         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
21447         return tag_ptr(ret_conv, true);
21448 }
21449
21450 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_ok(int64_t o) {
21451         LDKChannelCounterparty o_conv;
21452         o_conv.inner = untag_ptr(o);
21453         o_conv.is_owned = ptr_is_owned(o);
21454         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21455         o_conv = ChannelCounterparty_clone(&o_conv);
21456         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21457         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
21458         return tag_ptr(ret_conv, true);
21459 }
21460
21461 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_err(int64_t e) {
21462         void* e_ptr = untag_ptr(e);
21463         CHECK_ACCESS(e_ptr);
21464         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21465         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21466         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21467         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
21468         return tag_ptr(ret_conv, true);
21469 }
21470
21471 jboolean  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(int64_t o) {
21472         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
21473         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
21474         return ret_conv;
21475 }
21476
21477 void  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_free(int64_t _res) {
21478         if (!ptr_is_owned(_res)) return;
21479         void* _res_ptr = untag_ptr(_res);
21480         CHECK_ACCESS(_res_ptr);
21481         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
21482         FREE(untag_ptr(_res));
21483         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
21484 }
21485
21486 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
21487         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21488         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
21489         return tag_ptr(ret_conv, true);
21490 }
21491 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(int64_t arg) {
21492         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
21493         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
21494         return ret_conv;
21495 }
21496
21497 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_clone(int64_t orig) {
21498         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
21499         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21500         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
21501         return tag_ptr(ret_conv, true);
21502 }
21503
21504 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_ok(int64_t o) {
21505         LDKChannelDetails o_conv;
21506         o_conv.inner = untag_ptr(o);
21507         o_conv.is_owned = ptr_is_owned(o);
21508         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21509         o_conv = ChannelDetails_clone(&o_conv);
21510         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21511         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
21512         return tag_ptr(ret_conv, true);
21513 }
21514
21515 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_err(int64_t e) {
21516         void* e_ptr = untag_ptr(e);
21517         CHECK_ACCESS(e_ptr);
21518         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21519         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21520         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21521         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
21522         return tag_ptr(ret_conv, true);
21523 }
21524
21525 jboolean  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_is_ok(int64_t o) {
21526         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
21527         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
21528         return ret_conv;
21529 }
21530
21531 void  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_free(int64_t _res) {
21532         if (!ptr_is_owned(_res)) return;
21533         void* _res_ptr = untag_ptr(_res);
21534         CHECK_ACCESS(_res_ptr);
21535         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
21536         FREE(untag_ptr(_res));
21537         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
21538 }
21539
21540 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
21541         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21542         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
21543         return tag_ptr(ret_conv, true);
21544 }
21545 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(int64_t arg) {
21546         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
21547         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
21548         return ret_conv;
21549 }
21550
21551 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_clone(int64_t orig) {
21552         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
21553         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21554         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
21555         return tag_ptr(ret_conv, true);
21556 }
21557
21558 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_ok(int64_t o) {
21559         LDKPhantomRouteHints o_conv;
21560         o_conv.inner = untag_ptr(o);
21561         o_conv.is_owned = ptr_is_owned(o);
21562         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21563         o_conv = PhantomRouteHints_clone(&o_conv);
21564         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21565         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
21566         return tag_ptr(ret_conv, true);
21567 }
21568
21569 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_err(int64_t e) {
21570         void* e_ptr = untag_ptr(e);
21571         CHECK_ACCESS(e_ptr);
21572         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21573         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21574         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21575         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
21576         return tag_ptr(ret_conv, true);
21577 }
21578
21579 jboolean  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(int64_t o) {
21580         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
21581         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
21582         return ret_conv;
21583 }
21584
21585 void  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_free(int64_t _res) {
21586         if (!ptr_is_owned(_res)) return;
21587         void* _res_ptr = untag_ptr(_res);
21588         CHECK_ACCESS(_res_ptr);
21589         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
21590         FREE(untag_ptr(_res));
21591         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
21592 }
21593
21594 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
21595         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21596         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
21597         return tag_ptr(ret_conv, true);
21598 }
21599 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(int64_t arg) {
21600         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
21601         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
21602         return ret_conv;
21603 }
21604
21605 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_clone(int64_t orig) {
21606         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
21607         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21608         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
21609         return tag_ptr(ret_conv, true);
21610 }
21611
21612 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_ok(int32_t o) {
21613         LDKChannelShutdownState o_conv = LDKChannelShutdownState_from_cs(o);
21614         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
21615         *ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_ok(o_conv);
21616         return tag_ptr(ret_conv, true);
21617 }
21618
21619 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_err(int64_t e) {
21620         void* e_ptr = untag_ptr(e);
21621         CHECK_ACCESS(e_ptr);
21622         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21623         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21624         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
21625         *ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_err(e_conv);
21626         return tag_ptr(ret_conv, true);
21627 }
21628
21629 jboolean  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_is_ok(int64_t o) {
21630         LDKCResult_ChannelShutdownStateDecodeErrorZ* o_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(o);
21631         jboolean ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_is_ok(o_conv);
21632         return ret_conv;
21633 }
21634
21635 void  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_free(int64_t _res) {
21636         if (!ptr_is_owned(_res)) return;
21637         void* _res_ptr = untag_ptr(_res);
21638         CHECK_ACCESS(_res_ptr);
21639         LDKCResult_ChannelShutdownStateDecodeErrorZ _res_conv = *(LDKCResult_ChannelShutdownStateDecodeErrorZ*)(_res_ptr);
21640         FREE(untag_ptr(_res));
21641         CResult_ChannelShutdownStateDecodeErrorZ_free(_res_conv);
21642 }
21643
21644 static inline uint64_t CResult_ChannelShutdownStateDecodeErrorZ_clone_ptr(LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR arg) {
21645         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
21646         *ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_clone(arg);
21647         return tag_ptr(ret_conv, true);
21648 }
21649 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_clone_ptr(int64_t arg) {
21650         LDKCResult_ChannelShutdownStateDecodeErrorZ* arg_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(arg);
21651         int64_t ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_clone_ptr(arg_conv);
21652         return ret_conv;
21653 }
21654
21655 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_clone(int64_t orig) {
21656         LDKCResult_ChannelShutdownStateDecodeErrorZ* orig_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(orig);
21657         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
21658         *ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_clone(orig_conv);
21659         return tag_ptr(ret_conv, true);
21660 }
21661
21662 void  CS_LDK_CVec_ChannelMonitorZ_free(int64_tArray _res) {
21663         LDKCVec_ChannelMonitorZ _res_constr;
21664         _res_constr.datalen = _res->arr_len;
21665         if (_res_constr.datalen > 0)
21666                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21667         else
21668                 _res_constr.data = NULL;
21669         int64_t* _res_vals = _res->elems;
21670         for (size_t q = 0; q < _res_constr.datalen; q++) {
21671                 int64_t _res_conv_16 = _res_vals[q];
21672                 LDKChannelMonitor _res_conv_16_conv;
21673                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
21674                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
21675                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21676                 _res_constr.data[q] = _res_conv_16_conv;
21677         }
21678         FREE(_res);
21679         CVec_ChannelMonitorZ_free(_res_constr);
21680 }
21681
21682 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_new(int8_tArray a, int64_t b) {
21683         LDKThirtyTwoBytes a_ref;
21684         CHECK(a->arr_len == 32);
21685         memcpy(a_ref.data, a->elems, 32); FREE(a);
21686         LDKChannelManager b_conv;
21687         b_conv.inner = untag_ptr(b);
21688         b_conv.is_owned = ptr_is_owned(b);
21689         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21690         // WARNING: we need a move here but no clone is available for LDKChannelManager
21691         
21692         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ), "LDKC2Tuple_ThirtyTwoBytesChannelManagerZ");
21693         *ret_conv = C2Tuple_ThirtyTwoBytesChannelManagerZ_new(a_ref, b_conv);
21694         return tag_ptr(ret_conv, true);
21695 }
21696
21697 void  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_free(int64_t _res) {
21698         if (!ptr_is_owned(_res)) return;
21699         void* _res_ptr = untag_ptr(_res);
21700         CHECK_ACCESS(_res_ptr);
21701         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ*)(_res_ptr);
21702         FREE(untag_ptr(_res));
21703         C2Tuple_ThirtyTwoBytesChannelManagerZ_free(_res_conv);
21704 }
21705
21706 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_ok(int64_t o) {
21707         void* o_ptr = untag_ptr(o);
21708         CHECK_ACCESS(o_ptr);
21709         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ*)(o_ptr);
21710         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_ThirtyTwoBytesChannelManagerZ
21711         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ");
21712         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_ok(o_conv);
21713         return tag_ptr(ret_conv, true);
21714 }
21715
21716 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_err(int64_t e) {
21717         void* e_ptr = untag_ptr(e);
21718         CHECK_ACCESS(e_ptr);
21719         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21720         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21721         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ");
21722         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_err(e_conv);
21723         return tag_ptr(ret_conv, true);
21724 }
21725
21726 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_is_ok(int64_t o) {
21727         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ*)untag_ptr(o);
21728         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_is_ok(o_conv);
21729         return ret_conv;
21730 }
21731
21732 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_free(int64_t _res) {
21733         if (!ptr_is_owned(_res)) return;
21734         void* _res_ptr = untag_ptr(_res);
21735         CHECK_ACCESS(_res_ptr);
21736         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ*)(_res_ptr);
21737         FREE(untag_ptr(_res));
21738         CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_free(_res_conv);
21739 }
21740
21741 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_ok(int64_t o) {
21742         void* o_ptr = untag_ptr(o);
21743         CHECK_ACCESS(o_ptr);
21744         LDKMaxDustHTLCExposure o_conv = *(LDKMaxDustHTLCExposure*)(o_ptr);
21745         o_conv = MaxDustHTLCExposure_clone((LDKMaxDustHTLCExposure*)untag_ptr(o));
21746         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
21747         *ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_ok(o_conv);
21748         return tag_ptr(ret_conv, true);
21749 }
21750
21751 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_err(int64_t e) {
21752         void* e_ptr = untag_ptr(e);
21753         CHECK_ACCESS(e_ptr);
21754         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21755         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21756         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
21757         *ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_err(e_conv);
21758         return tag_ptr(ret_conv, true);
21759 }
21760
21761 jboolean  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(int64_t o) {
21762         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* o_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(o);
21763         jboolean ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(o_conv);
21764         return ret_conv;
21765 }
21766
21767 void  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_free(int64_t _res) {
21768         if (!ptr_is_owned(_res)) return;
21769         void* _res_ptr = untag_ptr(_res);
21770         CHECK_ACCESS(_res_ptr);
21771         LDKCResult_MaxDustHTLCExposureDecodeErrorZ _res_conv = *(LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)(_res_ptr);
21772         FREE(untag_ptr(_res));
21773         CResult_MaxDustHTLCExposureDecodeErrorZ_free(_res_conv);
21774 }
21775
21776 static inline uint64_t CResult_MaxDustHTLCExposureDecodeErrorZ_clone_ptr(LDKCResult_MaxDustHTLCExposureDecodeErrorZ *NONNULL_PTR arg) {
21777         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
21778         *ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_clone(arg);
21779         return tag_ptr(ret_conv, true);
21780 }
21781 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_clone_ptr(int64_t arg) {
21782         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* arg_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(arg);
21783         int64_t ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_clone_ptr(arg_conv);
21784         return ret_conv;
21785 }
21786
21787 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_clone(int64_t orig) {
21788         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* orig_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(orig);
21789         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
21790         *ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_clone(orig_conv);
21791         return tag_ptr(ret_conv, true);
21792 }
21793
21794 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_ok(int64_t o) {
21795         LDKChannelConfig o_conv;
21796         o_conv.inner = untag_ptr(o);
21797         o_conv.is_owned = ptr_is_owned(o);
21798         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21799         o_conv = ChannelConfig_clone(&o_conv);
21800         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21801         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
21802         return tag_ptr(ret_conv, true);
21803 }
21804
21805 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_err(int64_t e) {
21806         void* e_ptr = untag_ptr(e);
21807         CHECK_ACCESS(e_ptr);
21808         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21809         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21810         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21811         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
21812         return tag_ptr(ret_conv, true);
21813 }
21814
21815 jboolean  CS_LDK_CResult_ChannelConfigDecodeErrorZ_is_ok(int64_t o) {
21816         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
21817         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
21818         return ret_conv;
21819 }
21820
21821 void  CS_LDK_CResult_ChannelConfigDecodeErrorZ_free(int64_t _res) {
21822         if (!ptr_is_owned(_res)) return;
21823         void* _res_ptr = untag_ptr(_res);
21824         CHECK_ACCESS(_res_ptr);
21825         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
21826         FREE(untag_ptr(_res));
21827         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
21828 }
21829
21830 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
21831         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21832         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
21833         return tag_ptr(ret_conv, true);
21834 }
21835 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_clone_ptr(int64_t arg) {
21836         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
21837         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
21838         return ret_conv;
21839 }
21840
21841 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_clone(int64_t orig) {
21842         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
21843         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21844         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
21845         return tag_ptr(ret_conv, true);
21846 }
21847
21848 int64_t  CS_LDK_COption_MaxDustHTLCExposureZ_some(int64_t o) {
21849         void* o_ptr = untag_ptr(o);
21850         CHECK_ACCESS(o_ptr);
21851         LDKMaxDustHTLCExposure o_conv = *(LDKMaxDustHTLCExposure*)(o_ptr);
21852         o_conv = MaxDustHTLCExposure_clone((LDKMaxDustHTLCExposure*)untag_ptr(o));
21853         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
21854         *ret_copy = COption_MaxDustHTLCExposureZ_some(o_conv);
21855         int64_t ret_ref = tag_ptr(ret_copy, true);
21856         return ret_ref;
21857 }
21858
21859 int64_t  CS_LDK_COption_MaxDustHTLCExposureZ_none() {
21860         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
21861         *ret_copy = COption_MaxDustHTLCExposureZ_none();
21862         int64_t ret_ref = tag_ptr(ret_copy, true);
21863         return ret_ref;
21864 }
21865
21866 void  CS_LDK_COption_MaxDustHTLCExposureZ_free(int64_t _res) {
21867         if (!ptr_is_owned(_res)) return;
21868         void* _res_ptr = untag_ptr(_res);
21869         CHECK_ACCESS(_res_ptr);
21870         LDKCOption_MaxDustHTLCExposureZ _res_conv = *(LDKCOption_MaxDustHTLCExposureZ*)(_res_ptr);
21871         FREE(untag_ptr(_res));
21872         COption_MaxDustHTLCExposureZ_free(_res_conv);
21873 }
21874
21875 static inline uint64_t COption_MaxDustHTLCExposureZ_clone_ptr(LDKCOption_MaxDustHTLCExposureZ *NONNULL_PTR arg) {
21876         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
21877         *ret_copy = COption_MaxDustHTLCExposureZ_clone(arg);
21878         int64_t ret_ref = tag_ptr(ret_copy, true);
21879         return ret_ref;
21880 }
21881 int64_t  CS_LDK_COption_MaxDustHTLCExposureZ_clone_ptr(int64_t arg) {
21882         LDKCOption_MaxDustHTLCExposureZ* arg_conv = (LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(arg);
21883         int64_t ret_conv = COption_MaxDustHTLCExposureZ_clone_ptr(arg_conv);
21884         return ret_conv;
21885 }
21886
21887 int64_t  CS_LDK_COption_MaxDustHTLCExposureZ_clone(int64_t orig) {
21888         LDKCOption_MaxDustHTLCExposureZ* orig_conv = (LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(orig);
21889         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
21890         *ret_copy = COption_MaxDustHTLCExposureZ_clone(orig_conv);
21891         int64_t ret_ref = tag_ptr(ret_copy, true);
21892         return ret_ref;
21893 }
21894
21895 int64_t  CS_LDK_COption_APIErrorZ_some(int64_t o) {
21896         void* o_ptr = untag_ptr(o);
21897         CHECK_ACCESS(o_ptr);
21898         LDKAPIError o_conv = *(LDKAPIError*)(o_ptr);
21899         o_conv = APIError_clone((LDKAPIError*)untag_ptr(o));
21900         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21901         *ret_copy = COption_APIErrorZ_some(o_conv);
21902         int64_t ret_ref = tag_ptr(ret_copy, true);
21903         return ret_ref;
21904 }
21905
21906 int64_t  CS_LDK_COption_APIErrorZ_none() {
21907         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21908         *ret_copy = COption_APIErrorZ_none();
21909         int64_t ret_ref = tag_ptr(ret_copy, true);
21910         return ret_ref;
21911 }
21912
21913 void  CS_LDK_COption_APIErrorZ_free(int64_t _res) {
21914         if (!ptr_is_owned(_res)) return;
21915         void* _res_ptr = untag_ptr(_res);
21916         CHECK_ACCESS(_res_ptr);
21917         LDKCOption_APIErrorZ _res_conv = *(LDKCOption_APIErrorZ*)(_res_ptr);
21918         FREE(untag_ptr(_res));
21919         COption_APIErrorZ_free(_res_conv);
21920 }
21921
21922 static inline uint64_t COption_APIErrorZ_clone_ptr(LDKCOption_APIErrorZ *NONNULL_PTR arg) {
21923         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21924         *ret_copy = COption_APIErrorZ_clone(arg);
21925         int64_t ret_ref = tag_ptr(ret_copy, true);
21926         return ret_ref;
21927 }
21928 int64_t  CS_LDK_COption_APIErrorZ_clone_ptr(int64_t arg) {
21929         LDKCOption_APIErrorZ* arg_conv = (LDKCOption_APIErrorZ*)untag_ptr(arg);
21930         int64_t ret_conv = COption_APIErrorZ_clone_ptr(arg_conv);
21931         return ret_conv;
21932 }
21933
21934 int64_t  CS_LDK_COption_APIErrorZ_clone(int64_t orig) {
21935         LDKCOption_APIErrorZ* orig_conv = (LDKCOption_APIErrorZ*)untag_ptr(orig);
21936         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21937         *ret_copy = COption_APIErrorZ_clone(orig_conv);
21938         int64_t ret_ref = tag_ptr(ret_copy, true);
21939         return ret_ref;
21940 }
21941
21942 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_ok(int64_t o) {
21943         void* o_ptr = untag_ptr(o);
21944         CHECK_ACCESS(o_ptr);
21945         LDKCOption_APIErrorZ o_conv = *(LDKCOption_APIErrorZ*)(o_ptr);
21946         o_conv = COption_APIErrorZ_clone((LDKCOption_APIErrorZ*)untag_ptr(o));
21947         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21948         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_ok(o_conv);
21949         return tag_ptr(ret_conv, true);
21950 }
21951
21952 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_err(int64_t e) {
21953         void* e_ptr = untag_ptr(e);
21954         CHECK_ACCESS(e_ptr);
21955         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21956         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21957         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21958         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_err(e_conv);
21959         return tag_ptr(ret_conv, true);
21960 }
21961
21962 jboolean  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_is_ok(int64_t o) {
21963         LDKCResult_COption_APIErrorZDecodeErrorZ* o_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(o);
21964         jboolean ret_conv = CResult_COption_APIErrorZDecodeErrorZ_is_ok(o_conv);
21965         return ret_conv;
21966 }
21967
21968 void  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_free(int64_t _res) {
21969         if (!ptr_is_owned(_res)) return;
21970         void* _res_ptr = untag_ptr(_res);
21971         CHECK_ACCESS(_res_ptr);
21972         LDKCResult_COption_APIErrorZDecodeErrorZ _res_conv = *(LDKCResult_COption_APIErrorZDecodeErrorZ*)(_res_ptr);
21973         FREE(untag_ptr(_res));
21974         CResult_COption_APIErrorZDecodeErrorZ_free(_res_conv);
21975 }
21976
21977 static inline uint64_t CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR arg) {
21978         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21979         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(arg);
21980         return tag_ptr(ret_conv, true);
21981 }
21982 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(int64_t arg) {
21983         LDKCResult_COption_APIErrorZDecodeErrorZ* arg_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(arg);
21984         int64_t ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(arg_conv);
21985         return ret_conv;
21986 }
21987
21988 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_clone(int64_t orig) {
21989         LDKCResult_COption_APIErrorZDecodeErrorZ* orig_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(orig);
21990         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21991         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(orig_conv);
21992         return tag_ptr(ret_conv, true);
21993 }
21994
21995 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(int64_t o) {
21996         LDKChannelMonitorUpdate o_conv;
21997         o_conv.inner = untag_ptr(o);
21998         o_conv.is_owned = ptr_is_owned(o);
21999         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22000         o_conv = ChannelMonitorUpdate_clone(&o_conv);
22001         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22002         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
22003         return tag_ptr(ret_conv, true);
22004 }
22005
22006 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_err(int64_t e) {
22007         void* e_ptr = untag_ptr(e);
22008         CHECK_ACCESS(e_ptr);
22009         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22010         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22011         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22012         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22013         return tag_ptr(ret_conv, true);
22014 }
22015
22016 jboolean  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(int64_t o) {
22017         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22018         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22019         return ret_conv;
22020 }
22021
22022 void  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_free(int64_t _res) {
22023         if (!ptr_is_owned(_res)) return;
22024         void* _res_ptr = untag_ptr(_res);
22025         CHECK_ACCESS(_res_ptr);
22026         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22027         FREE(untag_ptr(_res));
22028         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
22029 }
22030
22031 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
22032         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22033         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
22034         return tag_ptr(ret_conv, true);
22035 }
22036 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(int64_t arg) {
22037         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22038         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22039         return ret_conv;
22040 }
22041
22042 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(int64_t orig) {
22043         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22044         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22045         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22046         return tag_ptr(ret_conv, true);
22047 }
22048
22049 int64_t  CS_LDK_COption_MonitorEventZ_some(int64_t o) {
22050         void* o_ptr = untag_ptr(o);
22051         CHECK_ACCESS(o_ptr);
22052         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
22053         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
22054         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22055         *ret_copy = COption_MonitorEventZ_some(o_conv);
22056         int64_t ret_ref = tag_ptr(ret_copy, true);
22057         return ret_ref;
22058 }
22059
22060 int64_t  CS_LDK_COption_MonitorEventZ_none() {
22061         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22062         *ret_copy = COption_MonitorEventZ_none();
22063         int64_t ret_ref = tag_ptr(ret_copy, true);
22064         return ret_ref;
22065 }
22066
22067 void  CS_LDK_COption_MonitorEventZ_free(int64_t _res) {
22068         if (!ptr_is_owned(_res)) return;
22069         void* _res_ptr = untag_ptr(_res);
22070         CHECK_ACCESS(_res_ptr);
22071         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
22072         FREE(untag_ptr(_res));
22073         COption_MonitorEventZ_free(_res_conv);
22074 }
22075
22076 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
22077         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22078         *ret_copy = COption_MonitorEventZ_clone(arg);
22079         int64_t ret_ref = tag_ptr(ret_copy, true);
22080         return ret_ref;
22081 }
22082 int64_t  CS_LDK_COption_MonitorEventZ_clone_ptr(int64_t arg) {
22083         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
22084         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
22085         return ret_conv;
22086 }
22087
22088 int64_t  CS_LDK_COption_MonitorEventZ_clone(int64_t orig) {
22089         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
22090         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22091         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
22092         int64_t ret_ref = tag_ptr(ret_copy, true);
22093         return ret_ref;
22094 }
22095
22096 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_ok(int64_t o) {
22097         void* o_ptr = untag_ptr(o);
22098         CHECK_ACCESS(o_ptr);
22099         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
22100         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
22101         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22102         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
22103         return tag_ptr(ret_conv, true);
22104 }
22105
22106 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_err(int64_t e) {
22107         void* e_ptr = untag_ptr(e);
22108         CHECK_ACCESS(e_ptr);
22109         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22110         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22111         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22112         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
22113         return tag_ptr(ret_conv, true);
22114 }
22115
22116 jboolean  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(int64_t o) {
22117         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
22118         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
22119         return ret_conv;
22120 }
22121
22122 void  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_free(int64_t _res) {
22123         if (!ptr_is_owned(_res)) return;
22124         void* _res_ptr = untag_ptr(_res);
22125         CHECK_ACCESS(_res_ptr);
22126         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
22127         FREE(untag_ptr(_res));
22128         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
22129 }
22130
22131 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
22132         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22133         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
22134         return tag_ptr(ret_conv, true);
22135 }
22136 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(int64_t arg) {
22137         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
22138         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
22139         return ret_conv;
22140 }
22141
22142 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_clone(int64_t orig) {
22143         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
22144         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22145         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
22146         return tag_ptr(ret_conv, true);
22147 }
22148
22149 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_ok(int64_t o) {
22150         LDKHTLCUpdate o_conv;
22151         o_conv.inner = untag_ptr(o);
22152         o_conv.is_owned = ptr_is_owned(o);
22153         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22154         o_conv = HTLCUpdate_clone(&o_conv);
22155         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22156         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
22157         return tag_ptr(ret_conv, true);
22158 }
22159
22160 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_err(int64_t e) {
22161         void* e_ptr = untag_ptr(e);
22162         CHECK_ACCESS(e_ptr);
22163         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22164         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22165         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22166         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
22167         return tag_ptr(ret_conv, true);
22168 }
22169
22170 jboolean  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_is_ok(int64_t o) {
22171         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
22172         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
22173         return ret_conv;
22174 }
22175
22176 void  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_free(int64_t _res) {
22177         if (!ptr_is_owned(_res)) return;
22178         void* _res_ptr = untag_ptr(_res);
22179         CHECK_ACCESS(_res_ptr);
22180         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
22181         FREE(untag_ptr(_res));
22182         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
22183 }
22184
22185 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
22186         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22187         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
22188         return tag_ptr(ret_conv, true);
22189 }
22190 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(int64_t arg) {
22191         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
22192         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
22193         return ret_conv;
22194 }
22195
22196 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_clone(int64_t orig) {
22197         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
22198         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22199         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
22200         return tag_ptr(ret_conv, true);
22201 }
22202
22203 static inline uint64_t C2Tuple_OutPointCVec_u8ZZ_clone_ptr(LDKC2Tuple_OutPointCVec_u8ZZ *NONNULL_PTR arg) {
22204         LDKC2Tuple_OutPointCVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_u8ZZ), "LDKC2Tuple_OutPointCVec_u8ZZ");
22205         *ret_conv = C2Tuple_OutPointCVec_u8ZZ_clone(arg);
22206         return tag_ptr(ret_conv, true);
22207 }
22208 int64_t  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_clone_ptr(int64_t arg) {
22209         LDKC2Tuple_OutPointCVec_u8ZZ* arg_conv = (LDKC2Tuple_OutPointCVec_u8ZZ*)untag_ptr(arg);
22210         int64_t ret_conv = C2Tuple_OutPointCVec_u8ZZ_clone_ptr(arg_conv);
22211         return ret_conv;
22212 }
22213
22214 int64_t  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_clone(int64_t orig) {
22215         LDKC2Tuple_OutPointCVec_u8ZZ* orig_conv = (LDKC2Tuple_OutPointCVec_u8ZZ*)untag_ptr(orig);
22216         LDKC2Tuple_OutPointCVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_u8ZZ), "LDKC2Tuple_OutPointCVec_u8ZZ");
22217         *ret_conv = C2Tuple_OutPointCVec_u8ZZ_clone(orig_conv);
22218         return tag_ptr(ret_conv, true);
22219 }
22220
22221 int64_t  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_new(int64_t a, int8_tArray b) {
22222         LDKOutPoint a_conv;
22223         a_conv.inner = untag_ptr(a);
22224         a_conv.is_owned = ptr_is_owned(a);
22225         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22226         a_conv = OutPoint_clone(&a_conv);
22227         LDKCVec_u8Z b_ref;
22228         b_ref.datalen = b->arr_len;
22229         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22230         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
22231         LDKC2Tuple_OutPointCVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_u8ZZ), "LDKC2Tuple_OutPointCVec_u8ZZ");
22232         *ret_conv = C2Tuple_OutPointCVec_u8ZZ_new(a_conv, b_ref);
22233         return tag_ptr(ret_conv, true);
22234 }
22235
22236 void  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_free(int64_t _res) {
22237         if (!ptr_is_owned(_res)) return;
22238         void* _res_ptr = untag_ptr(_res);
22239         CHECK_ACCESS(_res_ptr);
22240         LDKC2Tuple_OutPointCVec_u8ZZ _res_conv = *(LDKC2Tuple_OutPointCVec_u8ZZ*)(_res_ptr);
22241         FREE(untag_ptr(_res));
22242         C2Tuple_OutPointCVec_u8ZZ_free(_res_conv);
22243 }
22244
22245 static inline uint64_t C2Tuple_u32CVec_u8ZZ_clone_ptr(LDKC2Tuple_u32CVec_u8ZZ *NONNULL_PTR arg) {
22246         LDKC2Tuple_u32CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKC2Tuple_u32CVec_u8ZZ");
22247         *ret_conv = C2Tuple_u32CVec_u8ZZ_clone(arg);
22248         return tag_ptr(ret_conv, true);
22249 }
22250 int64_t  CS_LDK_C2Tuple_u32CVec_u8ZZ_clone_ptr(int64_t arg) {
22251         LDKC2Tuple_u32CVec_u8ZZ* arg_conv = (LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(arg);
22252         int64_t ret_conv = C2Tuple_u32CVec_u8ZZ_clone_ptr(arg_conv);
22253         return ret_conv;
22254 }
22255
22256 int64_t  CS_LDK_C2Tuple_u32CVec_u8ZZ_clone(int64_t orig) {
22257         LDKC2Tuple_u32CVec_u8ZZ* orig_conv = (LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(orig);
22258         LDKC2Tuple_u32CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKC2Tuple_u32CVec_u8ZZ");
22259         *ret_conv = C2Tuple_u32CVec_u8ZZ_clone(orig_conv);
22260         return tag_ptr(ret_conv, true);
22261 }
22262
22263 int64_t  CS_LDK_C2Tuple_u32CVec_u8ZZ_new(int32_t a, int8_tArray b) {
22264         LDKCVec_u8Z b_ref;
22265         b_ref.datalen = b->arr_len;
22266         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22267         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
22268         LDKC2Tuple_u32CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKC2Tuple_u32CVec_u8ZZ");
22269         *ret_conv = C2Tuple_u32CVec_u8ZZ_new(a, b_ref);
22270         return tag_ptr(ret_conv, true);
22271 }
22272
22273 void  CS_LDK_C2Tuple_u32CVec_u8ZZ_free(int64_t _res) {
22274         if (!ptr_is_owned(_res)) return;
22275         void* _res_ptr = untag_ptr(_res);
22276         CHECK_ACCESS(_res_ptr);
22277         LDKC2Tuple_u32CVec_u8ZZ _res_conv = *(LDKC2Tuple_u32CVec_u8ZZ*)(_res_ptr);
22278         FREE(untag_ptr(_res));
22279         C2Tuple_u32CVec_u8ZZ_free(_res_conv);
22280 }
22281
22282 void  CS_LDK_CVec_C2Tuple_u32CVec_u8ZZZ_free(int64_tArray _res) {
22283         LDKCVec_C2Tuple_u32CVec_u8ZZZ _res_constr;
22284         _res_constr.datalen = _res->arr_len;
22285         if (_res_constr.datalen > 0)
22286                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKCVec_C2Tuple_u32CVec_u8ZZZ Elements");
22287         else
22288                 _res_constr.data = NULL;
22289         int64_t* _res_vals = _res->elems;
22290         for (size_t x = 0; x < _res_constr.datalen; x++) {
22291                 int64_t _res_conv_23 = _res_vals[x];
22292                 void* _res_conv_23_ptr = untag_ptr(_res_conv_23);
22293                 CHECK_ACCESS(_res_conv_23_ptr);
22294                 LDKC2Tuple_u32CVec_u8ZZ _res_conv_23_conv = *(LDKC2Tuple_u32CVec_u8ZZ*)(_res_conv_23_ptr);
22295                 FREE(untag_ptr(_res_conv_23));
22296                 _res_constr.data[x] = _res_conv_23_conv;
22297         }
22298         FREE(_res);
22299         CVec_C2Tuple_u32CVec_u8ZZZ_free(_res_constr);
22300 }
22301
22302 static inline uint64_t C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ *NONNULL_PTR arg) {
22303         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ");
22304         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(arg);
22305         return tag_ptr(ret_conv, true);
22306 }
22307 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone_ptr(int64_t arg) {
22308         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)untag_ptr(arg);
22309         int64_t ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone_ptr(arg_conv);
22310         return ret_conv;
22311 }
22312
22313 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(int64_t orig) {
22314         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)untag_ptr(orig);
22315         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ");
22316         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(orig_conv);
22317         return tag_ptr(ret_conv, true);
22318 }
22319
22320 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_new(int8_tArray a, int64_tArray b) {
22321         LDKThirtyTwoBytes a_ref;
22322         CHECK(a->arr_len == 32);
22323         memcpy(a_ref.data, a->elems, 32); FREE(a);
22324         LDKCVec_C2Tuple_u32CVec_u8ZZZ b_constr;
22325         b_constr.datalen = b->arr_len;
22326         if (b_constr.datalen > 0)
22327                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKCVec_C2Tuple_u32CVec_u8ZZZ Elements");
22328         else
22329                 b_constr.data = NULL;
22330         int64_t* b_vals = b->elems;
22331         for (size_t x = 0; x < b_constr.datalen; x++) {
22332                 int64_t b_conv_23 = b_vals[x];
22333                 void* b_conv_23_ptr = untag_ptr(b_conv_23);
22334                 CHECK_ACCESS(b_conv_23_ptr);
22335                 LDKC2Tuple_u32CVec_u8ZZ b_conv_23_conv = *(LDKC2Tuple_u32CVec_u8ZZ*)(b_conv_23_ptr);
22336                 b_conv_23_conv = C2Tuple_u32CVec_u8ZZ_clone((LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(b_conv_23));
22337                 b_constr.data[x] = b_conv_23_conv;
22338         }
22339         FREE(b);
22340         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ");
22341         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_new(a_ref, b_constr);
22342         return tag_ptr(ret_conv, true);
22343 }
22344
22345 void  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_free(int64_t _res) {
22346         if (!ptr_is_owned(_res)) return;
22347         void* _res_ptr = untag_ptr(_res);
22348         CHECK_ACCESS(_res_ptr);
22349         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)(_res_ptr);
22350         FREE(untag_ptr(_res));
22351         C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_free(_res_conv);
22352 }
22353
22354 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_free(int64_tArray _res) {
22355         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ _res_constr;
22356         _res_constr.datalen = _res->arr_len;
22357         if (_res_constr.datalen > 0)
22358                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ Elements");
22359         else
22360                 _res_constr.data = NULL;
22361         int64_t* _res_vals = _res->elems;
22362         for (size_t a = 0; a < _res_constr.datalen; a++) {
22363                 int64_t _res_conv_52 = _res_vals[a];
22364                 void* _res_conv_52_ptr = untag_ptr(_res_conv_52);
22365                 CHECK_ACCESS(_res_conv_52_ptr);
22366                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ _res_conv_52_conv = *(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)(_res_conv_52_ptr);
22367                 FREE(untag_ptr(_res_conv_52));
22368                 _res_constr.data[a] = _res_conv_52_conv;
22369         }
22370         FREE(_res);
22371         CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_free(_res_constr);
22372 }
22373
22374 void  CS_LDK_CVec_CommitmentTransactionZ_free(int64_tArray _res) {
22375         LDKCVec_CommitmentTransactionZ _res_constr;
22376         _res_constr.datalen = _res->arr_len;
22377         if (_res_constr.datalen > 0)
22378                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCommitmentTransaction), "LDKCVec_CommitmentTransactionZ Elements");
22379         else
22380                 _res_constr.data = NULL;
22381         int64_t* _res_vals = _res->elems;
22382         for (size_t x = 0; x < _res_constr.datalen; x++) {
22383                 int64_t _res_conv_23 = _res_vals[x];
22384                 LDKCommitmentTransaction _res_conv_23_conv;
22385                 _res_conv_23_conv.inner = untag_ptr(_res_conv_23);
22386                 _res_conv_23_conv.is_owned = ptr_is_owned(_res_conv_23);
22387                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_23_conv);
22388                 _res_constr.data[x] = _res_conv_23_conv;
22389         }
22390         FREE(_res);
22391         CVec_CommitmentTransactionZ_free(_res_constr);
22392 }
22393
22394 void  CS_LDK_CVec_TransactionZ_free(ptrArray _res) {
22395         LDKCVec_TransactionZ _res_constr;
22396         _res_constr.datalen = _res->arr_len;
22397         if (_res_constr.datalen > 0)
22398                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
22399         else
22400                 _res_constr.data = NULL;
22401         int8_tArray* _res_vals = (void*) _res->elems;
22402         for (size_t i = 0; i < _res_constr.datalen; i++) {
22403                 int8_tArray _res_conv_8 = _res_vals[i];
22404                 LDKTransaction _res_conv_8_ref;
22405                 _res_conv_8_ref.datalen = _res_conv_8->arr_len;
22406                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
22407                 memcpy(_res_conv_8_ref.data, _res_conv_8->elems, _res_conv_8_ref.datalen); FREE(_res_conv_8);
22408                 _res_conv_8_ref.data_is_owned = true;
22409                 _res_constr.data[i] = _res_conv_8_ref;
22410         }
22411         FREE(_res);
22412         CVec_TransactionZ_free(_res_constr);
22413 }
22414
22415 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
22416         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22417         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
22418         return tag_ptr(ret_conv, true);
22419 }
22420 int64_t  CS_LDK_C2Tuple_u32TxOutZ_clone_ptr(int64_t arg) {
22421         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
22422         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
22423         return ret_conv;
22424 }
22425
22426 int64_t  CS_LDK_C2Tuple_u32TxOutZ_clone(int64_t orig) {
22427         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
22428         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22429         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
22430         return tag_ptr(ret_conv, true);
22431 }
22432
22433 int64_t  CS_LDK_C2Tuple_u32TxOutZ_new(int32_t a, int64_t b) {
22434         void* b_ptr = untag_ptr(b);
22435         CHECK_ACCESS(b_ptr);
22436         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
22437         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
22438         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22439         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
22440         return tag_ptr(ret_conv, true);
22441 }
22442
22443 void  CS_LDK_C2Tuple_u32TxOutZ_free(int64_t _res) {
22444         if (!ptr_is_owned(_res)) return;
22445         void* _res_ptr = untag_ptr(_res);
22446         CHECK_ACCESS(_res_ptr);
22447         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
22448         FREE(untag_ptr(_res));
22449         C2Tuple_u32TxOutZ_free(_res_conv);
22450 }
22451
22452 void  CS_LDK_CVec_C2Tuple_u32TxOutZZ_free(int64_tArray _res) {
22453         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
22454         _res_constr.datalen = _res->arr_len;
22455         if (_res_constr.datalen > 0)
22456                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22457         else
22458                 _res_constr.data = NULL;
22459         int64_t* _res_vals = _res->elems;
22460         for (size_t u = 0; u < _res_constr.datalen; u++) {
22461                 int64_t _res_conv_20 = _res_vals[u];
22462                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
22463                 CHECK_ACCESS(_res_conv_20_ptr);
22464                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
22465                 FREE(untag_ptr(_res_conv_20));
22466                 _res_constr.data[u] = _res_conv_20_conv;
22467         }
22468         FREE(_res);
22469         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
22470 }
22471
22472 static inline uint64_t C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
22473         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
22474         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(arg);
22475         return tag_ptr(ret_conv, true);
22476 }
22477 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone_ptr(int64_t arg) {
22478         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
22479         int64_t ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
22480         return ret_conv;
22481 }
22482
22483 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(int64_t orig) {
22484         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
22485         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
22486         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
22487         return tag_ptr(ret_conv, true);
22488 }
22489
22490 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, int64_tArray b) {
22491         LDKThirtyTwoBytes a_ref;
22492         CHECK(a->arr_len == 32);
22493         memcpy(a_ref.data, a->elems, 32); FREE(a);
22494         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
22495         b_constr.datalen = b->arr_len;
22496         if (b_constr.datalen > 0)
22497                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22498         else
22499                 b_constr.data = NULL;
22500         int64_t* b_vals = b->elems;
22501         for (size_t u = 0; u < b_constr.datalen; u++) {
22502                 int64_t b_conv_20 = b_vals[u];
22503                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
22504                 CHECK_ACCESS(b_conv_20_ptr);
22505                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
22506                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
22507                 b_constr.data[u] = b_conv_20_conv;
22508         }
22509         FREE(b);
22510         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
22511         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
22512         return tag_ptr(ret_conv, true);
22513 }
22514
22515 void  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_free(int64_t _res) {
22516         if (!ptr_is_owned(_res)) return;
22517         void* _res_ptr = untag_ptr(_res);
22518         CHECK_ACCESS(_res_ptr);
22519         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
22520         FREE(untag_ptr(_res));
22521         C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
22522 }
22523
22524 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ_free(int64_tArray _res) {
22525         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ _res_constr;
22526         _res_constr.datalen = _res->arr_len;
22527         if (_res_constr.datalen > 0)
22528                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ Elements");
22529         else
22530                 _res_constr.data = NULL;
22531         int64_t* _res_vals = _res->elems;
22532         for (size_t x = 0; x < _res_constr.datalen; x++) {
22533                 int64_t _res_conv_49 = _res_vals[x];
22534                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
22535                 CHECK_ACCESS(_res_conv_49_ptr);
22536                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_49_ptr);
22537                 FREE(untag_ptr(_res_conv_49));
22538                 _res_constr.data[x] = _res_conv_49_conv;
22539         }
22540         FREE(_res);
22541         CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
22542 }
22543
22544 void  CS_LDK_CVec_BalanceZ_free(int64_tArray _res) {
22545         LDKCVec_BalanceZ _res_constr;
22546         _res_constr.datalen = _res->arr_len;
22547         if (_res_constr.datalen > 0)
22548                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
22549         else
22550                 _res_constr.data = NULL;
22551         int64_t* _res_vals = _res->elems;
22552         for (size_t j = 0; j < _res_constr.datalen; j++) {
22553                 int64_t _res_conv_9 = _res_vals[j];
22554                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
22555                 CHECK_ACCESS(_res_conv_9_ptr);
22556                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
22557                 FREE(untag_ptr(_res_conv_9));
22558                 _res_constr.data[j] = _res_conv_9_conv;
22559         }
22560         FREE(_res);
22561         CVec_BalanceZ_free(_res_constr);
22562 }
22563
22564 static inline uint64_t C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ *NONNULL_PTR arg) {
22565         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
22566         *ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(arg);
22567         return tag_ptr(ret_conv, true);
22568 }
22569 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone_ptr(int64_t arg) {
22570         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(arg);
22571         int64_t ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone_ptr(arg_conv);
22572         return ret_conv;
22573 }
22574
22575 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(int64_t orig) {
22576         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(orig);
22577         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
22578         *ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(orig_conv);
22579         return tag_ptr(ret_conv, true);
22580 }
22581
22582 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_new(int8_tArray a, int64_t b) {
22583         LDKThirtyTwoBytes a_ref;
22584         CHECK(a->arr_len == 32);
22585         memcpy(a_ref.data, a->elems, 32); FREE(a);
22586         LDKChannelMonitor b_conv;
22587         b_conv.inner = untag_ptr(b);
22588         b_conv.is_owned = ptr_is_owned(b);
22589         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22590         b_conv = ChannelMonitor_clone(&b_conv);
22591         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
22592         *ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_new(a_ref, b_conv);
22593         return tag_ptr(ret_conv, true);
22594 }
22595
22596 void  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_free(int64_t _res) {
22597         if (!ptr_is_owned(_res)) return;
22598         void* _res_ptr = untag_ptr(_res);
22599         CHECK_ACCESS(_res_ptr);
22600         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(_res_ptr);
22601         FREE(untag_ptr(_res));
22602         C2Tuple_ThirtyTwoBytesChannelMonitorZ_free(_res_conv);
22603 }
22604
22605 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_ok(int64_t o) {
22606         void* o_ptr = untag_ptr(o);
22607         CHECK_ACCESS(o_ptr);
22608         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(o_ptr);
22609         o_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone((LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(o));
22610         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
22611         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_ok(o_conv);
22612         return tag_ptr(ret_conv, true);
22613 }
22614
22615 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_err(int64_t e) {
22616         void* e_ptr = untag_ptr(e);
22617         CHECK_ACCESS(e_ptr);
22618         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22619         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22620         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
22621         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_err(e_conv);
22622         return tag_ptr(ret_conv, true);
22623 }
22624
22625 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_is_ok(int64_t o) {
22626         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(o);
22627         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_is_ok(o_conv);
22628         return ret_conv;
22629 }
22630
22631 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_free(int64_t _res) {
22632         if (!ptr_is_owned(_res)) return;
22633         void* _res_ptr = untag_ptr(_res);
22634         CHECK_ACCESS(_res_ptr);
22635         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)(_res_ptr);
22636         FREE(untag_ptr(_res));
22637         CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_free(_res_conv);
22638 }
22639
22640 static inline uint64_t CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
22641         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
22642         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone(arg);
22643         return tag_ptr(ret_conv, true);
22644 }
22645 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone_ptr(int64_t arg) {
22646         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
22647         int64_t ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
22648         return ret_conv;
22649 }
22650
22651 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone(int64_t orig) {
22652         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
22653         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
22654         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone(orig_conv);
22655         return tag_ptr(ret_conv, true);
22656 }
22657
22658 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
22659         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22660         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
22661         return tag_ptr(ret_conv, true);
22662 }
22663 int64_t  CS_LDK_C2Tuple_PublicKeyTypeZ_clone_ptr(int64_t arg) {
22664         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
22665         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
22666         return ret_conv;
22667 }
22668
22669 int64_t  CS_LDK_C2Tuple_PublicKeyTypeZ_clone(int64_t orig) {
22670         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
22671         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22672         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
22673         return tag_ptr(ret_conv, true);
22674 }
22675
22676 int64_t  CS_LDK_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, int64_t b) {
22677         LDKPublicKey a_ref;
22678         CHECK(a->arr_len == 33);
22679         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
22680         void* b_ptr = untag_ptr(b);
22681         CHECK_ACCESS(b_ptr);
22682         LDKType b_conv = *(LDKType*)(b_ptr);
22683         if (b_conv.free == LDKType_JCalls_free) {
22684                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22685                 LDKType_JCalls_cloned(&b_conv);
22686         }
22687         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22688         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
22689         return tag_ptr(ret_conv, true);
22690 }
22691
22692 void  CS_LDK_C2Tuple_PublicKeyTypeZ_free(int64_t _res) {
22693         if (!ptr_is_owned(_res)) return;
22694         void* _res_ptr = untag_ptr(_res);
22695         CHECK_ACCESS(_res_ptr);
22696         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
22697         FREE(untag_ptr(_res));
22698         C2Tuple_PublicKeyTypeZ_free(_res_conv);
22699 }
22700
22701 void  CS_LDK_CVec_C2Tuple_PublicKeyTypeZZ_free(int64_tArray _res) {
22702         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
22703         _res_constr.datalen = _res->arr_len;
22704         if (_res_constr.datalen > 0)
22705                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
22706         else
22707                 _res_constr.data = NULL;
22708         int64_t* _res_vals = _res->elems;
22709         for (size_t z = 0; z < _res_constr.datalen; z++) {
22710                 int64_t _res_conv_25 = _res_vals[z];
22711                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
22712                 CHECK_ACCESS(_res_conv_25_ptr);
22713                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
22714                 FREE(untag_ptr(_res_conv_25));
22715                 _res_constr.data[z] = _res_conv_25_conv;
22716         }
22717         FREE(_res);
22718         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
22719 }
22720
22721 int64_t  CS_LDK_COption_OnionMessageContentsZ_some(int64_t o) {
22722         void* o_ptr = untag_ptr(o);
22723         CHECK_ACCESS(o_ptr);
22724         LDKOnionMessageContents o_conv = *(LDKOnionMessageContents*)(o_ptr);
22725         if (o_conv.free == LDKOnionMessageContents_JCalls_free) {
22726                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22727                 LDKOnionMessageContents_JCalls_cloned(&o_conv);
22728         }
22729         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
22730         *ret_copy = COption_OnionMessageContentsZ_some(o_conv);
22731         int64_t ret_ref = tag_ptr(ret_copy, true);
22732         return ret_ref;
22733 }
22734
22735 int64_t  CS_LDK_COption_OnionMessageContentsZ_none() {
22736         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
22737         *ret_copy = COption_OnionMessageContentsZ_none();
22738         int64_t ret_ref = tag_ptr(ret_copy, true);
22739         return ret_ref;
22740 }
22741
22742 void  CS_LDK_COption_OnionMessageContentsZ_free(int64_t _res) {
22743         if (!ptr_is_owned(_res)) return;
22744         void* _res_ptr = untag_ptr(_res);
22745         CHECK_ACCESS(_res_ptr);
22746         LDKCOption_OnionMessageContentsZ _res_conv = *(LDKCOption_OnionMessageContentsZ*)(_res_ptr);
22747         FREE(untag_ptr(_res));
22748         COption_OnionMessageContentsZ_free(_res_conv);
22749 }
22750
22751 static inline uint64_t COption_OnionMessageContentsZ_clone_ptr(LDKCOption_OnionMessageContentsZ *NONNULL_PTR arg) {
22752         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
22753         *ret_copy = COption_OnionMessageContentsZ_clone(arg);
22754         int64_t ret_ref = tag_ptr(ret_copy, true);
22755         return ret_ref;
22756 }
22757 int64_t  CS_LDK_COption_OnionMessageContentsZ_clone_ptr(int64_t arg) {
22758         LDKCOption_OnionMessageContentsZ* arg_conv = (LDKCOption_OnionMessageContentsZ*)untag_ptr(arg);
22759         int64_t ret_conv = COption_OnionMessageContentsZ_clone_ptr(arg_conv);
22760         return ret_conv;
22761 }
22762
22763 int64_t  CS_LDK_COption_OnionMessageContentsZ_clone(int64_t orig) {
22764         LDKCOption_OnionMessageContentsZ* orig_conv = (LDKCOption_OnionMessageContentsZ*)untag_ptr(orig);
22765         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
22766         *ret_copy = COption_OnionMessageContentsZ_clone(orig_conv);
22767         int64_t ret_ref = tag_ptr(ret_copy, true);
22768         return ret_ref;
22769 }
22770
22771 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_ok(int64_t o) {
22772         void* o_ptr = untag_ptr(o);
22773         CHECK_ACCESS(o_ptr);
22774         LDKCOption_OnionMessageContentsZ o_conv = *(LDKCOption_OnionMessageContentsZ*)(o_ptr);
22775         o_conv = COption_OnionMessageContentsZ_clone((LDKCOption_OnionMessageContentsZ*)untag_ptr(o));
22776         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
22777         *ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_ok(o_conv);
22778         return tag_ptr(ret_conv, true);
22779 }
22780
22781 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_err(int64_t e) {
22782         void* e_ptr = untag_ptr(e);
22783         CHECK_ACCESS(e_ptr);
22784         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22785         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22786         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
22787         *ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_err(e_conv);
22788         return tag_ptr(ret_conv, true);
22789 }
22790
22791 jboolean  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_is_ok(int64_t o) {
22792         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
22793         jboolean ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
22794         return ret_conv;
22795 }
22796
22797 void  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_free(int64_t _res) {
22798         if (!ptr_is_owned(_res)) return;
22799         void* _res_ptr = untag_ptr(_res);
22800         CHECK_ACCESS(_res_ptr);
22801         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)(_res_ptr);
22802         FREE(untag_ptr(_res));
22803         CResult_COption_OnionMessageContentsZDecodeErrorZ_free(_res_conv);
22804 }
22805
22806 static inline uint64_t CResult_COption_OnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
22807         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
22808         *ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(arg);
22809         return tag_ptr(ret_conv, true);
22810 }
22811 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_clone_ptr(int64_t arg) {
22812         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
22813         int64_t ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
22814         return ret_conv;
22815 }
22816
22817 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(int64_t orig) {
22818         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
22819         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
22820         *ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(orig_conv);
22821         return tag_ptr(ret_conv, true);
22822 }
22823
22824 static inline uint64_t C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone_ptr(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR arg) {
22825         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ");
22826         *ret_conv = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(arg);
22827         return tag_ptr(ret_conv, true);
22828 }
22829 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone_ptr(int64_t arg) {
22830         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* arg_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(arg);
22831         int64_t ret_conv = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone_ptr(arg_conv);
22832         return ret_conv;
22833 }
22834
22835 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(int64_t orig) {
22836         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* orig_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(orig);
22837         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ");
22838         *ret_conv = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(orig_conv);
22839         return tag_ptr(ret_conv, true);
22840 }
22841
22842 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_new(int64_t a, int64_t b, int64_t c) {
22843         void* a_ptr = untag_ptr(a);
22844         CHECK_ACCESS(a_ptr);
22845         LDKOnionMessageContents a_conv = *(LDKOnionMessageContents*)(a_ptr);
22846         if (a_conv.free == LDKOnionMessageContents_JCalls_free) {
22847                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22848                 LDKOnionMessageContents_JCalls_cloned(&a_conv);
22849         }
22850         void* b_ptr = untag_ptr(b);
22851         CHECK_ACCESS(b_ptr);
22852         LDKDestination b_conv = *(LDKDestination*)(b_ptr);
22853         b_conv = Destination_clone((LDKDestination*)untag_ptr(b));
22854         LDKBlindedPath c_conv;
22855         c_conv.inner = untag_ptr(c);
22856         c_conv.is_owned = ptr_is_owned(c);
22857         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
22858         c_conv = BlindedPath_clone(&c_conv);
22859         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ");
22860         *ret_conv = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_new(a_conv, b_conv, c_conv);
22861         return tag_ptr(ret_conv, true);
22862 }
22863
22864 void  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(int64_t _res) {
22865         if (!ptr_is_owned(_res)) return;
22866         void* _res_ptr = untag_ptr(_res);
22867         CHECK_ACCESS(_res_ptr);
22868         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ _res_conv = *(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)(_res_ptr);
22869         FREE(untag_ptr(_res));
22870         C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(_res_conv);
22871 }
22872
22873 void  CS_LDK_CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(int64_tArray _res) {
22874         LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ _res_constr;
22875         _res_constr.datalen = _res->arr_len;
22876         if (_res_constr.datalen > 0)
22877                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ Elements");
22878         else
22879                 _res_constr.data = NULL;
22880         int64_t* _res_vals = _res->elems;
22881         for (size_t e = 0; e < _res_constr.datalen; e++) {
22882                 int64_t _res_conv_56 = _res_vals[e];
22883                 void* _res_conv_56_ptr = untag_ptr(_res_conv_56);
22884                 CHECK_ACCESS(_res_conv_56_ptr);
22885                 LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ _res_conv_56_conv = *(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)(_res_conv_56_ptr);
22886                 FREE(untag_ptr(_res_conv_56));
22887                 _res_constr.data[e] = _res_conv_56_conv;
22888         }
22889         FREE(_res);
22890         CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(_res_constr);
22891 }
22892
22893 int64_t  CS_LDK_COption_TypeZ_some(int64_t o) {
22894         void* o_ptr = untag_ptr(o);
22895         CHECK_ACCESS(o_ptr);
22896         LDKType o_conv = *(LDKType*)(o_ptr);
22897         if (o_conv.free == LDKType_JCalls_free) {
22898                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22899                 LDKType_JCalls_cloned(&o_conv);
22900         }
22901         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22902         *ret_copy = COption_TypeZ_some(o_conv);
22903         int64_t ret_ref = tag_ptr(ret_copy, true);
22904         return ret_ref;
22905 }
22906
22907 int64_t  CS_LDK_COption_TypeZ_none() {
22908         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22909         *ret_copy = COption_TypeZ_none();
22910         int64_t ret_ref = tag_ptr(ret_copy, true);
22911         return ret_ref;
22912 }
22913
22914 void  CS_LDK_COption_TypeZ_free(int64_t _res) {
22915         if (!ptr_is_owned(_res)) return;
22916         void* _res_ptr = untag_ptr(_res);
22917         CHECK_ACCESS(_res_ptr);
22918         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
22919         FREE(untag_ptr(_res));
22920         COption_TypeZ_free(_res_conv);
22921 }
22922
22923 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
22924         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22925         *ret_copy = COption_TypeZ_clone(arg);
22926         int64_t ret_ref = tag_ptr(ret_copy, true);
22927         return ret_ref;
22928 }
22929 int64_t  CS_LDK_COption_TypeZ_clone_ptr(int64_t arg) {
22930         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
22931         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
22932         return ret_conv;
22933 }
22934
22935 int64_t  CS_LDK_COption_TypeZ_clone(int64_t orig) {
22936         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
22937         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22938         *ret_copy = COption_TypeZ_clone(orig_conv);
22939         int64_t ret_ref = tag_ptr(ret_copy, true);
22940         return ret_ref;
22941 }
22942
22943 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_ok(int64_t o) {
22944         void* o_ptr = untag_ptr(o);
22945         CHECK_ACCESS(o_ptr);
22946         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
22947         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
22948         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22949         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
22950         return tag_ptr(ret_conv, true);
22951 }
22952
22953 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_err(int64_t e) {
22954         void* e_ptr = untag_ptr(e);
22955         CHECK_ACCESS(e_ptr);
22956         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22957         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22958         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22959         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
22960         return tag_ptr(ret_conv, true);
22961 }
22962
22963 jboolean  CS_LDK_CResult_COption_TypeZDecodeErrorZ_is_ok(int64_t o) {
22964         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
22965         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
22966         return ret_conv;
22967 }
22968
22969 void  CS_LDK_CResult_COption_TypeZDecodeErrorZ_free(int64_t _res) {
22970         if (!ptr_is_owned(_res)) return;
22971         void* _res_ptr = untag_ptr(_res);
22972         CHECK_ACCESS(_res_ptr);
22973         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
22974         FREE(untag_ptr(_res));
22975         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
22976 }
22977
22978 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
22979         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22980         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
22981         return tag_ptr(ret_conv, true);
22982 }
22983 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_clone_ptr(int64_t arg) {
22984         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
22985         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
22986         return ret_conv;
22987 }
22988
22989 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_clone(int64_t orig) {
22990         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
22991         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22992         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
22993         return tag_ptr(ret_conv, true);
22994 }
22995
22996 int64_t  CS_LDK_COption_SocketAddressZ_some(int64_t o) {
22997         void* o_ptr = untag_ptr(o);
22998         CHECK_ACCESS(o_ptr);
22999         LDKSocketAddress o_conv = *(LDKSocketAddress*)(o_ptr);
23000         o_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(o));
23001         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
23002         *ret_copy = COption_SocketAddressZ_some(o_conv);
23003         int64_t ret_ref = tag_ptr(ret_copy, true);
23004         return ret_ref;
23005 }
23006
23007 int64_t  CS_LDK_COption_SocketAddressZ_none() {
23008         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
23009         *ret_copy = COption_SocketAddressZ_none();
23010         int64_t ret_ref = tag_ptr(ret_copy, true);
23011         return ret_ref;
23012 }
23013
23014 void  CS_LDK_COption_SocketAddressZ_free(int64_t _res) {
23015         if (!ptr_is_owned(_res)) return;
23016         void* _res_ptr = untag_ptr(_res);
23017         CHECK_ACCESS(_res_ptr);
23018         LDKCOption_SocketAddressZ _res_conv = *(LDKCOption_SocketAddressZ*)(_res_ptr);
23019         FREE(untag_ptr(_res));
23020         COption_SocketAddressZ_free(_res_conv);
23021 }
23022
23023 static inline uint64_t COption_SocketAddressZ_clone_ptr(LDKCOption_SocketAddressZ *NONNULL_PTR arg) {
23024         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
23025         *ret_copy = COption_SocketAddressZ_clone(arg);
23026         int64_t ret_ref = tag_ptr(ret_copy, true);
23027         return ret_ref;
23028 }
23029 int64_t  CS_LDK_COption_SocketAddressZ_clone_ptr(int64_t arg) {
23030         LDKCOption_SocketAddressZ* arg_conv = (LDKCOption_SocketAddressZ*)untag_ptr(arg);
23031         int64_t ret_conv = COption_SocketAddressZ_clone_ptr(arg_conv);
23032         return ret_conv;
23033 }
23034
23035 int64_t  CS_LDK_COption_SocketAddressZ_clone(int64_t orig) {
23036         LDKCOption_SocketAddressZ* orig_conv = (LDKCOption_SocketAddressZ*)untag_ptr(orig);
23037         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
23038         *ret_copy = COption_SocketAddressZ_clone(orig_conv);
23039         int64_t ret_ref = tag_ptr(ret_copy, true);
23040         return ret_ref;
23041 }
23042
23043 static inline uint64_t C2Tuple_PublicKeyCOption_SocketAddressZZ_clone_ptr(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ *NONNULL_PTR arg) {
23044         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKC2Tuple_PublicKeyCOption_SocketAddressZZ");
23045         *ret_conv = C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(arg);
23046         return tag_ptr(ret_conv, true);
23047 }
23048 int64_t  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_clone_ptr(int64_t arg) {
23049         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* arg_conv = (LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)untag_ptr(arg);
23050         int64_t ret_conv = C2Tuple_PublicKeyCOption_SocketAddressZZ_clone_ptr(arg_conv);
23051         return ret_conv;
23052 }
23053
23054 int64_t  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(int64_t orig) {
23055         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* orig_conv = (LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)untag_ptr(orig);
23056         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKC2Tuple_PublicKeyCOption_SocketAddressZZ");
23057         *ret_conv = C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(orig_conv);
23058         return tag_ptr(ret_conv, true);
23059 }
23060
23061 int64_t  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_new(int8_tArray a, int64_t b) {
23062         LDKPublicKey a_ref;
23063         CHECK(a->arr_len == 33);
23064         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
23065         void* b_ptr = untag_ptr(b);
23066         CHECK_ACCESS(b_ptr);
23067         LDKCOption_SocketAddressZ b_conv = *(LDKCOption_SocketAddressZ*)(b_ptr);
23068         b_conv = COption_SocketAddressZ_clone((LDKCOption_SocketAddressZ*)untag_ptr(b));
23069         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKC2Tuple_PublicKeyCOption_SocketAddressZZ");
23070         *ret_conv = C2Tuple_PublicKeyCOption_SocketAddressZZ_new(a_ref, b_conv);
23071         return tag_ptr(ret_conv, true);
23072 }
23073
23074 void  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_free(int64_t _res) {
23075         if (!ptr_is_owned(_res)) return;
23076         void* _res_ptr = untag_ptr(_res);
23077         CHECK_ACCESS(_res_ptr);
23078         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ _res_conv = *(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)(_res_ptr);
23079         FREE(untag_ptr(_res));
23080         C2Tuple_PublicKeyCOption_SocketAddressZZ_free(_res_conv);
23081 }
23082
23083 void  CS_LDK_CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_free(int64_tArray _res) {
23084         LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ _res_constr;
23085         _res_constr.datalen = _res->arr_len;
23086         if (_res_constr.datalen > 0)
23087                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ Elements");
23088         else
23089                 _res_constr.data = NULL;
23090         int64_t* _res_vals = _res->elems;
23091         for (size_t r = 0; r < _res_constr.datalen; r++) {
23092                 int64_t _res_conv_43 = _res_vals[r];
23093                 void* _res_conv_43_ptr = untag_ptr(_res_conv_43);
23094                 CHECK_ACCESS(_res_conv_43_ptr);
23095                 LDKC2Tuple_PublicKeyCOption_SocketAddressZZ _res_conv_43_conv = *(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)(_res_conv_43_ptr);
23096                 FREE(untag_ptr(_res_conv_43));
23097                 _res_constr.data[r] = _res_conv_43_conv;
23098         }
23099         FREE(_res);
23100         CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_free(_res_constr);
23101 }
23102
23103 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
23104         LDKCVec_u8Z o_ref;
23105         o_ref.datalen = o->arr_len;
23106         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23107         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
23108         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23109         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
23110         return tag_ptr(ret_conv, true);
23111 }
23112
23113 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_err(int64_t e) {
23114         LDKPeerHandleError e_conv;
23115         e_conv.inner = untag_ptr(e);
23116         e_conv.is_owned = ptr_is_owned(e);
23117         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23118         e_conv = PeerHandleError_clone(&e_conv);
23119         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23120         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
23121         return tag_ptr(ret_conv, true);
23122 }
23123
23124 jboolean  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(int64_t o) {
23125         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23126         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23127         return ret_conv;
23128 }
23129
23130 void  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_free(int64_t _res) {
23131         if (!ptr_is_owned(_res)) return;
23132         void* _res_ptr = untag_ptr(_res);
23133         CHECK_ACCESS(_res_ptr);
23134         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23135         FREE(untag_ptr(_res));
23136         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23137 }
23138
23139 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23140         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23141         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23142         return tag_ptr(ret_conv, true);
23143 }
23144 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(int64_t arg) {
23145         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23146         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23147         return ret_conv;
23148 }
23149
23150 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_clone(int64_t orig) {
23151         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23152         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23153         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23154         return tag_ptr(ret_conv, true);
23155 }
23156
23157 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_ok() {
23158         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23159         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23160         return tag_ptr(ret_conv, true);
23161 }
23162
23163 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_err(int64_t e) {
23164         LDKPeerHandleError e_conv;
23165         e_conv.inner = untag_ptr(e);
23166         e_conv.is_owned = ptr_is_owned(e);
23167         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23168         e_conv = PeerHandleError_clone(&e_conv);
23169         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23170         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23171         return tag_ptr(ret_conv, true);
23172 }
23173
23174 jboolean  CS_LDK_CResult_NonePeerHandleErrorZ_is_ok(int64_t o) {
23175         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23176         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23177         return ret_conv;
23178 }
23179
23180 void  CS_LDK_CResult_NonePeerHandleErrorZ_free(int64_t _res) {
23181         if (!ptr_is_owned(_res)) return;
23182         void* _res_ptr = untag_ptr(_res);
23183         CHECK_ACCESS(_res_ptr);
23184         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23185         FREE(untag_ptr(_res));
23186         CResult_NonePeerHandleErrorZ_free(_res_conv);
23187 }
23188
23189 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23190         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23191         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23192         return tag_ptr(ret_conv, true);
23193 }
23194 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_clone_ptr(int64_t arg) {
23195         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23196         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23197         return ret_conv;
23198 }
23199
23200 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_clone(int64_t orig) {
23201         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23202         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23203         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23204         return tag_ptr(ret_conv, true);
23205 }
23206
23207 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
23208         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23209         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23210         return tag_ptr(ret_conv, true);
23211 }
23212
23213 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_err(int64_t e) {
23214         LDKPeerHandleError e_conv;
23215         e_conv.inner = untag_ptr(e);
23216         e_conv.is_owned = ptr_is_owned(e);
23217         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23218         e_conv = PeerHandleError_clone(&e_conv);
23219         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23220         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23221         return tag_ptr(ret_conv, true);
23222 }
23223
23224 jboolean  CS_LDK_CResult_boolPeerHandleErrorZ_is_ok(int64_t o) {
23225         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23226         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23227         return ret_conv;
23228 }
23229
23230 void  CS_LDK_CResult_boolPeerHandleErrorZ_free(int64_t _res) {
23231         if (!ptr_is_owned(_res)) return;
23232         void* _res_ptr = untag_ptr(_res);
23233         CHECK_ACCESS(_res_ptr);
23234         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23235         FREE(untag_ptr(_res));
23236         CResult_boolPeerHandleErrorZ_free(_res_conv);
23237 }
23238
23239 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23240         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23241         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23242         return tag_ptr(ret_conv, true);
23243 }
23244 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_clone_ptr(int64_t arg) {
23245         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
23246         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
23247         return ret_conv;
23248 }
23249
23250 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_clone(int64_t orig) {
23251         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
23252         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23253         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
23254         return tag_ptr(ret_conv, true);
23255 }
23256
23257 int64_t  CS_LDK_CResult_u32GraphSyncErrorZ_ok(int32_t o) {
23258         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23259         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
23260         return tag_ptr(ret_conv, true);
23261 }
23262
23263 int64_t  CS_LDK_CResult_u32GraphSyncErrorZ_err(int64_t e) {
23264         void* e_ptr = untag_ptr(e);
23265         CHECK_ACCESS(e_ptr);
23266         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
23267         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
23268         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23269         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
23270         return tag_ptr(ret_conv, true);
23271 }
23272
23273 jboolean  CS_LDK_CResult_u32GraphSyncErrorZ_is_ok(int64_t o) {
23274         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
23275         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
23276         return ret_conv;
23277 }
23278
23279 void  CS_LDK_CResult_u32GraphSyncErrorZ_free(int64_t _res) {
23280         if (!ptr_is_owned(_res)) return;
23281         void* _res_ptr = untag_ptr(_res);
23282         CHECK_ACCESS(_res_ptr);
23283         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
23284         FREE(untag_ptr(_res));
23285         CResult_u32GraphSyncErrorZ_free(_res_conv);
23286 }
23287
23288 int64_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_ok(int8_tArray o) {
23289         LDKCVec_u8Z o_ref;
23290         o_ref.datalen = o->arr_len;
23291         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23292         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
23293         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
23294         *ret_conv = CResult_CVec_u8ZIOErrorZ_ok(o_ref);
23295         return tag_ptr(ret_conv, true);
23296 }
23297
23298 int64_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_err(int32_t e) {
23299         LDKIOError e_conv = LDKIOError_from_cs(e);
23300         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
23301         *ret_conv = CResult_CVec_u8ZIOErrorZ_err(e_conv);
23302         return tag_ptr(ret_conv, true);
23303 }
23304
23305 jboolean  CS_LDK_CResult_CVec_u8ZIOErrorZ_is_ok(int64_t o) {
23306         LDKCResult_CVec_u8ZIOErrorZ* o_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(o);
23307         jboolean ret_conv = CResult_CVec_u8ZIOErrorZ_is_ok(o_conv);
23308         return ret_conv;
23309 }
23310
23311 void  CS_LDK_CResult_CVec_u8ZIOErrorZ_free(int64_t _res) {
23312         if (!ptr_is_owned(_res)) return;
23313         void* _res_ptr = untag_ptr(_res);
23314         CHECK_ACCESS(_res_ptr);
23315         LDKCResult_CVec_u8ZIOErrorZ _res_conv = *(LDKCResult_CVec_u8ZIOErrorZ*)(_res_ptr);
23316         FREE(untag_ptr(_res));
23317         CResult_CVec_u8ZIOErrorZ_free(_res_conv);
23318 }
23319
23320 static inline uint64_t CResult_CVec_u8ZIOErrorZ_clone_ptr(LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR arg) {
23321         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
23322         *ret_conv = CResult_CVec_u8ZIOErrorZ_clone(arg);
23323         return tag_ptr(ret_conv, true);
23324 }
23325 int64_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_clone_ptr(int64_t arg) {
23326         LDKCResult_CVec_u8ZIOErrorZ* arg_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(arg);
23327         int64_t ret_conv = CResult_CVec_u8ZIOErrorZ_clone_ptr(arg_conv);
23328         return ret_conv;
23329 }
23330
23331 int64_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_clone(int64_t orig) {
23332         LDKCResult_CVec_u8ZIOErrorZ* orig_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(orig);
23333         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
23334         *ret_conv = CResult_CVec_u8ZIOErrorZ_clone(orig_conv);
23335         return tag_ptr(ret_conv, true);
23336 }
23337
23338 void  CS_LDK_CVec_StrZ_free(ptrArray _res) {
23339         LDKCVec_StrZ _res_constr;
23340         _res_constr.datalen = _res->arr_len;
23341         if (_res_constr.datalen > 0)
23342                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKStr), "LDKCVec_StrZ Elements");
23343         else
23344                 _res_constr.data = NULL;
23345         jstring* _res_vals = (void*) _res->elems;
23346         for (size_t i = 0; i < _res_constr.datalen; i++) {
23347                 jstring _res_conv_8 = _res_vals[i];
23348                 LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
23349                 _res_constr.data[i] = dummy;
23350         }
23351         FREE(_res);
23352         CVec_StrZ_free(_res_constr);
23353 }
23354
23355 int64_t  CS_LDK_CResult_CVec_StrZIOErrorZ_ok(ptrArray o) {
23356         LDKCVec_StrZ o_constr;
23357         o_constr.datalen = o->arr_len;
23358         if (o_constr.datalen > 0)
23359                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKStr), "LDKCVec_StrZ Elements");
23360         else
23361                 o_constr.data = NULL;
23362         jstring* o_vals = (void*) o->elems;
23363         for (size_t i = 0; i < o_constr.datalen; i++) {
23364                 jstring o_conv_8 = o_vals[i];
23365                 LDKStr o_conv_8_conv = str_ref_to_owned_c(o_conv_8);
23366                 o_constr.data[i] = o_conv_8_conv;
23367         }
23368         FREE(o);
23369         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
23370         *ret_conv = CResult_CVec_StrZIOErrorZ_ok(o_constr);
23371         return tag_ptr(ret_conv, true);
23372 }
23373
23374 int64_t  CS_LDK_CResult_CVec_StrZIOErrorZ_err(int32_t e) {
23375         LDKIOError e_conv = LDKIOError_from_cs(e);
23376         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
23377         *ret_conv = CResult_CVec_StrZIOErrorZ_err(e_conv);
23378         return tag_ptr(ret_conv, true);
23379 }
23380
23381 jboolean  CS_LDK_CResult_CVec_StrZIOErrorZ_is_ok(int64_t o) {
23382         LDKCResult_CVec_StrZIOErrorZ* o_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(o);
23383         jboolean ret_conv = CResult_CVec_StrZIOErrorZ_is_ok(o_conv);
23384         return ret_conv;
23385 }
23386
23387 void  CS_LDK_CResult_CVec_StrZIOErrorZ_free(int64_t _res) {
23388         if (!ptr_is_owned(_res)) return;
23389         void* _res_ptr = untag_ptr(_res);
23390         CHECK_ACCESS(_res_ptr);
23391         LDKCResult_CVec_StrZIOErrorZ _res_conv = *(LDKCResult_CVec_StrZIOErrorZ*)(_res_ptr);
23392         FREE(untag_ptr(_res));
23393         CResult_CVec_StrZIOErrorZ_free(_res_conv);
23394 }
23395
23396 static inline uint64_t CResult_CVec_StrZIOErrorZ_clone_ptr(LDKCResult_CVec_StrZIOErrorZ *NONNULL_PTR arg) {
23397         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
23398         *ret_conv = CResult_CVec_StrZIOErrorZ_clone(arg);
23399         return tag_ptr(ret_conv, true);
23400 }
23401 int64_t  CS_LDK_CResult_CVec_StrZIOErrorZ_clone_ptr(int64_t arg) {
23402         LDKCResult_CVec_StrZIOErrorZ* arg_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(arg);
23403         int64_t ret_conv = CResult_CVec_StrZIOErrorZ_clone_ptr(arg_conv);
23404         return ret_conv;
23405 }
23406
23407 int64_t  CS_LDK_CResult_CVec_StrZIOErrorZ_clone(int64_t orig) {
23408         LDKCResult_CVec_StrZIOErrorZ* orig_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(orig);
23409         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
23410         *ret_conv = CResult_CVec_StrZIOErrorZ_clone(orig_conv);
23411         return tag_ptr(ret_conv, true);
23412 }
23413
23414 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_free(int64_tArray _res) {
23415         LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ _res_constr;
23416         _res_constr.datalen = _res->arr_len;
23417         if (_res_constr.datalen > 0)
23418                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ Elements");
23419         else
23420                 _res_constr.data = NULL;
23421         int64_t* _res_vals = _res->elems;
23422         for (size_t o = 0; o < _res_constr.datalen; o++) {
23423                 int64_t _res_conv_40 = _res_vals[o];
23424                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23425                 CHECK_ACCESS(_res_conv_40_ptr);
23426                 LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ _res_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(_res_conv_40_ptr);
23427                 FREE(untag_ptr(_res_conv_40));
23428                 _res_constr.data[o] = _res_conv_40_conv;
23429         }
23430         FREE(_res);
23431         CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_free(_res_constr);
23432 }
23433
23434 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_ok(int64_tArray o) {
23435         LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ o_constr;
23436         o_constr.datalen = o->arr_len;
23437         if (o_constr.datalen > 0)
23438                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ Elements");
23439         else
23440                 o_constr.data = NULL;
23441         int64_t* o_vals = o->elems;
23442         for (size_t o = 0; o < o_constr.datalen; o++) {
23443                 int64_t o_conv_40 = o_vals[o];
23444                 void* o_conv_40_ptr = untag_ptr(o_conv_40);
23445                 CHECK_ACCESS(o_conv_40_ptr);
23446                 LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ o_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(o_conv_40_ptr);
23447                 o_conv_40_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone((LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(o_conv_40));
23448                 o_constr.data[o] = o_conv_40_conv;
23449         }
23450         FREE(o);
23451         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
23452         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_ok(o_constr);
23453         return tag_ptr(ret_conv, true);
23454 }
23455
23456 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_err(int32_t e) {
23457         LDKIOError e_conv = LDKIOError_from_cs(e);
23458         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
23459         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_err(e_conv);
23460         return tag_ptr(ret_conv, true);
23461 }
23462
23463 jboolean  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_is_ok(int64_t o) {
23464         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(o);
23465         jboolean ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_is_ok(o_conv);
23466         return ret_conv;
23467 }
23468
23469 void  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_free(int64_t _res) {
23470         if (!ptr_is_owned(_res)) return;
23471         void* _res_ptr = untag_ptr(_res);
23472         CHECK_ACCESS(_res_ptr);
23473         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)(_res_ptr);
23474         FREE(untag_ptr(_res));
23475         CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_free(_res_conv);
23476 }
23477
23478 static inline uint64_t CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ *NONNULL_PTR arg) {
23479         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
23480         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone(arg);
23481         return tag_ptr(ret_conv, true);
23482 }
23483 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone_ptr(int64_t arg) {
23484         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(arg);
23485         int64_t ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone_ptr(arg_conv);
23486         return ret_conv;
23487 }
23488
23489 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone(int64_t orig) {
23490         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(orig);
23491         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
23492         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone(orig_conv);
23493         return tag_ptr(ret_conv, true);
23494 }
23495
23496 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_ok(int64_t o) {
23497         void* o_ptr = untag_ptr(o);
23498         CHECK_ACCESS(o_ptr);
23499         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(o_ptr);
23500         o_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone((LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(o));
23501         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
23502         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_ok(o_conv);
23503         return tag_ptr(ret_conv, true);
23504 }
23505
23506 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_err(int32_t e) {
23507         LDKIOError e_conv = LDKIOError_from_cs(e);
23508         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
23509         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_err(e_conv);
23510         return tag_ptr(ret_conv, true);
23511 }
23512
23513 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_is_ok(int64_t o) {
23514         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(o);
23515         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_is_ok(o_conv);
23516         return ret_conv;
23517 }
23518
23519 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_free(int64_t _res) {
23520         if (!ptr_is_owned(_res)) return;
23521         void* _res_ptr = untag_ptr(_res);
23522         CHECK_ACCESS(_res_ptr);
23523         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)(_res_ptr);
23524         FREE(untag_ptr(_res));
23525         CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_free(_res_conv);
23526 }
23527
23528 static inline uint64_t CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone_ptr(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ *NONNULL_PTR arg) {
23529         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
23530         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(arg);
23531         return tag_ptr(ret_conv, true);
23532 }
23533 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone_ptr(int64_t arg) {
23534         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* arg_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(arg);
23535         int64_t ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone_ptr(arg_conv);
23536         return ret_conv;
23537 }
23538
23539 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(int64_t orig) {
23540         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* orig_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(orig);
23541         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
23542         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(orig_conv);
23543         return tag_ptr(ret_conv, true);
23544 }
23545
23546 int64_t  CS_LDK_COption_SecretKeyZ_some(int8_tArray o) {
23547         LDKSecretKey o_ref;
23548         CHECK(o->arr_len == 32);
23549         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
23550         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
23551         *ret_copy = COption_SecretKeyZ_some(o_ref);
23552         int64_t ret_ref = tag_ptr(ret_copy, true);
23553         return ret_ref;
23554 }
23555
23556 int64_t  CS_LDK_COption_SecretKeyZ_none() {
23557         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
23558         *ret_copy = COption_SecretKeyZ_none();
23559         int64_t ret_ref = tag_ptr(ret_copy, true);
23560         return ret_ref;
23561 }
23562
23563 void  CS_LDK_COption_SecretKeyZ_free(int64_t _res) {
23564         if (!ptr_is_owned(_res)) return;
23565         void* _res_ptr = untag_ptr(_res);
23566         CHECK_ACCESS(_res_ptr);
23567         LDKCOption_SecretKeyZ _res_conv = *(LDKCOption_SecretKeyZ*)(_res_ptr);
23568         FREE(untag_ptr(_res));
23569         COption_SecretKeyZ_free(_res_conv);
23570 }
23571
23572 static inline uint64_t COption_SecretKeyZ_clone_ptr(LDKCOption_SecretKeyZ *NONNULL_PTR arg) {
23573         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
23574         *ret_copy = COption_SecretKeyZ_clone(arg);
23575         int64_t ret_ref = tag_ptr(ret_copy, true);
23576         return ret_ref;
23577 }
23578 int64_t  CS_LDK_COption_SecretKeyZ_clone_ptr(int64_t arg) {
23579         LDKCOption_SecretKeyZ* arg_conv = (LDKCOption_SecretKeyZ*)untag_ptr(arg);
23580         int64_t ret_conv = COption_SecretKeyZ_clone_ptr(arg_conv);
23581         return ret_conv;
23582 }
23583
23584 int64_t  CS_LDK_COption_SecretKeyZ_clone(int64_t orig) {
23585         LDKCOption_SecretKeyZ* orig_conv = (LDKCOption_SecretKeyZ*)untag_ptr(orig);
23586         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
23587         *ret_copy = COption_SecretKeyZ_clone(orig_conv);
23588         int64_t ret_ref = tag_ptr(ret_copy, true);
23589         return ret_ref;
23590 }
23591
23592 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_ok(int64_t o) {
23593         LDKVerifiedInvoiceRequest o_conv;
23594         o_conv.inner = untag_ptr(o);
23595         o_conv.is_owned = ptr_is_owned(o);
23596         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23597         o_conv = VerifiedInvoiceRequest_clone(&o_conv);
23598         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
23599         *ret_conv = CResult_VerifiedInvoiceRequestNoneZ_ok(o_conv);
23600         return tag_ptr(ret_conv, true);
23601 }
23602
23603 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_err() {
23604         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
23605         *ret_conv = CResult_VerifiedInvoiceRequestNoneZ_err();
23606         return tag_ptr(ret_conv, true);
23607 }
23608
23609 jboolean  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_is_ok(int64_t o) {
23610         LDKCResult_VerifiedInvoiceRequestNoneZ* o_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(o);
23611         jboolean ret_conv = CResult_VerifiedInvoiceRequestNoneZ_is_ok(o_conv);
23612         return ret_conv;
23613 }
23614
23615 void  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_free(int64_t _res) {
23616         if (!ptr_is_owned(_res)) return;
23617         void* _res_ptr = untag_ptr(_res);
23618         CHECK_ACCESS(_res_ptr);
23619         LDKCResult_VerifiedInvoiceRequestNoneZ _res_conv = *(LDKCResult_VerifiedInvoiceRequestNoneZ*)(_res_ptr);
23620         FREE(untag_ptr(_res));
23621         CResult_VerifiedInvoiceRequestNoneZ_free(_res_conv);
23622 }
23623
23624 static inline uint64_t CResult_VerifiedInvoiceRequestNoneZ_clone_ptr(LDKCResult_VerifiedInvoiceRequestNoneZ *NONNULL_PTR arg) {
23625         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
23626         *ret_conv = CResult_VerifiedInvoiceRequestNoneZ_clone(arg);
23627         return tag_ptr(ret_conv, true);
23628 }
23629 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_clone_ptr(int64_t arg) {
23630         LDKCResult_VerifiedInvoiceRequestNoneZ* arg_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(arg);
23631         int64_t ret_conv = CResult_VerifiedInvoiceRequestNoneZ_clone_ptr(arg_conv);
23632         return ret_conv;
23633 }
23634
23635 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_clone(int64_t orig) {
23636         LDKCResult_VerifiedInvoiceRequestNoneZ* orig_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(orig);
23637         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
23638         *ret_conv = CResult_VerifiedInvoiceRequestNoneZ_clone(orig_conv);
23639         return tag_ptr(ret_conv, true);
23640 }
23641
23642 int32_t  CS_LDK_COption_NoneZ_some() {
23643         int32_t ret_conv = LDKCOption_NoneZ_to_cs(COption_NoneZ_some());
23644         return ret_conv;
23645 }
23646
23647 int32_t  CS_LDK_COption_NoneZ_none() {
23648         int32_t ret_conv = LDKCOption_NoneZ_to_cs(COption_NoneZ_none());
23649         return ret_conv;
23650 }
23651
23652 void  CS_LDK_COption_NoneZ_free(int32_t _res) {
23653         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_cs(_res);
23654         COption_NoneZ_free(_res_conv);
23655 }
23656
23657 void  CS_LDK_CVec_WitnessZ_free(ptrArray _res) {
23658         LDKCVec_WitnessZ _res_constr;
23659         _res_constr.datalen = _res->arr_len;
23660         if (_res_constr.datalen > 0)
23661                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKWitness), "LDKCVec_WitnessZ Elements");
23662         else
23663                 _res_constr.data = NULL;
23664         int8_tArray* _res_vals = (void*) _res->elems;
23665         for (size_t i = 0; i < _res_constr.datalen; i++) {
23666                 int8_tArray _res_conv_8 = _res_vals[i];
23667                 LDKWitness _res_conv_8_ref;
23668                 _res_conv_8_ref.datalen = _res_conv_8->arr_len;
23669                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKWitness Bytes");
23670                 memcpy(_res_conv_8_ref.data, _res_conv_8->elems, _res_conv_8_ref.datalen); FREE(_res_conv_8);
23671                 _res_conv_8_ref.data_is_owned = true;
23672                 _res_constr.data[i] = _res_conv_8_ref;
23673         }
23674         FREE(_res);
23675         CVec_WitnessZ_free(_res_constr);
23676 }
23677
23678 int64_t  CS_LDK_COption_i64Z_some(int64_t o) {
23679         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
23680         *ret_copy = COption_i64Z_some(o);
23681         int64_t ret_ref = tag_ptr(ret_copy, true);
23682         return ret_ref;
23683 }
23684
23685 int64_t  CS_LDK_COption_i64Z_none() {
23686         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
23687         *ret_copy = COption_i64Z_none();
23688         int64_t ret_ref = tag_ptr(ret_copy, true);
23689         return ret_ref;
23690 }
23691
23692 void  CS_LDK_COption_i64Z_free(int64_t _res) {
23693         if (!ptr_is_owned(_res)) return;
23694         void* _res_ptr = untag_ptr(_res);
23695         CHECK_ACCESS(_res_ptr);
23696         LDKCOption_i64Z _res_conv = *(LDKCOption_i64Z*)(_res_ptr);
23697         FREE(untag_ptr(_res));
23698         COption_i64Z_free(_res_conv);
23699 }
23700
23701 static inline uint64_t COption_i64Z_clone_ptr(LDKCOption_i64Z *NONNULL_PTR arg) {
23702         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
23703         *ret_copy = COption_i64Z_clone(arg);
23704         int64_t ret_ref = tag_ptr(ret_copy, true);
23705         return ret_ref;
23706 }
23707 int64_t  CS_LDK_COption_i64Z_clone_ptr(int64_t arg) {
23708         LDKCOption_i64Z* arg_conv = (LDKCOption_i64Z*)untag_ptr(arg);
23709         int64_t ret_conv = COption_i64Z_clone_ptr(arg_conv);
23710         return ret_conv;
23711 }
23712
23713 int64_t  CS_LDK_COption_i64Z_clone(int64_t orig) {
23714         LDKCOption_i64Z* orig_conv = (LDKCOption_i64Z*)untag_ptr(orig);
23715         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
23716         *ret_copy = COption_i64Z_clone(orig_conv);
23717         int64_t ret_ref = tag_ptr(ret_copy, true);
23718         return ret_ref;
23719 }
23720
23721 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_ok(int64_t o) {
23722         void* o_ptr = untag_ptr(o);
23723         CHECK_ACCESS(o_ptr);
23724         LDKSocketAddress o_conv = *(LDKSocketAddress*)(o_ptr);
23725         o_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(o));
23726         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
23727         *ret_conv = CResult_SocketAddressDecodeErrorZ_ok(o_conv);
23728         return tag_ptr(ret_conv, true);
23729 }
23730
23731 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_err(int64_t e) {
23732         void* e_ptr = untag_ptr(e);
23733         CHECK_ACCESS(e_ptr);
23734         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23735         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23736         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
23737         *ret_conv = CResult_SocketAddressDecodeErrorZ_err(e_conv);
23738         return tag_ptr(ret_conv, true);
23739 }
23740
23741 jboolean  CS_LDK_CResult_SocketAddressDecodeErrorZ_is_ok(int64_t o) {
23742         LDKCResult_SocketAddressDecodeErrorZ* o_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(o);
23743         jboolean ret_conv = CResult_SocketAddressDecodeErrorZ_is_ok(o_conv);
23744         return ret_conv;
23745 }
23746
23747 void  CS_LDK_CResult_SocketAddressDecodeErrorZ_free(int64_t _res) {
23748         if (!ptr_is_owned(_res)) return;
23749         void* _res_ptr = untag_ptr(_res);
23750         CHECK_ACCESS(_res_ptr);
23751         LDKCResult_SocketAddressDecodeErrorZ _res_conv = *(LDKCResult_SocketAddressDecodeErrorZ*)(_res_ptr);
23752         FREE(untag_ptr(_res));
23753         CResult_SocketAddressDecodeErrorZ_free(_res_conv);
23754 }
23755
23756 static inline uint64_t CResult_SocketAddressDecodeErrorZ_clone_ptr(LDKCResult_SocketAddressDecodeErrorZ *NONNULL_PTR arg) {
23757         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
23758         *ret_conv = CResult_SocketAddressDecodeErrorZ_clone(arg);
23759         return tag_ptr(ret_conv, true);
23760 }
23761 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_clone_ptr(int64_t arg) {
23762         LDKCResult_SocketAddressDecodeErrorZ* arg_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(arg);
23763         int64_t ret_conv = CResult_SocketAddressDecodeErrorZ_clone_ptr(arg_conv);
23764         return ret_conv;
23765 }
23766
23767 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_clone(int64_t orig) {
23768         LDKCResult_SocketAddressDecodeErrorZ* orig_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(orig);
23769         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
23770         *ret_conv = CResult_SocketAddressDecodeErrorZ_clone(orig_conv);
23771         return tag_ptr(ret_conv, true);
23772 }
23773
23774 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_ok(int64_t o) {
23775         void* o_ptr = untag_ptr(o);
23776         CHECK_ACCESS(o_ptr);
23777         LDKSocketAddress o_conv = *(LDKSocketAddress*)(o_ptr);
23778         o_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(o));
23779         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
23780         *ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_ok(o_conv);
23781         return tag_ptr(ret_conv, true);
23782 }
23783
23784 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_err(int32_t e) {
23785         LDKSocketAddressParseError e_conv = LDKSocketAddressParseError_from_cs(e);
23786         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
23787         *ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_err(e_conv);
23788         return tag_ptr(ret_conv, true);
23789 }
23790
23791 jboolean  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_is_ok(int64_t o) {
23792         LDKCResult_SocketAddressSocketAddressParseErrorZ* o_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(o);
23793         jboolean ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_is_ok(o_conv);
23794         return ret_conv;
23795 }
23796
23797 void  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_free(int64_t _res) {
23798         if (!ptr_is_owned(_res)) return;
23799         void* _res_ptr = untag_ptr(_res);
23800         CHECK_ACCESS(_res_ptr);
23801         LDKCResult_SocketAddressSocketAddressParseErrorZ _res_conv = *(LDKCResult_SocketAddressSocketAddressParseErrorZ*)(_res_ptr);
23802         FREE(untag_ptr(_res));
23803         CResult_SocketAddressSocketAddressParseErrorZ_free(_res_conv);
23804 }
23805
23806 static inline uint64_t CResult_SocketAddressSocketAddressParseErrorZ_clone_ptr(LDKCResult_SocketAddressSocketAddressParseErrorZ *NONNULL_PTR arg) {
23807         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
23808         *ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_clone(arg);
23809         return tag_ptr(ret_conv, true);
23810 }
23811 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_clone_ptr(int64_t arg) {
23812         LDKCResult_SocketAddressSocketAddressParseErrorZ* arg_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(arg);
23813         int64_t ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_clone_ptr(arg_conv);
23814         return ret_conv;
23815 }
23816
23817 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_clone(int64_t orig) {
23818         LDKCResult_SocketAddressSocketAddressParseErrorZ* orig_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(orig);
23819         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
23820         *ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_clone(orig_conv);
23821         return tag_ptr(ret_conv, true);
23822 }
23823
23824 void  CS_LDK_CVec_UpdateAddHTLCZ_free(int64_tArray _res) {
23825         LDKCVec_UpdateAddHTLCZ _res_constr;
23826         _res_constr.datalen = _res->arr_len;
23827         if (_res_constr.datalen > 0)
23828                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23829         else
23830                 _res_constr.data = NULL;
23831         int64_t* _res_vals = _res->elems;
23832         for (size_t p = 0; p < _res_constr.datalen; p++) {
23833                 int64_t _res_conv_15 = _res_vals[p];
23834                 LDKUpdateAddHTLC _res_conv_15_conv;
23835                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
23836                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
23837                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
23838                 _res_constr.data[p] = _res_conv_15_conv;
23839         }
23840         FREE(_res);
23841         CVec_UpdateAddHTLCZ_free(_res_constr);
23842 }
23843
23844 void  CS_LDK_CVec_UpdateFulfillHTLCZ_free(int64_tArray _res) {
23845         LDKCVec_UpdateFulfillHTLCZ _res_constr;
23846         _res_constr.datalen = _res->arr_len;
23847         if (_res_constr.datalen > 0)
23848                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23849         else
23850                 _res_constr.data = NULL;
23851         int64_t* _res_vals = _res->elems;
23852         for (size_t t = 0; t < _res_constr.datalen; t++) {
23853                 int64_t _res_conv_19 = _res_vals[t];
23854                 LDKUpdateFulfillHTLC _res_conv_19_conv;
23855                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
23856                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
23857                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23858                 _res_constr.data[t] = _res_conv_19_conv;
23859         }
23860         FREE(_res);
23861         CVec_UpdateFulfillHTLCZ_free(_res_constr);
23862 }
23863
23864 void  CS_LDK_CVec_UpdateFailHTLCZ_free(int64_tArray _res) {
23865         LDKCVec_UpdateFailHTLCZ _res_constr;
23866         _res_constr.datalen = _res->arr_len;
23867         if (_res_constr.datalen > 0)
23868                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23869         else
23870                 _res_constr.data = NULL;
23871         int64_t* _res_vals = _res->elems;
23872         for (size_t q = 0; q < _res_constr.datalen; q++) {
23873                 int64_t _res_conv_16 = _res_vals[q];
23874                 LDKUpdateFailHTLC _res_conv_16_conv;
23875                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
23876                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
23877                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
23878                 _res_constr.data[q] = _res_conv_16_conv;
23879         }
23880         FREE(_res);
23881         CVec_UpdateFailHTLCZ_free(_res_constr);
23882 }
23883
23884 void  CS_LDK_CVec_UpdateFailMalformedHTLCZ_free(int64_tArray _res) {
23885         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
23886         _res_constr.datalen = _res->arr_len;
23887         if (_res_constr.datalen > 0)
23888                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23889         else
23890                 _res_constr.data = NULL;
23891         int64_t* _res_vals = _res->elems;
23892         for (size_t z = 0; z < _res_constr.datalen; z++) {
23893                 int64_t _res_conv_25 = _res_vals[z];
23894                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
23895                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
23896                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
23897                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
23898                 _res_constr.data[z] = _res_conv_25_conv;
23899         }
23900         FREE(_res);
23901         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
23902 }
23903
23904 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_ok(int64_t o) {
23905         LDKAcceptChannel o_conv;
23906         o_conv.inner = untag_ptr(o);
23907         o_conv.is_owned = ptr_is_owned(o);
23908         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23909         o_conv = AcceptChannel_clone(&o_conv);
23910         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23911         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
23912         return tag_ptr(ret_conv, true);
23913 }
23914
23915 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_err(int64_t e) {
23916         void* e_ptr = untag_ptr(e);
23917         CHECK_ACCESS(e_ptr);
23918         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23919         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23920         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23921         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
23922         return tag_ptr(ret_conv, true);
23923 }
23924
23925 jboolean  CS_LDK_CResult_AcceptChannelDecodeErrorZ_is_ok(int64_t o) {
23926         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
23927         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
23928         return ret_conv;
23929 }
23930
23931 void  CS_LDK_CResult_AcceptChannelDecodeErrorZ_free(int64_t _res) {
23932         if (!ptr_is_owned(_res)) return;
23933         void* _res_ptr = untag_ptr(_res);
23934         CHECK_ACCESS(_res_ptr);
23935         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
23936         FREE(untag_ptr(_res));
23937         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
23938 }
23939
23940 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
23941         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23942         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
23943         return tag_ptr(ret_conv, true);
23944 }
23945 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_clone_ptr(int64_t arg) {
23946         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
23947         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
23948         return ret_conv;
23949 }
23950
23951 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_clone(int64_t orig) {
23952         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
23953         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23954         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
23955         return tag_ptr(ret_conv, true);
23956 }
23957
23958 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_ok(int64_t o) {
23959         LDKAcceptChannelV2 o_conv;
23960         o_conv.inner = untag_ptr(o);
23961         o_conv.is_owned = ptr_is_owned(o);
23962         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23963         o_conv = AcceptChannelV2_clone(&o_conv);
23964         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
23965         *ret_conv = CResult_AcceptChannelV2DecodeErrorZ_ok(o_conv);
23966         return tag_ptr(ret_conv, true);
23967 }
23968
23969 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_err(int64_t e) {
23970         void* e_ptr = untag_ptr(e);
23971         CHECK_ACCESS(e_ptr);
23972         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23973         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23974         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
23975         *ret_conv = CResult_AcceptChannelV2DecodeErrorZ_err(e_conv);
23976         return tag_ptr(ret_conv, true);
23977 }
23978
23979 jboolean  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_is_ok(int64_t o) {
23980         LDKCResult_AcceptChannelV2DecodeErrorZ* o_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(o);
23981         jboolean ret_conv = CResult_AcceptChannelV2DecodeErrorZ_is_ok(o_conv);
23982         return ret_conv;
23983 }
23984
23985 void  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_free(int64_t _res) {
23986         if (!ptr_is_owned(_res)) return;
23987         void* _res_ptr = untag_ptr(_res);
23988         CHECK_ACCESS(_res_ptr);
23989         LDKCResult_AcceptChannelV2DecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelV2DecodeErrorZ*)(_res_ptr);
23990         FREE(untag_ptr(_res));
23991         CResult_AcceptChannelV2DecodeErrorZ_free(_res_conv);
23992 }
23993
23994 static inline uint64_t CResult_AcceptChannelV2DecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelV2DecodeErrorZ *NONNULL_PTR arg) {
23995         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
23996         *ret_conv = CResult_AcceptChannelV2DecodeErrorZ_clone(arg);
23997         return tag_ptr(ret_conv, true);
23998 }
23999 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_clone_ptr(int64_t arg) {
24000         LDKCResult_AcceptChannelV2DecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(arg);
24001         int64_t ret_conv = CResult_AcceptChannelV2DecodeErrorZ_clone_ptr(arg_conv);
24002         return ret_conv;
24003 }
24004
24005 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_clone(int64_t orig) {
24006         LDKCResult_AcceptChannelV2DecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(orig);
24007         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
24008         *ret_conv = CResult_AcceptChannelV2DecodeErrorZ_clone(orig_conv);
24009         return tag_ptr(ret_conv, true);
24010 }
24011
24012 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_ok(int64_t o) {
24013         LDKTxAddInput o_conv;
24014         o_conv.inner = untag_ptr(o);
24015         o_conv.is_owned = ptr_is_owned(o);
24016         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24017         o_conv = TxAddInput_clone(&o_conv);
24018         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
24019         *ret_conv = CResult_TxAddInputDecodeErrorZ_ok(o_conv);
24020         return tag_ptr(ret_conv, true);
24021 }
24022
24023 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_err(int64_t e) {
24024         void* e_ptr = untag_ptr(e);
24025         CHECK_ACCESS(e_ptr);
24026         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24027         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24028         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
24029         *ret_conv = CResult_TxAddInputDecodeErrorZ_err(e_conv);
24030         return tag_ptr(ret_conv, true);
24031 }
24032
24033 jboolean  CS_LDK_CResult_TxAddInputDecodeErrorZ_is_ok(int64_t o) {
24034         LDKCResult_TxAddInputDecodeErrorZ* o_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(o);
24035         jboolean ret_conv = CResult_TxAddInputDecodeErrorZ_is_ok(o_conv);
24036         return ret_conv;
24037 }
24038
24039 void  CS_LDK_CResult_TxAddInputDecodeErrorZ_free(int64_t _res) {
24040         if (!ptr_is_owned(_res)) return;
24041         void* _res_ptr = untag_ptr(_res);
24042         CHECK_ACCESS(_res_ptr);
24043         LDKCResult_TxAddInputDecodeErrorZ _res_conv = *(LDKCResult_TxAddInputDecodeErrorZ*)(_res_ptr);
24044         FREE(untag_ptr(_res));
24045         CResult_TxAddInputDecodeErrorZ_free(_res_conv);
24046 }
24047
24048 static inline uint64_t CResult_TxAddInputDecodeErrorZ_clone_ptr(LDKCResult_TxAddInputDecodeErrorZ *NONNULL_PTR arg) {
24049         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
24050         *ret_conv = CResult_TxAddInputDecodeErrorZ_clone(arg);
24051         return tag_ptr(ret_conv, true);
24052 }
24053 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_clone_ptr(int64_t arg) {
24054         LDKCResult_TxAddInputDecodeErrorZ* arg_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(arg);
24055         int64_t ret_conv = CResult_TxAddInputDecodeErrorZ_clone_ptr(arg_conv);
24056         return ret_conv;
24057 }
24058
24059 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_clone(int64_t orig) {
24060         LDKCResult_TxAddInputDecodeErrorZ* orig_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(orig);
24061         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
24062         *ret_conv = CResult_TxAddInputDecodeErrorZ_clone(orig_conv);
24063         return tag_ptr(ret_conv, true);
24064 }
24065
24066 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_ok(int64_t o) {
24067         LDKTxAddOutput o_conv;
24068         o_conv.inner = untag_ptr(o);
24069         o_conv.is_owned = ptr_is_owned(o);
24070         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24071         o_conv = TxAddOutput_clone(&o_conv);
24072         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
24073         *ret_conv = CResult_TxAddOutputDecodeErrorZ_ok(o_conv);
24074         return tag_ptr(ret_conv, true);
24075 }
24076
24077 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_err(int64_t e) {
24078         void* e_ptr = untag_ptr(e);
24079         CHECK_ACCESS(e_ptr);
24080         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24081         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24082         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
24083         *ret_conv = CResult_TxAddOutputDecodeErrorZ_err(e_conv);
24084         return tag_ptr(ret_conv, true);
24085 }
24086
24087 jboolean  CS_LDK_CResult_TxAddOutputDecodeErrorZ_is_ok(int64_t o) {
24088         LDKCResult_TxAddOutputDecodeErrorZ* o_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(o);
24089         jboolean ret_conv = CResult_TxAddOutputDecodeErrorZ_is_ok(o_conv);
24090         return ret_conv;
24091 }
24092
24093 void  CS_LDK_CResult_TxAddOutputDecodeErrorZ_free(int64_t _res) {
24094         if (!ptr_is_owned(_res)) return;
24095         void* _res_ptr = untag_ptr(_res);
24096         CHECK_ACCESS(_res_ptr);
24097         LDKCResult_TxAddOutputDecodeErrorZ _res_conv = *(LDKCResult_TxAddOutputDecodeErrorZ*)(_res_ptr);
24098         FREE(untag_ptr(_res));
24099         CResult_TxAddOutputDecodeErrorZ_free(_res_conv);
24100 }
24101
24102 static inline uint64_t CResult_TxAddOutputDecodeErrorZ_clone_ptr(LDKCResult_TxAddOutputDecodeErrorZ *NONNULL_PTR arg) {
24103         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
24104         *ret_conv = CResult_TxAddOutputDecodeErrorZ_clone(arg);
24105         return tag_ptr(ret_conv, true);
24106 }
24107 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_clone_ptr(int64_t arg) {
24108         LDKCResult_TxAddOutputDecodeErrorZ* arg_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(arg);
24109         int64_t ret_conv = CResult_TxAddOutputDecodeErrorZ_clone_ptr(arg_conv);
24110         return ret_conv;
24111 }
24112
24113 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_clone(int64_t orig) {
24114         LDKCResult_TxAddOutputDecodeErrorZ* orig_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(orig);
24115         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
24116         *ret_conv = CResult_TxAddOutputDecodeErrorZ_clone(orig_conv);
24117         return tag_ptr(ret_conv, true);
24118 }
24119
24120 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_ok(int64_t o) {
24121         LDKTxRemoveInput o_conv;
24122         o_conv.inner = untag_ptr(o);
24123         o_conv.is_owned = ptr_is_owned(o);
24124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24125         o_conv = TxRemoveInput_clone(&o_conv);
24126         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
24127         *ret_conv = CResult_TxRemoveInputDecodeErrorZ_ok(o_conv);
24128         return tag_ptr(ret_conv, true);
24129 }
24130
24131 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_err(int64_t e) {
24132         void* e_ptr = untag_ptr(e);
24133         CHECK_ACCESS(e_ptr);
24134         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24135         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24136         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
24137         *ret_conv = CResult_TxRemoveInputDecodeErrorZ_err(e_conv);
24138         return tag_ptr(ret_conv, true);
24139 }
24140
24141 jboolean  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_is_ok(int64_t o) {
24142         LDKCResult_TxRemoveInputDecodeErrorZ* o_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(o);
24143         jboolean ret_conv = CResult_TxRemoveInputDecodeErrorZ_is_ok(o_conv);
24144         return ret_conv;
24145 }
24146
24147 void  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_free(int64_t _res) {
24148         if (!ptr_is_owned(_res)) return;
24149         void* _res_ptr = untag_ptr(_res);
24150         CHECK_ACCESS(_res_ptr);
24151         LDKCResult_TxRemoveInputDecodeErrorZ _res_conv = *(LDKCResult_TxRemoveInputDecodeErrorZ*)(_res_ptr);
24152         FREE(untag_ptr(_res));
24153         CResult_TxRemoveInputDecodeErrorZ_free(_res_conv);
24154 }
24155
24156 static inline uint64_t CResult_TxRemoveInputDecodeErrorZ_clone_ptr(LDKCResult_TxRemoveInputDecodeErrorZ *NONNULL_PTR arg) {
24157         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
24158         *ret_conv = CResult_TxRemoveInputDecodeErrorZ_clone(arg);
24159         return tag_ptr(ret_conv, true);
24160 }
24161 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_clone_ptr(int64_t arg) {
24162         LDKCResult_TxRemoveInputDecodeErrorZ* arg_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(arg);
24163         int64_t ret_conv = CResult_TxRemoveInputDecodeErrorZ_clone_ptr(arg_conv);
24164         return ret_conv;
24165 }
24166
24167 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_clone(int64_t orig) {
24168         LDKCResult_TxRemoveInputDecodeErrorZ* orig_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(orig);
24169         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
24170         *ret_conv = CResult_TxRemoveInputDecodeErrorZ_clone(orig_conv);
24171         return tag_ptr(ret_conv, true);
24172 }
24173
24174 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_ok(int64_t o) {
24175         LDKTxRemoveOutput o_conv;
24176         o_conv.inner = untag_ptr(o);
24177         o_conv.is_owned = ptr_is_owned(o);
24178         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24179         o_conv = TxRemoveOutput_clone(&o_conv);
24180         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
24181         *ret_conv = CResult_TxRemoveOutputDecodeErrorZ_ok(o_conv);
24182         return tag_ptr(ret_conv, true);
24183 }
24184
24185 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_err(int64_t e) {
24186         void* e_ptr = untag_ptr(e);
24187         CHECK_ACCESS(e_ptr);
24188         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24189         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24190         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
24191         *ret_conv = CResult_TxRemoveOutputDecodeErrorZ_err(e_conv);
24192         return tag_ptr(ret_conv, true);
24193 }
24194
24195 jboolean  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_is_ok(int64_t o) {
24196         LDKCResult_TxRemoveOutputDecodeErrorZ* o_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(o);
24197         jboolean ret_conv = CResult_TxRemoveOutputDecodeErrorZ_is_ok(o_conv);
24198         return ret_conv;
24199 }
24200
24201 void  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_free(int64_t _res) {
24202         if (!ptr_is_owned(_res)) return;
24203         void* _res_ptr = untag_ptr(_res);
24204         CHECK_ACCESS(_res_ptr);
24205         LDKCResult_TxRemoveOutputDecodeErrorZ _res_conv = *(LDKCResult_TxRemoveOutputDecodeErrorZ*)(_res_ptr);
24206         FREE(untag_ptr(_res));
24207         CResult_TxRemoveOutputDecodeErrorZ_free(_res_conv);
24208 }
24209
24210 static inline uint64_t CResult_TxRemoveOutputDecodeErrorZ_clone_ptr(LDKCResult_TxRemoveOutputDecodeErrorZ *NONNULL_PTR arg) {
24211         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
24212         *ret_conv = CResult_TxRemoveOutputDecodeErrorZ_clone(arg);
24213         return tag_ptr(ret_conv, true);
24214 }
24215 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_clone_ptr(int64_t arg) {
24216         LDKCResult_TxRemoveOutputDecodeErrorZ* arg_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(arg);
24217         int64_t ret_conv = CResult_TxRemoveOutputDecodeErrorZ_clone_ptr(arg_conv);
24218         return ret_conv;
24219 }
24220
24221 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_clone(int64_t orig) {
24222         LDKCResult_TxRemoveOutputDecodeErrorZ* orig_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(orig);
24223         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
24224         *ret_conv = CResult_TxRemoveOutputDecodeErrorZ_clone(orig_conv);
24225         return tag_ptr(ret_conv, true);
24226 }
24227
24228 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_ok(int64_t o) {
24229         LDKTxComplete o_conv;
24230         o_conv.inner = untag_ptr(o);
24231         o_conv.is_owned = ptr_is_owned(o);
24232         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24233         o_conv = TxComplete_clone(&o_conv);
24234         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
24235         *ret_conv = CResult_TxCompleteDecodeErrorZ_ok(o_conv);
24236         return tag_ptr(ret_conv, true);
24237 }
24238
24239 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_err(int64_t e) {
24240         void* e_ptr = untag_ptr(e);
24241         CHECK_ACCESS(e_ptr);
24242         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24243         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24244         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
24245         *ret_conv = CResult_TxCompleteDecodeErrorZ_err(e_conv);
24246         return tag_ptr(ret_conv, true);
24247 }
24248
24249 jboolean  CS_LDK_CResult_TxCompleteDecodeErrorZ_is_ok(int64_t o) {
24250         LDKCResult_TxCompleteDecodeErrorZ* o_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(o);
24251         jboolean ret_conv = CResult_TxCompleteDecodeErrorZ_is_ok(o_conv);
24252         return ret_conv;
24253 }
24254
24255 void  CS_LDK_CResult_TxCompleteDecodeErrorZ_free(int64_t _res) {
24256         if (!ptr_is_owned(_res)) return;
24257         void* _res_ptr = untag_ptr(_res);
24258         CHECK_ACCESS(_res_ptr);
24259         LDKCResult_TxCompleteDecodeErrorZ _res_conv = *(LDKCResult_TxCompleteDecodeErrorZ*)(_res_ptr);
24260         FREE(untag_ptr(_res));
24261         CResult_TxCompleteDecodeErrorZ_free(_res_conv);
24262 }
24263
24264 static inline uint64_t CResult_TxCompleteDecodeErrorZ_clone_ptr(LDKCResult_TxCompleteDecodeErrorZ *NONNULL_PTR arg) {
24265         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
24266         *ret_conv = CResult_TxCompleteDecodeErrorZ_clone(arg);
24267         return tag_ptr(ret_conv, true);
24268 }
24269 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_clone_ptr(int64_t arg) {
24270         LDKCResult_TxCompleteDecodeErrorZ* arg_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(arg);
24271         int64_t ret_conv = CResult_TxCompleteDecodeErrorZ_clone_ptr(arg_conv);
24272         return ret_conv;
24273 }
24274
24275 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_clone(int64_t orig) {
24276         LDKCResult_TxCompleteDecodeErrorZ* orig_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(orig);
24277         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
24278         *ret_conv = CResult_TxCompleteDecodeErrorZ_clone(orig_conv);
24279         return tag_ptr(ret_conv, true);
24280 }
24281
24282 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_ok(int64_t o) {
24283         LDKTxSignatures o_conv;
24284         o_conv.inner = untag_ptr(o);
24285         o_conv.is_owned = ptr_is_owned(o);
24286         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24287         o_conv = TxSignatures_clone(&o_conv);
24288         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
24289         *ret_conv = CResult_TxSignaturesDecodeErrorZ_ok(o_conv);
24290         return tag_ptr(ret_conv, true);
24291 }
24292
24293 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_err(int64_t e) {
24294         void* e_ptr = untag_ptr(e);
24295         CHECK_ACCESS(e_ptr);
24296         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24297         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24298         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
24299         *ret_conv = CResult_TxSignaturesDecodeErrorZ_err(e_conv);
24300         return tag_ptr(ret_conv, true);
24301 }
24302
24303 jboolean  CS_LDK_CResult_TxSignaturesDecodeErrorZ_is_ok(int64_t o) {
24304         LDKCResult_TxSignaturesDecodeErrorZ* o_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(o);
24305         jboolean ret_conv = CResult_TxSignaturesDecodeErrorZ_is_ok(o_conv);
24306         return ret_conv;
24307 }
24308
24309 void  CS_LDK_CResult_TxSignaturesDecodeErrorZ_free(int64_t _res) {
24310         if (!ptr_is_owned(_res)) return;
24311         void* _res_ptr = untag_ptr(_res);
24312         CHECK_ACCESS(_res_ptr);
24313         LDKCResult_TxSignaturesDecodeErrorZ _res_conv = *(LDKCResult_TxSignaturesDecodeErrorZ*)(_res_ptr);
24314         FREE(untag_ptr(_res));
24315         CResult_TxSignaturesDecodeErrorZ_free(_res_conv);
24316 }
24317
24318 static inline uint64_t CResult_TxSignaturesDecodeErrorZ_clone_ptr(LDKCResult_TxSignaturesDecodeErrorZ *NONNULL_PTR arg) {
24319         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
24320         *ret_conv = CResult_TxSignaturesDecodeErrorZ_clone(arg);
24321         return tag_ptr(ret_conv, true);
24322 }
24323 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_clone_ptr(int64_t arg) {
24324         LDKCResult_TxSignaturesDecodeErrorZ* arg_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(arg);
24325         int64_t ret_conv = CResult_TxSignaturesDecodeErrorZ_clone_ptr(arg_conv);
24326         return ret_conv;
24327 }
24328
24329 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_clone(int64_t orig) {
24330         LDKCResult_TxSignaturesDecodeErrorZ* orig_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(orig);
24331         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
24332         *ret_conv = CResult_TxSignaturesDecodeErrorZ_clone(orig_conv);
24333         return tag_ptr(ret_conv, true);
24334 }
24335
24336 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_ok(int64_t o) {
24337         LDKTxInitRbf o_conv;
24338         o_conv.inner = untag_ptr(o);
24339         o_conv.is_owned = ptr_is_owned(o);
24340         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24341         o_conv = TxInitRbf_clone(&o_conv);
24342         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
24343         *ret_conv = CResult_TxInitRbfDecodeErrorZ_ok(o_conv);
24344         return tag_ptr(ret_conv, true);
24345 }
24346
24347 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_err(int64_t e) {
24348         void* e_ptr = untag_ptr(e);
24349         CHECK_ACCESS(e_ptr);
24350         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24351         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24352         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
24353         *ret_conv = CResult_TxInitRbfDecodeErrorZ_err(e_conv);
24354         return tag_ptr(ret_conv, true);
24355 }
24356
24357 jboolean  CS_LDK_CResult_TxInitRbfDecodeErrorZ_is_ok(int64_t o) {
24358         LDKCResult_TxInitRbfDecodeErrorZ* o_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(o);
24359         jboolean ret_conv = CResult_TxInitRbfDecodeErrorZ_is_ok(o_conv);
24360         return ret_conv;
24361 }
24362
24363 void  CS_LDK_CResult_TxInitRbfDecodeErrorZ_free(int64_t _res) {
24364         if (!ptr_is_owned(_res)) return;
24365         void* _res_ptr = untag_ptr(_res);
24366         CHECK_ACCESS(_res_ptr);
24367         LDKCResult_TxInitRbfDecodeErrorZ _res_conv = *(LDKCResult_TxInitRbfDecodeErrorZ*)(_res_ptr);
24368         FREE(untag_ptr(_res));
24369         CResult_TxInitRbfDecodeErrorZ_free(_res_conv);
24370 }
24371
24372 static inline uint64_t CResult_TxInitRbfDecodeErrorZ_clone_ptr(LDKCResult_TxInitRbfDecodeErrorZ *NONNULL_PTR arg) {
24373         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
24374         *ret_conv = CResult_TxInitRbfDecodeErrorZ_clone(arg);
24375         return tag_ptr(ret_conv, true);
24376 }
24377 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_clone_ptr(int64_t arg) {
24378         LDKCResult_TxInitRbfDecodeErrorZ* arg_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(arg);
24379         int64_t ret_conv = CResult_TxInitRbfDecodeErrorZ_clone_ptr(arg_conv);
24380         return ret_conv;
24381 }
24382
24383 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_clone(int64_t orig) {
24384         LDKCResult_TxInitRbfDecodeErrorZ* orig_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(orig);
24385         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
24386         *ret_conv = CResult_TxInitRbfDecodeErrorZ_clone(orig_conv);
24387         return tag_ptr(ret_conv, true);
24388 }
24389
24390 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_ok(int64_t o) {
24391         LDKTxAckRbf o_conv;
24392         o_conv.inner = untag_ptr(o);
24393         o_conv.is_owned = ptr_is_owned(o);
24394         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24395         o_conv = TxAckRbf_clone(&o_conv);
24396         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
24397         *ret_conv = CResult_TxAckRbfDecodeErrorZ_ok(o_conv);
24398         return tag_ptr(ret_conv, true);
24399 }
24400
24401 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_err(int64_t e) {
24402         void* e_ptr = untag_ptr(e);
24403         CHECK_ACCESS(e_ptr);
24404         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24405         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24406         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
24407         *ret_conv = CResult_TxAckRbfDecodeErrorZ_err(e_conv);
24408         return tag_ptr(ret_conv, true);
24409 }
24410
24411 jboolean  CS_LDK_CResult_TxAckRbfDecodeErrorZ_is_ok(int64_t o) {
24412         LDKCResult_TxAckRbfDecodeErrorZ* o_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(o);
24413         jboolean ret_conv = CResult_TxAckRbfDecodeErrorZ_is_ok(o_conv);
24414         return ret_conv;
24415 }
24416
24417 void  CS_LDK_CResult_TxAckRbfDecodeErrorZ_free(int64_t _res) {
24418         if (!ptr_is_owned(_res)) return;
24419         void* _res_ptr = untag_ptr(_res);
24420         CHECK_ACCESS(_res_ptr);
24421         LDKCResult_TxAckRbfDecodeErrorZ _res_conv = *(LDKCResult_TxAckRbfDecodeErrorZ*)(_res_ptr);
24422         FREE(untag_ptr(_res));
24423         CResult_TxAckRbfDecodeErrorZ_free(_res_conv);
24424 }
24425
24426 static inline uint64_t CResult_TxAckRbfDecodeErrorZ_clone_ptr(LDKCResult_TxAckRbfDecodeErrorZ *NONNULL_PTR arg) {
24427         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
24428         *ret_conv = CResult_TxAckRbfDecodeErrorZ_clone(arg);
24429         return tag_ptr(ret_conv, true);
24430 }
24431 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_clone_ptr(int64_t arg) {
24432         LDKCResult_TxAckRbfDecodeErrorZ* arg_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(arg);
24433         int64_t ret_conv = CResult_TxAckRbfDecodeErrorZ_clone_ptr(arg_conv);
24434         return ret_conv;
24435 }
24436
24437 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_clone(int64_t orig) {
24438         LDKCResult_TxAckRbfDecodeErrorZ* orig_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(orig);
24439         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
24440         *ret_conv = CResult_TxAckRbfDecodeErrorZ_clone(orig_conv);
24441         return tag_ptr(ret_conv, true);
24442 }
24443
24444 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_ok(int64_t o) {
24445         LDKTxAbort o_conv;
24446         o_conv.inner = untag_ptr(o);
24447         o_conv.is_owned = ptr_is_owned(o);
24448         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24449         o_conv = TxAbort_clone(&o_conv);
24450         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
24451         *ret_conv = CResult_TxAbortDecodeErrorZ_ok(o_conv);
24452         return tag_ptr(ret_conv, true);
24453 }
24454
24455 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_err(int64_t e) {
24456         void* e_ptr = untag_ptr(e);
24457         CHECK_ACCESS(e_ptr);
24458         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24459         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24460         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
24461         *ret_conv = CResult_TxAbortDecodeErrorZ_err(e_conv);
24462         return tag_ptr(ret_conv, true);
24463 }
24464
24465 jboolean  CS_LDK_CResult_TxAbortDecodeErrorZ_is_ok(int64_t o) {
24466         LDKCResult_TxAbortDecodeErrorZ* o_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(o);
24467         jboolean ret_conv = CResult_TxAbortDecodeErrorZ_is_ok(o_conv);
24468         return ret_conv;
24469 }
24470
24471 void  CS_LDK_CResult_TxAbortDecodeErrorZ_free(int64_t _res) {
24472         if (!ptr_is_owned(_res)) return;
24473         void* _res_ptr = untag_ptr(_res);
24474         CHECK_ACCESS(_res_ptr);
24475         LDKCResult_TxAbortDecodeErrorZ _res_conv = *(LDKCResult_TxAbortDecodeErrorZ*)(_res_ptr);
24476         FREE(untag_ptr(_res));
24477         CResult_TxAbortDecodeErrorZ_free(_res_conv);
24478 }
24479
24480 static inline uint64_t CResult_TxAbortDecodeErrorZ_clone_ptr(LDKCResult_TxAbortDecodeErrorZ *NONNULL_PTR arg) {
24481         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
24482         *ret_conv = CResult_TxAbortDecodeErrorZ_clone(arg);
24483         return tag_ptr(ret_conv, true);
24484 }
24485 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_clone_ptr(int64_t arg) {
24486         LDKCResult_TxAbortDecodeErrorZ* arg_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(arg);
24487         int64_t ret_conv = CResult_TxAbortDecodeErrorZ_clone_ptr(arg_conv);
24488         return ret_conv;
24489 }
24490
24491 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_clone(int64_t orig) {
24492         LDKCResult_TxAbortDecodeErrorZ* orig_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(orig);
24493         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
24494         *ret_conv = CResult_TxAbortDecodeErrorZ_clone(orig_conv);
24495         return tag_ptr(ret_conv, true);
24496 }
24497
24498 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_ok(int64_t o) {
24499         LDKAnnouncementSignatures o_conv;
24500         o_conv.inner = untag_ptr(o);
24501         o_conv.is_owned = ptr_is_owned(o);
24502         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24503         o_conv = AnnouncementSignatures_clone(&o_conv);
24504         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24505         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
24506         return tag_ptr(ret_conv, true);
24507 }
24508
24509 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_err(int64_t e) {
24510         void* e_ptr = untag_ptr(e);
24511         CHECK_ACCESS(e_ptr);
24512         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24513         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24514         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24515         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
24516         return tag_ptr(ret_conv, true);
24517 }
24518
24519 jboolean  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(int64_t o) {
24520         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
24521         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
24522         return ret_conv;
24523 }
24524
24525 void  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_free(int64_t _res) {
24526         if (!ptr_is_owned(_res)) return;
24527         void* _res_ptr = untag_ptr(_res);
24528         CHECK_ACCESS(_res_ptr);
24529         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
24530         FREE(untag_ptr(_res));
24531         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
24532 }
24533
24534 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
24535         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24536         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
24537         return tag_ptr(ret_conv, true);
24538 }
24539 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(int64_t arg) {
24540         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
24541         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
24542         return ret_conv;
24543 }
24544
24545 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_clone(int64_t orig) {
24546         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
24547         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24548         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
24549         return tag_ptr(ret_conv, true);
24550 }
24551
24552 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_ok(int64_t o) {
24553         LDKChannelReestablish o_conv;
24554         o_conv.inner = untag_ptr(o);
24555         o_conv.is_owned = ptr_is_owned(o);
24556         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24557         o_conv = ChannelReestablish_clone(&o_conv);
24558         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24559         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
24560         return tag_ptr(ret_conv, true);
24561 }
24562
24563 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_err(int64_t e) {
24564         void* e_ptr = untag_ptr(e);
24565         CHECK_ACCESS(e_ptr);
24566         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24567         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24568         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24569         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
24570         return tag_ptr(ret_conv, true);
24571 }
24572
24573 jboolean  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_is_ok(int64_t o) {
24574         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
24575         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
24576         return ret_conv;
24577 }
24578
24579 void  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_free(int64_t _res) {
24580         if (!ptr_is_owned(_res)) return;
24581         void* _res_ptr = untag_ptr(_res);
24582         CHECK_ACCESS(_res_ptr);
24583         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
24584         FREE(untag_ptr(_res));
24585         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
24586 }
24587
24588 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
24589         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24590         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
24591         return tag_ptr(ret_conv, true);
24592 }
24593 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(int64_t arg) {
24594         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
24595         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
24596         return ret_conv;
24597 }
24598
24599 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_clone(int64_t orig) {
24600         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
24601         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24602         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
24603         return tag_ptr(ret_conv, true);
24604 }
24605
24606 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_ok(int64_t o) {
24607         LDKClosingSigned o_conv;
24608         o_conv.inner = untag_ptr(o);
24609         o_conv.is_owned = ptr_is_owned(o);
24610         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24611         o_conv = ClosingSigned_clone(&o_conv);
24612         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24613         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
24614         return tag_ptr(ret_conv, true);
24615 }
24616
24617 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_err(int64_t e) {
24618         void* e_ptr = untag_ptr(e);
24619         CHECK_ACCESS(e_ptr);
24620         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24621         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24622         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24623         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
24624         return tag_ptr(ret_conv, true);
24625 }
24626
24627 jboolean  CS_LDK_CResult_ClosingSignedDecodeErrorZ_is_ok(int64_t o) {
24628         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
24629         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
24630         return ret_conv;
24631 }
24632
24633 void  CS_LDK_CResult_ClosingSignedDecodeErrorZ_free(int64_t _res) {
24634         if (!ptr_is_owned(_res)) return;
24635         void* _res_ptr = untag_ptr(_res);
24636         CHECK_ACCESS(_res_ptr);
24637         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
24638         FREE(untag_ptr(_res));
24639         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
24640 }
24641
24642 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
24643         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24644         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
24645         return tag_ptr(ret_conv, true);
24646 }
24647 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_clone_ptr(int64_t arg) {
24648         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
24649         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
24650         return ret_conv;
24651 }
24652
24653 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_clone(int64_t orig) {
24654         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
24655         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24656         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
24657         return tag_ptr(ret_conv, true);
24658 }
24659
24660 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(int64_t o) {
24661         LDKClosingSignedFeeRange o_conv;
24662         o_conv.inner = untag_ptr(o);
24663         o_conv.is_owned = ptr_is_owned(o);
24664         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24665         o_conv = ClosingSignedFeeRange_clone(&o_conv);
24666         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24667         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
24668         return tag_ptr(ret_conv, true);
24669 }
24670
24671 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(int64_t e) {
24672         void* e_ptr = untag_ptr(e);
24673         CHECK_ACCESS(e_ptr);
24674         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24675         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24676         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24677         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
24678         return tag_ptr(ret_conv, true);
24679 }
24680
24681 jboolean  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(int64_t o) {
24682         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
24683         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
24684         return ret_conv;
24685 }
24686
24687 void  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(int64_t _res) {
24688         if (!ptr_is_owned(_res)) return;
24689         void* _res_ptr = untag_ptr(_res);
24690         CHECK_ACCESS(_res_ptr);
24691         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
24692         FREE(untag_ptr(_res));
24693         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
24694 }
24695
24696 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
24697         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24698         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
24699         return tag_ptr(ret_conv, true);
24700 }
24701 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(int64_t arg) {
24702         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
24703         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
24704         return ret_conv;
24705 }
24706
24707 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(int64_t orig) {
24708         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
24709         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24710         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
24711         return tag_ptr(ret_conv, true);
24712 }
24713
24714 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_ok(int64_t o) {
24715         LDKCommitmentSigned o_conv;
24716         o_conv.inner = untag_ptr(o);
24717         o_conv.is_owned = ptr_is_owned(o);
24718         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24719         o_conv = CommitmentSigned_clone(&o_conv);
24720         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24721         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
24722         return tag_ptr(ret_conv, true);
24723 }
24724
24725 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_err(int64_t e) {
24726         void* e_ptr = untag_ptr(e);
24727         CHECK_ACCESS(e_ptr);
24728         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24729         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24730         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24731         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
24732         return tag_ptr(ret_conv, true);
24733 }
24734
24735 jboolean  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_is_ok(int64_t o) {
24736         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
24737         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
24738         return ret_conv;
24739 }
24740
24741 void  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_free(int64_t _res) {
24742         if (!ptr_is_owned(_res)) return;
24743         void* _res_ptr = untag_ptr(_res);
24744         CHECK_ACCESS(_res_ptr);
24745         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
24746         FREE(untag_ptr(_res));
24747         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
24748 }
24749
24750 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
24751         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24752         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
24753         return tag_ptr(ret_conv, true);
24754 }
24755 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(int64_t arg) {
24756         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
24757         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
24758         return ret_conv;
24759 }
24760
24761 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_clone(int64_t orig) {
24762         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
24763         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24764         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
24765         return tag_ptr(ret_conv, true);
24766 }
24767
24768 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_ok(int64_t o) {
24769         LDKFundingCreated o_conv;
24770         o_conv.inner = untag_ptr(o);
24771         o_conv.is_owned = ptr_is_owned(o);
24772         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24773         o_conv = FundingCreated_clone(&o_conv);
24774         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24775         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
24776         return tag_ptr(ret_conv, true);
24777 }
24778
24779 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_err(int64_t e) {
24780         void* e_ptr = untag_ptr(e);
24781         CHECK_ACCESS(e_ptr);
24782         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24783         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24784         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24785         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
24786         return tag_ptr(ret_conv, true);
24787 }
24788
24789 jboolean  CS_LDK_CResult_FundingCreatedDecodeErrorZ_is_ok(int64_t o) {
24790         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
24791         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
24792         return ret_conv;
24793 }
24794
24795 void  CS_LDK_CResult_FundingCreatedDecodeErrorZ_free(int64_t _res) {
24796         if (!ptr_is_owned(_res)) return;
24797         void* _res_ptr = untag_ptr(_res);
24798         CHECK_ACCESS(_res_ptr);
24799         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
24800         FREE(untag_ptr(_res));
24801         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
24802 }
24803
24804 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
24805         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24806         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
24807         return tag_ptr(ret_conv, true);
24808 }
24809 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_clone_ptr(int64_t arg) {
24810         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
24811         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
24812         return ret_conv;
24813 }
24814
24815 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_clone(int64_t orig) {
24816         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
24817         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24818         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
24819         return tag_ptr(ret_conv, true);
24820 }
24821
24822 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_ok(int64_t o) {
24823         LDKFundingSigned o_conv;
24824         o_conv.inner = untag_ptr(o);
24825         o_conv.is_owned = ptr_is_owned(o);
24826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24827         o_conv = FundingSigned_clone(&o_conv);
24828         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24829         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
24830         return tag_ptr(ret_conv, true);
24831 }
24832
24833 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_err(int64_t e) {
24834         void* e_ptr = untag_ptr(e);
24835         CHECK_ACCESS(e_ptr);
24836         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24837         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24838         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24839         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
24840         return tag_ptr(ret_conv, true);
24841 }
24842
24843 jboolean  CS_LDK_CResult_FundingSignedDecodeErrorZ_is_ok(int64_t o) {
24844         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
24845         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
24846         return ret_conv;
24847 }
24848
24849 void  CS_LDK_CResult_FundingSignedDecodeErrorZ_free(int64_t _res) {
24850         if (!ptr_is_owned(_res)) return;
24851         void* _res_ptr = untag_ptr(_res);
24852         CHECK_ACCESS(_res_ptr);
24853         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
24854         FREE(untag_ptr(_res));
24855         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
24856 }
24857
24858 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
24859         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24860         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
24861         return tag_ptr(ret_conv, true);
24862 }
24863 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_clone_ptr(int64_t arg) {
24864         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
24865         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
24866         return ret_conv;
24867 }
24868
24869 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_clone(int64_t orig) {
24870         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
24871         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24872         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
24873         return tag_ptr(ret_conv, true);
24874 }
24875
24876 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_ok(int64_t o) {
24877         LDKChannelReady o_conv;
24878         o_conv.inner = untag_ptr(o);
24879         o_conv.is_owned = ptr_is_owned(o);
24880         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24881         o_conv = ChannelReady_clone(&o_conv);
24882         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24883         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
24884         return tag_ptr(ret_conv, true);
24885 }
24886
24887 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_err(int64_t e) {
24888         void* e_ptr = untag_ptr(e);
24889         CHECK_ACCESS(e_ptr);
24890         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24891         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24892         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24893         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
24894         return tag_ptr(ret_conv, true);
24895 }
24896
24897 jboolean  CS_LDK_CResult_ChannelReadyDecodeErrorZ_is_ok(int64_t o) {
24898         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
24899         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
24900         return ret_conv;
24901 }
24902
24903 void  CS_LDK_CResult_ChannelReadyDecodeErrorZ_free(int64_t _res) {
24904         if (!ptr_is_owned(_res)) return;
24905         void* _res_ptr = untag_ptr(_res);
24906         CHECK_ACCESS(_res_ptr);
24907         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
24908         FREE(untag_ptr(_res));
24909         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
24910 }
24911
24912 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
24913         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24914         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
24915         return tag_ptr(ret_conv, true);
24916 }
24917 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_clone_ptr(int64_t arg) {
24918         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
24919         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
24920         return ret_conv;
24921 }
24922
24923 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_clone(int64_t orig) {
24924         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
24925         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24926         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
24927         return tag_ptr(ret_conv, true);
24928 }
24929
24930 int64_t  CS_LDK_CResult_InitDecodeErrorZ_ok(int64_t o) {
24931         LDKInit o_conv;
24932         o_conv.inner = untag_ptr(o);
24933         o_conv.is_owned = ptr_is_owned(o);
24934         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24935         o_conv = Init_clone(&o_conv);
24936         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24937         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
24938         return tag_ptr(ret_conv, true);
24939 }
24940
24941 int64_t  CS_LDK_CResult_InitDecodeErrorZ_err(int64_t e) {
24942         void* e_ptr = untag_ptr(e);
24943         CHECK_ACCESS(e_ptr);
24944         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24945         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24946         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24947         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
24948         return tag_ptr(ret_conv, true);
24949 }
24950
24951 jboolean  CS_LDK_CResult_InitDecodeErrorZ_is_ok(int64_t o) {
24952         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
24953         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
24954         return ret_conv;
24955 }
24956
24957 void  CS_LDK_CResult_InitDecodeErrorZ_free(int64_t _res) {
24958         if (!ptr_is_owned(_res)) return;
24959         void* _res_ptr = untag_ptr(_res);
24960         CHECK_ACCESS(_res_ptr);
24961         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
24962         FREE(untag_ptr(_res));
24963         CResult_InitDecodeErrorZ_free(_res_conv);
24964 }
24965
24966 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
24967         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24968         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
24969         return tag_ptr(ret_conv, true);
24970 }
24971 int64_t  CS_LDK_CResult_InitDecodeErrorZ_clone_ptr(int64_t arg) {
24972         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
24973         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
24974         return ret_conv;
24975 }
24976
24977 int64_t  CS_LDK_CResult_InitDecodeErrorZ_clone(int64_t orig) {
24978         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
24979         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24980         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
24981         return tag_ptr(ret_conv, true);
24982 }
24983
24984 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_ok(int64_t o) {
24985         LDKOpenChannel o_conv;
24986         o_conv.inner = untag_ptr(o);
24987         o_conv.is_owned = ptr_is_owned(o);
24988         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24989         o_conv = OpenChannel_clone(&o_conv);
24990         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24991         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
24992         return tag_ptr(ret_conv, true);
24993 }
24994
24995 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_err(int64_t e) {
24996         void* e_ptr = untag_ptr(e);
24997         CHECK_ACCESS(e_ptr);
24998         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24999         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25000         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25001         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
25002         return tag_ptr(ret_conv, true);
25003 }
25004
25005 jboolean  CS_LDK_CResult_OpenChannelDecodeErrorZ_is_ok(int64_t o) {
25006         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
25007         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
25008         return ret_conv;
25009 }
25010
25011 void  CS_LDK_CResult_OpenChannelDecodeErrorZ_free(int64_t _res) {
25012         if (!ptr_is_owned(_res)) return;
25013         void* _res_ptr = untag_ptr(_res);
25014         CHECK_ACCESS(_res_ptr);
25015         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
25016         FREE(untag_ptr(_res));
25017         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
25018 }
25019
25020 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
25021         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25022         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
25023         return tag_ptr(ret_conv, true);
25024 }
25025 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_clone_ptr(int64_t arg) {
25026         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
25027         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
25028         return ret_conv;
25029 }
25030
25031 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_clone(int64_t orig) {
25032         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
25033         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25034         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
25035         return tag_ptr(ret_conv, true);
25036 }
25037
25038 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_ok(int64_t o) {
25039         LDKOpenChannelV2 o_conv;
25040         o_conv.inner = untag_ptr(o);
25041         o_conv.is_owned = ptr_is_owned(o);
25042         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25043         o_conv = OpenChannelV2_clone(&o_conv);
25044         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
25045         *ret_conv = CResult_OpenChannelV2DecodeErrorZ_ok(o_conv);
25046         return tag_ptr(ret_conv, true);
25047 }
25048
25049 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_err(int64_t e) {
25050         void* e_ptr = untag_ptr(e);
25051         CHECK_ACCESS(e_ptr);
25052         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25053         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25054         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
25055         *ret_conv = CResult_OpenChannelV2DecodeErrorZ_err(e_conv);
25056         return tag_ptr(ret_conv, true);
25057 }
25058
25059 jboolean  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_is_ok(int64_t o) {
25060         LDKCResult_OpenChannelV2DecodeErrorZ* o_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(o);
25061         jboolean ret_conv = CResult_OpenChannelV2DecodeErrorZ_is_ok(o_conv);
25062         return ret_conv;
25063 }
25064
25065 void  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_free(int64_t _res) {
25066         if (!ptr_is_owned(_res)) return;
25067         void* _res_ptr = untag_ptr(_res);
25068         CHECK_ACCESS(_res_ptr);
25069         LDKCResult_OpenChannelV2DecodeErrorZ _res_conv = *(LDKCResult_OpenChannelV2DecodeErrorZ*)(_res_ptr);
25070         FREE(untag_ptr(_res));
25071         CResult_OpenChannelV2DecodeErrorZ_free(_res_conv);
25072 }
25073
25074 static inline uint64_t CResult_OpenChannelV2DecodeErrorZ_clone_ptr(LDKCResult_OpenChannelV2DecodeErrorZ *NONNULL_PTR arg) {
25075         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
25076         *ret_conv = CResult_OpenChannelV2DecodeErrorZ_clone(arg);
25077         return tag_ptr(ret_conv, true);
25078 }
25079 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_clone_ptr(int64_t arg) {
25080         LDKCResult_OpenChannelV2DecodeErrorZ* arg_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(arg);
25081         int64_t ret_conv = CResult_OpenChannelV2DecodeErrorZ_clone_ptr(arg_conv);
25082         return ret_conv;
25083 }
25084
25085 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_clone(int64_t orig) {
25086         LDKCResult_OpenChannelV2DecodeErrorZ* orig_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(orig);
25087         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
25088         *ret_conv = CResult_OpenChannelV2DecodeErrorZ_clone(orig_conv);
25089         return tag_ptr(ret_conv, true);
25090 }
25091
25092 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_ok(int64_t o) {
25093         LDKRevokeAndACK o_conv;
25094         o_conv.inner = untag_ptr(o);
25095         o_conv.is_owned = ptr_is_owned(o);
25096         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25097         o_conv = RevokeAndACK_clone(&o_conv);
25098         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25099         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
25100         return tag_ptr(ret_conv, true);
25101 }
25102
25103 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_err(int64_t e) {
25104         void* e_ptr = untag_ptr(e);
25105         CHECK_ACCESS(e_ptr);
25106         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25107         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25108         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25109         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
25110         return tag_ptr(ret_conv, true);
25111 }
25112
25113 jboolean  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_is_ok(int64_t o) {
25114         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
25115         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
25116         return ret_conv;
25117 }
25118
25119 void  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_free(int64_t _res) {
25120         if (!ptr_is_owned(_res)) return;
25121         void* _res_ptr = untag_ptr(_res);
25122         CHECK_ACCESS(_res_ptr);
25123         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
25124         FREE(untag_ptr(_res));
25125         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
25126 }
25127
25128 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
25129         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25130         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
25131         return tag_ptr(ret_conv, true);
25132 }
25133 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(int64_t arg) {
25134         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
25135         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
25136         return ret_conv;
25137 }
25138
25139 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_clone(int64_t orig) {
25140         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
25141         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25142         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
25143         return tag_ptr(ret_conv, true);
25144 }
25145
25146 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_ok(int64_t o) {
25147         LDKShutdown o_conv;
25148         o_conv.inner = untag_ptr(o);
25149         o_conv.is_owned = ptr_is_owned(o);
25150         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25151         o_conv = Shutdown_clone(&o_conv);
25152         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25153         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
25154         return tag_ptr(ret_conv, true);
25155 }
25156
25157 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_err(int64_t e) {
25158         void* e_ptr = untag_ptr(e);
25159         CHECK_ACCESS(e_ptr);
25160         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25161         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25162         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25163         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
25164         return tag_ptr(ret_conv, true);
25165 }
25166
25167 jboolean  CS_LDK_CResult_ShutdownDecodeErrorZ_is_ok(int64_t o) {
25168         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
25169         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
25170         return ret_conv;
25171 }
25172
25173 void  CS_LDK_CResult_ShutdownDecodeErrorZ_free(int64_t _res) {
25174         if (!ptr_is_owned(_res)) return;
25175         void* _res_ptr = untag_ptr(_res);
25176         CHECK_ACCESS(_res_ptr);
25177         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
25178         FREE(untag_ptr(_res));
25179         CResult_ShutdownDecodeErrorZ_free(_res_conv);
25180 }
25181
25182 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
25183         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25184         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
25185         return tag_ptr(ret_conv, true);
25186 }
25187 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_clone_ptr(int64_t arg) {
25188         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
25189         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
25190         return ret_conv;
25191 }
25192
25193 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_clone(int64_t orig) {
25194         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
25195         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25196         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
25197         return tag_ptr(ret_conv, true);
25198 }
25199
25200 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_ok(int64_t o) {
25201         LDKUpdateFailHTLC o_conv;
25202         o_conv.inner = untag_ptr(o);
25203         o_conv.is_owned = ptr_is_owned(o);
25204         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25205         o_conv = UpdateFailHTLC_clone(&o_conv);
25206         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25207         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
25208         return tag_ptr(ret_conv, true);
25209 }
25210
25211 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_err(int64_t e) {
25212         void* e_ptr = untag_ptr(e);
25213         CHECK_ACCESS(e_ptr);
25214         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25215         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25216         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25217         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
25218         return tag_ptr(ret_conv, true);
25219 }
25220
25221 jboolean  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(int64_t o) {
25222         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
25223         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
25224         return ret_conv;
25225 }
25226
25227 void  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_free(int64_t _res) {
25228         if (!ptr_is_owned(_res)) return;
25229         void* _res_ptr = untag_ptr(_res);
25230         CHECK_ACCESS(_res_ptr);
25231         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
25232         FREE(untag_ptr(_res));
25233         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
25234 }
25235
25236 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
25237         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25238         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
25239         return tag_ptr(ret_conv, true);
25240 }
25241 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
25242         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
25243         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
25244         return ret_conv;
25245 }
25246
25247 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_clone(int64_t orig) {
25248         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
25249         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25250         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
25251         return tag_ptr(ret_conv, true);
25252 }
25253
25254 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(int64_t o) {
25255         LDKUpdateFailMalformedHTLC o_conv;
25256         o_conv.inner = untag_ptr(o);
25257         o_conv.is_owned = ptr_is_owned(o);
25258         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25259         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
25260         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25261         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
25262         return tag_ptr(ret_conv, true);
25263 }
25264
25265 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(int64_t e) {
25266         void* e_ptr = untag_ptr(e);
25267         CHECK_ACCESS(e_ptr);
25268         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25269         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25270         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25271         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
25272         return tag_ptr(ret_conv, true);
25273 }
25274
25275 jboolean  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(int64_t o) {
25276         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
25277         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
25278         return ret_conv;
25279 }
25280
25281 void  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(int64_t _res) {
25282         if (!ptr_is_owned(_res)) return;
25283         void* _res_ptr = untag_ptr(_res);
25284         CHECK_ACCESS(_res_ptr);
25285         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
25286         FREE(untag_ptr(_res));
25287         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
25288 }
25289
25290 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
25291         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25292         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
25293         return tag_ptr(ret_conv, true);
25294 }
25295 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
25296         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
25297         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
25298         return ret_conv;
25299 }
25300
25301 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(int64_t orig) {
25302         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
25303         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25304         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
25305         return tag_ptr(ret_conv, true);
25306 }
25307
25308 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_ok(int64_t o) {
25309         LDKUpdateFee o_conv;
25310         o_conv.inner = untag_ptr(o);
25311         o_conv.is_owned = ptr_is_owned(o);
25312         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25313         o_conv = UpdateFee_clone(&o_conv);
25314         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25315         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
25316         return tag_ptr(ret_conv, true);
25317 }
25318
25319 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_err(int64_t e) {
25320         void* e_ptr = untag_ptr(e);
25321         CHECK_ACCESS(e_ptr);
25322         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25323         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25324         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25325         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
25326         return tag_ptr(ret_conv, true);
25327 }
25328
25329 jboolean  CS_LDK_CResult_UpdateFeeDecodeErrorZ_is_ok(int64_t o) {
25330         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
25331         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
25332         return ret_conv;
25333 }
25334
25335 void  CS_LDK_CResult_UpdateFeeDecodeErrorZ_free(int64_t _res) {
25336         if (!ptr_is_owned(_res)) return;
25337         void* _res_ptr = untag_ptr(_res);
25338         CHECK_ACCESS(_res_ptr);
25339         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
25340         FREE(untag_ptr(_res));
25341         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
25342 }
25343
25344 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
25345         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25346         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
25347         return tag_ptr(ret_conv, true);
25348 }
25349 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_clone_ptr(int64_t arg) {
25350         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
25351         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
25352         return ret_conv;
25353 }
25354
25355 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_clone(int64_t orig) {
25356         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
25357         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25358         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
25359         return tag_ptr(ret_conv, true);
25360 }
25361
25362 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(int64_t o) {
25363         LDKUpdateFulfillHTLC o_conv;
25364         o_conv.inner = untag_ptr(o);
25365         o_conv.is_owned = ptr_is_owned(o);
25366         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25367         o_conv = UpdateFulfillHTLC_clone(&o_conv);
25368         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25369         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
25370         return tag_ptr(ret_conv, true);
25371 }
25372
25373 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_err(int64_t e) {
25374         void* e_ptr = untag_ptr(e);
25375         CHECK_ACCESS(e_ptr);
25376         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25377         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25378         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25379         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
25380         return tag_ptr(ret_conv, true);
25381 }
25382
25383 jboolean  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(int64_t o) {
25384         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
25385         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
25386         return ret_conv;
25387 }
25388
25389 void  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_free(int64_t _res) {
25390         if (!ptr_is_owned(_res)) return;
25391         void* _res_ptr = untag_ptr(_res);
25392         CHECK_ACCESS(_res_ptr);
25393         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
25394         FREE(untag_ptr(_res));
25395         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
25396 }
25397
25398 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
25399         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25400         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
25401         return tag_ptr(ret_conv, true);
25402 }
25403 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
25404         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
25405         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
25406         return ret_conv;
25407 }
25408
25409 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(int64_t orig) {
25410         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
25411         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25412         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
25413         return tag_ptr(ret_conv, true);
25414 }
25415
25416 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_ok(int64_t o) {
25417         LDKUpdateAddHTLC o_conv;
25418         o_conv.inner = untag_ptr(o);
25419         o_conv.is_owned = ptr_is_owned(o);
25420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25421         o_conv = UpdateAddHTLC_clone(&o_conv);
25422         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25423         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
25424         return tag_ptr(ret_conv, true);
25425 }
25426
25427 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_err(int64_t e) {
25428         void* e_ptr = untag_ptr(e);
25429         CHECK_ACCESS(e_ptr);
25430         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25431         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25432         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25433         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
25434         return tag_ptr(ret_conv, true);
25435 }
25436
25437 jboolean  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(int64_t o) {
25438         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
25439         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
25440         return ret_conv;
25441 }
25442
25443 void  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_free(int64_t _res) {
25444         if (!ptr_is_owned(_res)) return;
25445         void* _res_ptr = untag_ptr(_res);
25446         CHECK_ACCESS(_res_ptr);
25447         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
25448         FREE(untag_ptr(_res));
25449         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
25450 }
25451
25452 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
25453         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25454         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
25455         return tag_ptr(ret_conv, true);
25456 }
25457 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
25458         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
25459         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
25460         return ret_conv;
25461 }
25462
25463 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_clone(int64_t orig) {
25464         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
25465         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25466         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
25467         return tag_ptr(ret_conv, true);
25468 }
25469
25470 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_ok(int64_t o) {
25471         LDKOnionMessage o_conv;
25472         o_conv.inner = untag_ptr(o);
25473         o_conv.is_owned = ptr_is_owned(o);
25474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25475         o_conv = OnionMessage_clone(&o_conv);
25476         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25477         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
25478         return tag_ptr(ret_conv, true);
25479 }
25480
25481 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_err(int64_t e) {
25482         void* e_ptr = untag_ptr(e);
25483         CHECK_ACCESS(e_ptr);
25484         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25485         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25486         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25487         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
25488         return tag_ptr(ret_conv, true);
25489 }
25490
25491 jboolean  CS_LDK_CResult_OnionMessageDecodeErrorZ_is_ok(int64_t o) {
25492         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
25493         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
25494         return ret_conv;
25495 }
25496
25497 void  CS_LDK_CResult_OnionMessageDecodeErrorZ_free(int64_t _res) {
25498         if (!ptr_is_owned(_res)) return;
25499         void* _res_ptr = untag_ptr(_res);
25500         CHECK_ACCESS(_res_ptr);
25501         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
25502         FREE(untag_ptr(_res));
25503         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
25504 }
25505
25506 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
25507         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25508         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
25509         return tag_ptr(ret_conv, true);
25510 }
25511 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_clone_ptr(int64_t arg) {
25512         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
25513         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
25514         return ret_conv;
25515 }
25516
25517 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_clone(int64_t orig) {
25518         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
25519         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25520         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
25521         return tag_ptr(ret_conv, true);
25522 }
25523
25524 int64_t  CS_LDK_CResult_PingDecodeErrorZ_ok(int64_t o) {
25525         LDKPing o_conv;
25526         o_conv.inner = untag_ptr(o);
25527         o_conv.is_owned = ptr_is_owned(o);
25528         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25529         o_conv = Ping_clone(&o_conv);
25530         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25531         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
25532         return tag_ptr(ret_conv, true);
25533 }
25534
25535 int64_t  CS_LDK_CResult_PingDecodeErrorZ_err(int64_t e) {
25536         void* e_ptr = untag_ptr(e);
25537         CHECK_ACCESS(e_ptr);
25538         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25539         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25540         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25541         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
25542         return tag_ptr(ret_conv, true);
25543 }
25544
25545 jboolean  CS_LDK_CResult_PingDecodeErrorZ_is_ok(int64_t o) {
25546         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
25547         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
25548         return ret_conv;
25549 }
25550
25551 void  CS_LDK_CResult_PingDecodeErrorZ_free(int64_t _res) {
25552         if (!ptr_is_owned(_res)) return;
25553         void* _res_ptr = untag_ptr(_res);
25554         CHECK_ACCESS(_res_ptr);
25555         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
25556         FREE(untag_ptr(_res));
25557         CResult_PingDecodeErrorZ_free(_res_conv);
25558 }
25559
25560 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
25561         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25562         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
25563         return tag_ptr(ret_conv, true);
25564 }
25565 int64_t  CS_LDK_CResult_PingDecodeErrorZ_clone_ptr(int64_t arg) {
25566         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
25567         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
25568         return ret_conv;
25569 }
25570
25571 int64_t  CS_LDK_CResult_PingDecodeErrorZ_clone(int64_t orig) {
25572         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
25573         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25574         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
25575         return tag_ptr(ret_conv, true);
25576 }
25577
25578 int64_t  CS_LDK_CResult_PongDecodeErrorZ_ok(int64_t o) {
25579         LDKPong o_conv;
25580         o_conv.inner = untag_ptr(o);
25581         o_conv.is_owned = ptr_is_owned(o);
25582         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25583         o_conv = Pong_clone(&o_conv);
25584         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25585         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
25586         return tag_ptr(ret_conv, true);
25587 }
25588
25589 int64_t  CS_LDK_CResult_PongDecodeErrorZ_err(int64_t e) {
25590         void* e_ptr = untag_ptr(e);
25591         CHECK_ACCESS(e_ptr);
25592         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25593         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25594         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25595         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
25596         return tag_ptr(ret_conv, true);
25597 }
25598
25599 jboolean  CS_LDK_CResult_PongDecodeErrorZ_is_ok(int64_t o) {
25600         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
25601         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
25602         return ret_conv;
25603 }
25604
25605 void  CS_LDK_CResult_PongDecodeErrorZ_free(int64_t _res) {
25606         if (!ptr_is_owned(_res)) return;
25607         void* _res_ptr = untag_ptr(_res);
25608         CHECK_ACCESS(_res_ptr);
25609         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
25610         FREE(untag_ptr(_res));
25611         CResult_PongDecodeErrorZ_free(_res_conv);
25612 }
25613
25614 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
25615         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25616         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
25617         return tag_ptr(ret_conv, true);
25618 }
25619 int64_t  CS_LDK_CResult_PongDecodeErrorZ_clone_ptr(int64_t arg) {
25620         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
25621         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
25622         return ret_conv;
25623 }
25624
25625 int64_t  CS_LDK_CResult_PongDecodeErrorZ_clone(int64_t orig) {
25626         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
25627         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25628         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
25629         return tag_ptr(ret_conv, true);
25630 }
25631
25632 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(int64_t o) {
25633         LDKUnsignedChannelAnnouncement o_conv;
25634         o_conv.inner = untag_ptr(o);
25635         o_conv.is_owned = ptr_is_owned(o);
25636         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25637         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
25638         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25639         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
25640         return tag_ptr(ret_conv, true);
25641 }
25642
25643 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(int64_t e) {
25644         void* e_ptr = untag_ptr(e);
25645         CHECK_ACCESS(e_ptr);
25646         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25647         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25648         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25649         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
25650         return tag_ptr(ret_conv, true);
25651 }
25652
25653 jboolean  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(int64_t o) {
25654         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25655         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25656         return ret_conv;
25657 }
25658
25659 void  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(int64_t _res) {
25660         if (!ptr_is_owned(_res)) return;
25661         void* _res_ptr = untag_ptr(_res);
25662         CHECK_ACCESS(_res_ptr);
25663         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25664         FREE(untag_ptr(_res));
25665         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
25666 }
25667
25668 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25669         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25670         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
25671         return tag_ptr(ret_conv, true);
25672 }
25673 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(int64_t arg) {
25674         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25675         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25676         return ret_conv;
25677 }
25678
25679 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(int64_t orig) {
25680         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25681         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25682         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25683         return tag_ptr(ret_conv, true);
25684 }
25685
25686 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_ok(int64_t o) {
25687         LDKChannelAnnouncement o_conv;
25688         o_conv.inner = untag_ptr(o);
25689         o_conv.is_owned = ptr_is_owned(o);
25690         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25691         o_conv = ChannelAnnouncement_clone(&o_conv);
25692         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25693         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
25694         return tag_ptr(ret_conv, true);
25695 }
25696
25697 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_err(int64_t e) {
25698         void* e_ptr = untag_ptr(e);
25699         CHECK_ACCESS(e_ptr);
25700         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25701         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25702         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25703         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
25704         return tag_ptr(ret_conv, true);
25705 }
25706
25707 jboolean  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(int64_t o) {
25708         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25709         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25710         return ret_conv;
25711 }
25712
25713 void  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_free(int64_t _res) {
25714         if (!ptr_is_owned(_res)) return;
25715         void* _res_ptr = untag_ptr(_res);
25716         CHECK_ACCESS(_res_ptr);
25717         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25718         FREE(untag_ptr(_res));
25719         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
25720 }
25721
25722 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25723         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25724         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
25725         return tag_ptr(ret_conv, true);
25726 }
25727 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(int64_t arg) {
25728         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25729         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25730         return ret_conv;
25731 }
25732
25733 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_clone(int64_t orig) {
25734         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25735         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25736         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25737         return tag_ptr(ret_conv, true);
25738 }
25739
25740 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(int64_t o) {
25741         LDKUnsignedChannelUpdate o_conv;
25742         o_conv.inner = untag_ptr(o);
25743         o_conv.is_owned = ptr_is_owned(o);
25744         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25745         o_conv = UnsignedChannelUpdate_clone(&o_conv);
25746         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25747         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
25748         return tag_ptr(ret_conv, true);
25749 }
25750
25751 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_err(int64_t e) {
25752         void* e_ptr = untag_ptr(e);
25753         CHECK_ACCESS(e_ptr);
25754         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25755         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25756         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25757         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
25758         return tag_ptr(ret_conv, true);
25759 }
25760
25761 jboolean  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(int64_t o) {
25762         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
25763         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
25764         return ret_conv;
25765 }
25766
25767 void  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_free(int64_t _res) {
25768         if (!ptr_is_owned(_res)) return;
25769         void* _res_ptr = untag_ptr(_res);
25770         CHECK_ACCESS(_res_ptr);
25771         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
25772         FREE(untag_ptr(_res));
25773         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
25774 }
25775
25776 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25777         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25778         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
25779         return tag_ptr(ret_conv, true);
25780 }
25781 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(int64_t arg) {
25782         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25783         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25784         return ret_conv;
25785 }
25786
25787 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(int64_t orig) {
25788         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25789         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25790         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
25791         return tag_ptr(ret_conv, true);
25792 }
25793
25794 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_ok(int64_t o) {
25795         LDKChannelUpdate o_conv;
25796         o_conv.inner = untag_ptr(o);
25797         o_conv.is_owned = ptr_is_owned(o);
25798         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25799         o_conv = ChannelUpdate_clone(&o_conv);
25800         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25801         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
25802         return tag_ptr(ret_conv, true);
25803 }
25804
25805 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_err(int64_t e) {
25806         void* e_ptr = untag_ptr(e);
25807         CHECK_ACCESS(e_ptr);
25808         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25809         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25810         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25811         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
25812         return tag_ptr(ret_conv, true);
25813 }
25814
25815 jboolean  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_is_ok(int64_t o) {
25816         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
25817         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
25818         return ret_conv;
25819 }
25820
25821 void  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_free(int64_t _res) {
25822         if (!ptr_is_owned(_res)) return;
25823         void* _res_ptr = untag_ptr(_res);
25824         CHECK_ACCESS(_res_ptr);
25825         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
25826         FREE(untag_ptr(_res));
25827         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
25828 }
25829
25830 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25831         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25832         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
25833         return tag_ptr(ret_conv, true);
25834 }
25835 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(int64_t arg) {
25836         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25837         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25838         return ret_conv;
25839 }
25840
25841 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_clone(int64_t orig) {
25842         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25843         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25844         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
25845         return tag_ptr(ret_conv, true);
25846 }
25847
25848 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_ok(int64_t o) {
25849         LDKErrorMessage o_conv;
25850         o_conv.inner = untag_ptr(o);
25851         o_conv.is_owned = ptr_is_owned(o);
25852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25853         o_conv = ErrorMessage_clone(&o_conv);
25854         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25855         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
25856         return tag_ptr(ret_conv, true);
25857 }
25858
25859 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_err(int64_t e) {
25860         void* e_ptr = untag_ptr(e);
25861         CHECK_ACCESS(e_ptr);
25862         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25863         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25864         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25865         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
25866         return tag_ptr(ret_conv, true);
25867 }
25868
25869 jboolean  CS_LDK_CResult_ErrorMessageDecodeErrorZ_is_ok(int64_t o) {
25870         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
25871         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
25872         return ret_conv;
25873 }
25874
25875 void  CS_LDK_CResult_ErrorMessageDecodeErrorZ_free(int64_t _res) {
25876         if (!ptr_is_owned(_res)) return;
25877         void* _res_ptr = untag_ptr(_res);
25878         CHECK_ACCESS(_res_ptr);
25879         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
25880         FREE(untag_ptr(_res));
25881         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
25882 }
25883
25884 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
25885         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25886         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
25887         return tag_ptr(ret_conv, true);
25888 }
25889 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_clone_ptr(int64_t arg) {
25890         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
25891         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
25892         return ret_conv;
25893 }
25894
25895 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_clone(int64_t orig) {
25896         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
25897         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25898         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
25899         return tag_ptr(ret_conv, true);
25900 }
25901
25902 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_ok(int64_t o) {
25903         LDKWarningMessage o_conv;
25904         o_conv.inner = untag_ptr(o);
25905         o_conv.is_owned = ptr_is_owned(o);
25906         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25907         o_conv = WarningMessage_clone(&o_conv);
25908         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25909         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
25910         return tag_ptr(ret_conv, true);
25911 }
25912
25913 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_err(int64_t e) {
25914         void* e_ptr = untag_ptr(e);
25915         CHECK_ACCESS(e_ptr);
25916         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25917         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25918         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25919         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
25920         return tag_ptr(ret_conv, true);
25921 }
25922
25923 jboolean  CS_LDK_CResult_WarningMessageDecodeErrorZ_is_ok(int64_t o) {
25924         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
25925         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
25926         return ret_conv;
25927 }
25928
25929 void  CS_LDK_CResult_WarningMessageDecodeErrorZ_free(int64_t _res) {
25930         if (!ptr_is_owned(_res)) return;
25931         void* _res_ptr = untag_ptr(_res);
25932         CHECK_ACCESS(_res_ptr);
25933         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
25934         FREE(untag_ptr(_res));
25935         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
25936 }
25937
25938 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
25939         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25940         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
25941         return tag_ptr(ret_conv, true);
25942 }
25943 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_clone_ptr(int64_t arg) {
25944         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
25945         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
25946         return ret_conv;
25947 }
25948
25949 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_clone(int64_t orig) {
25950         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
25951         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25952         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
25953         return tag_ptr(ret_conv, true);
25954 }
25955
25956 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(int64_t o) {
25957         LDKUnsignedNodeAnnouncement o_conv;
25958         o_conv.inner = untag_ptr(o);
25959         o_conv.is_owned = ptr_is_owned(o);
25960         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25961         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
25962         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25963         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
25964         return tag_ptr(ret_conv, true);
25965 }
25966
25967 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(int64_t e) {
25968         void* e_ptr = untag_ptr(e);
25969         CHECK_ACCESS(e_ptr);
25970         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25971         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25972         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25973         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
25974         return tag_ptr(ret_conv, true);
25975 }
25976
25977 jboolean  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(int64_t o) {
25978         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
25979         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
25980         return ret_conv;
25981 }
25982
25983 void  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(int64_t _res) {
25984         if (!ptr_is_owned(_res)) return;
25985         void* _res_ptr = untag_ptr(_res);
25986         CHECK_ACCESS(_res_ptr);
25987         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
25988         FREE(untag_ptr(_res));
25989         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
25990 }
25991
25992 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25993         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25994         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
25995         return tag_ptr(ret_conv, true);
25996 }
25997 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(int64_t arg) {
25998         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
25999         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26000         return ret_conv;
26001 }
26002
26003 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(int64_t orig) {
26004         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26005         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26006         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
26007         return tag_ptr(ret_conv, true);
26008 }
26009
26010 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_ok(int64_t o) {
26011         LDKNodeAnnouncement o_conv;
26012         o_conv.inner = untag_ptr(o);
26013         o_conv.is_owned = ptr_is_owned(o);
26014         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26015         o_conv = NodeAnnouncement_clone(&o_conv);
26016         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26017         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
26018         return tag_ptr(ret_conv, true);
26019 }
26020
26021 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_err(int64_t e) {
26022         void* e_ptr = untag_ptr(e);
26023         CHECK_ACCESS(e_ptr);
26024         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26025         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26026         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26027         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
26028         return tag_ptr(ret_conv, true);
26029 }
26030
26031 jboolean  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_is_ok(int64_t o) {
26032         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26033         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26034         return ret_conv;
26035 }
26036
26037 void  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_free(int64_t _res) {
26038         if (!ptr_is_owned(_res)) return;
26039         void* _res_ptr = untag_ptr(_res);
26040         CHECK_ACCESS(_res_ptr);
26041         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
26042         FREE(untag_ptr(_res));
26043         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
26044 }
26045
26046 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26047         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26048         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
26049         return tag_ptr(ret_conv, true);
26050 }
26051 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(int64_t arg) {
26052         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26053         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26054         return ret_conv;
26055 }
26056
26057 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_clone(int64_t orig) {
26058         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26059         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26060         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
26061         return tag_ptr(ret_conv, true);
26062 }
26063
26064 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_ok(int64_t o) {
26065         LDKQueryShortChannelIds o_conv;
26066         o_conv.inner = untag_ptr(o);
26067         o_conv.is_owned = ptr_is_owned(o);
26068         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26069         o_conv = QueryShortChannelIds_clone(&o_conv);
26070         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26071         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
26072         return tag_ptr(ret_conv, true);
26073 }
26074
26075 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_err(int64_t e) {
26076         void* e_ptr = untag_ptr(e);
26077         CHECK_ACCESS(e_ptr);
26078         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26079         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26080         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26081         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
26082         return tag_ptr(ret_conv, true);
26083 }
26084
26085 jboolean  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(int64_t o) {
26086         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
26087         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
26088         return ret_conv;
26089 }
26090
26091 void  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_free(int64_t _res) {
26092         if (!ptr_is_owned(_res)) return;
26093         void* _res_ptr = untag_ptr(_res);
26094         CHECK_ACCESS(_res_ptr);
26095         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
26096         FREE(untag_ptr(_res));
26097         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
26098 }
26099
26100 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
26101         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26102         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
26103         return tag_ptr(ret_conv, true);
26104 }
26105 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(int64_t arg) {
26106         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
26107         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
26108         return ret_conv;
26109 }
26110
26111 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_clone(int64_t orig) {
26112         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
26113         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26114         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
26115         return tag_ptr(ret_conv, true);
26116 }
26117
26118 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(int64_t o) {
26119         LDKReplyShortChannelIdsEnd o_conv;
26120         o_conv.inner = untag_ptr(o);
26121         o_conv.is_owned = ptr_is_owned(o);
26122         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26123         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
26124         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26125         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
26126         return tag_ptr(ret_conv, true);
26127 }
26128
26129 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(int64_t e) {
26130         void* e_ptr = untag_ptr(e);
26131         CHECK_ACCESS(e_ptr);
26132         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26133         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26134         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26135         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
26136         return tag_ptr(ret_conv, true);
26137 }
26138
26139 jboolean  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(int64_t o) {
26140         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
26141         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
26142         return ret_conv;
26143 }
26144
26145 void  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(int64_t _res) {
26146         if (!ptr_is_owned(_res)) return;
26147         void* _res_ptr = untag_ptr(_res);
26148         CHECK_ACCESS(_res_ptr);
26149         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
26150         FREE(untag_ptr(_res));
26151         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
26152 }
26153
26154 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
26155         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26156         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
26157         return tag_ptr(ret_conv, true);
26158 }
26159 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(int64_t arg) {
26160         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
26161         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
26162         return ret_conv;
26163 }
26164
26165 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(int64_t orig) {
26166         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
26167         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26168         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
26169         return tag_ptr(ret_conv, true);
26170 }
26171
26172 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_ok(int64_t o) {
26173         LDKQueryChannelRange o_conv;
26174         o_conv.inner = untag_ptr(o);
26175         o_conv.is_owned = ptr_is_owned(o);
26176         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26177         o_conv = QueryChannelRange_clone(&o_conv);
26178         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26179         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
26180         return tag_ptr(ret_conv, true);
26181 }
26182
26183 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_err(int64_t e) {
26184         void* e_ptr = untag_ptr(e);
26185         CHECK_ACCESS(e_ptr);
26186         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26187         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26188         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26189         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
26190         return tag_ptr(ret_conv, true);
26191 }
26192
26193 jboolean  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_is_ok(int64_t o) {
26194         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
26195         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
26196         return ret_conv;
26197 }
26198
26199 void  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_free(int64_t _res) {
26200         if (!ptr_is_owned(_res)) return;
26201         void* _res_ptr = untag_ptr(_res);
26202         CHECK_ACCESS(_res_ptr);
26203         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
26204         FREE(untag_ptr(_res));
26205         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
26206 }
26207
26208 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26209         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26210         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
26211         return tag_ptr(ret_conv, true);
26212 }
26213 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(int64_t arg) {
26214         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
26215         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26216         return ret_conv;
26217 }
26218
26219 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_clone(int64_t orig) {
26220         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
26221         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26222         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
26223         return tag_ptr(ret_conv, true);
26224 }
26225
26226 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_ok(int64_t o) {
26227         LDKReplyChannelRange o_conv;
26228         o_conv.inner = untag_ptr(o);
26229         o_conv.is_owned = ptr_is_owned(o);
26230         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26231         o_conv = ReplyChannelRange_clone(&o_conv);
26232         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26233         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
26234         return tag_ptr(ret_conv, true);
26235 }
26236
26237 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_err(int64_t e) {
26238         void* e_ptr = untag_ptr(e);
26239         CHECK_ACCESS(e_ptr);
26240         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26241         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26242         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26243         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
26244         return tag_ptr(ret_conv, true);
26245 }
26246
26247 jboolean  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(int64_t o) {
26248         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
26249         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
26250         return ret_conv;
26251 }
26252
26253 void  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_free(int64_t _res) {
26254         if (!ptr_is_owned(_res)) return;
26255         void* _res_ptr = untag_ptr(_res);
26256         CHECK_ACCESS(_res_ptr);
26257         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
26258         FREE(untag_ptr(_res));
26259         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
26260 }
26261
26262 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26263         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26264         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
26265         return tag_ptr(ret_conv, true);
26266 }
26267 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(int64_t arg) {
26268         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
26269         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26270         return ret_conv;
26271 }
26272
26273 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_clone(int64_t orig) {
26274         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
26275         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26276         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
26277         return tag_ptr(ret_conv, true);
26278 }
26279
26280 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_ok(int64_t o) {
26281         LDKGossipTimestampFilter o_conv;
26282         o_conv.inner = untag_ptr(o);
26283         o_conv.is_owned = ptr_is_owned(o);
26284         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26285         o_conv = GossipTimestampFilter_clone(&o_conv);
26286         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26287         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
26288         return tag_ptr(ret_conv, true);
26289 }
26290
26291 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_err(int64_t e) {
26292         void* e_ptr = untag_ptr(e);
26293         CHECK_ACCESS(e_ptr);
26294         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26295         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26296         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26297         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
26298         return tag_ptr(ret_conv, true);
26299 }
26300
26301 jboolean  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(int64_t o) {
26302         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
26303         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
26304         return ret_conv;
26305 }
26306
26307 void  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_free(int64_t _res) {
26308         if (!ptr_is_owned(_res)) return;
26309         void* _res_ptr = untag_ptr(_res);
26310         CHECK_ACCESS(_res_ptr);
26311         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
26312         FREE(untag_ptr(_res));
26313         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
26314 }
26315
26316 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
26317         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26318         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
26319         return tag_ptr(ret_conv, true);
26320 }
26321 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(int64_t arg) {
26322         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
26323         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
26324         return ret_conv;
26325 }
26326
26327 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_clone(int64_t orig) {
26328         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
26329         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26330         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
26331         return tag_ptr(ret_conv, true);
26332 }
26333
26334 void  CS_LDK_CVec_PhantomRouteHintsZ_free(int64_tArray _res) {
26335         LDKCVec_PhantomRouteHintsZ _res_constr;
26336         _res_constr.datalen = _res->arr_len;
26337         if (_res_constr.datalen > 0)
26338                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
26339         else
26340                 _res_constr.data = NULL;
26341         int64_t* _res_vals = _res->elems;
26342         for (size_t t = 0; t < _res_constr.datalen; t++) {
26343                 int64_t _res_conv_19 = _res_vals[t];
26344                 LDKPhantomRouteHints _res_conv_19_conv;
26345                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
26346                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
26347                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
26348                 _res_constr.data[t] = _res_conv_19_conv;
26349         }
26350         FREE(_res);
26351         CVec_PhantomRouteHintsZ_free(_res_constr);
26352 }
26353
26354 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(int64_t o) {
26355         LDKBolt11Invoice o_conv;
26356         o_conv.inner = untag_ptr(o);
26357         o_conv.is_owned = ptr_is_owned(o);
26358         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26359         o_conv = Bolt11Invoice_clone(&o_conv);
26360         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
26361         *ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(o_conv);
26362         return tag_ptr(ret_conv, true);
26363 }
26364
26365 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_err(int64_t e) {
26366         void* e_ptr = untag_ptr(e);
26367         CHECK_ACCESS(e_ptr);
26368         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
26369         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
26370         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
26371         *ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_err(e_conv);
26372         return tag_ptr(ret_conv, true);
26373 }
26374
26375 jboolean  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(int64_t o) {
26376         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(o);
26377         jboolean ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(o_conv);
26378         return ret_conv;
26379 }
26380
26381 void  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_free(int64_t _res) {
26382         if (!ptr_is_owned(_res)) return;
26383         void* _res_ptr = untag_ptr(_res);
26384         CHECK_ACCESS(_res_ptr);
26385         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)(_res_ptr);
26386         FREE(untag_ptr(_res));
26387         CResult_Bolt11InvoiceSignOrCreationErrorZ_free(_res_conv);
26388 }
26389
26390 static inline uint64_t CResult_Bolt11InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
26391         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
26392         *ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(arg);
26393         return tag_ptr(ret_conv, true);
26394 }
26395 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_clone_ptr(int64_t arg) {
26396         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
26397         int64_t ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
26398         return ret_conv;
26399 }
26400
26401 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(int64_t orig) {
26402         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
26403         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
26404         *ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(orig_conv);
26405         return tag_ptr(ret_conv, true);
26406 }
26407
26408 void  CS_LDK_CVec_FutureZ_free(int64_tArray _res) {
26409         LDKCVec_FutureZ _res_constr;
26410         _res_constr.datalen = _res->arr_len;
26411         if (_res_constr.datalen > 0)
26412                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
26413         else
26414                 _res_constr.data = NULL;
26415         int64_t* _res_vals = _res->elems;
26416         for (size_t i = 0; i < _res_constr.datalen; i++) {
26417                 int64_t _res_conv_8 = _res_vals[i];
26418                 LDKFuture _res_conv_8_conv;
26419                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
26420                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
26421                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
26422                 _res_constr.data[i] = _res_conv_8_conv;
26423         }
26424         FREE(_res);
26425         CVec_FutureZ_free(_res_constr);
26426 }
26427
26428 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_ok(int64_t o) {
26429         void* o_ptr = untag_ptr(o);
26430         CHECK_ACCESS(o_ptr);
26431         LDKOffersMessage o_conv = *(LDKOffersMessage*)(o_ptr);
26432         o_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(o));
26433         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
26434         *ret_conv = CResult_OffersMessageDecodeErrorZ_ok(o_conv);
26435         return tag_ptr(ret_conv, true);
26436 }
26437
26438 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_err(int64_t e) {
26439         void* e_ptr = untag_ptr(e);
26440         CHECK_ACCESS(e_ptr);
26441         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26442         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26443         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
26444         *ret_conv = CResult_OffersMessageDecodeErrorZ_err(e_conv);
26445         return tag_ptr(ret_conv, true);
26446 }
26447
26448 jboolean  CS_LDK_CResult_OffersMessageDecodeErrorZ_is_ok(int64_t o) {
26449         LDKCResult_OffersMessageDecodeErrorZ* o_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(o);
26450         jboolean ret_conv = CResult_OffersMessageDecodeErrorZ_is_ok(o_conv);
26451         return ret_conv;
26452 }
26453
26454 void  CS_LDK_CResult_OffersMessageDecodeErrorZ_free(int64_t _res) {
26455         if (!ptr_is_owned(_res)) return;
26456         void* _res_ptr = untag_ptr(_res);
26457         CHECK_ACCESS(_res_ptr);
26458         LDKCResult_OffersMessageDecodeErrorZ _res_conv = *(LDKCResult_OffersMessageDecodeErrorZ*)(_res_ptr);
26459         FREE(untag_ptr(_res));
26460         CResult_OffersMessageDecodeErrorZ_free(_res_conv);
26461 }
26462
26463 static inline uint64_t CResult_OffersMessageDecodeErrorZ_clone_ptr(LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR arg) {
26464         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
26465         *ret_conv = CResult_OffersMessageDecodeErrorZ_clone(arg);
26466         return tag_ptr(ret_conv, true);
26467 }
26468 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_clone_ptr(int64_t arg) {
26469         LDKCResult_OffersMessageDecodeErrorZ* arg_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(arg);
26470         int64_t ret_conv = CResult_OffersMessageDecodeErrorZ_clone_ptr(arg_conv);
26471         return ret_conv;
26472 }
26473
26474 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_clone(int64_t orig) {
26475         LDKCResult_OffersMessageDecodeErrorZ* orig_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(orig);
26476         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
26477         *ret_conv = CResult_OffersMessageDecodeErrorZ_clone(orig_conv);
26478         return tag_ptr(ret_conv, true);
26479 }
26480
26481 int64_t  CS_LDK_COption_HTLCClaimZ_some(int32_t o) {
26482         LDKHTLCClaim o_conv = LDKHTLCClaim_from_cs(o);
26483         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
26484         *ret_copy = COption_HTLCClaimZ_some(o_conv);
26485         int64_t ret_ref = tag_ptr(ret_copy, true);
26486         return ret_ref;
26487 }
26488
26489 int64_t  CS_LDK_COption_HTLCClaimZ_none() {
26490         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
26491         *ret_copy = COption_HTLCClaimZ_none();
26492         int64_t ret_ref = tag_ptr(ret_copy, true);
26493         return ret_ref;
26494 }
26495
26496 void  CS_LDK_COption_HTLCClaimZ_free(int64_t _res) {
26497         if (!ptr_is_owned(_res)) return;
26498         void* _res_ptr = untag_ptr(_res);
26499         CHECK_ACCESS(_res_ptr);
26500         LDKCOption_HTLCClaimZ _res_conv = *(LDKCOption_HTLCClaimZ*)(_res_ptr);
26501         FREE(untag_ptr(_res));
26502         COption_HTLCClaimZ_free(_res_conv);
26503 }
26504
26505 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(int64_t o) {
26506         LDKCounterpartyCommitmentSecrets o_conv;
26507         o_conv.inner = untag_ptr(o);
26508         o_conv.is_owned = ptr_is_owned(o);
26509         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26510         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
26511         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
26512         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
26513         return tag_ptr(ret_conv, true);
26514 }
26515
26516 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(int64_t e) {
26517         void* e_ptr = untag_ptr(e);
26518         CHECK_ACCESS(e_ptr);
26519         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26520         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26521         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
26522         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
26523         return tag_ptr(ret_conv, true);
26524 }
26525
26526 jboolean  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(int64_t o) {
26527         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
26528         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
26529         return ret_conv;
26530 }
26531
26532 void  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(int64_t _res) {
26533         if (!ptr_is_owned(_res)) return;
26534         void* _res_ptr = untag_ptr(_res);
26535         CHECK_ACCESS(_res_ptr);
26536         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
26537         FREE(untag_ptr(_res));
26538         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
26539 }
26540
26541 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
26542         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
26543         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
26544         return tag_ptr(ret_conv, true);
26545 }
26546 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(int64_t arg) {
26547         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
26548         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
26549         return ret_conv;
26550 }
26551
26552 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(int64_t orig) {
26553         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
26554         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
26555         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
26556         return tag_ptr(ret_conv, true);
26557 }
26558
26559 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_ok(int64_t o) {
26560         LDKTxCreationKeys o_conv;
26561         o_conv.inner = untag_ptr(o);
26562         o_conv.is_owned = ptr_is_owned(o);
26563         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26564         o_conv = TxCreationKeys_clone(&o_conv);
26565         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
26566         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
26567         return tag_ptr(ret_conv, true);
26568 }
26569
26570 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_err(int64_t e) {
26571         void* e_ptr = untag_ptr(e);
26572         CHECK_ACCESS(e_ptr);
26573         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26574         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26575         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
26576         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
26577         return tag_ptr(ret_conv, true);
26578 }
26579
26580 jboolean  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_is_ok(int64_t o) {
26581         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
26582         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
26583         return ret_conv;
26584 }
26585
26586 void  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_free(int64_t _res) {
26587         if (!ptr_is_owned(_res)) return;
26588         void* _res_ptr = untag_ptr(_res);
26589         CHECK_ACCESS(_res_ptr);
26590         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
26591         FREE(untag_ptr(_res));
26592         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
26593 }
26594
26595 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
26596         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
26597         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
26598         return tag_ptr(ret_conv, true);
26599 }
26600 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(int64_t arg) {
26601         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
26602         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
26603         return ret_conv;
26604 }
26605
26606 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_clone(int64_t orig) {
26607         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
26608         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
26609         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
26610         return tag_ptr(ret_conv, true);
26611 }
26612
26613 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_ok(int64_t o) {
26614         LDKChannelPublicKeys o_conv;
26615         o_conv.inner = untag_ptr(o);
26616         o_conv.is_owned = ptr_is_owned(o);
26617         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26618         o_conv = ChannelPublicKeys_clone(&o_conv);
26619         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26620         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
26621         return tag_ptr(ret_conv, true);
26622 }
26623
26624 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_err(int64_t e) {
26625         void* e_ptr = untag_ptr(e);
26626         CHECK_ACCESS(e_ptr);
26627         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26628         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26629         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26630         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
26631         return tag_ptr(ret_conv, true);
26632 }
26633
26634 jboolean  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(int64_t o) {
26635         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
26636         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
26637         return ret_conv;
26638 }
26639
26640 void  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_free(int64_t _res) {
26641         if (!ptr_is_owned(_res)) return;
26642         void* _res_ptr = untag_ptr(_res);
26643         CHECK_ACCESS(_res_ptr);
26644         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
26645         FREE(untag_ptr(_res));
26646         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
26647 }
26648
26649 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
26650         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26651         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
26652         return tag_ptr(ret_conv, true);
26653 }
26654 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(int64_t arg) {
26655         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
26656         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
26657         return ret_conv;
26658 }
26659
26660 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_clone(int64_t orig) {
26661         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
26662         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26663         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
26664         return tag_ptr(ret_conv, true);
26665 }
26666
26667 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(int64_t o) {
26668         LDKHTLCOutputInCommitment o_conv;
26669         o_conv.inner = untag_ptr(o);
26670         o_conv.is_owned = ptr_is_owned(o);
26671         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26672         o_conv = HTLCOutputInCommitment_clone(&o_conv);
26673         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26674         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
26675         return tag_ptr(ret_conv, true);
26676 }
26677
26678 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(int64_t e) {
26679         void* e_ptr = untag_ptr(e);
26680         CHECK_ACCESS(e_ptr);
26681         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26682         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26683         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26684         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
26685         return tag_ptr(ret_conv, true);
26686 }
26687
26688 jboolean  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(int64_t o) {
26689         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
26690         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
26691         return ret_conv;
26692 }
26693
26694 void  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(int64_t _res) {
26695         if (!ptr_is_owned(_res)) return;
26696         void* _res_ptr = untag_ptr(_res);
26697         CHECK_ACCESS(_res_ptr);
26698         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
26699         FREE(untag_ptr(_res));
26700         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
26701 }
26702
26703 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
26704         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26705         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
26706         return tag_ptr(ret_conv, true);
26707 }
26708 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(int64_t arg) {
26709         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
26710         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
26711         return ret_conv;
26712 }
26713
26714 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(int64_t orig) {
26715         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
26716         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26717         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
26718         return tag_ptr(ret_conv, true);
26719 }
26720
26721 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(int64_t o) {
26722         LDKCounterpartyChannelTransactionParameters o_conv;
26723         o_conv.inner = untag_ptr(o);
26724         o_conv.is_owned = ptr_is_owned(o);
26725         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26726         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
26727         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26728         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
26729         return tag_ptr(ret_conv, true);
26730 }
26731
26732 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(int64_t e) {
26733         void* e_ptr = untag_ptr(e);
26734         CHECK_ACCESS(e_ptr);
26735         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26736         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26737         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26738         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
26739         return tag_ptr(ret_conv, true);
26740 }
26741
26742 jboolean  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(int64_t o) {
26743         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
26744         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
26745         return ret_conv;
26746 }
26747
26748 void  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(int64_t _res) {
26749         if (!ptr_is_owned(_res)) return;
26750         void* _res_ptr = untag_ptr(_res);
26751         CHECK_ACCESS(_res_ptr);
26752         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
26753         FREE(untag_ptr(_res));
26754         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
26755 }
26756
26757 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
26758         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26759         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
26760         return tag_ptr(ret_conv, true);
26761 }
26762 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(int64_t arg) {
26763         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
26764         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
26765         return ret_conv;
26766 }
26767
26768 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(int64_t orig) {
26769         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
26770         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26771         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
26772         return tag_ptr(ret_conv, true);
26773 }
26774
26775 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_ok(int64_t o) {
26776         LDKChannelTransactionParameters o_conv;
26777         o_conv.inner = untag_ptr(o);
26778         o_conv.is_owned = ptr_is_owned(o);
26779         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26780         o_conv = ChannelTransactionParameters_clone(&o_conv);
26781         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26782         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
26783         return tag_ptr(ret_conv, true);
26784 }
26785
26786 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_err(int64_t e) {
26787         void* e_ptr = untag_ptr(e);
26788         CHECK_ACCESS(e_ptr);
26789         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26790         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26791         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26792         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
26793         return tag_ptr(ret_conv, true);
26794 }
26795
26796 jboolean  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(int64_t o) {
26797         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
26798         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
26799         return ret_conv;
26800 }
26801
26802 void  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_free(int64_t _res) {
26803         if (!ptr_is_owned(_res)) return;
26804         void* _res_ptr = untag_ptr(_res);
26805         CHECK_ACCESS(_res_ptr);
26806         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
26807         FREE(untag_ptr(_res));
26808         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
26809 }
26810
26811 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
26812         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26813         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
26814         return tag_ptr(ret_conv, true);
26815 }
26816 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(int64_t arg) {
26817         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
26818         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
26819         return ret_conv;
26820 }
26821
26822 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_clone(int64_t orig) {
26823         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
26824         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26825         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
26826         return tag_ptr(ret_conv, true);
26827 }
26828
26829 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(int64_t o) {
26830         LDKHolderCommitmentTransaction o_conv;
26831         o_conv.inner = untag_ptr(o);
26832         o_conv.is_owned = ptr_is_owned(o);
26833         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26834         o_conv = HolderCommitmentTransaction_clone(&o_conv);
26835         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26836         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
26837         return tag_ptr(ret_conv, true);
26838 }
26839
26840 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_err(int64_t e) {
26841         void* e_ptr = untag_ptr(e);
26842         CHECK_ACCESS(e_ptr);
26843         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26844         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26845         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26846         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
26847         return tag_ptr(ret_conv, true);
26848 }
26849
26850 jboolean  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(int64_t o) {
26851         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
26852         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
26853         return ret_conv;
26854 }
26855
26856 void  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_free(int64_t _res) {
26857         if (!ptr_is_owned(_res)) return;
26858         void* _res_ptr = untag_ptr(_res);
26859         CHECK_ACCESS(_res_ptr);
26860         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
26861         FREE(untag_ptr(_res));
26862         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
26863 }
26864
26865 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
26866         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26867         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
26868         return tag_ptr(ret_conv, true);
26869 }
26870 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(int64_t arg) {
26871         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
26872         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
26873         return ret_conv;
26874 }
26875
26876 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(int64_t orig) {
26877         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
26878         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26879         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
26880         return tag_ptr(ret_conv, true);
26881 }
26882
26883 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(int64_t o) {
26884         LDKBuiltCommitmentTransaction o_conv;
26885         o_conv.inner = untag_ptr(o);
26886         o_conv.is_owned = ptr_is_owned(o);
26887         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26888         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
26889         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26890         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
26891         return tag_ptr(ret_conv, true);
26892 }
26893
26894 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(int64_t e) {
26895         void* e_ptr = untag_ptr(e);
26896         CHECK_ACCESS(e_ptr);
26897         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26898         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26899         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26900         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
26901         return tag_ptr(ret_conv, true);
26902 }
26903
26904 jboolean  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(int64_t o) {
26905         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
26906         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
26907         return ret_conv;
26908 }
26909
26910 void  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(int64_t _res) {
26911         if (!ptr_is_owned(_res)) return;
26912         void* _res_ptr = untag_ptr(_res);
26913         CHECK_ACCESS(_res_ptr);
26914         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
26915         FREE(untag_ptr(_res));
26916         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
26917 }
26918
26919 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
26920         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26921         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
26922         return tag_ptr(ret_conv, true);
26923 }
26924 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(int64_t arg) {
26925         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
26926         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
26927         return ret_conv;
26928 }
26929
26930 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(int64_t orig) {
26931         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
26932         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26933         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
26934         return tag_ptr(ret_conv, true);
26935 }
26936
26937 int64_t  CS_LDK_CResult_TrustedClosingTransactionNoneZ_ok(int64_t o) {
26938         LDKTrustedClosingTransaction o_conv;
26939         o_conv.inner = untag_ptr(o);
26940         o_conv.is_owned = ptr_is_owned(o);
26941         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26942         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
26943         
26944         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
26945         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
26946         return tag_ptr(ret_conv, true);
26947 }
26948
26949 int64_t  CS_LDK_CResult_TrustedClosingTransactionNoneZ_err() {
26950         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
26951         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
26952         return tag_ptr(ret_conv, true);
26953 }
26954
26955 jboolean  CS_LDK_CResult_TrustedClosingTransactionNoneZ_is_ok(int64_t o) {
26956         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
26957         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
26958         return ret_conv;
26959 }
26960
26961 void  CS_LDK_CResult_TrustedClosingTransactionNoneZ_free(int64_t _res) {
26962         if (!ptr_is_owned(_res)) return;
26963         void* _res_ptr = untag_ptr(_res);
26964         CHECK_ACCESS(_res_ptr);
26965         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
26966         FREE(untag_ptr(_res));
26967         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
26968 }
26969
26970 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_ok(int64_t o) {
26971         LDKCommitmentTransaction o_conv;
26972         o_conv.inner = untag_ptr(o);
26973         o_conv.is_owned = ptr_is_owned(o);
26974         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26975         o_conv = CommitmentTransaction_clone(&o_conv);
26976         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
26977         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
26978         return tag_ptr(ret_conv, true);
26979 }
26980
26981 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_err(int64_t e) {
26982         void* e_ptr = untag_ptr(e);
26983         CHECK_ACCESS(e_ptr);
26984         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26985         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26986         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
26987         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
26988         return tag_ptr(ret_conv, true);
26989 }
26990
26991 jboolean  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_is_ok(int64_t o) {
26992         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
26993         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
26994         return ret_conv;
26995 }
26996
26997 void  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_free(int64_t _res) {
26998         if (!ptr_is_owned(_res)) return;
26999         void* _res_ptr = untag_ptr(_res);
27000         CHECK_ACCESS(_res_ptr);
27001         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
27002         FREE(untag_ptr(_res));
27003         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
27004 }
27005
27006 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
27007         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
27008         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
27009         return tag_ptr(ret_conv, true);
27010 }
27011 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(int64_t arg) {
27012         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
27013         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
27014         return ret_conv;
27015 }
27016
27017 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_clone(int64_t orig) {
27018         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
27019         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
27020         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
27021         return tag_ptr(ret_conv, true);
27022 }
27023
27024 int64_t  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_ok(int64_t o) {
27025         LDKTrustedCommitmentTransaction o_conv;
27026         o_conv.inner = untag_ptr(o);
27027         o_conv.is_owned = ptr_is_owned(o);
27028         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27029         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
27030         
27031         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
27032         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
27033         return tag_ptr(ret_conv, true);
27034 }
27035
27036 int64_t  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_err() {
27037         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
27038         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
27039         return tag_ptr(ret_conv, true);
27040 }
27041
27042 jboolean  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_is_ok(int64_t o) {
27043         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
27044         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
27045         return ret_conv;
27046 }
27047
27048 void  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_free(int64_t _res) {
27049         if (!ptr_is_owned(_res)) return;
27050         void* _res_ptr = untag_ptr(_res);
27051         CHECK_ACCESS(_res_ptr);
27052         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
27053         FREE(untag_ptr(_res));
27054         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
27055 }
27056
27057 int64_t  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_ok(ptrArray o) {
27058         LDKCVec_ECDSASignatureZ o_constr;
27059         o_constr.datalen = o->arr_len;
27060         if (o_constr.datalen > 0)
27061                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
27062         else
27063                 o_constr.data = NULL;
27064         int8_tArray* o_vals = (void*) o->elems;
27065         for (size_t i = 0; i < o_constr.datalen; i++) {
27066                 int8_tArray o_conv_8 = o_vals[i];
27067                 LDKECDSASignature o_conv_8_ref;
27068                 CHECK(o_conv_8->arr_len == 64);
27069                 memcpy(o_conv_8_ref.compact_form, o_conv_8->elems, 64); FREE(o_conv_8);
27070                 o_constr.data[i] = o_conv_8_ref;
27071         }
27072         FREE(o);
27073         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
27074         *ret_conv = CResult_CVec_ECDSASignatureZNoneZ_ok(o_constr);
27075         return tag_ptr(ret_conv, true);
27076 }
27077
27078 int64_t  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_err() {
27079         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
27080         *ret_conv = CResult_CVec_ECDSASignatureZNoneZ_err();
27081         return tag_ptr(ret_conv, true);
27082 }
27083
27084 jboolean  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_is_ok(int64_t o) {
27085         LDKCResult_CVec_ECDSASignatureZNoneZ* o_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(o);
27086         jboolean ret_conv = CResult_CVec_ECDSASignatureZNoneZ_is_ok(o_conv);
27087         return ret_conv;
27088 }
27089
27090 void  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_free(int64_t _res) {
27091         if (!ptr_is_owned(_res)) return;
27092         void* _res_ptr = untag_ptr(_res);
27093         CHECK_ACCESS(_res_ptr);
27094         LDKCResult_CVec_ECDSASignatureZNoneZ _res_conv = *(LDKCResult_CVec_ECDSASignatureZNoneZ*)(_res_ptr);
27095         FREE(untag_ptr(_res));
27096         CResult_CVec_ECDSASignatureZNoneZ_free(_res_conv);
27097 }
27098
27099 static inline uint64_t CResult_CVec_ECDSASignatureZNoneZ_clone_ptr(LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR arg) {
27100         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
27101         *ret_conv = CResult_CVec_ECDSASignatureZNoneZ_clone(arg);
27102         return tag_ptr(ret_conv, true);
27103 }
27104 int64_t  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_clone_ptr(int64_t arg) {
27105         LDKCResult_CVec_ECDSASignatureZNoneZ* arg_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(arg);
27106         int64_t ret_conv = CResult_CVec_ECDSASignatureZNoneZ_clone_ptr(arg_conv);
27107         return ret_conv;
27108 }
27109
27110 int64_t  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_clone(int64_t orig) {
27111         LDKCResult_CVec_ECDSASignatureZNoneZ* orig_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(orig);
27112         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
27113         *ret_conv = CResult_CVec_ECDSASignatureZNoneZ_clone(orig_conv);
27114         return tag_ptr(ret_conv, true);
27115 }
27116
27117 int64_t  CS_LDK_COption_usizeZ_some(int64_t o) {
27118         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
27119         *ret_copy = COption_usizeZ_some(o);
27120         int64_t ret_ref = tag_ptr(ret_copy, true);
27121         return ret_ref;
27122 }
27123
27124 int64_t  CS_LDK_COption_usizeZ_none() {
27125         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
27126         *ret_copy = COption_usizeZ_none();
27127         int64_t ret_ref = tag_ptr(ret_copy, true);
27128         return ret_ref;
27129 }
27130
27131 void  CS_LDK_COption_usizeZ_free(int64_t _res) {
27132         if (!ptr_is_owned(_res)) return;
27133         void* _res_ptr = untag_ptr(_res);
27134         CHECK_ACCESS(_res_ptr);
27135         LDKCOption_usizeZ _res_conv = *(LDKCOption_usizeZ*)(_res_ptr);
27136         FREE(untag_ptr(_res));
27137         COption_usizeZ_free(_res_conv);
27138 }
27139
27140 static inline uint64_t COption_usizeZ_clone_ptr(LDKCOption_usizeZ *NONNULL_PTR arg) {
27141         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
27142         *ret_copy = COption_usizeZ_clone(arg);
27143         int64_t ret_ref = tag_ptr(ret_copy, true);
27144         return ret_ref;
27145 }
27146 int64_t  CS_LDK_COption_usizeZ_clone_ptr(int64_t arg) {
27147         LDKCOption_usizeZ* arg_conv = (LDKCOption_usizeZ*)untag_ptr(arg);
27148         int64_t ret_conv = COption_usizeZ_clone_ptr(arg_conv);
27149         return ret_conv;
27150 }
27151
27152 int64_t  CS_LDK_COption_usizeZ_clone(int64_t orig) {
27153         LDKCOption_usizeZ* orig_conv = (LDKCOption_usizeZ*)untag_ptr(orig);
27154         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
27155         *ret_copy = COption_usizeZ_clone(orig_conv);
27156         int64_t ret_ref = tag_ptr(ret_copy, true);
27157         return ret_ref;
27158 }
27159
27160 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_ok(int64_t o) {
27161         LDKShutdownScript o_conv;
27162         o_conv.inner = untag_ptr(o);
27163         o_conv.is_owned = ptr_is_owned(o);
27164         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27165         o_conv = ShutdownScript_clone(&o_conv);
27166         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27167         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
27168         return tag_ptr(ret_conv, true);
27169 }
27170
27171 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_err(int64_t e) {
27172         void* e_ptr = untag_ptr(e);
27173         CHECK_ACCESS(e_ptr);
27174         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27175         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27176         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27177         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
27178         return tag_ptr(ret_conv, true);
27179 }
27180
27181 jboolean  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_is_ok(int64_t o) {
27182         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
27183         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
27184         return ret_conv;
27185 }
27186
27187 void  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_free(int64_t _res) {
27188         if (!ptr_is_owned(_res)) return;
27189         void* _res_ptr = untag_ptr(_res);
27190         CHECK_ACCESS(_res_ptr);
27191         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
27192         FREE(untag_ptr(_res));
27193         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
27194 }
27195
27196 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
27197         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27198         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
27199         return tag_ptr(ret_conv, true);
27200 }
27201 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(int64_t arg) {
27202         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
27203         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
27204         return ret_conv;
27205 }
27206
27207 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_clone(int64_t orig) {
27208         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
27209         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27210         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
27211         return tag_ptr(ret_conv, true);
27212 }
27213
27214 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(int64_t o) {
27215         LDKShutdownScript o_conv;
27216         o_conv.inner = untag_ptr(o);
27217         o_conv.is_owned = ptr_is_owned(o);
27218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27219         o_conv = ShutdownScript_clone(&o_conv);
27220         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27221         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
27222         return tag_ptr(ret_conv, true);
27223 }
27224
27225 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_err(int64_t e) {
27226         LDKInvalidShutdownScript e_conv;
27227         e_conv.inner = untag_ptr(e);
27228         e_conv.is_owned = ptr_is_owned(e);
27229         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
27230         e_conv = InvalidShutdownScript_clone(&e_conv);
27231         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27232         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
27233         return tag_ptr(ret_conv, true);
27234 }
27235
27236 jboolean  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(int64_t o) {
27237         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
27238         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
27239         return ret_conv;
27240 }
27241
27242 void  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_free(int64_t _res) {
27243         if (!ptr_is_owned(_res)) return;
27244         void* _res_ptr = untag_ptr(_res);
27245         CHECK_ACCESS(_res_ptr);
27246         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
27247         FREE(untag_ptr(_res));
27248         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
27249 }
27250
27251 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
27252         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27253         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
27254         return tag_ptr(ret_conv, true);
27255 }
27256 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(int64_t arg) {
27257         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
27258         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
27259         return ret_conv;
27260 }
27261
27262 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(int64_t orig) {
27263         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
27264         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27265         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
27266         return tag_ptr(ret_conv, true);
27267 }
27268
27269 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_ok(int64_t o) {
27270         void* o_ptr = untag_ptr(o);
27271         CHECK_ACCESS(o_ptr);
27272         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
27273         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
27274         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
27275         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
27276         return tag_ptr(ret_conv, true);
27277 }
27278
27279 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_err(int64_t e) {
27280         void* e_ptr = untag_ptr(e);
27281         CHECK_ACCESS(e_ptr);
27282         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27283         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27284         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
27285         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
27286         return tag_ptr(ret_conv, true);
27287 }
27288
27289 jboolean  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_is_ok(int64_t o) {
27290         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
27291         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
27292         return ret_conv;
27293 }
27294
27295 void  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_free(int64_t _res) {
27296         if (!ptr_is_owned(_res)) return;
27297         void* _res_ptr = untag_ptr(_res);
27298         CHECK_ACCESS(_res_ptr);
27299         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
27300         FREE(untag_ptr(_res));
27301         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
27302 }
27303
27304 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
27305         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
27306         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
27307         return tag_ptr(ret_conv, true);
27308 }
27309 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(int64_t arg) {
27310         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
27311         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
27312         return ret_conv;
27313 }
27314
27315 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_clone(int64_t orig) {
27316         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
27317         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
27318         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
27319         return tag_ptr(ret_conv, true);
27320 }
27321
27322 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_ok(int64_t o) {
27323         LDKClaimedHTLC o_conv;
27324         o_conv.inner = untag_ptr(o);
27325         o_conv.is_owned = ptr_is_owned(o);
27326         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27327         o_conv = ClaimedHTLC_clone(&o_conv);
27328         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
27329         *ret_conv = CResult_ClaimedHTLCDecodeErrorZ_ok(o_conv);
27330         return tag_ptr(ret_conv, true);
27331 }
27332
27333 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_err(int64_t e) {
27334         void* e_ptr = untag_ptr(e);
27335         CHECK_ACCESS(e_ptr);
27336         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27337         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27338         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
27339         *ret_conv = CResult_ClaimedHTLCDecodeErrorZ_err(e_conv);
27340         return tag_ptr(ret_conv, true);
27341 }
27342
27343 jboolean  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_is_ok(int64_t o) {
27344         LDKCResult_ClaimedHTLCDecodeErrorZ* o_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(o);
27345         jboolean ret_conv = CResult_ClaimedHTLCDecodeErrorZ_is_ok(o_conv);
27346         return ret_conv;
27347 }
27348
27349 void  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_free(int64_t _res) {
27350         if (!ptr_is_owned(_res)) return;
27351         void* _res_ptr = untag_ptr(_res);
27352         CHECK_ACCESS(_res_ptr);
27353         LDKCResult_ClaimedHTLCDecodeErrorZ _res_conv = *(LDKCResult_ClaimedHTLCDecodeErrorZ*)(_res_ptr);
27354         FREE(untag_ptr(_res));
27355         CResult_ClaimedHTLCDecodeErrorZ_free(_res_conv);
27356 }
27357
27358 static inline uint64_t CResult_ClaimedHTLCDecodeErrorZ_clone_ptr(LDKCResult_ClaimedHTLCDecodeErrorZ *NONNULL_PTR arg) {
27359         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
27360         *ret_conv = CResult_ClaimedHTLCDecodeErrorZ_clone(arg);
27361         return tag_ptr(ret_conv, true);
27362 }
27363 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
27364         LDKCResult_ClaimedHTLCDecodeErrorZ* arg_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(arg);
27365         int64_t ret_conv = CResult_ClaimedHTLCDecodeErrorZ_clone_ptr(arg_conv);
27366         return ret_conv;
27367 }
27368
27369 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_clone(int64_t orig) {
27370         LDKCResult_ClaimedHTLCDecodeErrorZ* orig_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(orig);
27371         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
27372         *ret_conv = CResult_ClaimedHTLCDecodeErrorZ_clone(orig_conv);
27373         return tag_ptr(ret_conv, true);
27374 }
27375
27376 int64_t  CS_LDK_COption_PathFailureZ_some(int64_t o) {
27377         void* o_ptr = untag_ptr(o);
27378         CHECK_ACCESS(o_ptr);
27379         LDKPathFailure o_conv = *(LDKPathFailure*)(o_ptr);
27380         o_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(o));
27381         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
27382         *ret_copy = COption_PathFailureZ_some(o_conv);
27383         int64_t ret_ref = tag_ptr(ret_copy, true);
27384         return ret_ref;
27385 }
27386
27387 int64_t  CS_LDK_COption_PathFailureZ_none() {
27388         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
27389         *ret_copy = COption_PathFailureZ_none();
27390         int64_t ret_ref = tag_ptr(ret_copy, true);
27391         return ret_ref;
27392 }
27393
27394 void  CS_LDK_COption_PathFailureZ_free(int64_t _res) {
27395         if (!ptr_is_owned(_res)) return;
27396         void* _res_ptr = untag_ptr(_res);
27397         CHECK_ACCESS(_res_ptr);
27398         LDKCOption_PathFailureZ _res_conv = *(LDKCOption_PathFailureZ*)(_res_ptr);
27399         FREE(untag_ptr(_res));
27400         COption_PathFailureZ_free(_res_conv);
27401 }
27402
27403 static inline uint64_t COption_PathFailureZ_clone_ptr(LDKCOption_PathFailureZ *NONNULL_PTR arg) {
27404         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
27405         *ret_copy = COption_PathFailureZ_clone(arg);
27406         int64_t ret_ref = tag_ptr(ret_copy, true);
27407         return ret_ref;
27408 }
27409 int64_t  CS_LDK_COption_PathFailureZ_clone_ptr(int64_t arg) {
27410         LDKCOption_PathFailureZ* arg_conv = (LDKCOption_PathFailureZ*)untag_ptr(arg);
27411         int64_t ret_conv = COption_PathFailureZ_clone_ptr(arg_conv);
27412         return ret_conv;
27413 }
27414
27415 int64_t  CS_LDK_COption_PathFailureZ_clone(int64_t orig) {
27416         LDKCOption_PathFailureZ* orig_conv = (LDKCOption_PathFailureZ*)untag_ptr(orig);
27417         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
27418         *ret_copy = COption_PathFailureZ_clone(orig_conv);
27419         int64_t ret_ref = tag_ptr(ret_copy, true);
27420         return ret_ref;
27421 }
27422
27423 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_ok(int64_t o) {
27424         void* o_ptr = untag_ptr(o);
27425         CHECK_ACCESS(o_ptr);
27426         LDKCOption_PathFailureZ o_conv = *(LDKCOption_PathFailureZ*)(o_ptr);
27427         o_conv = COption_PathFailureZ_clone((LDKCOption_PathFailureZ*)untag_ptr(o));
27428         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
27429         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_ok(o_conv);
27430         return tag_ptr(ret_conv, true);
27431 }
27432
27433 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_err(int64_t e) {
27434         void* e_ptr = untag_ptr(e);
27435         CHECK_ACCESS(e_ptr);
27436         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27437         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27438         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
27439         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_err(e_conv);
27440         return tag_ptr(ret_conv, true);
27441 }
27442
27443 jboolean  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_is_ok(int64_t o) {
27444         LDKCResult_COption_PathFailureZDecodeErrorZ* o_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(o);
27445         jboolean ret_conv = CResult_COption_PathFailureZDecodeErrorZ_is_ok(o_conv);
27446         return ret_conv;
27447 }
27448
27449 void  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_free(int64_t _res) {
27450         if (!ptr_is_owned(_res)) return;
27451         void* _res_ptr = untag_ptr(_res);
27452         CHECK_ACCESS(_res_ptr);
27453         LDKCResult_COption_PathFailureZDecodeErrorZ _res_conv = *(LDKCResult_COption_PathFailureZDecodeErrorZ*)(_res_ptr);
27454         FREE(untag_ptr(_res));
27455         CResult_COption_PathFailureZDecodeErrorZ_free(_res_conv);
27456 }
27457
27458 static inline uint64_t CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR arg) {
27459         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
27460         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(arg);
27461         return tag_ptr(ret_conv, true);
27462 }
27463 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(int64_t arg) {
27464         LDKCResult_COption_PathFailureZDecodeErrorZ* arg_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(arg);
27465         int64_t ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(arg_conv);
27466         return ret_conv;
27467 }
27468
27469 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_clone(int64_t orig) {
27470         LDKCResult_COption_PathFailureZDecodeErrorZ* orig_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(orig);
27471         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
27472         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(orig_conv);
27473         return tag_ptr(ret_conv, true);
27474 }
27475
27476 int64_t  CS_LDK_COption_ClosureReasonZ_some(int64_t o) {
27477         void* o_ptr = untag_ptr(o);
27478         CHECK_ACCESS(o_ptr);
27479         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
27480         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
27481         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
27482         *ret_copy = COption_ClosureReasonZ_some(o_conv);
27483         int64_t ret_ref = tag_ptr(ret_copy, true);
27484         return ret_ref;
27485 }
27486
27487 int64_t  CS_LDK_COption_ClosureReasonZ_none() {
27488         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
27489         *ret_copy = COption_ClosureReasonZ_none();
27490         int64_t ret_ref = tag_ptr(ret_copy, true);
27491         return ret_ref;
27492 }
27493
27494 void  CS_LDK_COption_ClosureReasonZ_free(int64_t _res) {
27495         if (!ptr_is_owned(_res)) return;
27496         void* _res_ptr = untag_ptr(_res);
27497         CHECK_ACCESS(_res_ptr);
27498         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
27499         FREE(untag_ptr(_res));
27500         COption_ClosureReasonZ_free(_res_conv);
27501 }
27502
27503 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
27504         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
27505         *ret_copy = COption_ClosureReasonZ_clone(arg);
27506         int64_t ret_ref = tag_ptr(ret_copy, true);
27507         return ret_ref;
27508 }
27509 int64_t  CS_LDK_COption_ClosureReasonZ_clone_ptr(int64_t arg) {
27510         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
27511         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
27512         return ret_conv;
27513 }
27514
27515 int64_t  CS_LDK_COption_ClosureReasonZ_clone(int64_t orig) {
27516         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
27517         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
27518         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
27519         int64_t ret_ref = tag_ptr(ret_copy, true);
27520         return ret_ref;
27521 }
27522
27523 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_ok(int64_t o) {
27524         void* o_ptr = untag_ptr(o);
27525         CHECK_ACCESS(o_ptr);
27526         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
27527         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
27528         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
27529         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
27530         return tag_ptr(ret_conv, true);
27531 }
27532
27533 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_err(int64_t e) {
27534         void* e_ptr = untag_ptr(e);
27535         CHECK_ACCESS(e_ptr);
27536         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27537         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27538         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
27539         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
27540         return tag_ptr(ret_conv, true);
27541 }
27542
27543 jboolean  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(int64_t o) {
27544         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
27545         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
27546         return ret_conv;
27547 }
27548
27549 void  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_free(int64_t _res) {
27550         if (!ptr_is_owned(_res)) return;
27551         void* _res_ptr = untag_ptr(_res);
27552         CHECK_ACCESS(_res_ptr);
27553         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
27554         FREE(untag_ptr(_res));
27555         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
27556 }
27557
27558 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
27559         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
27560         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
27561         return tag_ptr(ret_conv, true);
27562 }
27563 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(int64_t arg) {
27564         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
27565         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
27566         return ret_conv;
27567 }
27568
27569 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_clone(int64_t orig) {
27570         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
27571         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
27572         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
27573         return tag_ptr(ret_conv, true);
27574 }
27575
27576 int64_t  CS_LDK_COption_HTLCDestinationZ_some(int64_t o) {
27577         void* o_ptr = untag_ptr(o);
27578         CHECK_ACCESS(o_ptr);
27579         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
27580         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
27581         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
27582         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
27583         int64_t ret_ref = tag_ptr(ret_copy, true);
27584         return ret_ref;
27585 }
27586
27587 int64_t  CS_LDK_COption_HTLCDestinationZ_none() {
27588         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
27589         *ret_copy = COption_HTLCDestinationZ_none();
27590         int64_t ret_ref = tag_ptr(ret_copy, true);
27591         return ret_ref;
27592 }
27593
27594 void  CS_LDK_COption_HTLCDestinationZ_free(int64_t _res) {
27595         if (!ptr_is_owned(_res)) return;
27596         void* _res_ptr = untag_ptr(_res);
27597         CHECK_ACCESS(_res_ptr);
27598         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
27599         FREE(untag_ptr(_res));
27600         COption_HTLCDestinationZ_free(_res_conv);
27601 }
27602
27603 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
27604         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
27605         *ret_copy = COption_HTLCDestinationZ_clone(arg);
27606         int64_t ret_ref = tag_ptr(ret_copy, true);
27607         return ret_ref;
27608 }
27609 int64_t  CS_LDK_COption_HTLCDestinationZ_clone_ptr(int64_t arg) {
27610         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
27611         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
27612         return ret_conv;
27613 }
27614
27615 int64_t  CS_LDK_COption_HTLCDestinationZ_clone(int64_t orig) {
27616         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
27617         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
27618         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
27619         int64_t ret_ref = tag_ptr(ret_copy, true);
27620         return ret_ref;
27621 }
27622
27623 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_ok(int64_t o) {
27624         void* o_ptr = untag_ptr(o);
27625         CHECK_ACCESS(o_ptr);
27626         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
27627         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
27628         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
27629         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
27630         return tag_ptr(ret_conv, true);
27631 }
27632
27633 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_err(int64_t e) {
27634         void* e_ptr = untag_ptr(e);
27635         CHECK_ACCESS(e_ptr);
27636         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27637         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27638         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
27639         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
27640         return tag_ptr(ret_conv, true);
27641 }
27642
27643 jboolean  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(int64_t o) {
27644         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
27645         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
27646         return ret_conv;
27647 }
27648
27649 void  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_free(int64_t _res) {
27650         if (!ptr_is_owned(_res)) return;
27651         void* _res_ptr = untag_ptr(_res);
27652         CHECK_ACCESS(_res_ptr);
27653         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
27654         FREE(untag_ptr(_res));
27655         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
27656 }
27657
27658 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
27659         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
27660         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
27661         return tag_ptr(ret_conv, true);
27662 }
27663 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(int64_t arg) {
27664         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
27665         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
27666         return ret_conv;
27667 }
27668
27669 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_clone(int64_t orig) {
27670         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
27671         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
27672         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
27673         return tag_ptr(ret_conv, true);
27674 }
27675
27676 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_ok(int32_t o) {
27677         LDKPaymentFailureReason o_conv = LDKPaymentFailureReason_from_cs(o);
27678         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
27679         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_ok(o_conv);
27680         return tag_ptr(ret_conv, true);
27681 }
27682
27683 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_err(int64_t e) {
27684         void* e_ptr = untag_ptr(e);
27685         CHECK_ACCESS(e_ptr);
27686         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27687         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27688         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
27689         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_err(e_conv);
27690         return tag_ptr(ret_conv, true);
27691 }
27692
27693 jboolean  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_is_ok(int64_t o) {
27694         LDKCResult_PaymentFailureReasonDecodeErrorZ* o_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(o);
27695         jboolean ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o_conv);
27696         return ret_conv;
27697 }
27698
27699 void  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_free(int64_t _res) {
27700         if (!ptr_is_owned(_res)) return;
27701         void* _res_ptr = untag_ptr(_res);
27702         CHECK_ACCESS(_res_ptr);
27703         LDKCResult_PaymentFailureReasonDecodeErrorZ _res_conv = *(LDKCResult_PaymentFailureReasonDecodeErrorZ*)(_res_ptr);
27704         FREE(untag_ptr(_res));
27705         CResult_PaymentFailureReasonDecodeErrorZ_free(_res_conv);
27706 }
27707
27708 static inline uint64_t CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR arg) {
27709         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
27710         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone(arg);
27711         return tag_ptr(ret_conv, true);
27712 }
27713 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(int64_t arg) {
27714         LDKCResult_PaymentFailureReasonDecodeErrorZ* arg_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(arg);
27715         int64_t ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(arg_conv);
27716         return ret_conv;
27717 }
27718
27719 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_clone(int64_t orig) {
27720         LDKCResult_PaymentFailureReasonDecodeErrorZ* orig_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(orig);
27721         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
27722         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone(orig_conv);
27723         return tag_ptr(ret_conv, true);
27724 }
27725
27726 int64_t  CS_LDK_COption_U128Z_some(int8_tArray o) {
27727         LDKU128 o_ref;
27728         CHECK(o->arr_len == 16);
27729         memcpy(o_ref.le_bytes, o->elems, 16); FREE(o);
27730         LDKCOption_U128Z *ret_copy = MALLOC(sizeof(LDKCOption_U128Z), "LDKCOption_U128Z");
27731         *ret_copy = COption_U128Z_some(o_ref);
27732         int64_t ret_ref = tag_ptr(ret_copy, true);
27733         return ret_ref;
27734 }
27735
27736 int64_t  CS_LDK_COption_U128Z_none() {
27737         LDKCOption_U128Z *ret_copy = MALLOC(sizeof(LDKCOption_U128Z), "LDKCOption_U128Z");
27738         *ret_copy = COption_U128Z_none();
27739         int64_t ret_ref = tag_ptr(ret_copy, true);
27740         return ret_ref;
27741 }
27742
27743 void  CS_LDK_COption_U128Z_free(int64_t _res) {
27744         if (!ptr_is_owned(_res)) return;
27745         void* _res_ptr = untag_ptr(_res);
27746         CHECK_ACCESS(_res_ptr);
27747         LDKCOption_U128Z _res_conv = *(LDKCOption_U128Z*)(_res_ptr);
27748         FREE(untag_ptr(_res));
27749         COption_U128Z_free(_res_conv);
27750 }
27751
27752 static inline uint64_t COption_U128Z_clone_ptr(LDKCOption_U128Z *NONNULL_PTR arg) {
27753         LDKCOption_U128Z *ret_copy = MALLOC(sizeof(LDKCOption_U128Z), "LDKCOption_U128Z");
27754         *ret_copy = COption_U128Z_clone(arg);
27755         int64_t ret_ref = tag_ptr(ret_copy, true);
27756         return ret_ref;
27757 }
27758 int64_t  CS_LDK_COption_U128Z_clone_ptr(int64_t arg) {
27759         LDKCOption_U128Z* arg_conv = (LDKCOption_U128Z*)untag_ptr(arg);
27760         int64_t ret_conv = COption_U128Z_clone_ptr(arg_conv);
27761         return ret_conv;
27762 }
27763
27764 int64_t  CS_LDK_COption_U128Z_clone(int64_t orig) {
27765         LDKCOption_U128Z* orig_conv = (LDKCOption_U128Z*)untag_ptr(orig);
27766         LDKCOption_U128Z *ret_copy = MALLOC(sizeof(LDKCOption_U128Z), "LDKCOption_U128Z");
27767         *ret_copy = COption_U128Z_clone(orig_conv);
27768         int64_t ret_ref = tag_ptr(ret_copy, true);
27769         return ret_ref;
27770 }
27771
27772 void  CS_LDK_CVec_ClaimedHTLCZ_free(int64_tArray _res) {
27773         LDKCVec_ClaimedHTLCZ _res_constr;
27774         _res_constr.datalen = _res->arr_len;
27775         if (_res_constr.datalen > 0)
27776                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKClaimedHTLC), "LDKCVec_ClaimedHTLCZ Elements");
27777         else
27778                 _res_constr.data = NULL;
27779         int64_t* _res_vals = _res->elems;
27780         for (size_t n = 0; n < _res_constr.datalen; n++) {
27781                 int64_t _res_conv_13 = _res_vals[n];
27782                 LDKClaimedHTLC _res_conv_13_conv;
27783                 _res_conv_13_conv.inner = untag_ptr(_res_conv_13);
27784                 _res_conv_13_conv.is_owned = ptr_is_owned(_res_conv_13);
27785                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_13_conv);
27786                 _res_constr.data[n] = _res_conv_13_conv;
27787         }
27788         FREE(_res);
27789         CVec_ClaimedHTLCZ_free(_res_constr);
27790 }
27791
27792 int64_t  CS_LDK_COption_PaymentFailureReasonZ_some(int32_t o) {
27793         LDKPaymentFailureReason o_conv = LDKPaymentFailureReason_from_cs(o);
27794         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
27795         *ret_copy = COption_PaymentFailureReasonZ_some(o_conv);
27796         int64_t ret_ref = tag_ptr(ret_copy, true);
27797         return ret_ref;
27798 }
27799
27800 int64_t  CS_LDK_COption_PaymentFailureReasonZ_none() {
27801         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
27802         *ret_copy = COption_PaymentFailureReasonZ_none();
27803         int64_t ret_ref = tag_ptr(ret_copy, true);
27804         return ret_ref;
27805 }
27806
27807 void  CS_LDK_COption_PaymentFailureReasonZ_free(int64_t _res) {
27808         if (!ptr_is_owned(_res)) return;
27809         void* _res_ptr = untag_ptr(_res);
27810         CHECK_ACCESS(_res_ptr);
27811         LDKCOption_PaymentFailureReasonZ _res_conv = *(LDKCOption_PaymentFailureReasonZ*)(_res_ptr);
27812         FREE(untag_ptr(_res));
27813         COption_PaymentFailureReasonZ_free(_res_conv);
27814 }
27815
27816 static inline uint64_t COption_PaymentFailureReasonZ_clone_ptr(LDKCOption_PaymentFailureReasonZ *NONNULL_PTR arg) {
27817         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
27818         *ret_copy = COption_PaymentFailureReasonZ_clone(arg);
27819         int64_t ret_ref = tag_ptr(ret_copy, true);
27820         return ret_ref;
27821 }
27822 int64_t  CS_LDK_COption_PaymentFailureReasonZ_clone_ptr(int64_t arg) {
27823         LDKCOption_PaymentFailureReasonZ* arg_conv = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(arg);
27824         int64_t ret_conv = COption_PaymentFailureReasonZ_clone_ptr(arg_conv);
27825         return ret_conv;
27826 }
27827
27828 int64_t  CS_LDK_COption_PaymentFailureReasonZ_clone(int64_t orig) {
27829         LDKCOption_PaymentFailureReasonZ* orig_conv = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(orig);
27830         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
27831         *ret_copy = COption_PaymentFailureReasonZ_clone(orig_conv);
27832         int64_t ret_ref = tag_ptr(ret_copy, true);
27833         return ret_ref;
27834 }
27835
27836 int64_t  CS_LDK_COption_EventZ_some(int64_t o) {
27837         void* o_ptr = untag_ptr(o);
27838         CHECK_ACCESS(o_ptr);
27839         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
27840         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
27841         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
27842         *ret_copy = COption_EventZ_some(o_conv);
27843         int64_t ret_ref = tag_ptr(ret_copy, true);
27844         return ret_ref;
27845 }
27846
27847 int64_t  CS_LDK_COption_EventZ_none() {
27848         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
27849         *ret_copy = COption_EventZ_none();
27850         int64_t ret_ref = tag_ptr(ret_copy, true);
27851         return ret_ref;
27852 }
27853
27854 void  CS_LDK_COption_EventZ_free(int64_t _res) {
27855         if (!ptr_is_owned(_res)) return;
27856         void* _res_ptr = untag_ptr(_res);
27857         CHECK_ACCESS(_res_ptr);
27858         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
27859         FREE(untag_ptr(_res));
27860         COption_EventZ_free(_res_conv);
27861 }
27862
27863 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
27864         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
27865         *ret_copy = COption_EventZ_clone(arg);
27866         int64_t ret_ref = tag_ptr(ret_copy, true);
27867         return ret_ref;
27868 }
27869 int64_t  CS_LDK_COption_EventZ_clone_ptr(int64_t arg) {
27870         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
27871         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
27872         return ret_conv;
27873 }
27874
27875 int64_t  CS_LDK_COption_EventZ_clone(int64_t orig) {
27876         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
27877         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
27878         *ret_copy = COption_EventZ_clone(orig_conv);
27879         int64_t ret_ref = tag_ptr(ret_copy, true);
27880         return ret_ref;
27881 }
27882
27883 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_ok(int64_t o) {
27884         void* o_ptr = untag_ptr(o);
27885         CHECK_ACCESS(o_ptr);
27886         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
27887         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
27888         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
27889         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
27890         return tag_ptr(ret_conv, true);
27891 }
27892
27893 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_err(int64_t e) {
27894         void* e_ptr = untag_ptr(e);
27895         CHECK_ACCESS(e_ptr);
27896         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27897         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27898         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
27899         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
27900         return tag_ptr(ret_conv, true);
27901 }
27902
27903 jboolean  CS_LDK_CResult_COption_EventZDecodeErrorZ_is_ok(int64_t o) {
27904         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
27905         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
27906         return ret_conv;
27907 }
27908
27909 void  CS_LDK_CResult_COption_EventZDecodeErrorZ_free(int64_t _res) {
27910         if (!ptr_is_owned(_res)) return;
27911         void* _res_ptr = untag_ptr(_res);
27912         CHECK_ACCESS(_res_ptr);
27913         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
27914         FREE(untag_ptr(_res));
27915         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
27916 }
27917
27918 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
27919         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
27920         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
27921         return tag_ptr(ret_conv, true);
27922 }
27923 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_clone_ptr(int64_t arg) {
27924         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
27925         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
27926         return ret_conv;
27927 }
27928
27929 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_clone(int64_t orig) {
27930         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
27931         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
27932         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
27933         return tag_ptr(ret_conv, true);
27934 }
27935
27936 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_ok(int32_t o) {
27937         LDKSiPrefix o_conv = LDKSiPrefix_from_cs(o);
27938         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
27939         *ret_conv = CResult_SiPrefixBolt11ParseErrorZ_ok(o_conv);
27940         return tag_ptr(ret_conv, true);
27941 }
27942
27943 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_err(int64_t e) {
27944         void* e_ptr = untag_ptr(e);
27945         CHECK_ACCESS(e_ptr);
27946         LDKBolt11ParseError e_conv = *(LDKBolt11ParseError*)(e_ptr);
27947         e_conv = Bolt11ParseError_clone((LDKBolt11ParseError*)untag_ptr(e));
27948         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
27949         *ret_conv = CResult_SiPrefixBolt11ParseErrorZ_err(e_conv);
27950         return tag_ptr(ret_conv, true);
27951 }
27952
27953 jboolean  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_is_ok(int64_t o) {
27954         LDKCResult_SiPrefixBolt11ParseErrorZ* o_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(o);
27955         jboolean ret_conv = CResult_SiPrefixBolt11ParseErrorZ_is_ok(o_conv);
27956         return ret_conv;
27957 }
27958
27959 void  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_free(int64_t _res) {
27960         if (!ptr_is_owned(_res)) return;
27961         void* _res_ptr = untag_ptr(_res);
27962         CHECK_ACCESS(_res_ptr);
27963         LDKCResult_SiPrefixBolt11ParseErrorZ _res_conv = *(LDKCResult_SiPrefixBolt11ParseErrorZ*)(_res_ptr);
27964         FREE(untag_ptr(_res));
27965         CResult_SiPrefixBolt11ParseErrorZ_free(_res_conv);
27966 }
27967
27968 static inline uint64_t CResult_SiPrefixBolt11ParseErrorZ_clone_ptr(LDKCResult_SiPrefixBolt11ParseErrorZ *NONNULL_PTR arg) {
27969         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
27970         *ret_conv = CResult_SiPrefixBolt11ParseErrorZ_clone(arg);
27971         return tag_ptr(ret_conv, true);
27972 }
27973 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_clone_ptr(int64_t arg) {
27974         LDKCResult_SiPrefixBolt11ParseErrorZ* arg_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(arg);
27975         int64_t ret_conv = CResult_SiPrefixBolt11ParseErrorZ_clone_ptr(arg_conv);
27976         return ret_conv;
27977 }
27978
27979 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_clone(int64_t orig) {
27980         LDKCResult_SiPrefixBolt11ParseErrorZ* orig_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(orig);
27981         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
27982         *ret_conv = CResult_SiPrefixBolt11ParseErrorZ_clone(orig_conv);
27983         return tag_ptr(ret_conv, true);
27984 }
27985
27986 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(int64_t o) {
27987         LDKBolt11Invoice o_conv;
27988         o_conv.inner = untag_ptr(o);
27989         o_conv.is_owned = ptr_is_owned(o);
27990         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27991         o_conv = Bolt11Invoice_clone(&o_conv);
27992         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
27993         *ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(o_conv);
27994         return tag_ptr(ret_conv, true);
27995 }
27996
27997 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(int64_t e) {
27998         void* e_ptr = untag_ptr(e);
27999         CHECK_ACCESS(e_ptr);
28000         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
28001         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
28002         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
28003         *ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e_conv);
28004         return tag_ptr(ret_conv, true);
28005 }
28006
28007 jboolean  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(int64_t o) {
28008         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
28009         jboolean ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
28010         return ret_conv;
28011 }
28012
28013 void  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(int64_t _res) {
28014         if (!ptr_is_owned(_res)) return;
28015         void* _res_ptr = untag_ptr(_res);
28016         CHECK_ACCESS(_res_ptr);
28017         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)(_res_ptr);
28018         FREE(untag_ptr(_res));
28019         CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(_res_conv);
28020 }
28021
28022 static inline uint64_t CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
28023         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
28024         *ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(arg);
28025         return tag_ptr(ret_conv, true);
28026 }
28027 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone_ptr(int64_t arg) {
28028         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
28029         int64_t ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
28030         return ret_conv;
28031 }
28032
28033 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(int64_t orig) {
28034         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
28035         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
28036         *ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(orig_conv);
28037         return tag_ptr(ret_conv, true);
28038 }
28039
28040 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(int64_t o) {
28041         LDKSignedRawBolt11Invoice o_conv;
28042         o_conv.inner = untag_ptr(o);
28043         o_conv.is_owned = ptr_is_owned(o);
28044         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28045         o_conv = SignedRawBolt11Invoice_clone(&o_conv);
28046         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
28047         *ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(o_conv);
28048         return tag_ptr(ret_conv, true);
28049 }
28050
28051 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(int64_t e) {
28052         void* e_ptr = untag_ptr(e);
28053         CHECK_ACCESS(e_ptr);
28054         LDKBolt11ParseError e_conv = *(LDKBolt11ParseError*)(e_ptr);
28055         e_conv = Bolt11ParseError_clone((LDKBolt11ParseError*)untag_ptr(e));
28056         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
28057         *ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e_conv);
28058         return tag_ptr(ret_conv, true);
28059 }
28060
28061 jboolean  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(int64_t o) {
28062         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* o_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(o);
28063         jboolean ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(o_conv);
28064         return ret_conv;
28065 }
28066
28067 void  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(int64_t _res) {
28068         if (!ptr_is_owned(_res)) return;
28069         void* _res_ptr = untag_ptr(_res);
28070         CHECK_ACCESS(_res_ptr);
28071         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ _res_conv = *(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)(_res_ptr);
28072         FREE(untag_ptr(_res));
28073         CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(_res_conv);
28074 }
28075
28076 static inline uint64_t CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone_ptr(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ *NONNULL_PTR arg) {
28077         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
28078         *ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(arg);
28079         return tag_ptr(ret_conv, true);
28080 }
28081 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone_ptr(int64_t arg) {
28082         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* arg_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(arg);
28083         int64_t ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone_ptr(arg_conv);
28084         return ret_conv;
28085 }
28086
28087 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(int64_t orig) {
28088         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* orig_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(orig);
28089         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
28090         *ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(orig_conv);
28091         return tag_ptr(ret_conv, true);
28092 }
28093
28094 static inline uint64_t C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR arg) {
28095         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ), "LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ");
28096         *ret_conv = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(arg);
28097         return tag_ptr(ret_conv, true);
28098 }
28099 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone_ptr(int64_t arg) {
28100         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(arg);
28101         int64_t ret_conv = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone_ptr(arg_conv);
28102         return ret_conv;
28103 }
28104
28105 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(int64_t orig) {
28106         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(orig);
28107         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ), "LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ");
28108         *ret_conv = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(orig_conv);
28109         return tag_ptr(ret_conv, true);
28110 }
28111
28112 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(int64_t a, int8_tArray b, int64_t c) {
28113         LDKRawBolt11Invoice a_conv;
28114         a_conv.inner = untag_ptr(a);
28115         a_conv.is_owned = ptr_is_owned(a);
28116         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28117         a_conv = RawBolt11Invoice_clone(&a_conv);
28118         LDKThirtyTwoBytes b_ref;
28119         CHECK(b->arr_len == 32);
28120         memcpy(b_ref.data, b->elems, 32); FREE(b);
28121         LDKBolt11InvoiceSignature c_conv;
28122         c_conv.inner = untag_ptr(c);
28123         c_conv.is_owned = ptr_is_owned(c);
28124         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
28125         c_conv = Bolt11InvoiceSignature_clone(&c_conv);
28126         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ), "LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ");
28127         *ret_conv = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
28128         return tag_ptr(ret_conv, true);
28129 }
28130
28131 void  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(int64_t _res) {
28132         if (!ptr_is_owned(_res)) return;
28133         void* _res_ptr = untag_ptr(_res);
28134         CHECK_ACCESS(_res_ptr);
28135         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)(_res_ptr);
28136         FREE(untag_ptr(_res));
28137         C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(_res_conv);
28138 }
28139
28140 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_ok(int64_t o) {
28141         LDKPayeePubKey o_conv;
28142         o_conv.inner = untag_ptr(o);
28143         o_conv.is_owned = ptr_is_owned(o);
28144         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28145         o_conv = PayeePubKey_clone(&o_conv);
28146         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
28147         *ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_ok(o_conv);
28148         return tag_ptr(ret_conv, true);
28149 }
28150
28151 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_err(int32_t e) {
28152         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_cs(e);
28153         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
28154         *ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_err(e_conv);
28155         return tag_ptr(ret_conv, true);
28156 }
28157
28158 jboolean  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_is_ok(int64_t o) {
28159         LDKCResult_PayeePubKeySecp256k1ErrorZ* o_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(o);
28160         jboolean ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_is_ok(o_conv);
28161         return ret_conv;
28162 }
28163
28164 void  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_free(int64_t _res) {
28165         if (!ptr_is_owned(_res)) return;
28166         void* _res_ptr = untag_ptr(_res);
28167         CHECK_ACCESS(_res_ptr);
28168         LDKCResult_PayeePubKeySecp256k1ErrorZ _res_conv = *(LDKCResult_PayeePubKeySecp256k1ErrorZ*)(_res_ptr);
28169         FREE(untag_ptr(_res));
28170         CResult_PayeePubKeySecp256k1ErrorZ_free(_res_conv);
28171 }
28172
28173 static inline uint64_t CResult_PayeePubKeySecp256k1ErrorZ_clone_ptr(LDKCResult_PayeePubKeySecp256k1ErrorZ *NONNULL_PTR arg) {
28174         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
28175         *ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_clone(arg);
28176         return tag_ptr(ret_conv, true);
28177 }
28178 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_clone_ptr(int64_t arg) {
28179         LDKCResult_PayeePubKeySecp256k1ErrorZ* arg_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(arg);
28180         int64_t ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_clone_ptr(arg_conv);
28181         return ret_conv;
28182 }
28183
28184 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_clone(int64_t orig) {
28185         LDKCResult_PayeePubKeySecp256k1ErrorZ* orig_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(orig);
28186         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
28187         *ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_clone(orig_conv);
28188         return tag_ptr(ret_conv, true);
28189 }
28190
28191 void  CS_LDK_CVec_PrivateRouteZ_free(int64_tArray _res) {
28192         LDKCVec_PrivateRouteZ _res_constr;
28193         _res_constr.datalen = _res->arr_len;
28194         if (_res_constr.datalen > 0)
28195                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
28196         else
28197                 _res_constr.data = NULL;
28198         int64_t* _res_vals = _res->elems;
28199         for (size_t o = 0; o < _res_constr.datalen; o++) {
28200                 int64_t _res_conv_14 = _res_vals[o];
28201                 LDKPrivateRoute _res_conv_14_conv;
28202                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
28203                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
28204                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
28205                 _res_constr.data[o] = _res_conv_14_conv;
28206         }
28207         FREE(_res);
28208         CVec_PrivateRouteZ_free(_res_constr);
28209 }
28210
28211 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_ok(int64_t o) {
28212         LDKPositiveTimestamp o_conv;
28213         o_conv.inner = untag_ptr(o);
28214         o_conv.is_owned = ptr_is_owned(o);
28215         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28216         o_conv = PositiveTimestamp_clone(&o_conv);
28217         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
28218         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
28219         return tag_ptr(ret_conv, true);
28220 }
28221
28222 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_err(int32_t e) {
28223         LDKCreationError e_conv = LDKCreationError_from_cs(e);
28224         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
28225         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
28226         return tag_ptr(ret_conv, true);
28227 }
28228
28229 jboolean  CS_LDK_CResult_PositiveTimestampCreationErrorZ_is_ok(int64_t o) {
28230         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
28231         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
28232         return ret_conv;
28233 }
28234
28235 void  CS_LDK_CResult_PositiveTimestampCreationErrorZ_free(int64_t _res) {
28236         if (!ptr_is_owned(_res)) return;
28237         void* _res_ptr = untag_ptr(_res);
28238         CHECK_ACCESS(_res_ptr);
28239         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
28240         FREE(untag_ptr(_res));
28241         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
28242 }
28243
28244 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
28245         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
28246         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
28247         return tag_ptr(ret_conv, true);
28248 }
28249 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_clone_ptr(int64_t arg) {
28250         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
28251         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
28252         return ret_conv;
28253 }
28254
28255 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_clone(int64_t orig) {
28256         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
28257         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
28258         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
28259         return tag_ptr(ret_conv, true);
28260 }
28261
28262 int64_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_ok() {
28263         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
28264         *ret_conv = CResult_NoneBolt11SemanticErrorZ_ok();
28265         return tag_ptr(ret_conv, true);
28266 }
28267
28268 int64_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_err(int32_t e) {
28269         LDKBolt11SemanticError e_conv = LDKBolt11SemanticError_from_cs(e);
28270         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
28271         *ret_conv = CResult_NoneBolt11SemanticErrorZ_err(e_conv);
28272         return tag_ptr(ret_conv, true);
28273 }
28274
28275 jboolean  CS_LDK_CResult_NoneBolt11SemanticErrorZ_is_ok(int64_t o) {
28276         LDKCResult_NoneBolt11SemanticErrorZ* o_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(o);
28277         jboolean ret_conv = CResult_NoneBolt11SemanticErrorZ_is_ok(o_conv);
28278         return ret_conv;
28279 }
28280
28281 void  CS_LDK_CResult_NoneBolt11SemanticErrorZ_free(int64_t _res) {
28282         if (!ptr_is_owned(_res)) return;
28283         void* _res_ptr = untag_ptr(_res);
28284         CHECK_ACCESS(_res_ptr);
28285         LDKCResult_NoneBolt11SemanticErrorZ _res_conv = *(LDKCResult_NoneBolt11SemanticErrorZ*)(_res_ptr);
28286         FREE(untag_ptr(_res));
28287         CResult_NoneBolt11SemanticErrorZ_free(_res_conv);
28288 }
28289
28290 static inline uint64_t CResult_NoneBolt11SemanticErrorZ_clone_ptr(LDKCResult_NoneBolt11SemanticErrorZ *NONNULL_PTR arg) {
28291         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
28292         *ret_conv = CResult_NoneBolt11SemanticErrorZ_clone(arg);
28293         return tag_ptr(ret_conv, true);
28294 }
28295 int64_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_clone_ptr(int64_t arg) {
28296         LDKCResult_NoneBolt11SemanticErrorZ* arg_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(arg);
28297         int64_t ret_conv = CResult_NoneBolt11SemanticErrorZ_clone_ptr(arg_conv);
28298         return ret_conv;
28299 }
28300
28301 int64_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_clone(int64_t orig) {
28302         LDKCResult_NoneBolt11SemanticErrorZ* orig_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(orig);
28303         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
28304         *ret_conv = CResult_NoneBolt11SemanticErrorZ_clone(orig_conv);
28305         return tag_ptr(ret_conv, true);
28306 }
28307
28308 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(int64_t o) {
28309         LDKBolt11Invoice o_conv;
28310         o_conv.inner = untag_ptr(o);
28311         o_conv.is_owned = ptr_is_owned(o);
28312         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28313         o_conv = Bolt11Invoice_clone(&o_conv);
28314         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
28315         *ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(o_conv);
28316         return tag_ptr(ret_conv, true);
28317 }
28318
28319 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(int32_t e) {
28320         LDKBolt11SemanticError e_conv = LDKBolt11SemanticError_from_cs(e);
28321         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
28322         *ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e_conv);
28323         return tag_ptr(ret_conv, true);
28324 }
28325
28326 jboolean  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(int64_t o) {
28327         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* o_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(o);
28328         jboolean ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(o_conv);
28329         return ret_conv;
28330 }
28331
28332 void  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(int64_t _res) {
28333         if (!ptr_is_owned(_res)) return;
28334         void* _res_ptr = untag_ptr(_res);
28335         CHECK_ACCESS(_res_ptr);
28336         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ _res_conv = *(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)(_res_ptr);
28337         FREE(untag_ptr(_res));
28338         CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(_res_conv);
28339 }
28340
28341 static inline uint64_t CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone_ptr(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ *NONNULL_PTR arg) {
28342         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
28343         *ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(arg);
28344         return tag_ptr(ret_conv, true);
28345 }
28346 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone_ptr(int64_t arg) {
28347         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* arg_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(arg);
28348         int64_t ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone_ptr(arg_conv);
28349         return ret_conv;
28350 }
28351
28352 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(int64_t orig) {
28353         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* orig_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(orig);
28354         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
28355         *ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(orig_conv);
28356         return tag_ptr(ret_conv, true);
28357 }
28358
28359 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_ok(int64_t o) {
28360         LDKDescription o_conv;
28361         o_conv.inner = untag_ptr(o);
28362         o_conv.is_owned = ptr_is_owned(o);
28363         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28364         o_conv = Description_clone(&o_conv);
28365         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
28366         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
28367         return tag_ptr(ret_conv, true);
28368 }
28369
28370 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_err(int32_t e) {
28371         LDKCreationError e_conv = LDKCreationError_from_cs(e);
28372         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
28373         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
28374         return tag_ptr(ret_conv, true);
28375 }
28376
28377 jboolean  CS_LDK_CResult_DescriptionCreationErrorZ_is_ok(int64_t o) {
28378         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
28379         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
28380         return ret_conv;
28381 }
28382
28383 void  CS_LDK_CResult_DescriptionCreationErrorZ_free(int64_t _res) {
28384         if (!ptr_is_owned(_res)) return;
28385         void* _res_ptr = untag_ptr(_res);
28386         CHECK_ACCESS(_res_ptr);
28387         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
28388         FREE(untag_ptr(_res));
28389         CResult_DescriptionCreationErrorZ_free(_res_conv);
28390 }
28391
28392 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
28393         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
28394         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
28395         return tag_ptr(ret_conv, true);
28396 }
28397 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_clone_ptr(int64_t arg) {
28398         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
28399         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
28400         return ret_conv;
28401 }
28402
28403 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_clone(int64_t orig) {
28404         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
28405         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
28406         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
28407         return tag_ptr(ret_conv, true);
28408 }
28409
28410 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_ok(int64_t o) {
28411         LDKPrivateRoute o_conv;
28412         o_conv.inner = untag_ptr(o);
28413         o_conv.is_owned = ptr_is_owned(o);
28414         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28415         o_conv = PrivateRoute_clone(&o_conv);
28416         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
28417         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
28418         return tag_ptr(ret_conv, true);
28419 }
28420
28421 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_err(int32_t e) {
28422         LDKCreationError e_conv = LDKCreationError_from_cs(e);
28423         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
28424         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
28425         return tag_ptr(ret_conv, true);
28426 }
28427
28428 jboolean  CS_LDK_CResult_PrivateRouteCreationErrorZ_is_ok(int64_t o) {
28429         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
28430         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
28431         return ret_conv;
28432 }
28433
28434 void  CS_LDK_CResult_PrivateRouteCreationErrorZ_free(int64_t _res) {
28435         if (!ptr_is_owned(_res)) return;
28436         void* _res_ptr = untag_ptr(_res);
28437         CHECK_ACCESS(_res_ptr);
28438         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
28439         FREE(untag_ptr(_res));
28440         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
28441 }
28442
28443 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
28444         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
28445         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
28446         return tag_ptr(ret_conv, true);
28447 }
28448 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_clone_ptr(int64_t arg) {
28449         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
28450         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
28451         return ret_conv;
28452 }
28453
28454 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_clone(int64_t orig) {
28455         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
28456         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
28457         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
28458         return tag_ptr(ret_conv, true);
28459 }
28460
28461 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_ok(int64_t o) {
28462         LDKOutPoint o_conv;
28463         o_conv.inner = untag_ptr(o);
28464         o_conv.is_owned = ptr_is_owned(o);
28465         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28466         o_conv = OutPoint_clone(&o_conv);
28467         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28468         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
28469         return tag_ptr(ret_conv, true);
28470 }
28471
28472 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_err(int64_t e) {
28473         void* e_ptr = untag_ptr(e);
28474         CHECK_ACCESS(e_ptr);
28475         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28476         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28477         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28478         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
28479         return tag_ptr(ret_conv, true);
28480 }
28481
28482 jboolean  CS_LDK_CResult_OutPointDecodeErrorZ_is_ok(int64_t o) {
28483         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
28484         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
28485         return ret_conv;
28486 }
28487
28488 void  CS_LDK_CResult_OutPointDecodeErrorZ_free(int64_t _res) {
28489         if (!ptr_is_owned(_res)) return;
28490         void* _res_ptr = untag_ptr(_res);
28491         CHECK_ACCESS(_res_ptr);
28492         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
28493         FREE(untag_ptr(_res));
28494         CResult_OutPointDecodeErrorZ_free(_res_conv);
28495 }
28496
28497 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
28498         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28499         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
28500         return tag_ptr(ret_conv, true);
28501 }
28502 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_clone_ptr(int64_t arg) {
28503         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
28504         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
28505         return ret_conv;
28506 }
28507
28508 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_clone(int64_t orig) {
28509         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
28510         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28511         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
28512         return tag_ptr(ret_conv, true);
28513 }
28514
28515 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_ok(int64_t o) {
28516         LDKBigSize o_conv;
28517         o_conv.inner = untag_ptr(o);
28518         o_conv.is_owned = ptr_is_owned(o);
28519         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28520         o_conv = BigSize_clone(&o_conv);
28521         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
28522         *ret_conv = CResult_BigSizeDecodeErrorZ_ok(o_conv);
28523         return tag_ptr(ret_conv, true);
28524 }
28525
28526 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_err(int64_t e) {
28527         void* e_ptr = untag_ptr(e);
28528         CHECK_ACCESS(e_ptr);
28529         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28530         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28531         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
28532         *ret_conv = CResult_BigSizeDecodeErrorZ_err(e_conv);
28533         return tag_ptr(ret_conv, true);
28534 }
28535
28536 jboolean  CS_LDK_CResult_BigSizeDecodeErrorZ_is_ok(int64_t o) {
28537         LDKCResult_BigSizeDecodeErrorZ* o_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(o);
28538         jboolean ret_conv = CResult_BigSizeDecodeErrorZ_is_ok(o_conv);
28539         return ret_conv;
28540 }
28541
28542 void  CS_LDK_CResult_BigSizeDecodeErrorZ_free(int64_t _res) {
28543         if (!ptr_is_owned(_res)) return;
28544         void* _res_ptr = untag_ptr(_res);
28545         CHECK_ACCESS(_res_ptr);
28546         LDKCResult_BigSizeDecodeErrorZ _res_conv = *(LDKCResult_BigSizeDecodeErrorZ*)(_res_ptr);
28547         FREE(untag_ptr(_res));
28548         CResult_BigSizeDecodeErrorZ_free(_res_conv);
28549 }
28550
28551 static inline uint64_t CResult_BigSizeDecodeErrorZ_clone_ptr(LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR arg) {
28552         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
28553         *ret_conv = CResult_BigSizeDecodeErrorZ_clone(arg);
28554         return tag_ptr(ret_conv, true);
28555 }
28556 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_clone_ptr(int64_t arg) {
28557         LDKCResult_BigSizeDecodeErrorZ* arg_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(arg);
28558         int64_t ret_conv = CResult_BigSizeDecodeErrorZ_clone_ptr(arg_conv);
28559         return ret_conv;
28560 }
28561
28562 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_clone(int64_t orig) {
28563         LDKCResult_BigSizeDecodeErrorZ* orig_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(orig);
28564         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
28565         *ret_conv = CResult_BigSizeDecodeErrorZ_clone(orig_conv);
28566         return tag_ptr(ret_conv, true);
28567 }
28568
28569 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_ok(int64_t o) {
28570         LDKHostname o_conv;
28571         o_conv.inner = untag_ptr(o);
28572         o_conv.is_owned = ptr_is_owned(o);
28573         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28574         o_conv = Hostname_clone(&o_conv);
28575         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
28576         *ret_conv = CResult_HostnameDecodeErrorZ_ok(o_conv);
28577         return tag_ptr(ret_conv, true);
28578 }
28579
28580 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_err(int64_t e) {
28581         void* e_ptr = untag_ptr(e);
28582         CHECK_ACCESS(e_ptr);
28583         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28584         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28585         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
28586         *ret_conv = CResult_HostnameDecodeErrorZ_err(e_conv);
28587         return tag_ptr(ret_conv, true);
28588 }
28589
28590 jboolean  CS_LDK_CResult_HostnameDecodeErrorZ_is_ok(int64_t o) {
28591         LDKCResult_HostnameDecodeErrorZ* o_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(o);
28592         jboolean ret_conv = CResult_HostnameDecodeErrorZ_is_ok(o_conv);
28593         return ret_conv;
28594 }
28595
28596 void  CS_LDK_CResult_HostnameDecodeErrorZ_free(int64_t _res) {
28597         if (!ptr_is_owned(_res)) return;
28598         void* _res_ptr = untag_ptr(_res);
28599         CHECK_ACCESS(_res_ptr);
28600         LDKCResult_HostnameDecodeErrorZ _res_conv = *(LDKCResult_HostnameDecodeErrorZ*)(_res_ptr);
28601         FREE(untag_ptr(_res));
28602         CResult_HostnameDecodeErrorZ_free(_res_conv);
28603 }
28604
28605 static inline uint64_t CResult_HostnameDecodeErrorZ_clone_ptr(LDKCResult_HostnameDecodeErrorZ *NONNULL_PTR arg) {
28606         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
28607         *ret_conv = CResult_HostnameDecodeErrorZ_clone(arg);
28608         return tag_ptr(ret_conv, true);
28609 }
28610 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_clone_ptr(int64_t arg) {
28611         LDKCResult_HostnameDecodeErrorZ* arg_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(arg);
28612         int64_t ret_conv = CResult_HostnameDecodeErrorZ_clone_ptr(arg_conv);
28613         return ret_conv;
28614 }
28615
28616 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_clone(int64_t orig) {
28617         LDKCResult_HostnameDecodeErrorZ* orig_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(orig);
28618         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
28619         *ret_conv = CResult_HostnameDecodeErrorZ_clone(orig_conv);
28620         return tag_ptr(ret_conv, true);
28621 }
28622
28623 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_ok(int64_t o) {
28624         LDKTransactionU16LenLimited o_conv;
28625         o_conv.inner = untag_ptr(o);
28626         o_conv.is_owned = ptr_is_owned(o);
28627         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28628         o_conv = TransactionU16LenLimited_clone(&o_conv);
28629         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
28630         *ret_conv = CResult_TransactionU16LenLimitedNoneZ_ok(o_conv);
28631         return tag_ptr(ret_conv, true);
28632 }
28633
28634 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_err() {
28635         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
28636         *ret_conv = CResult_TransactionU16LenLimitedNoneZ_err();
28637         return tag_ptr(ret_conv, true);
28638 }
28639
28640 jboolean  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_is_ok(int64_t o) {
28641         LDKCResult_TransactionU16LenLimitedNoneZ* o_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(o);
28642         jboolean ret_conv = CResult_TransactionU16LenLimitedNoneZ_is_ok(o_conv);
28643         return ret_conv;
28644 }
28645
28646 void  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_free(int64_t _res) {
28647         if (!ptr_is_owned(_res)) return;
28648         void* _res_ptr = untag_ptr(_res);
28649         CHECK_ACCESS(_res_ptr);
28650         LDKCResult_TransactionU16LenLimitedNoneZ _res_conv = *(LDKCResult_TransactionU16LenLimitedNoneZ*)(_res_ptr);
28651         FREE(untag_ptr(_res));
28652         CResult_TransactionU16LenLimitedNoneZ_free(_res_conv);
28653 }
28654
28655 static inline uint64_t CResult_TransactionU16LenLimitedNoneZ_clone_ptr(LDKCResult_TransactionU16LenLimitedNoneZ *NONNULL_PTR arg) {
28656         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
28657         *ret_conv = CResult_TransactionU16LenLimitedNoneZ_clone(arg);
28658         return tag_ptr(ret_conv, true);
28659 }
28660 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_clone_ptr(int64_t arg) {
28661         LDKCResult_TransactionU16LenLimitedNoneZ* arg_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(arg);
28662         int64_t ret_conv = CResult_TransactionU16LenLimitedNoneZ_clone_ptr(arg_conv);
28663         return ret_conv;
28664 }
28665
28666 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_clone(int64_t orig) {
28667         LDKCResult_TransactionU16LenLimitedNoneZ* orig_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(orig);
28668         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
28669         *ret_conv = CResult_TransactionU16LenLimitedNoneZ_clone(orig_conv);
28670         return tag_ptr(ret_conv, true);
28671 }
28672
28673 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_ok(int64_t o) {
28674         LDKTransactionU16LenLimited o_conv;
28675         o_conv.inner = untag_ptr(o);
28676         o_conv.is_owned = ptr_is_owned(o);
28677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28678         o_conv = TransactionU16LenLimited_clone(&o_conv);
28679         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
28680         *ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_ok(o_conv);
28681         return tag_ptr(ret_conv, true);
28682 }
28683
28684 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_err(int64_t e) {
28685         void* e_ptr = untag_ptr(e);
28686         CHECK_ACCESS(e_ptr);
28687         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28688         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28689         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
28690         *ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_err(e_conv);
28691         return tag_ptr(ret_conv, true);
28692 }
28693
28694 jboolean  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(int64_t o) {
28695         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* o_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(o);
28696         jboolean ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(o_conv);
28697         return ret_conv;
28698 }
28699
28700 void  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_free(int64_t _res) {
28701         if (!ptr_is_owned(_res)) return;
28702         void* _res_ptr = untag_ptr(_res);
28703         CHECK_ACCESS(_res_ptr);
28704         LDKCResult_TransactionU16LenLimitedDecodeErrorZ _res_conv = *(LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)(_res_ptr);
28705         FREE(untag_ptr(_res));
28706         CResult_TransactionU16LenLimitedDecodeErrorZ_free(_res_conv);
28707 }
28708
28709 static inline uint64_t CResult_TransactionU16LenLimitedDecodeErrorZ_clone_ptr(LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR arg) {
28710         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
28711         *ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_clone(arg);
28712         return tag_ptr(ret_conv, true);
28713 }
28714 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_clone_ptr(int64_t arg) {
28715         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* arg_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(arg);
28716         int64_t ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_clone_ptr(arg_conv);
28717         return ret_conv;
28718 }
28719
28720 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_clone(int64_t orig) {
28721         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* orig_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(orig);
28722         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
28723         *ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_clone(orig_conv);
28724         return tag_ptr(ret_conv, true);
28725 }
28726
28727 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_ok(int64_t o) {
28728         LDKUntrustedString o_conv;
28729         o_conv.inner = untag_ptr(o);
28730         o_conv.is_owned = ptr_is_owned(o);
28731         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28732         o_conv = UntrustedString_clone(&o_conv);
28733         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
28734         *ret_conv = CResult_UntrustedStringDecodeErrorZ_ok(o_conv);
28735         return tag_ptr(ret_conv, true);
28736 }
28737
28738 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_err(int64_t e) {
28739         void* e_ptr = untag_ptr(e);
28740         CHECK_ACCESS(e_ptr);
28741         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28742         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28743         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
28744         *ret_conv = CResult_UntrustedStringDecodeErrorZ_err(e_conv);
28745         return tag_ptr(ret_conv, true);
28746 }
28747
28748 jboolean  CS_LDK_CResult_UntrustedStringDecodeErrorZ_is_ok(int64_t o) {
28749         LDKCResult_UntrustedStringDecodeErrorZ* o_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(o);
28750         jboolean ret_conv = CResult_UntrustedStringDecodeErrorZ_is_ok(o_conv);
28751         return ret_conv;
28752 }
28753
28754 void  CS_LDK_CResult_UntrustedStringDecodeErrorZ_free(int64_t _res) {
28755         if (!ptr_is_owned(_res)) return;
28756         void* _res_ptr = untag_ptr(_res);
28757         CHECK_ACCESS(_res_ptr);
28758         LDKCResult_UntrustedStringDecodeErrorZ _res_conv = *(LDKCResult_UntrustedStringDecodeErrorZ*)(_res_ptr);
28759         FREE(untag_ptr(_res));
28760         CResult_UntrustedStringDecodeErrorZ_free(_res_conv);
28761 }
28762
28763 static inline uint64_t CResult_UntrustedStringDecodeErrorZ_clone_ptr(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR arg) {
28764         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
28765         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(arg);
28766         return tag_ptr(ret_conv, true);
28767 }
28768 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_clone_ptr(int64_t arg) {
28769         LDKCResult_UntrustedStringDecodeErrorZ* arg_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(arg);
28770         int64_t ret_conv = CResult_UntrustedStringDecodeErrorZ_clone_ptr(arg_conv);
28771         return ret_conv;
28772 }
28773
28774 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_clone(int64_t orig) {
28775         LDKCResult_UntrustedStringDecodeErrorZ* orig_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(orig);
28776         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
28777         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(orig_conv);
28778         return tag_ptr(ret_conv, true);
28779 }
28780
28781 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_ok(int64_t o) {
28782         LDKReceiveTlvs o_conv;
28783         o_conv.inner = untag_ptr(o);
28784         o_conv.is_owned = ptr_is_owned(o);
28785         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28786         o_conv = ReceiveTlvs_clone(&o_conv);
28787         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
28788         *ret_conv = CResult_ReceiveTlvsDecodeErrorZ_ok(o_conv);
28789         return tag_ptr(ret_conv, true);
28790 }
28791
28792 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_err(int64_t e) {
28793         void* e_ptr = untag_ptr(e);
28794         CHECK_ACCESS(e_ptr);
28795         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28796         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28797         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
28798         *ret_conv = CResult_ReceiveTlvsDecodeErrorZ_err(e_conv);
28799         return tag_ptr(ret_conv, true);
28800 }
28801
28802 jboolean  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_is_ok(int64_t o) {
28803         LDKCResult_ReceiveTlvsDecodeErrorZ* o_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(o);
28804         jboolean ret_conv = CResult_ReceiveTlvsDecodeErrorZ_is_ok(o_conv);
28805         return ret_conv;
28806 }
28807
28808 void  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_free(int64_t _res) {
28809         if (!ptr_is_owned(_res)) return;
28810         void* _res_ptr = untag_ptr(_res);
28811         CHECK_ACCESS(_res_ptr);
28812         LDKCResult_ReceiveTlvsDecodeErrorZ _res_conv = *(LDKCResult_ReceiveTlvsDecodeErrorZ*)(_res_ptr);
28813         FREE(untag_ptr(_res));
28814         CResult_ReceiveTlvsDecodeErrorZ_free(_res_conv);
28815 }
28816
28817 static inline uint64_t CResult_ReceiveTlvsDecodeErrorZ_clone_ptr(LDKCResult_ReceiveTlvsDecodeErrorZ *NONNULL_PTR arg) {
28818         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
28819         *ret_conv = CResult_ReceiveTlvsDecodeErrorZ_clone(arg);
28820         return tag_ptr(ret_conv, true);
28821 }
28822 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_clone_ptr(int64_t arg) {
28823         LDKCResult_ReceiveTlvsDecodeErrorZ* arg_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(arg);
28824         int64_t ret_conv = CResult_ReceiveTlvsDecodeErrorZ_clone_ptr(arg_conv);
28825         return ret_conv;
28826 }
28827
28828 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_clone(int64_t orig) {
28829         LDKCResult_ReceiveTlvsDecodeErrorZ* orig_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(orig);
28830         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
28831         *ret_conv = CResult_ReceiveTlvsDecodeErrorZ_clone(orig_conv);
28832         return tag_ptr(ret_conv, true);
28833 }
28834
28835 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_ok(int64_t o) {
28836         LDKPaymentRelay o_conv;
28837         o_conv.inner = untag_ptr(o);
28838         o_conv.is_owned = ptr_is_owned(o);
28839         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28840         o_conv = PaymentRelay_clone(&o_conv);
28841         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
28842         *ret_conv = CResult_PaymentRelayDecodeErrorZ_ok(o_conv);
28843         return tag_ptr(ret_conv, true);
28844 }
28845
28846 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_err(int64_t e) {
28847         void* e_ptr = untag_ptr(e);
28848         CHECK_ACCESS(e_ptr);
28849         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28850         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28851         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
28852         *ret_conv = CResult_PaymentRelayDecodeErrorZ_err(e_conv);
28853         return tag_ptr(ret_conv, true);
28854 }
28855
28856 jboolean  CS_LDK_CResult_PaymentRelayDecodeErrorZ_is_ok(int64_t o) {
28857         LDKCResult_PaymentRelayDecodeErrorZ* o_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(o);
28858         jboolean ret_conv = CResult_PaymentRelayDecodeErrorZ_is_ok(o_conv);
28859         return ret_conv;
28860 }
28861
28862 void  CS_LDK_CResult_PaymentRelayDecodeErrorZ_free(int64_t _res) {
28863         if (!ptr_is_owned(_res)) return;
28864         void* _res_ptr = untag_ptr(_res);
28865         CHECK_ACCESS(_res_ptr);
28866         LDKCResult_PaymentRelayDecodeErrorZ _res_conv = *(LDKCResult_PaymentRelayDecodeErrorZ*)(_res_ptr);
28867         FREE(untag_ptr(_res));
28868         CResult_PaymentRelayDecodeErrorZ_free(_res_conv);
28869 }
28870
28871 static inline uint64_t CResult_PaymentRelayDecodeErrorZ_clone_ptr(LDKCResult_PaymentRelayDecodeErrorZ *NONNULL_PTR arg) {
28872         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
28873         *ret_conv = CResult_PaymentRelayDecodeErrorZ_clone(arg);
28874         return tag_ptr(ret_conv, true);
28875 }
28876 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_clone_ptr(int64_t arg) {
28877         LDKCResult_PaymentRelayDecodeErrorZ* arg_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(arg);
28878         int64_t ret_conv = CResult_PaymentRelayDecodeErrorZ_clone_ptr(arg_conv);
28879         return ret_conv;
28880 }
28881
28882 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_clone(int64_t orig) {
28883         LDKCResult_PaymentRelayDecodeErrorZ* orig_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(orig);
28884         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
28885         *ret_conv = CResult_PaymentRelayDecodeErrorZ_clone(orig_conv);
28886         return tag_ptr(ret_conv, true);
28887 }
28888
28889 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_ok(int64_t o) {
28890         LDKPaymentConstraints o_conv;
28891         o_conv.inner = untag_ptr(o);
28892         o_conv.is_owned = ptr_is_owned(o);
28893         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28894         o_conv = PaymentConstraints_clone(&o_conv);
28895         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
28896         *ret_conv = CResult_PaymentConstraintsDecodeErrorZ_ok(o_conv);
28897         return tag_ptr(ret_conv, true);
28898 }
28899
28900 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_err(int64_t e) {
28901         void* e_ptr = untag_ptr(e);
28902         CHECK_ACCESS(e_ptr);
28903         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28904         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28905         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
28906         *ret_conv = CResult_PaymentConstraintsDecodeErrorZ_err(e_conv);
28907         return tag_ptr(ret_conv, true);
28908 }
28909
28910 jboolean  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_is_ok(int64_t o) {
28911         LDKCResult_PaymentConstraintsDecodeErrorZ* o_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(o);
28912         jboolean ret_conv = CResult_PaymentConstraintsDecodeErrorZ_is_ok(o_conv);
28913         return ret_conv;
28914 }
28915
28916 void  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_free(int64_t _res) {
28917         if (!ptr_is_owned(_res)) return;
28918         void* _res_ptr = untag_ptr(_res);
28919         CHECK_ACCESS(_res_ptr);
28920         LDKCResult_PaymentConstraintsDecodeErrorZ _res_conv = *(LDKCResult_PaymentConstraintsDecodeErrorZ*)(_res_ptr);
28921         FREE(untag_ptr(_res));
28922         CResult_PaymentConstraintsDecodeErrorZ_free(_res_conv);
28923 }
28924
28925 static inline uint64_t CResult_PaymentConstraintsDecodeErrorZ_clone_ptr(LDKCResult_PaymentConstraintsDecodeErrorZ *NONNULL_PTR arg) {
28926         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
28927         *ret_conv = CResult_PaymentConstraintsDecodeErrorZ_clone(arg);
28928         return tag_ptr(ret_conv, true);
28929 }
28930 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_clone_ptr(int64_t arg) {
28931         LDKCResult_PaymentConstraintsDecodeErrorZ* arg_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(arg);
28932         int64_t ret_conv = CResult_PaymentConstraintsDecodeErrorZ_clone_ptr(arg_conv);
28933         return ret_conv;
28934 }
28935
28936 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_clone(int64_t orig) {
28937         LDKCResult_PaymentConstraintsDecodeErrorZ* orig_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(orig);
28938         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
28939         *ret_conv = CResult_PaymentConstraintsDecodeErrorZ_clone(orig_conv);
28940         return tag_ptr(ret_conv, true);
28941 }
28942
28943 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_ok(int8_tArray o) {
28944         LDKThirtyTwoBytes o_ref;
28945         CHECK(o->arr_len == 32);
28946         memcpy(o_ref.data, o->elems, 32); FREE(o);
28947         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
28948         *ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_ok(o_ref);
28949         return tag_ptr(ret_conv, true);
28950 }
28951
28952 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_err(int64_t e) {
28953         void* e_ptr = untag_ptr(e);
28954         CHECK_ACCESS(e_ptr);
28955         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
28956         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
28957         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
28958         *ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_err(e_conv);
28959         return tag_ptr(ret_conv, true);
28960 }
28961
28962 jboolean  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_is_ok(int64_t o) {
28963         LDKCResult_ThirtyTwoBytesPaymentErrorZ* o_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(o);
28964         jboolean ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_is_ok(o_conv);
28965         return ret_conv;
28966 }
28967
28968 void  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_free(int64_t _res) {
28969         if (!ptr_is_owned(_res)) return;
28970         void* _res_ptr = untag_ptr(_res);
28971         CHECK_ACCESS(_res_ptr);
28972         LDKCResult_ThirtyTwoBytesPaymentErrorZ _res_conv = *(LDKCResult_ThirtyTwoBytesPaymentErrorZ*)(_res_ptr);
28973         FREE(untag_ptr(_res));
28974         CResult_ThirtyTwoBytesPaymentErrorZ_free(_res_conv);
28975 }
28976
28977 static inline uint64_t CResult_ThirtyTwoBytesPaymentErrorZ_clone_ptr(LDKCResult_ThirtyTwoBytesPaymentErrorZ *NONNULL_PTR arg) {
28978         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
28979         *ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_clone(arg);
28980         return tag_ptr(ret_conv, true);
28981 }
28982 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_clone_ptr(int64_t arg) {
28983         LDKCResult_ThirtyTwoBytesPaymentErrorZ* arg_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(arg);
28984         int64_t ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_clone_ptr(arg_conv);
28985         return ret_conv;
28986 }
28987
28988 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_clone(int64_t orig) {
28989         LDKCResult_ThirtyTwoBytesPaymentErrorZ* orig_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(orig);
28990         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
28991         *ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_clone(orig_conv);
28992         return tag_ptr(ret_conv, true);
28993 }
28994
28995 int64_t  CS_LDK_CResult_NonePaymentErrorZ_ok() {
28996         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
28997         *ret_conv = CResult_NonePaymentErrorZ_ok();
28998         return tag_ptr(ret_conv, true);
28999 }
29000
29001 int64_t  CS_LDK_CResult_NonePaymentErrorZ_err(int64_t e) {
29002         void* e_ptr = untag_ptr(e);
29003         CHECK_ACCESS(e_ptr);
29004         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
29005         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
29006         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
29007         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
29008         return tag_ptr(ret_conv, true);
29009 }
29010
29011 jboolean  CS_LDK_CResult_NonePaymentErrorZ_is_ok(int64_t o) {
29012         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
29013         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
29014         return ret_conv;
29015 }
29016
29017 void  CS_LDK_CResult_NonePaymentErrorZ_free(int64_t _res) {
29018         if (!ptr_is_owned(_res)) return;
29019         void* _res_ptr = untag_ptr(_res);
29020         CHECK_ACCESS(_res_ptr);
29021         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
29022         FREE(untag_ptr(_res));
29023         CResult_NonePaymentErrorZ_free(_res_conv);
29024 }
29025
29026 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
29027         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
29028         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
29029         return tag_ptr(ret_conv, true);
29030 }
29031 int64_t  CS_LDK_CResult_NonePaymentErrorZ_clone_ptr(int64_t arg) {
29032         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
29033         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
29034         return ret_conv;
29035 }
29036
29037 int64_t  CS_LDK_CResult_NonePaymentErrorZ_clone(int64_t orig) {
29038         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
29039         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
29040         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
29041         return tag_ptr(ret_conv, true);
29042 }
29043
29044 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_ok(int64_tArray o) {
29045         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ o_constr;
29046         o_constr.datalen = o->arr_len;
29047         if (o_constr.datalen > 0)
29048                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ Elements");
29049         else
29050                 o_constr.data = NULL;
29051         int64_t* o_vals = o->elems;
29052         for (size_t o = 0; o < o_constr.datalen; o++) {
29053                 int64_t o_conv_40 = o_vals[o];
29054                 void* o_conv_40_ptr = untag_ptr(o_conv_40);
29055                 CHECK_ACCESS(o_conv_40_ptr);
29056                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(o_conv_40_ptr);
29057                 o_conv_40_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone((LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(o_conv_40));
29058                 o_constr.data[o] = o_conv_40_conv;
29059         }
29060         FREE(o);
29061         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
29062         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_ok(o_constr);
29063         return tag_ptr(ret_conv, true);
29064 }
29065
29066 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_err(int64_t e) {
29067         void* e_ptr = untag_ptr(e);
29068         CHECK_ACCESS(e_ptr);
29069         LDKProbingError e_conv = *(LDKProbingError*)(e_ptr);
29070         e_conv = ProbingError_clone((LDKProbingError*)untag_ptr(e));
29071         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
29072         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_err(e_conv);
29073         return tag_ptr(ret_conv, true);
29074 }
29075
29076 jboolean  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_is_ok(int64_t o) {
29077         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(o);
29078         jboolean ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_is_ok(o_conv);
29079         return ret_conv;
29080 }
29081
29082 void  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_free(int64_t _res) {
29083         if (!ptr_is_owned(_res)) return;
29084         void* _res_ptr = untag_ptr(_res);
29085         CHECK_ACCESS(_res_ptr);
29086         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)(_res_ptr);
29087         FREE(untag_ptr(_res));
29088         CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_free(_res_conv);
29089 }
29090
29091 static inline uint64_t CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ *NONNULL_PTR arg) {
29092         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
29093         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone(arg);
29094         return tag_ptr(ret_conv, true);
29095 }
29096 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone_ptr(int64_t arg) {
29097         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(arg);
29098         int64_t ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone_ptr(arg_conv);
29099         return ret_conv;
29100 }
29101
29102 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone(int64_t orig) {
29103         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(orig);
29104         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
29105         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone(orig_conv);
29106         return tag_ptr(ret_conv, true);
29107 }
29108
29109 int64_t  CS_LDK_CResult_StrSecp256k1ErrorZ_ok(jstring o) {
29110         LDKStr o_conv = str_ref_to_owned_c(o);
29111         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
29112         *ret_conv = CResult_StrSecp256k1ErrorZ_ok(o_conv);
29113         return tag_ptr(ret_conv, true);
29114 }
29115
29116 int64_t  CS_LDK_CResult_StrSecp256k1ErrorZ_err(int32_t e) {
29117         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_cs(e);
29118         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
29119         *ret_conv = CResult_StrSecp256k1ErrorZ_err(e_conv);
29120         return tag_ptr(ret_conv, true);
29121 }
29122
29123 jboolean  CS_LDK_CResult_StrSecp256k1ErrorZ_is_ok(int64_t o) {
29124         LDKCResult_StrSecp256k1ErrorZ* o_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(o);
29125         jboolean ret_conv = CResult_StrSecp256k1ErrorZ_is_ok(o_conv);
29126         return ret_conv;
29127 }
29128
29129 void  CS_LDK_CResult_StrSecp256k1ErrorZ_free(int64_t _res) {
29130         if (!ptr_is_owned(_res)) return;
29131         void* _res_ptr = untag_ptr(_res);
29132         CHECK_ACCESS(_res_ptr);
29133         LDKCResult_StrSecp256k1ErrorZ _res_conv = *(LDKCResult_StrSecp256k1ErrorZ*)(_res_ptr);
29134         FREE(untag_ptr(_res));
29135         CResult_StrSecp256k1ErrorZ_free(_res_conv);
29136 }
29137
29138 static inline uint64_t CResult_StrSecp256k1ErrorZ_clone_ptr(LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR arg) {
29139         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
29140         *ret_conv = CResult_StrSecp256k1ErrorZ_clone(arg);
29141         return tag_ptr(ret_conv, true);
29142 }
29143 int64_t  CS_LDK_CResult_StrSecp256k1ErrorZ_clone_ptr(int64_t arg) {
29144         LDKCResult_StrSecp256k1ErrorZ* arg_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(arg);
29145         int64_t ret_conv = CResult_StrSecp256k1ErrorZ_clone_ptr(arg_conv);
29146         return ret_conv;
29147 }
29148
29149 int64_t  CS_LDK_CResult_StrSecp256k1ErrorZ_clone(int64_t orig) {
29150         LDKCResult_StrSecp256k1ErrorZ* orig_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(orig);
29151         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
29152         *ret_conv = CResult_StrSecp256k1ErrorZ_clone(orig_conv);
29153         return tag_ptr(ret_conv, true);
29154 }
29155
29156 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_ok(int64_t o) {
29157         void* o_ptr = untag_ptr(o);
29158         CHECK_ACCESS(o_ptr);
29159         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
29160         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
29161         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
29162         *ret_conv = CResult_TxOutUtxoLookupErrorZ_ok(o_conv);
29163         return tag_ptr(ret_conv, true);
29164 }
29165
29166 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_err(int32_t e) {
29167         LDKUtxoLookupError e_conv = LDKUtxoLookupError_from_cs(e);
29168         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
29169         *ret_conv = CResult_TxOutUtxoLookupErrorZ_err(e_conv);
29170         return tag_ptr(ret_conv, true);
29171 }
29172
29173 jboolean  CS_LDK_CResult_TxOutUtxoLookupErrorZ_is_ok(int64_t o) {
29174         LDKCResult_TxOutUtxoLookupErrorZ* o_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(o);
29175         jboolean ret_conv = CResult_TxOutUtxoLookupErrorZ_is_ok(o_conv);
29176         return ret_conv;
29177 }
29178
29179 void  CS_LDK_CResult_TxOutUtxoLookupErrorZ_free(int64_t _res) {
29180         if (!ptr_is_owned(_res)) return;
29181         void* _res_ptr = untag_ptr(_res);
29182         CHECK_ACCESS(_res_ptr);
29183         LDKCResult_TxOutUtxoLookupErrorZ _res_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(_res_ptr);
29184         FREE(untag_ptr(_res));
29185         CResult_TxOutUtxoLookupErrorZ_free(_res_conv);
29186 }
29187
29188 static inline uint64_t CResult_TxOutUtxoLookupErrorZ_clone_ptr(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR arg) {
29189         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
29190         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(arg);
29191         return tag_ptr(ret_conv, true);
29192 }
29193 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_clone_ptr(int64_t arg) {
29194         LDKCResult_TxOutUtxoLookupErrorZ* arg_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(arg);
29195         int64_t ret_conv = CResult_TxOutUtxoLookupErrorZ_clone_ptr(arg_conv);
29196         return ret_conv;
29197 }
29198
29199 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_clone(int64_t orig) {
29200         LDKCResult_TxOutUtxoLookupErrorZ* orig_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(orig);
29201         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
29202         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(orig_conv);
29203         return tag_ptr(ret_conv, true);
29204 }
29205
29206 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_ok(int64_t o) {
29207         LDKOnionMessagePath o_conv;
29208         o_conv.inner = untag_ptr(o);
29209         o_conv.is_owned = ptr_is_owned(o);
29210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29211         o_conv = OnionMessagePath_clone(&o_conv);
29212         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
29213         *ret_conv = CResult_OnionMessagePathNoneZ_ok(o_conv);
29214         return tag_ptr(ret_conv, true);
29215 }
29216
29217 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_err() {
29218         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
29219         *ret_conv = CResult_OnionMessagePathNoneZ_err();
29220         return tag_ptr(ret_conv, true);
29221 }
29222
29223 jboolean  CS_LDK_CResult_OnionMessagePathNoneZ_is_ok(int64_t o) {
29224         LDKCResult_OnionMessagePathNoneZ* o_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(o);
29225         jboolean ret_conv = CResult_OnionMessagePathNoneZ_is_ok(o_conv);
29226         return ret_conv;
29227 }
29228
29229 void  CS_LDK_CResult_OnionMessagePathNoneZ_free(int64_t _res) {
29230         if (!ptr_is_owned(_res)) return;
29231         void* _res_ptr = untag_ptr(_res);
29232         CHECK_ACCESS(_res_ptr);
29233         LDKCResult_OnionMessagePathNoneZ _res_conv = *(LDKCResult_OnionMessagePathNoneZ*)(_res_ptr);
29234         FREE(untag_ptr(_res));
29235         CResult_OnionMessagePathNoneZ_free(_res_conv);
29236 }
29237
29238 static inline uint64_t CResult_OnionMessagePathNoneZ_clone_ptr(LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR arg) {
29239         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
29240         *ret_conv = CResult_OnionMessagePathNoneZ_clone(arg);
29241         return tag_ptr(ret_conv, true);
29242 }
29243 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_clone_ptr(int64_t arg) {
29244         LDKCResult_OnionMessagePathNoneZ* arg_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(arg);
29245         int64_t ret_conv = CResult_OnionMessagePathNoneZ_clone_ptr(arg_conv);
29246         return ret_conv;
29247 }
29248
29249 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_clone(int64_t orig) {
29250         LDKCResult_OnionMessagePathNoneZ* orig_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(orig);
29251         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
29252         *ret_conv = CResult_OnionMessagePathNoneZ_clone(orig_conv);
29253         return tag_ptr(ret_conv, true);
29254 }
29255
29256 static inline uint64_t C2Tuple_PublicKeyOnionMessageZ_clone_ptr(LDKC2Tuple_PublicKeyOnionMessageZ *NONNULL_PTR arg) {
29257         LDKC2Tuple_PublicKeyOnionMessageZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyOnionMessageZ), "LDKC2Tuple_PublicKeyOnionMessageZ");
29258         *ret_conv = C2Tuple_PublicKeyOnionMessageZ_clone(arg);
29259         return tag_ptr(ret_conv, true);
29260 }
29261 int64_t  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_clone_ptr(int64_t arg) {
29262         LDKC2Tuple_PublicKeyOnionMessageZ* arg_conv = (LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(arg);
29263         int64_t ret_conv = C2Tuple_PublicKeyOnionMessageZ_clone_ptr(arg_conv);
29264         return ret_conv;
29265 }
29266
29267 int64_t  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_clone(int64_t orig) {
29268         LDKC2Tuple_PublicKeyOnionMessageZ* orig_conv = (LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(orig);
29269         LDKC2Tuple_PublicKeyOnionMessageZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyOnionMessageZ), "LDKC2Tuple_PublicKeyOnionMessageZ");
29270         *ret_conv = C2Tuple_PublicKeyOnionMessageZ_clone(orig_conv);
29271         return tag_ptr(ret_conv, true);
29272 }
29273
29274 int64_t  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_new(int8_tArray a, int64_t b) {
29275         LDKPublicKey a_ref;
29276         CHECK(a->arr_len == 33);
29277         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
29278         LDKOnionMessage b_conv;
29279         b_conv.inner = untag_ptr(b);
29280         b_conv.is_owned = ptr_is_owned(b);
29281         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29282         b_conv = OnionMessage_clone(&b_conv);
29283         LDKC2Tuple_PublicKeyOnionMessageZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyOnionMessageZ), "LDKC2Tuple_PublicKeyOnionMessageZ");
29284         *ret_conv = C2Tuple_PublicKeyOnionMessageZ_new(a_ref, b_conv);
29285         return tag_ptr(ret_conv, true);
29286 }
29287
29288 void  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_free(int64_t _res) {
29289         if (!ptr_is_owned(_res)) return;
29290         void* _res_ptr = untag_ptr(_res);
29291         CHECK_ACCESS(_res_ptr);
29292         LDKC2Tuple_PublicKeyOnionMessageZ _res_conv = *(LDKC2Tuple_PublicKeyOnionMessageZ*)(_res_ptr);
29293         FREE(untag_ptr(_res));
29294         C2Tuple_PublicKeyOnionMessageZ_free(_res_conv);
29295 }
29296
29297 int64_t  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_ok(int64_t o) {
29298         void* o_ptr = untag_ptr(o);
29299         CHECK_ACCESS(o_ptr);
29300         LDKC2Tuple_PublicKeyOnionMessageZ o_conv = *(LDKC2Tuple_PublicKeyOnionMessageZ*)(o_ptr);
29301         o_conv = C2Tuple_PublicKeyOnionMessageZ_clone((LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(o));
29302         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ), "LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ");
29303         *ret_conv = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_ok(o_conv);
29304         return tag_ptr(ret_conv, true);
29305 }
29306
29307 int64_t  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_err(int64_t e) {
29308         void* e_ptr = untag_ptr(e);
29309         CHECK_ACCESS(e_ptr);
29310         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
29311         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
29312         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ), "LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ");
29313         *ret_conv = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_err(e_conv);
29314         return tag_ptr(ret_conv, true);
29315 }
29316
29317 jboolean  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_is_ok(int64_t o) {
29318         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* o_conv = (LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ*)untag_ptr(o);
29319         jboolean ret_conv = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_is_ok(o_conv);
29320         return ret_conv;
29321 }
29322
29323 void  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_free(int64_t _res) {
29324         if (!ptr_is_owned(_res)) return;
29325         void* _res_ptr = untag_ptr(_res);
29326         CHECK_ACCESS(_res_ptr);
29327         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ _res_conv = *(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ*)(_res_ptr);
29328         FREE(untag_ptr(_res));
29329         CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_free(_res_conv);
29330 }
29331
29332 int64_t  CS_LDK_CResult_PeeledOnionNoneZ_ok(int64_t o) {
29333         void* o_ptr = untag_ptr(o);
29334         CHECK_ACCESS(o_ptr);
29335         LDKPeeledOnion o_conv = *(LDKPeeledOnion*)(o_ptr);
29336         o_conv = PeeledOnion_clone((LDKPeeledOnion*)untag_ptr(o));
29337         LDKCResult_PeeledOnionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PeeledOnionNoneZ), "LDKCResult_PeeledOnionNoneZ");
29338         *ret_conv = CResult_PeeledOnionNoneZ_ok(o_conv);
29339         return tag_ptr(ret_conv, true);
29340 }
29341
29342 int64_t  CS_LDK_CResult_PeeledOnionNoneZ_err() {
29343         LDKCResult_PeeledOnionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PeeledOnionNoneZ), "LDKCResult_PeeledOnionNoneZ");
29344         *ret_conv = CResult_PeeledOnionNoneZ_err();
29345         return tag_ptr(ret_conv, true);
29346 }
29347
29348 jboolean  CS_LDK_CResult_PeeledOnionNoneZ_is_ok(int64_t o) {
29349         LDKCResult_PeeledOnionNoneZ* o_conv = (LDKCResult_PeeledOnionNoneZ*)untag_ptr(o);
29350         jboolean ret_conv = CResult_PeeledOnionNoneZ_is_ok(o_conv);
29351         return ret_conv;
29352 }
29353
29354 void  CS_LDK_CResult_PeeledOnionNoneZ_free(int64_t _res) {
29355         if (!ptr_is_owned(_res)) return;
29356         void* _res_ptr = untag_ptr(_res);
29357         CHECK_ACCESS(_res_ptr);
29358         LDKCResult_PeeledOnionNoneZ _res_conv = *(LDKCResult_PeeledOnionNoneZ*)(_res_ptr);
29359         FREE(untag_ptr(_res));
29360         CResult_PeeledOnionNoneZ_free(_res_conv);
29361 }
29362
29363 int64_t  CS_LDK_CResult_NoneSendErrorZ_ok() {
29364         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
29365         *ret_conv = CResult_NoneSendErrorZ_ok();
29366         return tag_ptr(ret_conv, true);
29367 }
29368
29369 int64_t  CS_LDK_CResult_NoneSendErrorZ_err(int64_t e) {
29370         void* e_ptr = untag_ptr(e);
29371         CHECK_ACCESS(e_ptr);
29372         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
29373         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
29374         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
29375         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
29376         return tag_ptr(ret_conv, true);
29377 }
29378
29379 jboolean  CS_LDK_CResult_NoneSendErrorZ_is_ok(int64_t o) {
29380         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
29381         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
29382         return ret_conv;
29383 }
29384
29385 void  CS_LDK_CResult_NoneSendErrorZ_free(int64_t _res) {
29386         if (!ptr_is_owned(_res)) return;
29387         void* _res_ptr = untag_ptr(_res);
29388         CHECK_ACCESS(_res_ptr);
29389         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
29390         FREE(untag_ptr(_res));
29391         CResult_NoneSendErrorZ_free(_res_conv);
29392 }
29393
29394 int64_t  CS_LDK_CResult_BlindedPathNoneZ_ok(int64_t o) {
29395         LDKBlindedPath o_conv;
29396         o_conv.inner = untag_ptr(o);
29397         o_conv.is_owned = ptr_is_owned(o);
29398         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29399         o_conv = BlindedPath_clone(&o_conv);
29400         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
29401         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
29402         return tag_ptr(ret_conv, true);
29403 }
29404
29405 int64_t  CS_LDK_CResult_BlindedPathNoneZ_err() {
29406         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
29407         *ret_conv = CResult_BlindedPathNoneZ_err();
29408         return tag_ptr(ret_conv, true);
29409 }
29410
29411 jboolean  CS_LDK_CResult_BlindedPathNoneZ_is_ok(int64_t o) {
29412         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
29413         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
29414         return ret_conv;
29415 }
29416
29417 void  CS_LDK_CResult_BlindedPathNoneZ_free(int64_t _res) {
29418         if (!ptr_is_owned(_res)) return;
29419         void* _res_ptr = untag_ptr(_res);
29420         CHECK_ACCESS(_res_ptr);
29421         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
29422         FREE(untag_ptr(_res));
29423         CResult_BlindedPathNoneZ_free(_res_conv);
29424 }
29425
29426 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
29427         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
29428         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
29429         return tag_ptr(ret_conv, true);
29430 }
29431 int64_t  CS_LDK_CResult_BlindedPathNoneZ_clone_ptr(int64_t arg) {
29432         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
29433         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
29434         return ret_conv;
29435 }
29436
29437 int64_t  CS_LDK_CResult_BlindedPathNoneZ_clone(int64_t orig) {
29438         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
29439         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
29440         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
29441         return tag_ptr(ret_conv, true);
29442 }
29443
29444 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_ok(int64_t o) {
29445         void* o_ptr = untag_ptr(o);
29446         CHECK_ACCESS(o_ptr);
29447         LDKC2Tuple_BlindedPayInfoBlindedPathZ o_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(o_ptr);
29448         o_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(o));
29449         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
29450         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_ok(o_conv);
29451         return tag_ptr(ret_conv, true);
29452 }
29453
29454 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_err() {
29455         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
29456         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_err();
29457         return tag_ptr(ret_conv, true);
29458 }
29459
29460 jboolean  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_is_ok(int64_t o) {
29461         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* o_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(o);
29462         jboolean ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_is_ok(o_conv);
29463         return ret_conv;
29464 }
29465
29466 void  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(int64_t _res) {
29467         if (!ptr_is_owned(_res)) return;
29468         void* _res_ptr = untag_ptr(_res);
29469         CHECK_ACCESS(_res_ptr);
29470         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ _res_conv = *(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)(_res_ptr);
29471         FREE(untag_ptr(_res));
29472         CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(_res_conv);
29473 }
29474
29475 static inline uint64_t CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone_ptr(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR arg) {
29476         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
29477         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(arg);
29478         return tag_ptr(ret_conv, true);
29479 }
29480 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone_ptr(int64_t arg) {
29481         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* arg_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(arg);
29482         int64_t ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone_ptr(arg_conv);
29483         return ret_conv;
29484 }
29485
29486 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(int64_t orig) {
29487         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* orig_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(orig);
29488         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
29489         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(orig_conv);
29490         return tag_ptr(ret_conv, true);
29491 }
29492
29493 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_ok(int64_t o) {
29494         LDKBlindedPath o_conv;
29495         o_conv.inner = untag_ptr(o);
29496         o_conv.is_owned = ptr_is_owned(o);
29497         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29498         o_conv = BlindedPath_clone(&o_conv);
29499         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
29500         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
29501         return tag_ptr(ret_conv, true);
29502 }
29503
29504 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_err(int64_t e) {
29505         void* e_ptr = untag_ptr(e);
29506         CHECK_ACCESS(e_ptr);
29507         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
29508         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
29509         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
29510         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
29511         return tag_ptr(ret_conv, true);
29512 }
29513
29514 jboolean  CS_LDK_CResult_BlindedPathDecodeErrorZ_is_ok(int64_t o) {
29515         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
29516         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
29517         return ret_conv;
29518 }
29519
29520 void  CS_LDK_CResult_BlindedPathDecodeErrorZ_free(int64_t _res) {
29521         if (!ptr_is_owned(_res)) return;
29522         void* _res_ptr = untag_ptr(_res);
29523         CHECK_ACCESS(_res_ptr);
29524         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
29525         FREE(untag_ptr(_res));
29526         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
29527 }
29528
29529 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
29530         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
29531         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
29532         return tag_ptr(ret_conv, true);
29533 }
29534 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_clone_ptr(int64_t arg) {
29535         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
29536         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
29537         return ret_conv;
29538 }
29539
29540 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_clone(int64_t orig) {
29541         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
29542         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
29543         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
29544         return tag_ptr(ret_conv, true);
29545 }
29546
29547 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_ok(int64_t o) {
29548         LDKBlindedHop o_conv;
29549         o_conv.inner = untag_ptr(o);
29550         o_conv.is_owned = ptr_is_owned(o);
29551         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29552         o_conv = BlindedHop_clone(&o_conv);
29553         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
29554         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
29555         return tag_ptr(ret_conv, true);
29556 }
29557
29558 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_err(int64_t e) {
29559         void* e_ptr = untag_ptr(e);
29560         CHECK_ACCESS(e_ptr);
29561         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
29562         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
29563         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
29564         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
29565         return tag_ptr(ret_conv, true);
29566 }
29567
29568 jboolean  CS_LDK_CResult_BlindedHopDecodeErrorZ_is_ok(int64_t o) {
29569         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
29570         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
29571         return ret_conv;
29572 }
29573
29574 void  CS_LDK_CResult_BlindedHopDecodeErrorZ_free(int64_t _res) {
29575         if (!ptr_is_owned(_res)) return;
29576         void* _res_ptr = untag_ptr(_res);
29577         CHECK_ACCESS(_res_ptr);
29578         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
29579         FREE(untag_ptr(_res));
29580         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
29581 }
29582
29583 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
29584         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
29585         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
29586         return tag_ptr(ret_conv, true);
29587 }
29588 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_clone_ptr(int64_t arg) {
29589         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
29590         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
29591         return ret_conv;
29592 }
29593
29594 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_clone(int64_t orig) {
29595         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
29596         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
29597         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
29598         return tag_ptr(ret_conv, true);
29599 }
29600
29601 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_ok(int64_t o) {
29602         LDKInvoiceError o_conv;
29603         o_conv.inner = untag_ptr(o);
29604         o_conv.is_owned = ptr_is_owned(o);
29605         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29606         o_conv = InvoiceError_clone(&o_conv);
29607         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
29608         *ret_conv = CResult_InvoiceErrorDecodeErrorZ_ok(o_conv);
29609         return tag_ptr(ret_conv, true);
29610 }
29611
29612 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_err(int64_t e) {
29613         void* e_ptr = untag_ptr(e);
29614         CHECK_ACCESS(e_ptr);
29615         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
29616         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
29617         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
29618         *ret_conv = CResult_InvoiceErrorDecodeErrorZ_err(e_conv);
29619         return tag_ptr(ret_conv, true);
29620 }
29621
29622 jboolean  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_is_ok(int64_t o) {
29623         LDKCResult_InvoiceErrorDecodeErrorZ* o_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(o);
29624         jboolean ret_conv = CResult_InvoiceErrorDecodeErrorZ_is_ok(o_conv);
29625         return ret_conv;
29626 }
29627
29628 void  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_free(int64_t _res) {
29629         if (!ptr_is_owned(_res)) return;
29630         void* _res_ptr = untag_ptr(_res);
29631         CHECK_ACCESS(_res_ptr);
29632         LDKCResult_InvoiceErrorDecodeErrorZ _res_conv = *(LDKCResult_InvoiceErrorDecodeErrorZ*)(_res_ptr);
29633         FREE(untag_ptr(_res));
29634         CResult_InvoiceErrorDecodeErrorZ_free(_res_conv);
29635 }
29636
29637 static inline uint64_t CResult_InvoiceErrorDecodeErrorZ_clone_ptr(LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR arg) {
29638         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
29639         *ret_conv = CResult_InvoiceErrorDecodeErrorZ_clone(arg);
29640         return tag_ptr(ret_conv, true);
29641 }
29642 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_clone_ptr(int64_t arg) {
29643         LDKCResult_InvoiceErrorDecodeErrorZ* arg_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(arg);
29644         int64_t ret_conv = CResult_InvoiceErrorDecodeErrorZ_clone_ptr(arg_conv);
29645         return ret_conv;
29646 }
29647
29648 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_clone(int64_t orig) {
29649         LDKCResult_InvoiceErrorDecodeErrorZ* orig_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(orig);
29650         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
29651         *ret_conv = CResult_InvoiceErrorDecodeErrorZ_clone(orig_conv);
29652         return tag_ptr(ret_conv, true);
29653 }
29654
29655 int64_t  CS_LDK_COption_FilterZ_some(int64_t o) {
29656         void* o_ptr = untag_ptr(o);
29657         CHECK_ACCESS(o_ptr);
29658         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
29659         if (o_conv.free == LDKFilter_JCalls_free) {
29660                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29661                 LDKFilter_JCalls_cloned(&o_conv);
29662         }
29663         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
29664         *ret_copy = COption_FilterZ_some(o_conv);
29665         int64_t ret_ref = tag_ptr(ret_copy, true);
29666         return ret_ref;
29667 }
29668
29669 int64_t  CS_LDK_COption_FilterZ_none() {
29670         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
29671         *ret_copy = COption_FilterZ_none();
29672         int64_t ret_ref = tag_ptr(ret_copy, true);
29673         return ret_ref;
29674 }
29675
29676 void  CS_LDK_COption_FilterZ_free(int64_t _res) {
29677         if (!ptr_is_owned(_res)) return;
29678         void* _res_ptr = untag_ptr(_res);
29679         CHECK_ACCESS(_res_ptr);
29680         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
29681         FREE(untag_ptr(_res));
29682         COption_FilterZ_free(_res_conv);
29683 }
29684
29685 int64_t  CS_LDK_CResult_LockedChannelMonitorNoneZ_ok(int64_t o) {
29686         LDKLockedChannelMonitor o_conv;
29687         o_conv.inner = untag_ptr(o);
29688         o_conv.is_owned = ptr_is_owned(o);
29689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29690         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
29691         
29692         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29693         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
29694         return tag_ptr(ret_conv, true);
29695 }
29696
29697 int64_t  CS_LDK_CResult_LockedChannelMonitorNoneZ_err() {
29698         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29699         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
29700         return tag_ptr(ret_conv, true);
29701 }
29702
29703 jboolean  CS_LDK_CResult_LockedChannelMonitorNoneZ_is_ok(int64_t o) {
29704         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
29705         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
29706         return ret_conv;
29707 }
29708
29709 void  CS_LDK_CResult_LockedChannelMonitorNoneZ_free(int64_t _res) {
29710         if (!ptr_is_owned(_res)) return;
29711         void* _res_ptr = untag_ptr(_res);
29712         CHECK_ACCESS(_res_ptr);
29713         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
29714         FREE(untag_ptr(_res));
29715         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
29716 }
29717
29718 void  CS_LDK_CVec_OutPointZ_free(int64_tArray _res) {
29719         LDKCVec_OutPointZ _res_constr;
29720         _res_constr.datalen = _res->arr_len;
29721         if (_res_constr.datalen > 0)
29722                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
29723         else
29724                 _res_constr.data = NULL;
29725         int64_t* _res_vals = _res->elems;
29726         for (size_t k = 0; k < _res_constr.datalen; k++) {
29727                 int64_t _res_conv_10 = _res_vals[k];
29728                 LDKOutPoint _res_conv_10_conv;
29729                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
29730                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
29731                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
29732                 _res_constr.data[k] = _res_conv_10_conv;
29733         }
29734         FREE(_res);
29735         CVec_OutPointZ_free(_res_constr);
29736 }
29737
29738 void  CS_LDK_CVec_MonitorUpdateIdZ_free(int64_tArray _res) {
29739         LDKCVec_MonitorUpdateIdZ _res_constr;
29740         _res_constr.datalen = _res->arr_len;
29741         if (_res_constr.datalen > 0)
29742                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
29743         else
29744                 _res_constr.data = NULL;
29745         int64_t* _res_vals = _res->elems;
29746         for (size_t r = 0; r < _res_constr.datalen; r++) {
29747                 int64_t _res_conv_17 = _res_vals[r];
29748                 LDKMonitorUpdateId _res_conv_17_conv;
29749                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
29750                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
29751                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
29752                 _res_constr.data[r] = _res_conv_17_conv;
29753         }
29754         FREE(_res);
29755         CVec_MonitorUpdateIdZ_free(_res_constr);
29756 }
29757
29758 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
29759         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29760         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
29761         return tag_ptr(ret_conv, true);
29762 }
29763 int64_t  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(int64_t arg) {
29764         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
29765         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
29766         return ret_conv;
29767 }
29768
29769 int64_t  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(int64_t orig) {
29770         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
29771         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29772         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
29773         return tag_ptr(ret_conv, true);
29774 }
29775
29776 int64_t  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(int64_t a, int64_tArray b) {
29777         LDKOutPoint a_conv;
29778         a_conv.inner = untag_ptr(a);
29779         a_conv.is_owned = ptr_is_owned(a);
29780         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29781         a_conv = OutPoint_clone(&a_conv);
29782         LDKCVec_MonitorUpdateIdZ b_constr;
29783         b_constr.datalen = b->arr_len;
29784         if (b_constr.datalen > 0)
29785                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
29786         else
29787                 b_constr.data = NULL;
29788         int64_t* b_vals = b->elems;
29789         for (size_t r = 0; r < b_constr.datalen; r++) {
29790                 int64_t b_conv_17 = b_vals[r];
29791                 LDKMonitorUpdateId b_conv_17_conv;
29792                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
29793                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
29794                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
29795                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
29796                 b_constr.data[r] = b_conv_17_conv;
29797         }
29798         FREE(b);
29799         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29800         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
29801         return tag_ptr(ret_conv, true);
29802 }
29803
29804 void  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(int64_t _res) {
29805         if (!ptr_is_owned(_res)) return;
29806         void* _res_ptr = untag_ptr(_res);
29807         CHECK_ACCESS(_res_ptr);
29808         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
29809         FREE(untag_ptr(_res));
29810         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
29811 }
29812
29813 void  CS_LDK_CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(int64_tArray _res) {
29814         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
29815         _res_constr.datalen = _res->arr_len;
29816         if (_res_constr.datalen > 0)
29817                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
29818         else
29819                 _res_constr.data = NULL;
29820         int64_t* _res_vals = _res->elems;
29821         for (size_t p = 0; p < _res_constr.datalen; p++) {
29822                 int64_t _res_conv_41 = _res_vals[p];
29823                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
29824                 CHECK_ACCESS(_res_conv_41_ptr);
29825                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
29826                 FREE(untag_ptr(_res_conv_41));
29827                 _res_constr.data[p] = _res_conv_41_conv;
29828         }
29829         FREE(_res);
29830         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
29831 }
29832
29833 void  CS_LDK_APIError_free(int64_t this_ptr) {
29834         if (!ptr_is_owned(this_ptr)) return;
29835         void* this_ptr_ptr = untag_ptr(this_ptr);
29836         CHECK_ACCESS(this_ptr_ptr);
29837         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
29838         FREE(untag_ptr(this_ptr));
29839         APIError_free(this_ptr_conv);
29840 }
29841
29842 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
29843         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29844         *ret_copy = APIError_clone(arg);
29845         int64_t ret_ref = tag_ptr(ret_copy, true);
29846         return ret_ref;
29847 }
29848 int64_t  CS_LDK_APIError_clone_ptr(int64_t arg) {
29849         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
29850         int64_t ret_conv = APIError_clone_ptr(arg_conv);
29851         return ret_conv;
29852 }
29853
29854 int64_t  CS_LDK_APIError_clone(int64_t orig) {
29855         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
29856         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29857         *ret_copy = APIError_clone(orig_conv);
29858         int64_t ret_ref = tag_ptr(ret_copy, true);
29859         return ret_ref;
29860 }
29861
29862 int64_t  CS_LDK_APIError_apimisuse_error(jstring err) {
29863         LDKStr err_conv = str_ref_to_owned_c(err);
29864         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29865         *ret_copy = APIError_apimisuse_error(err_conv);
29866         int64_t ret_ref = tag_ptr(ret_copy, true);
29867         return ret_ref;
29868 }
29869
29870 int64_t  CS_LDK_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
29871         LDKStr err_conv = str_ref_to_owned_c(err);
29872         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29873         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
29874         int64_t ret_ref = tag_ptr(ret_copy, true);
29875         return ret_ref;
29876 }
29877
29878 int64_t  CS_LDK_APIError_invalid_route(jstring err) {
29879         LDKStr err_conv = str_ref_to_owned_c(err);
29880         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29881         *ret_copy = APIError_invalid_route(err_conv);
29882         int64_t ret_ref = tag_ptr(ret_copy, true);
29883         return ret_ref;
29884 }
29885
29886 int64_t  CS_LDK_APIError_channel_unavailable(jstring err) {
29887         LDKStr err_conv = str_ref_to_owned_c(err);
29888         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29889         *ret_copy = APIError_channel_unavailable(err_conv);
29890         int64_t ret_ref = tag_ptr(ret_copy, true);
29891         return ret_ref;
29892 }
29893
29894 int64_t  CS_LDK_APIError_monitor_update_in_progress() {
29895         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29896         *ret_copy = APIError_monitor_update_in_progress();
29897         int64_t ret_ref = tag_ptr(ret_copy, true);
29898         return ret_ref;
29899 }
29900
29901 int64_t  CS_LDK_APIError_incompatible_shutdown_script(int64_t script) {
29902         LDKShutdownScript script_conv;
29903         script_conv.inner = untag_ptr(script);
29904         script_conv.is_owned = ptr_is_owned(script);
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
29906         script_conv = ShutdownScript_clone(&script_conv);
29907         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29908         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
29909         int64_t ret_ref = tag_ptr(ret_copy, true);
29910         return ret_ref;
29911 }
29912
29913 jboolean  CS_LDK_APIError_eq(int64_t a, int64_t b) {
29914         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
29915         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
29916         jboolean ret_conv = APIError_eq(a_conv, b_conv);
29917         return ret_conv;
29918 }
29919
29920 int8_tArray  CS_LDK_APIError_write(int64_t obj) {
29921         LDKAPIError* obj_conv = (LDKAPIError*)untag_ptr(obj);
29922         LDKCVec_u8Z ret_var = APIError_write(obj_conv);
29923         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29924         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29925         CVec_u8Z_free(ret_var);
29926         return ret_arr;
29927 }
29928
29929 int64_t  CS_LDK_APIError_read(int8_tArray ser) {
29930         LDKu8slice ser_ref;
29931         ser_ref.datalen = ser->arr_len;
29932         ser_ref.data = ser->elems;
29933         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
29934         *ret_conv = APIError_read(ser_ref);
29935         FREE(ser);
29936         return tag_ptr(ret_conv, true);
29937 }
29938
29939 void  CS_LDK_BigSize_free(int64_t this_obj) {
29940         LDKBigSize this_obj_conv;
29941         this_obj_conv.inner = untag_ptr(this_obj);
29942         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29944         BigSize_free(this_obj_conv);
29945 }
29946
29947 int64_t  CS_LDK_BigSize_get_a(int64_t this_ptr) {
29948         LDKBigSize this_ptr_conv;
29949         this_ptr_conv.inner = untag_ptr(this_ptr);
29950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29952         this_ptr_conv.is_owned = false;
29953         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
29954         return ret_conv;
29955 }
29956
29957 void  CS_LDK_BigSize_set_a(int64_t this_ptr, int64_t val) {
29958         LDKBigSize this_ptr_conv;
29959         this_ptr_conv.inner = untag_ptr(this_ptr);
29960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29962         this_ptr_conv.is_owned = false;
29963         BigSize_set_a(&this_ptr_conv, val);
29964 }
29965
29966 int64_t  CS_LDK_BigSize_new(int64_t a_arg) {
29967         LDKBigSize ret_var = BigSize_new(a_arg);
29968         int64_t ret_ref = 0;
29969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29970         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29971         return ret_ref;
29972 }
29973
29974 static inline uint64_t BigSize_clone_ptr(LDKBigSize *NONNULL_PTR arg) {
29975         LDKBigSize ret_var = BigSize_clone(arg);
29976         int64_t ret_ref = 0;
29977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29979         return ret_ref;
29980 }
29981 int64_t  CS_LDK_BigSize_clone_ptr(int64_t arg) {
29982         LDKBigSize arg_conv;
29983         arg_conv.inner = untag_ptr(arg);
29984         arg_conv.is_owned = ptr_is_owned(arg);
29985         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29986         arg_conv.is_owned = false;
29987         int64_t ret_conv = BigSize_clone_ptr(&arg_conv);
29988         return ret_conv;
29989 }
29990
29991 int64_t  CS_LDK_BigSize_clone(int64_t orig) {
29992         LDKBigSize orig_conv;
29993         orig_conv.inner = untag_ptr(orig);
29994         orig_conv.is_owned = ptr_is_owned(orig);
29995         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29996         orig_conv.is_owned = false;
29997         LDKBigSize ret_var = BigSize_clone(&orig_conv);
29998         int64_t ret_ref = 0;
29999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30000         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30001         return ret_ref;
30002 }
30003
30004 int64_t  CS_LDK_BigSize_hash(int64_t o) {
30005         LDKBigSize o_conv;
30006         o_conv.inner = untag_ptr(o);
30007         o_conv.is_owned = ptr_is_owned(o);
30008         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30009         o_conv.is_owned = false;
30010         int64_t ret_conv = BigSize_hash(&o_conv);
30011         return ret_conv;
30012 }
30013
30014 jboolean  CS_LDK_BigSize_eq(int64_t a, int64_t b) {
30015         LDKBigSize a_conv;
30016         a_conv.inner = untag_ptr(a);
30017         a_conv.is_owned = ptr_is_owned(a);
30018         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30019         a_conv.is_owned = false;
30020         LDKBigSize b_conv;
30021         b_conv.inner = untag_ptr(b);
30022         b_conv.is_owned = ptr_is_owned(b);
30023         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30024         b_conv.is_owned = false;
30025         jboolean ret_conv = BigSize_eq(&a_conv, &b_conv);
30026         return ret_conv;
30027 }
30028
30029 int8_tArray  CS_LDK_BigSize_write(int64_t obj) {
30030         LDKBigSize obj_conv;
30031         obj_conv.inner = untag_ptr(obj);
30032         obj_conv.is_owned = ptr_is_owned(obj);
30033         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30034         obj_conv.is_owned = false;
30035         LDKCVec_u8Z ret_var = BigSize_write(&obj_conv);
30036         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30037         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30038         CVec_u8Z_free(ret_var);
30039         return ret_arr;
30040 }
30041
30042 int64_t  CS_LDK_BigSize_read(int8_tArray ser) {
30043         LDKu8slice ser_ref;
30044         ser_ref.datalen = ser->arr_len;
30045         ser_ref.data = ser->elems;
30046         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
30047         *ret_conv = BigSize_read(ser_ref);
30048         FREE(ser);
30049         return tag_ptr(ret_conv, true);
30050 }
30051
30052 void  CS_LDK_Hostname_free(int64_t this_obj) {
30053         LDKHostname this_obj_conv;
30054         this_obj_conv.inner = untag_ptr(this_obj);
30055         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30057         Hostname_free(this_obj_conv);
30058 }
30059
30060 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
30061         LDKHostname ret_var = Hostname_clone(arg);
30062         int64_t ret_ref = 0;
30063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30064         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30065         return ret_ref;
30066 }
30067 int64_t  CS_LDK_Hostname_clone_ptr(int64_t arg) {
30068         LDKHostname arg_conv;
30069         arg_conv.inner = untag_ptr(arg);
30070         arg_conv.is_owned = ptr_is_owned(arg);
30071         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30072         arg_conv.is_owned = false;
30073         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
30074         return ret_conv;
30075 }
30076
30077 int64_t  CS_LDK_Hostname_clone(int64_t orig) {
30078         LDKHostname orig_conv;
30079         orig_conv.inner = untag_ptr(orig);
30080         orig_conv.is_owned = ptr_is_owned(orig);
30081         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30082         orig_conv.is_owned = false;
30083         LDKHostname ret_var = Hostname_clone(&orig_conv);
30084         int64_t ret_ref = 0;
30085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30087         return ret_ref;
30088 }
30089
30090 jboolean  CS_LDK_Hostname_eq(int64_t a, int64_t b) {
30091         LDKHostname a_conv;
30092         a_conv.inner = untag_ptr(a);
30093         a_conv.is_owned = ptr_is_owned(a);
30094         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30095         a_conv.is_owned = false;
30096         LDKHostname b_conv;
30097         b_conv.inner = untag_ptr(b);
30098         b_conv.is_owned = ptr_is_owned(b);
30099         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30100         b_conv.is_owned = false;
30101         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
30102         return ret_conv;
30103 }
30104
30105 int8_t  CS_LDK_Hostname_len(int64_t this_arg) {
30106         LDKHostname this_arg_conv;
30107         this_arg_conv.inner = untag_ptr(this_arg);
30108         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30110         this_arg_conv.is_owned = false;
30111         int8_t ret_conv = Hostname_len(&this_arg_conv);
30112         return ret_conv;
30113 }
30114
30115 int8_tArray  CS_LDK_Hostname_write(int64_t obj) {
30116         LDKHostname obj_conv;
30117         obj_conv.inner = untag_ptr(obj);
30118         obj_conv.is_owned = ptr_is_owned(obj);
30119         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30120         obj_conv.is_owned = false;
30121         LDKCVec_u8Z ret_var = Hostname_write(&obj_conv);
30122         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30123         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30124         CVec_u8Z_free(ret_var);
30125         return ret_arr;
30126 }
30127
30128 int64_t  CS_LDK_Hostname_read(int8_tArray ser) {
30129         LDKu8slice ser_ref;
30130         ser_ref.datalen = ser->arr_len;
30131         ser_ref.data = ser->elems;
30132         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
30133         *ret_conv = Hostname_read(ser_ref);
30134         FREE(ser);
30135         return tag_ptr(ret_conv, true);
30136 }
30137
30138 void  CS_LDK_TransactionU16LenLimited_free(int64_t this_obj) {
30139         LDKTransactionU16LenLimited this_obj_conv;
30140         this_obj_conv.inner = untag_ptr(this_obj);
30141         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30143         TransactionU16LenLimited_free(this_obj_conv);
30144 }
30145
30146 static inline uint64_t TransactionU16LenLimited_clone_ptr(LDKTransactionU16LenLimited *NONNULL_PTR arg) {
30147         LDKTransactionU16LenLimited ret_var = TransactionU16LenLimited_clone(arg);
30148         int64_t ret_ref = 0;
30149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30150         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30151         return ret_ref;
30152 }
30153 int64_t  CS_LDK_TransactionU16LenLimited_clone_ptr(int64_t arg) {
30154         LDKTransactionU16LenLimited arg_conv;
30155         arg_conv.inner = untag_ptr(arg);
30156         arg_conv.is_owned = ptr_is_owned(arg);
30157         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30158         arg_conv.is_owned = false;
30159         int64_t ret_conv = TransactionU16LenLimited_clone_ptr(&arg_conv);
30160         return ret_conv;
30161 }
30162
30163 int64_t  CS_LDK_TransactionU16LenLimited_clone(int64_t orig) {
30164         LDKTransactionU16LenLimited orig_conv;
30165         orig_conv.inner = untag_ptr(orig);
30166         orig_conv.is_owned = ptr_is_owned(orig);
30167         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30168         orig_conv.is_owned = false;
30169         LDKTransactionU16LenLimited ret_var = TransactionU16LenLimited_clone(&orig_conv);
30170         int64_t ret_ref = 0;
30171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30173         return ret_ref;
30174 }
30175
30176 jboolean  CS_LDK_TransactionU16LenLimited_eq(int64_t a, int64_t b) {
30177         LDKTransactionU16LenLimited a_conv;
30178         a_conv.inner = untag_ptr(a);
30179         a_conv.is_owned = ptr_is_owned(a);
30180         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30181         a_conv.is_owned = false;
30182         LDKTransactionU16LenLimited b_conv;
30183         b_conv.inner = untag_ptr(b);
30184         b_conv.is_owned = ptr_is_owned(b);
30185         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30186         b_conv.is_owned = false;
30187         jboolean ret_conv = TransactionU16LenLimited_eq(&a_conv, &b_conv);
30188         return ret_conv;
30189 }
30190
30191 int64_t  CS_LDK_TransactionU16LenLimited_new(int8_tArray transaction) {
30192         LDKTransaction transaction_ref;
30193         transaction_ref.datalen = transaction->arr_len;
30194         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
30195         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
30196         transaction_ref.data_is_owned = true;
30197         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
30198         *ret_conv = TransactionU16LenLimited_new(transaction_ref);
30199         return tag_ptr(ret_conv, true);
30200 }
30201
30202 int8_tArray  CS_LDK_TransactionU16LenLimited_into_transaction(int64_t this_arg) {
30203         LDKTransactionU16LenLimited this_arg_conv;
30204         this_arg_conv.inner = untag_ptr(this_arg);
30205         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30207         this_arg_conv = TransactionU16LenLimited_clone(&this_arg_conv);
30208         LDKTransaction ret_var = TransactionU16LenLimited_into_transaction(this_arg_conv);
30209         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30210         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30211         Transaction_free(ret_var);
30212         return ret_arr;
30213 }
30214
30215 int8_tArray  CS_LDK_TransactionU16LenLimited_write(int64_t obj) {
30216         LDKTransactionU16LenLimited obj_conv;
30217         obj_conv.inner = untag_ptr(obj);
30218         obj_conv.is_owned = ptr_is_owned(obj);
30219         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30220         obj_conv.is_owned = false;
30221         LDKCVec_u8Z ret_var = TransactionU16LenLimited_write(&obj_conv);
30222         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30223         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30224         CVec_u8Z_free(ret_var);
30225         return ret_arr;
30226 }
30227
30228 int64_t  CS_LDK_TransactionU16LenLimited_read(int8_tArray ser) {
30229         LDKu8slice ser_ref;
30230         ser_ref.datalen = ser->arr_len;
30231         ser_ref.data = ser->elems;
30232         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
30233         *ret_conv = TransactionU16LenLimited_read(ser_ref);
30234         FREE(ser);
30235         return tag_ptr(ret_conv, true);
30236 }
30237
30238 int64_t  CS_LDK_sign(int8_tArray msg, int8_tArray sk) {
30239         LDKu8slice msg_ref;
30240         msg_ref.datalen = msg->arr_len;
30241         msg_ref.data = msg->elems;
30242         uint8_t sk_arr[32];
30243         CHECK(sk->arr_len == 32);
30244         memcpy(sk_arr, sk->elems, 32); FREE(sk);
30245         uint8_t (*sk_ref)[32] = &sk_arr;
30246         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
30247         *ret_conv = sign(msg_ref, sk_ref);
30248         FREE(msg);
30249         return tag_ptr(ret_conv, true);
30250 }
30251
30252 int64_t  CS_LDK_recover_pk(int8_tArray msg, jstring sig) {
30253         LDKu8slice msg_ref;
30254         msg_ref.datalen = msg->arr_len;
30255         msg_ref.data = msg->elems;
30256         LDKStr sig_conv = str_ref_to_owned_c(sig);
30257         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
30258         *ret_conv = recover_pk(msg_ref, sig_conv);
30259         FREE(msg);
30260         return tag_ptr(ret_conv, true);
30261 }
30262
30263 jboolean  CS_LDK_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
30264         LDKu8slice msg_ref;
30265         msg_ref.datalen = msg->arr_len;
30266         msg_ref.data = msg->elems;
30267         LDKStr sig_conv = str_ref_to_owned_c(sig);
30268         LDKPublicKey pk_ref;
30269         CHECK(pk->arr_len == 33);
30270         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
30271         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
30272         FREE(msg);
30273         return ret_conv;
30274 }
30275
30276 int8_tArray  CS_LDK_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
30277         LDKu8slice hrp_bytes_ref;
30278         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
30279         hrp_bytes_ref.data = hrp_bytes->elems;
30280         LDKCVec_U5Z data_without_signature_constr;
30281         data_without_signature_constr.datalen = data_without_signature->arr_len;
30282         if (data_without_signature_constr.datalen > 0)
30283                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
30284         else
30285                 data_without_signature_constr.data = NULL;
30286         int8_t* data_without_signature_vals = (void*) data_without_signature->elems;
30287         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
30288                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
30289                 
30290                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
30291         }
30292         FREE(data_without_signature);
30293         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
30294         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30295         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30296         CVec_u8Z_free(ret_var);
30297         FREE(hrp_bytes);
30298         return ret_arr;
30299 }
30300
30301 void  CS_LDK_KVStore_free(int64_t this_ptr) {
30302         if (!ptr_is_owned(this_ptr)) return;
30303         void* this_ptr_ptr = untag_ptr(this_ptr);
30304         CHECK_ACCESS(this_ptr_ptr);
30305         LDKKVStore this_ptr_conv = *(LDKKVStore*)(this_ptr_ptr);
30306         FREE(untag_ptr(this_ptr));
30307         KVStore_free(this_ptr_conv);
30308 }
30309
30310 void  CS_LDK_Persister_free(int64_t this_ptr) {
30311         if (!ptr_is_owned(this_ptr)) return;
30312         void* this_ptr_ptr = untag_ptr(this_ptr);
30313         CHECK_ACCESS(this_ptr_ptr);
30314         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
30315         FREE(untag_ptr(this_ptr));
30316         Persister_free(this_ptr_conv);
30317 }
30318
30319 int64_t  CS_LDK_read_channel_monitors(int64_t kv_store, int64_t entropy_source, int64_t signer_provider) {
30320         void* kv_store_ptr = untag_ptr(kv_store);
30321         CHECK_ACCESS(kv_store_ptr);
30322         LDKKVStore kv_store_conv = *(LDKKVStore*)(kv_store_ptr);
30323         if (kv_store_conv.free == LDKKVStore_JCalls_free) {
30324                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30325                 LDKKVStore_JCalls_cloned(&kv_store_conv);
30326         }
30327         void* entropy_source_ptr = untag_ptr(entropy_source);
30328         CHECK_ACCESS(entropy_source_ptr);
30329         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
30330         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
30331                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30332                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
30333         }
30334         void* signer_provider_ptr = untag_ptr(signer_provider);
30335         CHECK_ACCESS(signer_provider_ptr);
30336         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
30337         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
30338                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30339                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
30340         }
30341         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
30342         *ret_conv = read_channel_monitors(kv_store_conv, entropy_source_conv, signer_provider_conv);
30343         return tag_ptr(ret_conv, true);
30344 }
30345
30346 void  CS_LDK_MonitorUpdatingPersister_free(int64_t this_obj) {
30347         LDKMonitorUpdatingPersister this_obj_conv;
30348         this_obj_conv.inner = untag_ptr(this_obj);
30349         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30351         MonitorUpdatingPersister_free(this_obj_conv);
30352 }
30353
30354 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) {
30355         void* kv_store_ptr = untag_ptr(kv_store);
30356         CHECK_ACCESS(kv_store_ptr);
30357         LDKKVStore kv_store_conv = *(LDKKVStore*)(kv_store_ptr);
30358         if (kv_store_conv.free == LDKKVStore_JCalls_free) {
30359                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30360                 LDKKVStore_JCalls_cloned(&kv_store_conv);
30361         }
30362         void* logger_ptr = untag_ptr(logger);
30363         CHECK_ACCESS(logger_ptr);
30364         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30365         if (logger_conv.free == LDKLogger_JCalls_free) {
30366                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30367                 LDKLogger_JCalls_cloned(&logger_conv);
30368         }
30369         void* entropy_source_ptr = untag_ptr(entropy_source);
30370         CHECK_ACCESS(entropy_source_ptr);
30371         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
30372         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
30373                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30374                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
30375         }
30376         void* signer_provider_ptr = untag_ptr(signer_provider);
30377         CHECK_ACCESS(signer_provider_ptr);
30378         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
30379         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
30380                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30381                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
30382         }
30383         LDKMonitorUpdatingPersister ret_var = MonitorUpdatingPersister_new(kv_store_conv, logger_conv, maximum_pending_updates, entropy_source_conv, signer_provider_conv);
30384         int64_t ret_ref = 0;
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30387         return ret_ref;
30388 }
30389
30390 int64_t  CS_LDK_MonitorUpdatingPersister_read_all_channel_monitors_with_updates(int64_t this_arg, int64_t broadcaster, int64_t fee_estimator) {
30391         LDKMonitorUpdatingPersister this_arg_conv;
30392         this_arg_conv.inner = untag_ptr(this_arg);
30393         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30395         this_arg_conv.is_owned = false;
30396         void* broadcaster_ptr = untag_ptr(broadcaster);
30397         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
30398         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
30399         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30400         if (ptr_is_owned(fee_estimator)) { CHECK_ACCESS(fee_estimator_ptr); }
30401         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
30402         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
30403         *ret_conv = MonitorUpdatingPersister_read_all_channel_monitors_with_updates(&this_arg_conv, broadcaster_conv, fee_estimator_conv);
30404         return tag_ptr(ret_conv, true);
30405 }
30406
30407 int64_t  CS_LDK_MonitorUpdatingPersister_read_channel_monitor_with_updates(int64_t this_arg, int64_t broadcaster, int64_t fee_estimator, jstring monitor_key) {
30408         LDKMonitorUpdatingPersister this_arg_conv;
30409         this_arg_conv.inner = untag_ptr(this_arg);
30410         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30412         this_arg_conv.is_owned = false;
30413         void* broadcaster_ptr = untag_ptr(broadcaster);
30414         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
30415         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
30416         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30417         if (ptr_is_owned(fee_estimator)) { CHECK_ACCESS(fee_estimator_ptr); }
30418         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
30419         LDKStr monitor_key_conv = str_ref_to_owned_c(monitor_key);
30420         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
30421         *ret_conv = MonitorUpdatingPersister_read_channel_monitor_with_updates(&this_arg_conv, broadcaster_conv, fee_estimator_conv, monitor_key_conv);
30422         return tag_ptr(ret_conv, true);
30423 }
30424
30425 int64_t  CS_LDK_MonitorUpdatingPersister_cleanup_stale_updates(int64_t this_arg, jboolean lazy) {
30426         LDKMonitorUpdatingPersister this_arg_conv;
30427         this_arg_conv.inner = untag_ptr(this_arg);
30428         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30430         this_arg_conv.is_owned = false;
30431         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
30432         *ret_conv = MonitorUpdatingPersister_cleanup_stale_updates(&this_arg_conv, lazy);
30433         return tag_ptr(ret_conv, true);
30434 }
30435
30436 int64_t  CS_LDK_MonitorUpdatingPersister_as_Persist(int64_t this_arg) {
30437         LDKMonitorUpdatingPersister this_arg_conv;
30438         this_arg_conv.inner = untag_ptr(this_arg);
30439         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30441         this_arg_conv.is_owned = false;
30442         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
30443         *ret_ret = MonitorUpdatingPersister_as_Persist(&this_arg_conv);
30444         return tag_ptr(ret_ret, true);
30445 }
30446
30447 void  CS_LDK_UntrustedString_free(int64_t this_obj) {
30448         LDKUntrustedString this_obj_conv;
30449         this_obj_conv.inner = untag_ptr(this_obj);
30450         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30452         UntrustedString_free(this_obj_conv);
30453 }
30454
30455 jstring  CS_LDK_UntrustedString_get_a(int64_t this_ptr) {
30456         LDKUntrustedString this_ptr_conv;
30457         this_ptr_conv.inner = untag_ptr(this_ptr);
30458         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30460         this_ptr_conv.is_owned = false;
30461         LDKStr ret_str = UntrustedString_get_a(&this_ptr_conv);
30462         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30463         Str_free(ret_str);
30464         return ret_conv;
30465 }
30466
30467 void  CS_LDK_UntrustedString_set_a(int64_t this_ptr, jstring val) {
30468         LDKUntrustedString this_ptr_conv;
30469         this_ptr_conv.inner = untag_ptr(this_ptr);
30470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30472         this_ptr_conv.is_owned = false;
30473         LDKStr val_conv = str_ref_to_owned_c(val);
30474         UntrustedString_set_a(&this_ptr_conv, val_conv);
30475 }
30476
30477 int64_t  CS_LDK_UntrustedString_new(jstring a_arg) {
30478         LDKStr a_arg_conv = str_ref_to_owned_c(a_arg);
30479         LDKUntrustedString ret_var = UntrustedString_new(a_arg_conv);
30480         int64_t ret_ref = 0;
30481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30483         return ret_ref;
30484 }
30485
30486 static inline uint64_t UntrustedString_clone_ptr(LDKUntrustedString *NONNULL_PTR arg) {
30487         LDKUntrustedString ret_var = UntrustedString_clone(arg);
30488         int64_t ret_ref = 0;
30489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30491         return ret_ref;
30492 }
30493 int64_t  CS_LDK_UntrustedString_clone_ptr(int64_t arg) {
30494         LDKUntrustedString arg_conv;
30495         arg_conv.inner = untag_ptr(arg);
30496         arg_conv.is_owned = ptr_is_owned(arg);
30497         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30498         arg_conv.is_owned = false;
30499         int64_t ret_conv = UntrustedString_clone_ptr(&arg_conv);
30500         return ret_conv;
30501 }
30502
30503 int64_t  CS_LDK_UntrustedString_clone(int64_t orig) {
30504         LDKUntrustedString orig_conv;
30505         orig_conv.inner = untag_ptr(orig);
30506         orig_conv.is_owned = ptr_is_owned(orig);
30507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30508         orig_conv.is_owned = false;
30509         LDKUntrustedString ret_var = UntrustedString_clone(&orig_conv);
30510         int64_t ret_ref = 0;
30511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30513         return ret_ref;
30514 }
30515
30516 jboolean  CS_LDK_UntrustedString_eq(int64_t a, int64_t b) {
30517         LDKUntrustedString a_conv;
30518         a_conv.inner = untag_ptr(a);
30519         a_conv.is_owned = ptr_is_owned(a);
30520         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30521         a_conv.is_owned = false;
30522         LDKUntrustedString b_conv;
30523         b_conv.inner = untag_ptr(b);
30524         b_conv.is_owned = ptr_is_owned(b);
30525         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30526         b_conv.is_owned = false;
30527         jboolean ret_conv = UntrustedString_eq(&a_conv, &b_conv);
30528         return ret_conv;
30529 }
30530
30531 int8_tArray  CS_LDK_UntrustedString_write(int64_t obj) {
30532         LDKUntrustedString obj_conv;
30533         obj_conv.inner = untag_ptr(obj);
30534         obj_conv.is_owned = ptr_is_owned(obj);
30535         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30536         obj_conv.is_owned = false;
30537         LDKCVec_u8Z ret_var = UntrustedString_write(&obj_conv);
30538         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30539         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30540         CVec_u8Z_free(ret_var);
30541         return ret_arr;
30542 }
30543
30544 int64_t  CS_LDK_UntrustedString_read(int8_tArray ser) {
30545         LDKu8slice ser_ref;
30546         ser_ref.datalen = ser->arr_len;
30547         ser_ref.data = ser->elems;
30548         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
30549         *ret_conv = UntrustedString_read(ser_ref);
30550         FREE(ser);
30551         return tag_ptr(ret_conv, true);
30552 }
30553
30554 void  CS_LDK_PrintableString_free(int64_t this_obj) {
30555         LDKPrintableString this_obj_conv;
30556         this_obj_conv.inner = untag_ptr(this_obj);
30557         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30559         PrintableString_free(this_obj_conv);
30560 }
30561
30562 jstring  CS_LDK_PrintableString_get_a(int64_t this_ptr) {
30563         LDKPrintableString this_ptr_conv;
30564         this_ptr_conv.inner = untag_ptr(this_ptr);
30565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30567         this_ptr_conv.is_owned = false;
30568         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
30569         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30570         Str_free(ret_str);
30571         return ret_conv;
30572 }
30573
30574 void  CS_LDK_PrintableString_set_a(int64_t this_ptr, jstring val) {
30575         LDKPrintableString this_ptr_conv;
30576         this_ptr_conv.inner = untag_ptr(this_ptr);
30577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30579         this_ptr_conv.is_owned = false;
30580         LDKStr val_conv = str_ref_to_owned_c(val);
30581         PrintableString_set_a(&this_ptr_conv, val_conv);
30582 }
30583
30584 int64_t  CS_LDK_PrintableString_new(jstring a_arg) {
30585         LDKStr a_arg_conv = str_ref_to_owned_c(a_arg);
30586         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
30587         int64_t ret_ref = 0;
30588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30590         return ret_ref;
30591 }
30592
30593 void  CS_LDK_FutureCallback_free(int64_t this_ptr) {
30594         if (!ptr_is_owned(this_ptr)) return;
30595         void* this_ptr_ptr = untag_ptr(this_ptr);
30596         CHECK_ACCESS(this_ptr_ptr);
30597         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
30598         FREE(untag_ptr(this_ptr));
30599         FutureCallback_free(this_ptr_conv);
30600 }
30601
30602 void  CS_LDK_Future_free(int64_t this_obj) {
30603         LDKFuture this_obj_conv;
30604         this_obj_conv.inner = untag_ptr(this_obj);
30605         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30607         Future_free(this_obj_conv);
30608 }
30609
30610 static inline uint64_t Future_clone_ptr(LDKFuture *NONNULL_PTR arg) {
30611         LDKFuture ret_var = Future_clone(arg);
30612         int64_t ret_ref = 0;
30613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30614         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30615         return ret_ref;
30616 }
30617 int64_t  CS_LDK_Future_clone_ptr(int64_t arg) {
30618         LDKFuture arg_conv;
30619         arg_conv.inner = untag_ptr(arg);
30620         arg_conv.is_owned = ptr_is_owned(arg);
30621         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30622         arg_conv.is_owned = false;
30623         int64_t ret_conv = Future_clone_ptr(&arg_conv);
30624         return ret_conv;
30625 }
30626
30627 int64_t  CS_LDK_Future_clone(int64_t orig) {
30628         LDKFuture orig_conv;
30629         orig_conv.inner = untag_ptr(orig);
30630         orig_conv.is_owned = ptr_is_owned(orig);
30631         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30632         orig_conv.is_owned = false;
30633         LDKFuture ret_var = Future_clone(&orig_conv);
30634         int64_t ret_ref = 0;
30635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30636         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30637         return ret_ref;
30638 }
30639
30640 void  CS_LDK_Future_register_callback_fn(int64_t this_arg, int64_t callback) {
30641         LDKFuture this_arg_conv;
30642         this_arg_conv.inner = untag_ptr(this_arg);
30643         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30645         this_arg_conv.is_owned = false;
30646         void* callback_ptr = untag_ptr(callback);
30647         CHECK_ACCESS(callback_ptr);
30648         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
30649         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
30650                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30651                 LDKFutureCallback_JCalls_cloned(&callback_conv);
30652         }
30653         Future_register_callback_fn(&this_arg_conv, callback_conv);
30654 }
30655
30656 void  CS_LDK_Future_wait(int64_t this_arg) {
30657         LDKFuture this_arg_conv;
30658         this_arg_conv.inner = untag_ptr(this_arg);
30659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30661         this_arg_conv = Future_clone(&this_arg_conv);
30662         Future_wait(this_arg_conv);
30663 }
30664
30665 jboolean  CS_LDK_Future_wait_timeout(int64_t this_arg, int64_t max_wait) {
30666         LDKFuture this_arg_conv;
30667         this_arg_conv.inner = untag_ptr(this_arg);
30668         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30670         this_arg_conv = Future_clone(&this_arg_conv);
30671         jboolean ret_conv = Future_wait_timeout(this_arg_conv, max_wait);
30672         return ret_conv;
30673 }
30674
30675 void  CS_LDK_Sleeper_free(int64_t this_obj) {
30676         LDKSleeper this_obj_conv;
30677         this_obj_conv.inner = untag_ptr(this_obj);
30678         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30680         Sleeper_free(this_obj_conv);
30681 }
30682
30683 int64_t  CS_LDK_Sleeper_from_single_future(int64_t future) {
30684         LDKFuture future_conv;
30685         future_conv.inner = untag_ptr(future);
30686         future_conv.is_owned = ptr_is_owned(future);
30687         CHECK_INNER_FIELD_ACCESS_OR_NULL(future_conv);
30688         future_conv = Future_clone(&future_conv);
30689         LDKSleeper ret_var = Sleeper_from_single_future(future_conv);
30690         int64_t ret_ref = 0;
30691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30693         return ret_ref;
30694 }
30695
30696 int64_t  CS_LDK_Sleeper_from_two_futures(int64_t fut_a, int64_t fut_b) {
30697         LDKFuture fut_a_conv;
30698         fut_a_conv.inner = untag_ptr(fut_a);
30699         fut_a_conv.is_owned = ptr_is_owned(fut_a);
30700         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_a_conv);
30701         fut_a_conv = Future_clone(&fut_a_conv);
30702         LDKFuture fut_b_conv;
30703         fut_b_conv.inner = untag_ptr(fut_b);
30704         fut_b_conv.is_owned = ptr_is_owned(fut_b);
30705         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_b_conv);
30706         fut_b_conv = Future_clone(&fut_b_conv);
30707         LDKSleeper ret_var = Sleeper_from_two_futures(fut_a_conv, fut_b_conv);
30708         int64_t ret_ref = 0;
30709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30710         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30711         return ret_ref;
30712 }
30713
30714 int64_t  CS_LDK_Sleeper_new(int64_tArray futures) {
30715         LDKCVec_FutureZ futures_constr;
30716         futures_constr.datalen = futures->arr_len;
30717         if (futures_constr.datalen > 0)
30718                 futures_constr.data = MALLOC(futures_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
30719         else
30720                 futures_constr.data = NULL;
30721         int64_t* futures_vals = futures->elems;
30722         for (size_t i = 0; i < futures_constr.datalen; i++) {
30723                 int64_t futures_conv_8 = futures_vals[i];
30724                 LDKFuture futures_conv_8_conv;
30725                 futures_conv_8_conv.inner = untag_ptr(futures_conv_8);
30726                 futures_conv_8_conv.is_owned = ptr_is_owned(futures_conv_8);
30727                 CHECK_INNER_FIELD_ACCESS_OR_NULL(futures_conv_8_conv);
30728                 futures_conv_8_conv = Future_clone(&futures_conv_8_conv);
30729                 futures_constr.data[i] = futures_conv_8_conv;
30730         }
30731         FREE(futures);
30732         LDKSleeper ret_var = Sleeper_new(futures_constr);
30733         int64_t ret_ref = 0;
30734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30736         return ret_ref;
30737 }
30738
30739 void  CS_LDK_Sleeper_wait(int64_t this_arg) {
30740         LDKSleeper this_arg_conv;
30741         this_arg_conv.inner = untag_ptr(this_arg);
30742         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30744         this_arg_conv.is_owned = false;
30745         Sleeper_wait(&this_arg_conv);
30746 }
30747
30748 jboolean  CS_LDK_Sleeper_wait_timeout(int64_t this_arg, int64_t max_wait) {
30749         LDKSleeper this_arg_conv;
30750         this_arg_conv.inner = untag_ptr(this_arg);
30751         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30753         this_arg_conv.is_owned = false;
30754         jboolean ret_conv = Sleeper_wait_timeout(&this_arg_conv, max_wait);
30755         return ret_conv;
30756 }
30757
30758 int32_t  CS_LDK_Level_clone(int64_t orig) {
30759         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
30760         int32_t ret_conv = LDKLevel_to_cs(Level_clone(orig_conv));
30761         return ret_conv;
30762 }
30763
30764 int32_t  CS_LDK_Level_gossip() {
30765         int32_t ret_conv = LDKLevel_to_cs(Level_gossip());
30766         return ret_conv;
30767 }
30768
30769 int32_t  CS_LDK_Level_trace() {
30770         int32_t ret_conv = LDKLevel_to_cs(Level_trace());
30771         return ret_conv;
30772 }
30773
30774 int32_t  CS_LDK_Level_debug() {
30775         int32_t ret_conv = LDKLevel_to_cs(Level_debug());
30776         return ret_conv;
30777 }
30778
30779 int32_t  CS_LDK_Level_info() {
30780         int32_t ret_conv = LDKLevel_to_cs(Level_info());
30781         return ret_conv;
30782 }
30783
30784 int32_t  CS_LDK_Level_warn() {
30785         int32_t ret_conv = LDKLevel_to_cs(Level_warn());
30786         return ret_conv;
30787 }
30788
30789 int32_t  CS_LDK_Level_error() {
30790         int32_t ret_conv = LDKLevel_to_cs(Level_error());
30791         return ret_conv;
30792 }
30793
30794 jboolean  CS_LDK_Level_eq(int64_t a, int64_t b) {
30795         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
30796         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
30797         jboolean ret_conv = Level_eq(a_conv, b_conv);
30798         return ret_conv;
30799 }
30800
30801 int64_t  CS_LDK_Level_hash(int64_t o) {
30802         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
30803         int64_t ret_conv = Level_hash(o_conv);
30804         return ret_conv;
30805 }
30806
30807 int32_t  CS_LDK_Level_max() {
30808         int32_t ret_conv = LDKLevel_to_cs(Level_max());
30809         return ret_conv;
30810 }
30811
30812 void  CS_LDK_Record_free(int64_t this_obj) {
30813         LDKRecord this_obj_conv;
30814         this_obj_conv.inner = untag_ptr(this_obj);
30815         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30817         Record_free(this_obj_conv);
30818 }
30819
30820 int32_t  CS_LDK_Record_get_level(int64_t this_ptr) {
30821         LDKRecord this_ptr_conv;
30822         this_ptr_conv.inner = untag_ptr(this_ptr);
30823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30825         this_ptr_conv.is_owned = false;
30826         int32_t ret_conv = LDKLevel_to_cs(Record_get_level(&this_ptr_conv));
30827         return ret_conv;
30828 }
30829
30830 void  CS_LDK_Record_set_level(int64_t this_ptr, int32_t val) {
30831         LDKRecord this_ptr_conv;
30832         this_ptr_conv.inner = untag_ptr(this_ptr);
30833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30835         this_ptr_conv.is_owned = false;
30836         LDKLevel val_conv = LDKLevel_from_cs(val);
30837         Record_set_level(&this_ptr_conv, val_conv);
30838 }
30839
30840 jstring  CS_LDK_Record_get_args(int64_t this_ptr) {
30841         LDKRecord this_ptr_conv;
30842         this_ptr_conv.inner = untag_ptr(this_ptr);
30843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30845         this_ptr_conv.is_owned = false;
30846         LDKStr ret_str = Record_get_args(&this_ptr_conv);
30847         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30848         Str_free(ret_str);
30849         return ret_conv;
30850 }
30851
30852 void  CS_LDK_Record_set_args(int64_t this_ptr, jstring val) {
30853         LDKRecord this_ptr_conv;
30854         this_ptr_conv.inner = untag_ptr(this_ptr);
30855         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30857         this_ptr_conv.is_owned = false;
30858         LDKStr val_conv = str_ref_to_owned_c(val);
30859         Record_set_args(&this_ptr_conv, val_conv);
30860 }
30861
30862 jstring  CS_LDK_Record_get_module_path(int64_t this_ptr) {
30863         LDKRecord this_ptr_conv;
30864         this_ptr_conv.inner = untag_ptr(this_ptr);
30865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30867         this_ptr_conv.is_owned = false;
30868         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
30869         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30870         Str_free(ret_str);
30871         return ret_conv;
30872 }
30873
30874 void  CS_LDK_Record_set_module_path(int64_t this_ptr, jstring val) {
30875         LDKRecord this_ptr_conv;
30876         this_ptr_conv.inner = untag_ptr(this_ptr);
30877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30879         this_ptr_conv.is_owned = false;
30880         LDKStr val_conv = str_ref_to_owned_c(val);
30881         Record_set_module_path(&this_ptr_conv, val_conv);
30882 }
30883
30884 jstring  CS_LDK_Record_get_file(int64_t this_ptr) {
30885         LDKRecord this_ptr_conv;
30886         this_ptr_conv.inner = untag_ptr(this_ptr);
30887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30889         this_ptr_conv.is_owned = false;
30890         LDKStr ret_str = Record_get_file(&this_ptr_conv);
30891         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30892         Str_free(ret_str);
30893         return ret_conv;
30894 }
30895
30896 void  CS_LDK_Record_set_file(int64_t this_ptr, jstring val) {
30897         LDKRecord this_ptr_conv;
30898         this_ptr_conv.inner = untag_ptr(this_ptr);
30899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30901         this_ptr_conv.is_owned = false;
30902         LDKStr val_conv = str_ref_to_owned_c(val);
30903         Record_set_file(&this_ptr_conv, val_conv);
30904 }
30905
30906 int32_t  CS_LDK_Record_get_line(int64_t this_ptr) {
30907         LDKRecord this_ptr_conv;
30908         this_ptr_conv.inner = untag_ptr(this_ptr);
30909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30911         this_ptr_conv.is_owned = false;
30912         int32_t ret_conv = Record_get_line(&this_ptr_conv);
30913         return ret_conv;
30914 }
30915
30916 void  CS_LDK_Record_set_line(int64_t this_ptr, int32_t val) {
30917         LDKRecord this_ptr_conv;
30918         this_ptr_conv.inner = untag_ptr(this_ptr);
30919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30921         this_ptr_conv.is_owned = false;
30922         Record_set_line(&this_ptr_conv, val);
30923 }
30924
30925 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
30926         LDKRecord ret_var = Record_clone(arg);
30927         int64_t ret_ref = 0;
30928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30930         return ret_ref;
30931 }
30932 int64_t  CS_LDK_Record_clone_ptr(int64_t arg) {
30933         LDKRecord arg_conv;
30934         arg_conv.inner = untag_ptr(arg);
30935         arg_conv.is_owned = ptr_is_owned(arg);
30936         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30937         arg_conv.is_owned = false;
30938         int64_t ret_conv = Record_clone_ptr(&arg_conv);
30939         return ret_conv;
30940 }
30941
30942 int64_t  CS_LDK_Record_clone(int64_t orig) {
30943         LDKRecord orig_conv;
30944         orig_conv.inner = untag_ptr(orig);
30945         orig_conv.is_owned = ptr_is_owned(orig);
30946         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30947         orig_conv.is_owned = false;
30948         LDKRecord ret_var = Record_clone(&orig_conv);
30949         int64_t ret_ref = 0;
30950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30952         return ret_ref;
30953 }
30954
30955 void  CS_LDK_Logger_free(int64_t this_ptr) {
30956         if (!ptr_is_owned(this_ptr)) return;
30957         void* this_ptr_ptr = untag_ptr(this_ptr);
30958         CHECK_ACCESS(this_ptr_ptr);
30959         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
30960         FREE(untag_ptr(this_ptr));
30961         Logger_free(this_ptr_conv);
30962 }
30963
30964 void  CS_LDK_ChannelHandshakeConfig_free(int64_t this_obj) {
30965         LDKChannelHandshakeConfig this_obj_conv;
30966         this_obj_conv.inner = untag_ptr(this_obj);
30967         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30969         ChannelHandshakeConfig_free(this_obj_conv);
30970 }
30971
30972 int32_t  CS_LDK_ChannelHandshakeConfig_get_minimum_depth(int64_t this_ptr) {
30973         LDKChannelHandshakeConfig this_ptr_conv;
30974         this_ptr_conv.inner = untag_ptr(this_ptr);
30975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30977         this_ptr_conv.is_owned = false;
30978         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
30979         return ret_conv;
30980 }
30981
30982 void  CS_LDK_ChannelHandshakeConfig_set_minimum_depth(int64_t this_ptr, int32_t val) {
30983         LDKChannelHandshakeConfig this_ptr_conv;
30984         this_ptr_conv.inner = untag_ptr(this_ptr);
30985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30987         this_ptr_conv.is_owned = false;
30988         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
30989 }
30990
30991 int16_t  CS_LDK_ChannelHandshakeConfig_get_our_to_self_delay(int64_t this_ptr) {
30992         LDKChannelHandshakeConfig this_ptr_conv;
30993         this_ptr_conv.inner = untag_ptr(this_ptr);
30994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30996         this_ptr_conv.is_owned = false;
30997         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
30998         return ret_conv;
30999 }
31000
31001 void  CS_LDK_ChannelHandshakeConfig_set_our_to_self_delay(int64_t this_ptr, int16_t val) {
31002         LDKChannelHandshakeConfig this_ptr_conv;
31003         this_ptr_conv.inner = untag_ptr(this_ptr);
31004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31006         this_ptr_conv.is_owned = false;
31007         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
31008 }
31009
31010 int64_t  CS_LDK_ChannelHandshakeConfig_get_our_htlc_minimum_msat(int64_t this_ptr) {
31011         LDKChannelHandshakeConfig this_ptr_conv;
31012         this_ptr_conv.inner = untag_ptr(this_ptr);
31013         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31015         this_ptr_conv.is_owned = false;
31016         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
31017         return ret_conv;
31018 }
31019
31020 void  CS_LDK_ChannelHandshakeConfig_set_our_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
31021         LDKChannelHandshakeConfig this_ptr_conv;
31022         this_ptr_conv.inner = untag_ptr(this_ptr);
31023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31025         this_ptr_conv.is_owned = false;
31026         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
31027 }
31028
31029 int8_t  CS_LDK_ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(int64_t this_ptr) {
31030         LDKChannelHandshakeConfig this_ptr_conv;
31031         this_ptr_conv.inner = untag_ptr(this_ptr);
31032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31034         this_ptr_conv.is_owned = false;
31035         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
31036         return ret_conv;
31037 }
31038
31039 void  CS_LDK_ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(int64_t this_ptr, int8_t val) {
31040         LDKChannelHandshakeConfig this_ptr_conv;
31041         this_ptr_conv.inner = untag_ptr(this_ptr);
31042         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31044         this_ptr_conv.is_owned = false;
31045         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
31046 }
31047
31048 jboolean  CS_LDK_ChannelHandshakeConfig_get_negotiate_scid_privacy(int64_t this_ptr) {
31049         LDKChannelHandshakeConfig this_ptr_conv;
31050         this_ptr_conv.inner = untag_ptr(this_ptr);
31051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31053         this_ptr_conv.is_owned = false;
31054         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
31055         return ret_conv;
31056 }
31057
31058 void  CS_LDK_ChannelHandshakeConfig_set_negotiate_scid_privacy(int64_t this_ptr, jboolean val) {
31059         LDKChannelHandshakeConfig this_ptr_conv;
31060         this_ptr_conv.inner = untag_ptr(this_ptr);
31061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31063         this_ptr_conv.is_owned = false;
31064         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
31065 }
31066
31067 jboolean  CS_LDK_ChannelHandshakeConfig_get_announced_channel(int64_t this_ptr) {
31068         LDKChannelHandshakeConfig this_ptr_conv;
31069         this_ptr_conv.inner = untag_ptr(this_ptr);
31070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31072         this_ptr_conv.is_owned = false;
31073         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
31074         return ret_conv;
31075 }
31076
31077 void  CS_LDK_ChannelHandshakeConfig_set_announced_channel(int64_t this_ptr, jboolean val) {
31078         LDKChannelHandshakeConfig this_ptr_conv;
31079         this_ptr_conv.inner = untag_ptr(this_ptr);
31080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31082         this_ptr_conv.is_owned = false;
31083         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
31084 }
31085
31086 jboolean  CS_LDK_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(int64_t this_ptr) {
31087         LDKChannelHandshakeConfig this_ptr_conv;
31088         this_ptr_conv.inner = untag_ptr(this_ptr);
31089         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31091         this_ptr_conv.is_owned = false;
31092         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
31093         return ret_conv;
31094 }
31095
31096 void  CS_LDK_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(int64_t this_ptr, jboolean val) {
31097         LDKChannelHandshakeConfig this_ptr_conv;
31098         this_ptr_conv.inner = untag_ptr(this_ptr);
31099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31101         this_ptr_conv.is_owned = false;
31102         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
31103 }
31104
31105 int32_t  CS_LDK_ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(int64_t this_ptr) {
31106         LDKChannelHandshakeConfig this_ptr_conv;
31107         this_ptr_conv.inner = untag_ptr(this_ptr);
31108         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31110         this_ptr_conv.is_owned = false;
31111         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
31112         return ret_conv;
31113 }
31114
31115 void  CS_LDK_ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(int64_t this_ptr, int32_t val) {
31116         LDKChannelHandshakeConfig this_ptr_conv;
31117         this_ptr_conv.inner = untag_ptr(this_ptr);
31118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31120         this_ptr_conv.is_owned = false;
31121         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
31122 }
31123
31124 jboolean  CS_LDK_ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(int64_t this_ptr) {
31125         LDKChannelHandshakeConfig this_ptr_conv;
31126         this_ptr_conv.inner = untag_ptr(this_ptr);
31127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31129         this_ptr_conv.is_owned = false;
31130         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(&this_ptr_conv);
31131         return ret_conv;
31132 }
31133
31134 void  CS_LDK_ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(int64_t this_ptr, jboolean val) {
31135         LDKChannelHandshakeConfig this_ptr_conv;
31136         this_ptr_conv.inner = untag_ptr(this_ptr);
31137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31139         this_ptr_conv.is_owned = false;
31140         ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(&this_ptr_conv, val);
31141 }
31142
31143 int16_t  CS_LDK_ChannelHandshakeConfig_get_our_max_accepted_htlcs(int64_t this_ptr) {
31144         LDKChannelHandshakeConfig this_ptr_conv;
31145         this_ptr_conv.inner = untag_ptr(this_ptr);
31146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31148         this_ptr_conv.is_owned = false;
31149         int16_t ret_conv = ChannelHandshakeConfig_get_our_max_accepted_htlcs(&this_ptr_conv);
31150         return ret_conv;
31151 }
31152
31153 void  CS_LDK_ChannelHandshakeConfig_set_our_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
31154         LDKChannelHandshakeConfig this_ptr_conv;
31155         this_ptr_conv.inner = untag_ptr(this_ptr);
31156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31158         this_ptr_conv.is_owned = false;
31159         ChannelHandshakeConfig_set_our_max_accepted_htlcs(&this_ptr_conv, val);
31160 }
31161
31162 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) {
31163         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);
31164         int64_t ret_ref = 0;
31165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31166         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31167         return ret_ref;
31168 }
31169
31170 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
31171         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
31172         int64_t ret_ref = 0;
31173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31175         return ret_ref;
31176 }
31177 int64_t  CS_LDK_ChannelHandshakeConfig_clone_ptr(int64_t arg) {
31178         LDKChannelHandshakeConfig arg_conv;
31179         arg_conv.inner = untag_ptr(arg);
31180         arg_conv.is_owned = ptr_is_owned(arg);
31181         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31182         arg_conv.is_owned = false;
31183         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
31184         return ret_conv;
31185 }
31186
31187 int64_t  CS_LDK_ChannelHandshakeConfig_clone(int64_t orig) {
31188         LDKChannelHandshakeConfig orig_conv;
31189         orig_conv.inner = untag_ptr(orig);
31190         orig_conv.is_owned = ptr_is_owned(orig);
31191         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31192         orig_conv.is_owned = false;
31193         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
31194         int64_t ret_ref = 0;
31195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31197         return ret_ref;
31198 }
31199
31200 int64_t  CS_LDK_ChannelHandshakeConfig_default() {
31201         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
31202         int64_t ret_ref = 0;
31203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31204         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31205         return ret_ref;
31206 }
31207
31208 void  CS_LDK_ChannelHandshakeLimits_free(int64_t this_obj) {
31209         LDKChannelHandshakeLimits this_obj_conv;
31210         this_obj_conv.inner = untag_ptr(this_obj);
31211         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31213         ChannelHandshakeLimits_free(this_obj_conv);
31214 }
31215
31216 int64_t  CS_LDK_ChannelHandshakeLimits_get_min_funding_satoshis(int64_t this_ptr) {
31217         LDKChannelHandshakeLimits this_ptr_conv;
31218         this_ptr_conv.inner = untag_ptr(this_ptr);
31219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31221         this_ptr_conv.is_owned = false;
31222         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
31223         return ret_conv;
31224 }
31225
31226 void  CS_LDK_ChannelHandshakeLimits_set_min_funding_satoshis(int64_t this_ptr, int64_t val) {
31227         LDKChannelHandshakeLimits this_ptr_conv;
31228         this_ptr_conv.inner = untag_ptr(this_ptr);
31229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31231         this_ptr_conv.is_owned = false;
31232         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
31233 }
31234
31235 int64_t  CS_LDK_ChannelHandshakeLimits_get_max_funding_satoshis(int64_t this_ptr) {
31236         LDKChannelHandshakeLimits this_ptr_conv;
31237         this_ptr_conv.inner = untag_ptr(this_ptr);
31238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31240         this_ptr_conv.is_owned = false;
31241         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
31242         return ret_conv;
31243 }
31244
31245 void  CS_LDK_ChannelHandshakeLimits_set_max_funding_satoshis(int64_t this_ptr, int64_t val) {
31246         LDKChannelHandshakeLimits this_ptr_conv;
31247         this_ptr_conv.inner = untag_ptr(this_ptr);
31248         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31250         this_ptr_conv.is_owned = false;
31251         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
31252 }
31253
31254 int64_t  CS_LDK_ChannelHandshakeLimits_get_max_htlc_minimum_msat(int64_t this_ptr) {
31255         LDKChannelHandshakeLimits this_ptr_conv;
31256         this_ptr_conv.inner = untag_ptr(this_ptr);
31257         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31259         this_ptr_conv.is_owned = false;
31260         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
31261         return ret_conv;
31262 }
31263
31264 void  CS_LDK_ChannelHandshakeLimits_set_max_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
31265         LDKChannelHandshakeLimits this_ptr_conv;
31266         this_ptr_conv.inner = untag_ptr(this_ptr);
31267         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31269         this_ptr_conv.is_owned = false;
31270         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
31271 }
31272
31273 int64_t  CS_LDK_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(int64_t this_ptr) {
31274         LDKChannelHandshakeLimits this_ptr_conv;
31275         this_ptr_conv.inner = untag_ptr(this_ptr);
31276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31278         this_ptr_conv.is_owned = false;
31279         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
31280         return ret_conv;
31281 }
31282
31283 void  CS_LDK_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
31284         LDKChannelHandshakeLimits this_ptr_conv;
31285         this_ptr_conv.inner = untag_ptr(this_ptr);
31286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31288         this_ptr_conv.is_owned = false;
31289         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
31290 }
31291
31292 int64_t  CS_LDK_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(int64_t this_ptr) {
31293         LDKChannelHandshakeLimits this_ptr_conv;
31294         this_ptr_conv.inner = untag_ptr(this_ptr);
31295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31297         this_ptr_conv.is_owned = false;
31298         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
31299         return ret_conv;
31300 }
31301
31302 void  CS_LDK_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(int64_t this_ptr, int64_t val) {
31303         LDKChannelHandshakeLimits this_ptr_conv;
31304         this_ptr_conv.inner = untag_ptr(this_ptr);
31305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31307         this_ptr_conv.is_owned = false;
31308         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
31309 }
31310
31311 int16_t  CS_LDK_ChannelHandshakeLimits_get_min_max_accepted_htlcs(int64_t this_ptr) {
31312         LDKChannelHandshakeLimits this_ptr_conv;
31313         this_ptr_conv.inner = untag_ptr(this_ptr);
31314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31316         this_ptr_conv.is_owned = false;
31317         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
31318         return ret_conv;
31319 }
31320
31321 void  CS_LDK_ChannelHandshakeLimits_set_min_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
31322         LDKChannelHandshakeLimits this_ptr_conv;
31323         this_ptr_conv.inner = untag_ptr(this_ptr);
31324         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31326         this_ptr_conv.is_owned = false;
31327         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
31328 }
31329
31330 int32_t  CS_LDK_ChannelHandshakeLimits_get_max_minimum_depth(int64_t this_ptr) {
31331         LDKChannelHandshakeLimits this_ptr_conv;
31332         this_ptr_conv.inner = untag_ptr(this_ptr);
31333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31335         this_ptr_conv.is_owned = false;
31336         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
31337         return ret_conv;
31338 }
31339
31340 void  CS_LDK_ChannelHandshakeLimits_set_max_minimum_depth(int64_t this_ptr, int32_t val) {
31341         LDKChannelHandshakeLimits this_ptr_conv;
31342         this_ptr_conv.inner = untag_ptr(this_ptr);
31343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31345         this_ptr_conv.is_owned = false;
31346         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
31347 }
31348
31349 jboolean  CS_LDK_ChannelHandshakeLimits_get_trust_own_funding_0conf(int64_t this_ptr) {
31350         LDKChannelHandshakeLimits this_ptr_conv;
31351         this_ptr_conv.inner = untag_ptr(this_ptr);
31352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31354         this_ptr_conv.is_owned = false;
31355         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
31356         return ret_conv;
31357 }
31358
31359 void  CS_LDK_ChannelHandshakeLimits_set_trust_own_funding_0conf(int64_t this_ptr, jboolean val) {
31360         LDKChannelHandshakeLimits this_ptr_conv;
31361         this_ptr_conv.inner = untag_ptr(this_ptr);
31362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31364         this_ptr_conv.is_owned = false;
31365         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
31366 }
31367
31368 jboolean  CS_LDK_ChannelHandshakeLimits_get_force_announced_channel_preference(int64_t this_ptr) {
31369         LDKChannelHandshakeLimits this_ptr_conv;
31370         this_ptr_conv.inner = untag_ptr(this_ptr);
31371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31373         this_ptr_conv.is_owned = false;
31374         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
31375         return ret_conv;
31376 }
31377
31378 void  CS_LDK_ChannelHandshakeLimits_set_force_announced_channel_preference(int64_t this_ptr, jboolean val) {
31379         LDKChannelHandshakeLimits this_ptr_conv;
31380         this_ptr_conv.inner = untag_ptr(this_ptr);
31381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31383         this_ptr_conv.is_owned = false;
31384         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
31385 }
31386
31387 int16_t  CS_LDK_ChannelHandshakeLimits_get_their_to_self_delay(int64_t this_ptr) {
31388         LDKChannelHandshakeLimits this_ptr_conv;
31389         this_ptr_conv.inner = untag_ptr(this_ptr);
31390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31392         this_ptr_conv.is_owned = false;
31393         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
31394         return ret_conv;
31395 }
31396
31397 void  CS_LDK_ChannelHandshakeLimits_set_their_to_self_delay(int64_t this_ptr, int16_t val) {
31398         LDKChannelHandshakeLimits this_ptr_conv;
31399         this_ptr_conv.inner = untag_ptr(this_ptr);
31400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31402         this_ptr_conv.is_owned = false;
31403         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
31404 }
31405
31406 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) {
31407         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);
31408         int64_t ret_ref = 0;
31409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31410         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31411         return ret_ref;
31412 }
31413
31414 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
31415         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
31416         int64_t ret_ref = 0;
31417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31418         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31419         return ret_ref;
31420 }
31421 int64_t  CS_LDK_ChannelHandshakeLimits_clone_ptr(int64_t arg) {
31422         LDKChannelHandshakeLimits arg_conv;
31423         arg_conv.inner = untag_ptr(arg);
31424         arg_conv.is_owned = ptr_is_owned(arg);
31425         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31426         arg_conv.is_owned = false;
31427         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
31428         return ret_conv;
31429 }
31430
31431 int64_t  CS_LDK_ChannelHandshakeLimits_clone(int64_t orig) {
31432         LDKChannelHandshakeLimits orig_conv;
31433         orig_conv.inner = untag_ptr(orig);
31434         orig_conv.is_owned = ptr_is_owned(orig);
31435         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31436         orig_conv.is_owned = false;
31437         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
31438         int64_t ret_ref = 0;
31439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31440         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31441         return ret_ref;
31442 }
31443
31444 int64_t  CS_LDK_ChannelHandshakeLimits_default() {
31445         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
31446         int64_t ret_ref = 0;
31447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31449         return ret_ref;
31450 }
31451
31452 void  CS_LDK_MaxDustHTLCExposure_free(int64_t this_ptr) {
31453         if (!ptr_is_owned(this_ptr)) return;
31454         void* this_ptr_ptr = untag_ptr(this_ptr);
31455         CHECK_ACCESS(this_ptr_ptr);
31456         LDKMaxDustHTLCExposure this_ptr_conv = *(LDKMaxDustHTLCExposure*)(this_ptr_ptr);
31457         FREE(untag_ptr(this_ptr));
31458         MaxDustHTLCExposure_free(this_ptr_conv);
31459 }
31460
31461 static inline uint64_t MaxDustHTLCExposure_clone_ptr(LDKMaxDustHTLCExposure *NONNULL_PTR arg) {
31462         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31463         *ret_copy = MaxDustHTLCExposure_clone(arg);
31464         int64_t ret_ref = tag_ptr(ret_copy, true);
31465         return ret_ref;
31466 }
31467 int64_t  CS_LDK_MaxDustHTLCExposure_clone_ptr(int64_t arg) {
31468         LDKMaxDustHTLCExposure* arg_conv = (LDKMaxDustHTLCExposure*)untag_ptr(arg);
31469         int64_t ret_conv = MaxDustHTLCExposure_clone_ptr(arg_conv);
31470         return ret_conv;
31471 }
31472
31473 int64_t  CS_LDK_MaxDustHTLCExposure_clone(int64_t orig) {
31474         LDKMaxDustHTLCExposure* orig_conv = (LDKMaxDustHTLCExposure*)untag_ptr(orig);
31475         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31476         *ret_copy = MaxDustHTLCExposure_clone(orig_conv);
31477         int64_t ret_ref = tag_ptr(ret_copy, true);
31478         return ret_ref;
31479 }
31480
31481 int64_t  CS_LDK_MaxDustHTLCExposure_fixed_limit_msat(int64_t a) {
31482         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31483         *ret_copy = MaxDustHTLCExposure_fixed_limit_msat(a);
31484         int64_t ret_ref = tag_ptr(ret_copy, true);
31485         return ret_ref;
31486 }
31487
31488 int64_t  CS_LDK_MaxDustHTLCExposure_fee_rate_multiplier(int64_t a) {
31489         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31490         *ret_copy = MaxDustHTLCExposure_fee_rate_multiplier(a);
31491         int64_t ret_ref = tag_ptr(ret_copy, true);
31492         return ret_ref;
31493 }
31494
31495 jboolean  CS_LDK_MaxDustHTLCExposure_eq(int64_t a, int64_t b) {
31496         LDKMaxDustHTLCExposure* a_conv = (LDKMaxDustHTLCExposure*)untag_ptr(a);
31497         LDKMaxDustHTLCExposure* b_conv = (LDKMaxDustHTLCExposure*)untag_ptr(b);
31498         jboolean ret_conv = MaxDustHTLCExposure_eq(a_conv, b_conv);
31499         return ret_conv;
31500 }
31501
31502 int8_tArray  CS_LDK_MaxDustHTLCExposure_write(int64_t obj) {
31503         LDKMaxDustHTLCExposure* obj_conv = (LDKMaxDustHTLCExposure*)untag_ptr(obj);
31504         LDKCVec_u8Z ret_var = MaxDustHTLCExposure_write(obj_conv);
31505         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31506         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31507         CVec_u8Z_free(ret_var);
31508         return ret_arr;
31509 }
31510
31511 int64_t  CS_LDK_MaxDustHTLCExposure_read(int8_tArray ser) {
31512         LDKu8slice ser_ref;
31513         ser_ref.datalen = ser->arr_len;
31514         ser_ref.data = ser->elems;
31515         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
31516         *ret_conv = MaxDustHTLCExposure_read(ser_ref);
31517         FREE(ser);
31518         return tag_ptr(ret_conv, true);
31519 }
31520
31521 void  CS_LDK_ChannelConfig_free(int64_t this_obj) {
31522         LDKChannelConfig this_obj_conv;
31523         this_obj_conv.inner = untag_ptr(this_obj);
31524         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31526         ChannelConfig_free(this_obj_conv);
31527 }
31528
31529 int32_t  CS_LDK_ChannelConfig_get_forwarding_fee_proportional_millionths(int64_t this_ptr) {
31530         LDKChannelConfig this_ptr_conv;
31531         this_ptr_conv.inner = untag_ptr(this_ptr);
31532         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31534         this_ptr_conv.is_owned = false;
31535         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
31536         return ret_conv;
31537 }
31538
31539 void  CS_LDK_ChannelConfig_set_forwarding_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
31540         LDKChannelConfig this_ptr_conv;
31541         this_ptr_conv.inner = untag_ptr(this_ptr);
31542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31544         this_ptr_conv.is_owned = false;
31545         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
31546 }
31547
31548 int32_t  CS_LDK_ChannelConfig_get_forwarding_fee_base_msat(int64_t this_ptr) {
31549         LDKChannelConfig this_ptr_conv;
31550         this_ptr_conv.inner = untag_ptr(this_ptr);
31551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31553         this_ptr_conv.is_owned = false;
31554         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
31555         return ret_conv;
31556 }
31557
31558 void  CS_LDK_ChannelConfig_set_forwarding_fee_base_msat(int64_t this_ptr, int32_t val) {
31559         LDKChannelConfig this_ptr_conv;
31560         this_ptr_conv.inner = untag_ptr(this_ptr);
31561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31563         this_ptr_conv.is_owned = false;
31564         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
31565 }
31566
31567 int16_t  CS_LDK_ChannelConfig_get_cltv_expiry_delta(int64_t this_ptr) {
31568         LDKChannelConfig this_ptr_conv;
31569         this_ptr_conv.inner = untag_ptr(this_ptr);
31570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31572         this_ptr_conv.is_owned = false;
31573         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
31574         return ret_conv;
31575 }
31576
31577 void  CS_LDK_ChannelConfig_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
31578         LDKChannelConfig this_ptr_conv;
31579         this_ptr_conv.inner = untag_ptr(this_ptr);
31580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31582         this_ptr_conv.is_owned = false;
31583         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
31584 }
31585
31586 int64_t  CS_LDK_ChannelConfig_get_max_dust_htlc_exposure(int64_t this_ptr) {
31587         LDKChannelConfig this_ptr_conv;
31588         this_ptr_conv.inner = untag_ptr(this_ptr);
31589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31591         this_ptr_conv.is_owned = false;
31592         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31593         *ret_copy = ChannelConfig_get_max_dust_htlc_exposure(&this_ptr_conv);
31594         int64_t ret_ref = tag_ptr(ret_copy, true);
31595         return ret_ref;
31596 }
31597
31598 void  CS_LDK_ChannelConfig_set_max_dust_htlc_exposure(int64_t this_ptr, int64_t val) {
31599         LDKChannelConfig this_ptr_conv;
31600         this_ptr_conv.inner = untag_ptr(this_ptr);
31601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31603         this_ptr_conv.is_owned = false;
31604         void* val_ptr = untag_ptr(val);
31605         CHECK_ACCESS(val_ptr);
31606         LDKMaxDustHTLCExposure val_conv = *(LDKMaxDustHTLCExposure*)(val_ptr);
31607         val_conv = MaxDustHTLCExposure_clone((LDKMaxDustHTLCExposure*)untag_ptr(val));
31608         ChannelConfig_set_max_dust_htlc_exposure(&this_ptr_conv, val_conv);
31609 }
31610
31611 int64_t  CS_LDK_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(int64_t this_ptr) {
31612         LDKChannelConfig this_ptr_conv;
31613         this_ptr_conv.inner = untag_ptr(this_ptr);
31614         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31616         this_ptr_conv.is_owned = false;
31617         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
31618         return ret_conv;
31619 }
31620
31621 void  CS_LDK_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(int64_t this_ptr, int64_t val) {
31622         LDKChannelConfig this_ptr_conv;
31623         this_ptr_conv.inner = untag_ptr(this_ptr);
31624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31626         this_ptr_conv.is_owned = false;
31627         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
31628 }
31629
31630 jboolean  CS_LDK_ChannelConfig_get_accept_underpaying_htlcs(int64_t this_ptr) {
31631         LDKChannelConfig this_ptr_conv;
31632         this_ptr_conv.inner = untag_ptr(this_ptr);
31633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31635         this_ptr_conv.is_owned = false;
31636         jboolean ret_conv = ChannelConfig_get_accept_underpaying_htlcs(&this_ptr_conv);
31637         return ret_conv;
31638 }
31639
31640 void  CS_LDK_ChannelConfig_set_accept_underpaying_htlcs(int64_t this_ptr, jboolean val) {
31641         LDKChannelConfig this_ptr_conv;
31642         this_ptr_conv.inner = untag_ptr(this_ptr);
31643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31645         this_ptr_conv.is_owned = false;
31646         ChannelConfig_set_accept_underpaying_htlcs(&this_ptr_conv, val);
31647 }
31648
31649 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) {
31650         void* max_dust_htlc_exposure_arg_ptr = untag_ptr(max_dust_htlc_exposure_arg);
31651         CHECK_ACCESS(max_dust_htlc_exposure_arg_ptr);
31652         LDKMaxDustHTLCExposure max_dust_htlc_exposure_arg_conv = *(LDKMaxDustHTLCExposure*)(max_dust_htlc_exposure_arg_ptr);
31653         max_dust_htlc_exposure_arg_conv = MaxDustHTLCExposure_clone((LDKMaxDustHTLCExposure*)untag_ptr(max_dust_htlc_exposure_arg));
31654         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);
31655         int64_t ret_ref = 0;
31656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31657         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31658         return ret_ref;
31659 }
31660
31661 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
31662         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
31663         int64_t ret_ref = 0;
31664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31666         return ret_ref;
31667 }
31668 int64_t  CS_LDK_ChannelConfig_clone_ptr(int64_t arg) {
31669         LDKChannelConfig arg_conv;
31670         arg_conv.inner = untag_ptr(arg);
31671         arg_conv.is_owned = ptr_is_owned(arg);
31672         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31673         arg_conv.is_owned = false;
31674         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
31675         return ret_conv;
31676 }
31677
31678 int64_t  CS_LDK_ChannelConfig_clone(int64_t orig) {
31679         LDKChannelConfig orig_conv;
31680         orig_conv.inner = untag_ptr(orig);
31681         orig_conv.is_owned = ptr_is_owned(orig);
31682         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31683         orig_conv.is_owned = false;
31684         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
31685         int64_t ret_ref = 0;
31686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31688         return ret_ref;
31689 }
31690
31691 jboolean  CS_LDK_ChannelConfig_eq(int64_t a, int64_t b) {
31692         LDKChannelConfig a_conv;
31693         a_conv.inner = untag_ptr(a);
31694         a_conv.is_owned = ptr_is_owned(a);
31695         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
31696         a_conv.is_owned = false;
31697         LDKChannelConfig b_conv;
31698         b_conv.inner = untag_ptr(b);
31699         b_conv.is_owned = ptr_is_owned(b);
31700         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
31701         b_conv.is_owned = false;
31702         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
31703         return ret_conv;
31704 }
31705
31706 void  CS_LDK_ChannelConfig_apply(int64_t this_arg, int64_t update) {
31707         LDKChannelConfig this_arg_conv;
31708         this_arg_conv.inner = untag_ptr(this_arg);
31709         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31711         this_arg_conv.is_owned = false;
31712         LDKChannelConfigUpdate update_conv;
31713         update_conv.inner = untag_ptr(update);
31714         update_conv.is_owned = ptr_is_owned(update);
31715         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
31716         update_conv.is_owned = false;
31717         ChannelConfig_apply(&this_arg_conv, &update_conv);
31718 }
31719
31720 int64_t  CS_LDK_ChannelConfig_default() {
31721         LDKChannelConfig ret_var = ChannelConfig_default();
31722         int64_t ret_ref = 0;
31723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31725         return ret_ref;
31726 }
31727
31728 int8_tArray  CS_LDK_ChannelConfig_write(int64_t obj) {
31729         LDKChannelConfig obj_conv;
31730         obj_conv.inner = untag_ptr(obj);
31731         obj_conv.is_owned = ptr_is_owned(obj);
31732         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31733         obj_conv.is_owned = false;
31734         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
31735         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31736         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31737         CVec_u8Z_free(ret_var);
31738         return ret_arr;
31739 }
31740
31741 int64_t  CS_LDK_ChannelConfig_read(int8_tArray ser) {
31742         LDKu8slice ser_ref;
31743         ser_ref.datalen = ser->arr_len;
31744         ser_ref.data = ser->elems;
31745         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
31746         *ret_conv = ChannelConfig_read(ser_ref);
31747         FREE(ser);
31748         return tag_ptr(ret_conv, true);
31749 }
31750
31751 void  CS_LDK_ChannelConfigUpdate_free(int64_t this_obj) {
31752         LDKChannelConfigUpdate this_obj_conv;
31753         this_obj_conv.inner = untag_ptr(this_obj);
31754         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31756         ChannelConfigUpdate_free(this_obj_conv);
31757 }
31758
31759 int64_t  CS_LDK_ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(int64_t this_ptr) {
31760         LDKChannelConfigUpdate this_ptr_conv;
31761         this_ptr_conv.inner = untag_ptr(this_ptr);
31762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31764         this_ptr_conv.is_owned = false;
31765         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
31766         *ret_copy = ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
31767         int64_t ret_ref = tag_ptr(ret_copy, true);
31768         return ret_ref;
31769 }
31770
31771 void  CS_LDK_ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(int64_t this_ptr, int64_t val) {
31772         LDKChannelConfigUpdate this_ptr_conv;
31773         this_ptr_conv.inner = untag_ptr(this_ptr);
31774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31776         this_ptr_conv.is_owned = false;
31777         void* val_ptr = untag_ptr(val);
31778         CHECK_ACCESS(val_ptr);
31779         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
31780         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
31781         ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val_conv);
31782 }
31783
31784 int64_t  CS_LDK_ChannelConfigUpdate_get_forwarding_fee_base_msat(int64_t this_ptr) {
31785         LDKChannelConfigUpdate this_ptr_conv;
31786         this_ptr_conv.inner = untag_ptr(this_ptr);
31787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31789         this_ptr_conv.is_owned = false;
31790         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
31791         *ret_copy = ChannelConfigUpdate_get_forwarding_fee_base_msat(&this_ptr_conv);
31792         int64_t ret_ref = tag_ptr(ret_copy, true);
31793         return ret_ref;
31794 }
31795
31796 void  CS_LDK_ChannelConfigUpdate_set_forwarding_fee_base_msat(int64_t this_ptr, int64_t val) {
31797         LDKChannelConfigUpdate this_ptr_conv;
31798         this_ptr_conv.inner = untag_ptr(this_ptr);
31799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31801         this_ptr_conv.is_owned = false;
31802         void* val_ptr = untag_ptr(val);
31803         CHECK_ACCESS(val_ptr);
31804         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
31805         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
31806         ChannelConfigUpdate_set_forwarding_fee_base_msat(&this_ptr_conv, val_conv);
31807 }
31808
31809 int64_t  CS_LDK_ChannelConfigUpdate_get_cltv_expiry_delta(int64_t this_ptr) {
31810         LDKChannelConfigUpdate this_ptr_conv;
31811         this_ptr_conv.inner = untag_ptr(this_ptr);
31812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31814         this_ptr_conv.is_owned = false;
31815         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
31816         *ret_copy = ChannelConfigUpdate_get_cltv_expiry_delta(&this_ptr_conv);
31817         int64_t ret_ref = tag_ptr(ret_copy, true);
31818         return ret_ref;
31819 }
31820
31821 void  CS_LDK_ChannelConfigUpdate_set_cltv_expiry_delta(int64_t this_ptr, int64_t val) {
31822         LDKChannelConfigUpdate this_ptr_conv;
31823         this_ptr_conv.inner = untag_ptr(this_ptr);
31824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31826         this_ptr_conv.is_owned = false;
31827         void* val_ptr = untag_ptr(val);
31828         CHECK_ACCESS(val_ptr);
31829         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
31830         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
31831         ChannelConfigUpdate_set_cltv_expiry_delta(&this_ptr_conv, val_conv);
31832 }
31833
31834 int64_t  CS_LDK_ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(int64_t this_ptr) {
31835         LDKChannelConfigUpdate this_ptr_conv;
31836         this_ptr_conv.inner = untag_ptr(this_ptr);
31837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31839         this_ptr_conv.is_owned = false;
31840         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
31841         *ret_copy = ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
31842         int64_t ret_ref = tag_ptr(ret_copy, true);
31843         return ret_ref;
31844 }
31845
31846 void  CS_LDK_ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(int64_t this_ptr, int64_t val) {
31847         LDKChannelConfigUpdate this_ptr_conv;
31848         this_ptr_conv.inner = untag_ptr(this_ptr);
31849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31851         this_ptr_conv.is_owned = false;
31852         void* val_ptr = untag_ptr(val);
31853         CHECK_ACCESS(val_ptr);
31854         LDKCOption_MaxDustHTLCExposureZ val_conv = *(LDKCOption_MaxDustHTLCExposureZ*)(val_ptr);
31855         val_conv = COption_MaxDustHTLCExposureZ_clone((LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(val));
31856         ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val_conv);
31857 }
31858
31859 int64_t  CS_LDK_ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(int64_t this_ptr) {
31860         LDKChannelConfigUpdate this_ptr_conv;
31861         this_ptr_conv.inner = untag_ptr(this_ptr);
31862         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31864         this_ptr_conv.is_owned = false;
31865         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31866         *ret_copy = ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
31867         int64_t ret_ref = tag_ptr(ret_copy, true);
31868         return ret_ref;
31869 }
31870
31871 void  CS_LDK_ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(int64_t this_ptr, int64_t val) {
31872         LDKChannelConfigUpdate this_ptr_conv;
31873         this_ptr_conv.inner = untag_ptr(this_ptr);
31874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31876         this_ptr_conv.is_owned = false;
31877         void* val_ptr = untag_ptr(val);
31878         CHECK_ACCESS(val_ptr);
31879         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31880         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31881         ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val_conv);
31882 }
31883
31884 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) {
31885         void* forwarding_fee_proportional_millionths_arg_ptr = untag_ptr(forwarding_fee_proportional_millionths_arg);
31886         CHECK_ACCESS(forwarding_fee_proportional_millionths_arg_ptr);
31887         LDKCOption_u32Z forwarding_fee_proportional_millionths_arg_conv = *(LDKCOption_u32Z*)(forwarding_fee_proportional_millionths_arg_ptr);
31888         forwarding_fee_proportional_millionths_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(forwarding_fee_proportional_millionths_arg));
31889         void* forwarding_fee_base_msat_arg_ptr = untag_ptr(forwarding_fee_base_msat_arg);
31890         CHECK_ACCESS(forwarding_fee_base_msat_arg_ptr);
31891         LDKCOption_u32Z forwarding_fee_base_msat_arg_conv = *(LDKCOption_u32Z*)(forwarding_fee_base_msat_arg_ptr);
31892         forwarding_fee_base_msat_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(forwarding_fee_base_msat_arg));
31893         void* cltv_expiry_delta_arg_ptr = untag_ptr(cltv_expiry_delta_arg);
31894         CHECK_ACCESS(cltv_expiry_delta_arg_ptr);
31895         LDKCOption_u16Z cltv_expiry_delta_arg_conv = *(LDKCOption_u16Z*)(cltv_expiry_delta_arg_ptr);
31896         cltv_expiry_delta_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(cltv_expiry_delta_arg));
31897         void* max_dust_htlc_exposure_msat_arg_ptr = untag_ptr(max_dust_htlc_exposure_msat_arg);
31898         CHECK_ACCESS(max_dust_htlc_exposure_msat_arg_ptr);
31899         LDKCOption_MaxDustHTLCExposureZ max_dust_htlc_exposure_msat_arg_conv = *(LDKCOption_MaxDustHTLCExposureZ*)(max_dust_htlc_exposure_msat_arg_ptr);
31900         max_dust_htlc_exposure_msat_arg_conv = COption_MaxDustHTLCExposureZ_clone((LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(max_dust_htlc_exposure_msat_arg));
31901         void* force_close_avoidance_max_fee_satoshis_arg_ptr = untag_ptr(force_close_avoidance_max_fee_satoshis_arg);
31902         CHECK_ACCESS(force_close_avoidance_max_fee_satoshis_arg_ptr);
31903         LDKCOption_u64Z force_close_avoidance_max_fee_satoshis_arg_conv = *(LDKCOption_u64Z*)(force_close_avoidance_max_fee_satoshis_arg_ptr);
31904         force_close_avoidance_max_fee_satoshis_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(force_close_avoidance_max_fee_satoshis_arg));
31905         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);
31906         int64_t ret_ref = 0;
31907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31908         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31909         return ret_ref;
31910 }
31911
31912 int64_t  CS_LDK_ChannelConfigUpdate_default() {
31913         LDKChannelConfigUpdate ret_var = ChannelConfigUpdate_default();
31914         int64_t ret_ref = 0;
31915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31916         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31917         return ret_ref;
31918 }
31919
31920 void  CS_LDK_UserConfig_free(int64_t this_obj) {
31921         LDKUserConfig this_obj_conv;
31922         this_obj_conv.inner = untag_ptr(this_obj);
31923         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31925         UserConfig_free(this_obj_conv);
31926 }
31927
31928 int64_t  CS_LDK_UserConfig_get_channel_handshake_config(int64_t this_ptr) {
31929         LDKUserConfig this_ptr_conv;
31930         this_ptr_conv.inner = untag_ptr(this_ptr);
31931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31933         this_ptr_conv.is_owned = false;
31934         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
31935         int64_t ret_ref = 0;
31936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31938         return ret_ref;
31939 }
31940
31941 void  CS_LDK_UserConfig_set_channel_handshake_config(int64_t this_ptr, int64_t val) {
31942         LDKUserConfig this_ptr_conv;
31943         this_ptr_conv.inner = untag_ptr(this_ptr);
31944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31946         this_ptr_conv.is_owned = false;
31947         LDKChannelHandshakeConfig val_conv;
31948         val_conv.inner = untag_ptr(val);
31949         val_conv.is_owned = ptr_is_owned(val);
31950         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31951         val_conv = ChannelHandshakeConfig_clone(&val_conv);
31952         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
31953 }
31954
31955 int64_t  CS_LDK_UserConfig_get_channel_handshake_limits(int64_t this_ptr) {
31956         LDKUserConfig this_ptr_conv;
31957         this_ptr_conv.inner = untag_ptr(this_ptr);
31958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31960         this_ptr_conv.is_owned = false;
31961         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
31962         int64_t ret_ref = 0;
31963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31964         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31965         return ret_ref;
31966 }
31967
31968 void  CS_LDK_UserConfig_set_channel_handshake_limits(int64_t this_ptr, int64_t val) {
31969         LDKUserConfig this_ptr_conv;
31970         this_ptr_conv.inner = untag_ptr(this_ptr);
31971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31973         this_ptr_conv.is_owned = false;
31974         LDKChannelHandshakeLimits val_conv;
31975         val_conv.inner = untag_ptr(val);
31976         val_conv.is_owned = ptr_is_owned(val);
31977         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31978         val_conv = ChannelHandshakeLimits_clone(&val_conv);
31979         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
31980 }
31981
31982 int64_t  CS_LDK_UserConfig_get_channel_config(int64_t this_ptr) {
31983         LDKUserConfig this_ptr_conv;
31984         this_ptr_conv.inner = untag_ptr(this_ptr);
31985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31987         this_ptr_conv.is_owned = false;
31988         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
31989         int64_t ret_ref = 0;
31990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31991         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31992         return ret_ref;
31993 }
31994
31995 void  CS_LDK_UserConfig_set_channel_config(int64_t this_ptr, int64_t val) {
31996         LDKUserConfig this_ptr_conv;
31997         this_ptr_conv.inner = untag_ptr(this_ptr);
31998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32000         this_ptr_conv.is_owned = false;
32001         LDKChannelConfig val_conv;
32002         val_conv.inner = untag_ptr(val);
32003         val_conv.is_owned = ptr_is_owned(val);
32004         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32005         val_conv = ChannelConfig_clone(&val_conv);
32006         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
32007 }
32008
32009 jboolean  CS_LDK_UserConfig_get_accept_forwards_to_priv_channels(int64_t this_ptr) {
32010         LDKUserConfig this_ptr_conv;
32011         this_ptr_conv.inner = untag_ptr(this_ptr);
32012         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32014         this_ptr_conv.is_owned = false;
32015         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
32016         return ret_conv;
32017 }
32018
32019 void  CS_LDK_UserConfig_set_accept_forwards_to_priv_channels(int64_t this_ptr, jboolean val) {
32020         LDKUserConfig this_ptr_conv;
32021         this_ptr_conv.inner = untag_ptr(this_ptr);
32022         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32024         this_ptr_conv.is_owned = false;
32025         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
32026 }
32027
32028 jboolean  CS_LDK_UserConfig_get_accept_inbound_channels(int64_t this_ptr) {
32029         LDKUserConfig this_ptr_conv;
32030         this_ptr_conv.inner = untag_ptr(this_ptr);
32031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32033         this_ptr_conv.is_owned = false;
32034         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
32035         return ret_conv;
32036 }
32037
32038 void  CS_LDK_UserConfig_set_accept_inbound_channels(int64_t this_ptr, jboolean val) {
32039         LDKUserConfig this_ptr_conv;
32040         this_ptr_conv.inner = untag_ptr(this_ptr);
32041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32043         this_ptr_conv.is_owned = false;
32044         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
32045 }
32046
32047 jboolean  CS_LDK_UserConfig_get_manually_accept_inbound_channels(int64_t this_ptr) {
32048         LDKUserConfig this_ptr_conv;
32049         this_ptr_conv.inner = untag_ptr(this_ptr);
32050         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32052         this_ptr_conv.is_owned = false;
32053         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
32054         return ret_conv;
32055 }
32056
32057 void  CS_LDK_UserConfig_set_manually_accept_inbound_channels(int64_t this_ptr, jboolean val) {
32058         LDKUserConfig this_ptr_conv;
32059         this_ptr_conv.inner = untag_ptr(this_ptr);
32060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32062         this_ptr_conv.is_owned = false;
32063         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
32064 }
32065
32066 jboolean  CS_LDK_UserConfig_get_accept_intercept_htlcs(int64_t this_ptr) {
32067         LDKUserConfig this_ptr_conv;
32068         this_ptr_conv.inner = untag_ptr(this_ptr);
32069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32071         this_ptr_conv.is_owned = false;
32072         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
32073         return ret_conv;
32074 }
32075
32076 void  CS_LDK_UserConfig_set_accept_intercept_htlcs(int64_t this_ptr, jboolean val) {
32077         LDKUserConfig this_ptr_conv;
32078         this_ptr_conv.inner = untag_ptr(this_ptr);
32079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32081         this_ptr_conv.is_owned = false;
32082         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
32083 }
32084
32085 jboolean  CS_LDK_UserConfig_get_accept_mpp_keysend(int64_t this_ptr) {
32086         LDKUserConfig this_ptr_conv;
32087         this_ptr_conv.inner = untag_ptr(this_ptr);
32088         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32090         this_ptr_conv.is_owned = false;
32091         jboolean ret_conv = UserConfig_get_accept_mpp_keysend(&this_ptr_conv);
32092         return ret_conv;
32093 }
32094
32095 void  CS_LDK_UserConfig_set_accept_mpp_keysend(int64_t this_ptr, jboolean val) {
32096         LDKUserConfig this_ptr_conv;
32097         this_ptr_conv.inner = untag_ptr(this_ptr);
32098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32100         this_ptr_conv.is_owned = false;
32101         UserConfig_set_accept_mpp_keysend(&this_ptr_conv, val);
32102 }
32103
32104 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) {
32105         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
32106         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
32107         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
32108         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
32109         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
32110         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
32111         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
32112         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
32113         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
32114         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
32115         LDKChannelConfig channel_config_arg_conv;
32116         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
32117         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
32118         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
32119         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
32120         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);
32121         int64_t ret_ref = 0;
32122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32124         return ret_ref;
32125 }
32126
32127 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
32128         LDKUserConfig ret_var = UserConfig_clone(arg);
32129         int64_t ret_ref = 0;
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32132         return ret_ref;
32133 }
32134 int64_t  CS_LDK_UserConfig_clone_ptr(int64_t arg) {
32135         LDKUserConfig arg_conv;
32136         arg_conv.inner = untag_ptr(arg);
32137         arg_conv.is_owned = ptr_is_owned(arg);
32138         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32139         arg_conv.is_owned = false;
32140         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
32141         return ret_conv;
32142 }
32143
32144 int64_t  CS_LDK_UserConfig_clone(int64_t orig) {
32145         LDKUserConfig orig_conv;
32146         orig_conv.inner = untag_ptr(orig);
32147         orig_conv.is_owned = ptr_is_owned(orig);
32148         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32149         orig_conv.is_owned = false;
32150         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
32151         int64_t ret_ref = 0;
32152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32153         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32154         return ret_ref;
32155 }
32156
32157 int64_t  CS_LDK_UserConfig_default() {
32158         LDKUserConfig ret_var = UserConfig_default();
32159         int64_t ret_ref = 0;
32160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32161         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32162         return ret_ref;
32163 }
32164
32165 void  CS_LDK_BestBlock_free(int64_t this_obj) {
32166         LDKBestBlock this_obj_conv;
32167         this_obj_conv.inner = untag_ptr(this_obj);
32168         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32170         BestBlock_free(this_obj_conv);
32171 }
32172
32173 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
32174         LDKBestBlock ret_var = BestBlock_clone(arg);
32175         int64_t ret_ref = 0;
32176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32178         return ret_ref;
32179 }
32180 int64_t  CS_LDK_BestBlock_clone_ptr(int64_t arg) {
32181         LDKBestBlock arg_conv;
32182         arg_conv.inner = untag_ptr(arg);
32183         arg_conv.is_owned = ptr_is_owned(arg);
32184         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32185         arg_conv.is_owned = false;
32186         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
32187         return ret_conv;
32188 }
32189
32190 int64_t  CS_LDK_BestBlock_clone(int64_t orig) {
32191         LDKBestBlock orig_conv;
32192         orig_conv.inner = untag_ptr(orig);
32193         orig_conv.is_owned = ptr_is_owned(orig);
32194         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32195         orig_conv.is_owned = false;
32196         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
32197         int64_t ret_ref = 0;
32198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32199         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32200         return ret_ref;
32201 }
32202
32203 jboolean  CS_LDK_BestBlock_eq(int64_t a, int64_t b) {
32204         LDKBestBlock a_conv;
32205         a_conv.inner = untag_ptr(a);
32206         a_conv.is_owned = ptr_is_owned(a);
32207         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32208         a_conv.is_owned = false;
32209         LDKBestBlock b_conv;
32210         b_conv.inner = untag_ptr(b);
32211         b_conv.is_owned = ptr_is_owned(b);
32212         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32213         b_conv.is_owned = false;
32214         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
32215         return ret_conv;
32216 }
32217
32218 int64_t  CS_LDK_BestBlock_from_network(int32_t network) {
32219         LDKNetwork network_conv = LDKNetwork_from_cs(network);
32220         LDKBestBlock ret_var = BestBlock_from_network(network_conv);
32221         int64_t ret_ref = 0;
32222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32223         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32224         return ret_ref;
32225 }
32226
32227 int64_t  CS_LDK_BestBlock_new(int8_tArray block_hash, int32_t height) {
32228         LDKThirtyTwoBytes block_hash_ref;
32229         CHECK(block_hash->arr_len == 32);
32230         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
32231         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
32232         int64_t ret_ref = 0;
32233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32235         return ret_ref;
32236 }
32237
32238 int8_tArray  CS_LDK_BestBlock_block_hash(int64_t this_arg) {
32239         LDKBestBlock this_arg_conv;
32240         this_arg_conv.inner = untag_ptr(this_arg);
32241         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32243         this_arg_conv.is_owned = false;
32244         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32245         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
32246         return ret_arr;
32247 }
32248
32249 int32_t  CS_LDK_BestBlock_height(int64_t this_arg) {
32250         LDKBestBlock this_arg_conv;
32251         this_arg_conv.inner = untag_ptr(this_arg);
32252         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32254         this_arg_conv.is_owned = false;
32255         int32_t ret_conv = BestBlock_height(&this_arg_conv);
32256         return ret_conv;
32257 }
32258
32259 void  CS_LDK_Listen_free(int64_t this_ptr) {
32260         if (!ptr_is_owned(this_ptr)) return;
32261         void* this_ptr_ptr = untag_ptr(this_ptr);
32262         CHECK_ACCESS(this_ptr_ptr);
32263         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
32264         FREE(untag_ptr(this_ptr));
32265         Listen_free(this_ptr_conv);
32266 }
32267
32268 void  CS_LDK_Confirm_free(int64_t this_ptr) {
32269         if (!ptr_is_owned(this_ptr)) return;
32270         void* this_ptr_ptr = untag_ptr(this_ptr);
32271         CHECK_ACCESS(this_ptr_ptr);
32272         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
32273         FREE(untag_ptr(this_ptr));
32274         Confirm_free(this_ptr_conv);
32275 }
32276
32277 int32_t  CS_LDK_ChannelMonitorUpdateStatus_clone(int64_t orig) {
32278         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
32279         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(ChannelMonitorUpdateStatus_clone(orig_conv));
32280         return ret_conv;
32281 }
32282
32283 int32_t  CS_LDK_ChannelMonitorUpdateStatus_completed() {
32284         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(ChannelMonitorUpdateStatus_completed());
32285         return ret_conv;
32286 }
32287
32288 int32_t  CS_LDK_ChannelMonitorUpdateStatus_in_progress() {
32289         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(ChannelMonitorUpdateStatus_in_progress());
32290         return ret_conv;
32291 }
32292
32293 int32_t  CS_LDK_ChannelMonitorUpdateStatus_unrecoverable_error() {
32294         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(ChannelMonitorUpdateStatus_unrecoverable_error());
32295         return ret_conv;
32296 }
32297
32298 jboolean  CS_LDK_ChannelMonitorUpdateStatus_eq(int64_t a, int64_t b) {
32299         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
32300         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
32301         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
32302         return ret_conv;
32303 }
32304
32305 void  CS_LDK_Watch_free(int64_t this_ptr) {
32306         if (!ptr_is_owned(this_ptr)) return;
32307         void* this_ptr_ptr = untag_ptr(this_ptr);
32308         CHECK_ACCESS(this_ptr_ptr);
32309         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
32310         FREE(untag_ptr(this_ptr));
32311         Watch_free(this_ptr_conv);
32312 }
32313
32314 void  CS_LDK_Filter_free(int64_t this_ptr) {
32315         if (!ptr_is_owned(this_ptr)) return;
32316         void* this_ptr_ptr = untag_ptr(this_ptr);
32317         CHECK_ACCESS(this_ptr_ptr);
32318         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
32319         FREE(untag_ptr(this_ptr));
32320         Filter_free(this_ptr_conv);
32321 }
32322
32323 void  CS_LDK_WatchedOutput_free(int64_t this_obj) {
32324         LDKWatchedOutput this_obj_conv;
32325         this_obj_conv.inner = untag_ptr(this_obj);
32326         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32328         WatchedOutput_free(this_obj_conv);
32329 }
32330
32331 int64_t  CS_LDK_WatchedOutput_get_block_hash(int64_t this_ptr) {
32332         LDKWatchedOutput this_ptr_conv;
32333         this_ptr_conv.inner = untag_ptr(this_ptr);
32334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32336         this_ptr_conv.is_owned = false;
32337         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
32338         *ret_copy = WatchedOutput_get_block_hash(&this_ptr_conv);
32339         int64_t ret_ref = tag_ptr(ret_copy, true);
32340         return ret_ref;
32341 }
32342
32343 void  CS_LDK_WatchedOutput_set_block_hash(int64_t this_ptr, int64_t val) {
32344         LDKWatchedOutput this_ptr_conv;
32345         this_ptr_conv.inner = untag_ptr(this_ptr);
32346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32348         this_ptr_conv.is_owned = false;
32349         void* val_ptr = untag_ptr(val);
32350         CHECK_ACCESS(val_ptr);
32351         LDKCOption_ThirtyTwoBytesZ val_conv = *(LDKCOption_ThirtyTwoBytesZ*)(val_ptr);
32352         val_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(val));
32353         WatchedOutput_set_block_hash(&this_ptr_conv, val_conv);
32354 }
32355
32356 int64_t  CS_LDK_WatchedOutput_get_outpoint(int64_t this_ptr) {
32357         LDKWatchedOutput this_ptr_conv;
32358         this_ptr_conv.inner = untag_ptr(this_ptr);
32359         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32361         this_ptr_conv.is_owned = false;
32362         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
32363         int64_t ret_ref = 0;
32364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32366         return ret_ref;
32367 }
32368
32369 void  CS_LDK_WatchedOutput_set_outpoint(int64_t this_ptr, int64_t val) {
32370         LDKWatchedOutput this_ptr_conv;
32371         this_ptr_conv.inner = untag_ptr(this_ptr);
32372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32374         this_ptr_conv.is_owned = false;
32375         LDKOutPoint val_conv;
32376         val_conv.inner = untag_ptr(val);
32377         val_conv.is_owned = ptr_is_owned(val);
32378         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32379         val_conv = OutPoint_clone(&val_conv);
32380         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
32381 }
32382
32383 int8_tArray  CS_LDK_WatchedOutput_get_script_pubkey(int64_t this_ptr) {
32384         LDKWatchedOutput this_ptr_conv;
32385         this_ptr_conv.inner = untag_ptr(this_ptr);
32386         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32388         this_ptr_conv.is_owned = false;
32389         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
32390         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32391         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32392         return ret_arr;
32393 }
32394
32395 void  CS_LDK_WatchedOutput_set_script_pubkey(int64_t this_ptr, int8_tArray val) {
32396         LDKWatchedOutput this_ptr_conv;
32397         this_ptr_conv.inner = untag_ptr(this_ptr);
32398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32400         this_ptr_conv.is_owned = false;
32401         LDKCVec_u8Z val_ref;
32402         val_ref.datalen = val->arr_len;
32403         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32404         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
32405         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
32406 }
32407
32408 int64_t  CS_LDK_WatchedOutput_new(int64_t block_hash_arg, int64_t outpoint_arg, int8_tArray script_pubkey_arg) {
32409         void* block_hash_arg_ptr = untag_ptr(block_hash_arg);
32410         CHECK_ACCESS(block_hash_arg_ptr);
32411         LDKCOption_ThirtyTwoBytesZ block_hash_arg_conv = *(LDKCOption_ThirtyTwoBytesZ*)(block_hash_arg_ptr);
32412         block_hash_arg_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(block_hash_arg));
32413         LDKOutPoint outpoint_arg_conv;
32414         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
32415         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
32416         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
32417         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
32418         LDKCVec_u8Z script_pubkey_arg_ref;
32419         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
32420         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32421         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
32422         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_conv, outpoint_arg_conv, script_pubkey_arg_ref);
32423         int64_t ret_ref = 0;
32424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32426         return ret_ref;
32427 }
32428
32429 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
32430         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
32431         int64_t ret_ref = 0;
32432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32433         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32434         return ret_ref;
32435 }
32436 int64_t  CS_LDK_WatchedOutput_clone_ptr(int64_t arg) {
32437         LDKWatchedOutput arg_conv;
32438         arg_conv.inner = untag_ptr(arg);
32439         arg_conv.is_owned = ptr_is_owned(arg);
32440         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32441         arg_conv.is_owned = false;
32442         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
32443         return ret_conv;
32444 }
32445
32446 int64_t  CS_LDK_WatchedOutput_clone(int64_t orig) {
32447         LDKWatchedOutput orig_conv;
32448         orig_conv.inner = untag_ptr(orig);
32449         orig_conv.is_owned = ptr_is_owned(orig);
32450         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32451         orig_conv.is_owned = false;
32452         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
32453         int64_t ret_ref = 0;
32454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32455         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32456         return ret_ref;
32457 }
32458
32459 jboolean  CS_LDK_WatchedOutput_eq(int64_t a, int64_t b) {
32460         LDKWatchedOutput a_conv;
32461         a_conv.inner = untag_ptr(a);
32462         a_conv.is_owned = ptr_is_owned(a);
32463         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32464         a_conv.is_owned = false;
32465         LDKWatchedOutput b_conv;
32466         b_conv.inner = untag_ptr(b);
32467         b_conv.is_owned = ptr_is_owned(b);
32468         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32469         b_conv.is_owned = false;
32470         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
32471         return ret_conv;
32472 }
32473
32474 int64_t  CS_LDK_WatchedOutput_hash(int64_t o) {
32475         LDKWatchedOutput o_conv;
32476         o_conv.inner = untag_ptr(o);
32477         o_conv.is_owned = ptr_is_owned(o);
32478         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32479         o_conv.is_owned = false;
32480         int64_t ret_conv = WatchedOutput_hash(&o_conv);
32481         return ret_conv;
32482 }
32483
32484 void  CS_LDK_BroadcasterInterface_free(int64_t this_ptr) {
32485         if (!ptr_is_owned(this_ptr)) return;
32486         void* this_ptr_ptr = untag_ptr(this_ptr);
32487         CHECK_ACCESS(this_ptr_ptr);
32488         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
32489         FREE(untag_ptr(this_ptr));
32490         BroadcasterInterface_free(this_ptr_conv);
32491 }
32492
32493 int32_t  CS_LDK_ConfirmationTarget_clone(int64_t orig) {
32494         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
32495         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_clone(orig_conv));
32496         return ret_conv;
32497 }
32498
32499 int32_t  CS_LDK_ConfirmationTarget_on_chain_sweep() {
32500         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_on_chain_sweep());
32501         return ret_conv;
32502 }
32503
32504 int32_t  CS_LDK_ConfirmationTarget_max_allowed_non_anchor_channel_remote_fee() {
32505         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_max_allowed_non_anchor_channel_remote_fee());
32506         return ret_conv;
32507 }
32508
32509 int32_t  CS_LDK_ConfirmationTarget_min_allowed_anchor_channel_remote_fee() {
32510         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_min_allowed_anchor_channel_remote_fee());
32511         return ret_conv;
32512 }
32513
32514 int32_t  CS_LDK_ConfirmationTarget_min_allowed_non_anchor_channel_remote_fee() {
32515         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_min_allowed_non_anchor_channel_remote_fee());
32516         return ret_conv;
32517 }
32518
32519 int32_t  CS_LDK_ConfirmationTarget_anchor_channel_fee() {
32520         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_anchor_channel_fee());
32521         return ret_conv;
32522 }
32523
32524 int32_t  CS_LDK_ConfirmationTarget_non_anchor_channel_fee() {
32525         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_non_anchor_channel_fee());
32526         return ret_conv;
32527 }
32528
32529 int32_t  CS_LDK_ConfirmationTarget_channel_close_minimum() {
32530         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_channel_close_minimum());
32531         return ret_conv;
32532 }
32533
32534 int64_t  CS_LDK_ConfirmationTarget_hash(int64_t o) {
32535         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
32536         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
32537         return ret_conv;
32538 }
32539
32540 jboolean  CS_LDK_ConfirmationTarget_eq(int64_t a, int64_t b) {
32541         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
32542         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
32543         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
32544         return ret_conv;
32545 }
32546
32547 void  CS_LDK_FeeEstimator_free(int64_t this_ptr) {
32548         if (!ptr_is_owned(this_ptr)) return;
32549         void* this_ptr_ptr = untag_ptr(this_ptr);
32550         CHECK_ACCESS(this_ptr_ptr);
32551         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
32552         FREE(untag_ptr(this_ptr));
32553         FeeEstimator_free(this_ptr_conv);
32554 }
32555
32556 void  CS_LDK_MonitorUpdateId_free(int64_t this_obj) {
32557         LDKMonitorUpdateId this_obj_conv;
32558         this_obj_conv.inner = untag_ptr(this_obj);
32559         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32561         MonitorUpdateId_free(this_obj_conv);
32562 }
32563
32564 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
32565         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
32566         int64_t ret_ref = 0;
32567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32568         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32569         return ret_ref;
32570 }
32571 int64_t  CS_LDK_MonitorUpdateId_clone_ptr(int64_t arg) {
32572         LDKMonitorUpdateId arg_conv;
32573         arg_conv.inner = untag_ptr(arg);
32574         arg_conv.is_owned = ptr_is_owned(arg);
32575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32576         arg_conv.is_owned = false;
32577         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
32578         return ret_conv;
32579 }
32580
32581 int64_t  CS_LDK_MonitorUpdateId_clone(int64_t orig) {
32582         LDKMonitorUpdateId orig_conv;
32583         orig_conv.inner = untag_ptr(orig);
32584         orig_conv.is_owned = ptr_is_owned(orig);
32585         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32586         orig_conv.is_owned = false;
32587         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
32588         int64_t ret_ref = 0;
32589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32591         return ret_ref;
32592 }
32593
32594 int64_t  CS_LDK_MonitorUpdateId_hash(int64_t o) {
32595         LDKMonitorUpdateId o_conv;
32596         o_conv.inner = untag_ptr(o);
32597         o_conv.is_owned = ptr_is_owned(o);
32598         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32599         o_conv.is_owned = false;
32600         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
32601         return ret_conv;
32602 }
32603
32604 jboolean  CS_LDK_MonitorUpdateId_eq(int64_t a, int64_t b) {
32605         LDKMonitorUpdateId a_conv;
32606         a_conv.inner = untag_ptr(a);
32607         a_conv.is_owned = ptr_is_owned(a);
32608         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32609         a_conv.is_owned = false;
32610         LDKMonitorUpdateId b_conv;
32611         b_conv.inner = untag_ptr(b);
32612         b_conv.is_owned = ptr_is_owned(b);
32613         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32614         b_conv.is_owned = false;
32615         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
32616         return ret_conv;
32617 }
32618
32619 void  CS_LDK_Persist_free(int64_t this_ptr) {
32620         if (!ptr_is_owned(this_ptr)) return;
32621         void* this_ptr_ptr = untag_ptr(this_ptr);
32622         CHECK_ACCESS(this_ptr_ptr);
32623         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
32624         FREE(untag_ptr(this_ptr));
32625         Persist_free(this_ptr_conv);
32626 }
32627
32628 void  CS_LDK_LockedChannelMonitor_free(int64_t this_obj) {
32629         LDKLockedChannelMonitor this_obj_conv;
32630         this_obj_conv.inner = untag_ptr(this_obj);
32631         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32633         LockedChannelMonitor_free(this_obj_conv);
32634 }
32635
32636 void  CS_LDK_ChainMonitor_free(int64_t this_obj) {
32637         LDKChainMonitor this_obj_conv;
32638         this_obj_conv.inner = untag_ptr(this_obj);
32639         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32641         ChainMonitor_free(this_obj_conv);
32642 }
32643
32644 int64_t  CS_LDK_ChainMonitor_new(int64_t chain_source, int64_t broadcaster, int64_t logger, int64_t feeest, int64_t persister) {
32645         void* chain_source_ptr = untag_ptr(chain_source);
32646         CHECK_ACCESS(chain_source_ptr);
32647         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
32648         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
32649         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
32650                 // Manually implement clone for Java trait instances
32651                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
32652                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32653                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
32654                 }
32655         }
32656         void* broadcaster_ptr = untag_ptr(broadcaster);
32657         CHECK_ACCESS(broadcaster_ptr);
32658         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
32659         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
32660                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32661                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
32662         }
32663         void* logger_ptr = untag_ptr(logger);
32664         CHECK_ACCESS(logger_ptr);
32665         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32666         if (logger_conv.free == LDKLogger_JCalls_free) {
32667                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32668                 LDKLogger_JCalls_cloned(&logger_conv);
32669         }
32670         void* feeest_ptr = untag_ptr(feeest);
32671         CHECK_ACCESS(feeest_ptr);
32672         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
32673         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
32674                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32675                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
32676         }
32677         void* persister_ptr = untag_ptr(persister);
32678         CHECK_ACCESS(persister_ptr);
32679         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
32680         if (persister_conv.free == LDKPersist_JCalls_free) {
32681                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32682                 LDKPersist_JCalls_cloned(&persister_conv);
32683         }
32684         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
32685         int64_t ret_ref = 0;
32686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32688         return ret_ref;
32689 }
32690
32691 int64_tArray  CS_LDK_ChainMonitor_get_claimable_balances(int64_t this_arg, int64_tArray ignored_channels) {
32692         LDKChainMonitor this_arg_conv;
32693         this_arg_conv.inner = untag_ptr(this_arg);
32694         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32696         this_arg_conv.is_owned = false;
32697         LDKCVec_ChannelDetailsZ ignored_channels_constr;
32698         ignored_channels_constr.datalen = ignored_channels->arr_len;
32699         if (ignored_channels_constr.datalen > 0)
32700                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
32701         else
32702                 ignored_channels_constr.data = NULL;
32703         int64_t* ignored_channels_vals = ignored_channels->elems;
32704         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
32705                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
32706                 LDKChannelDetails ignored_channels_conv_16_conv;
32707                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
32708                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
32709                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
32710                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
32711                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
32712         }
32713         FREE(ignored_channels);
32714         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
32715         int64_tArray ret_arr = NULL;
32716         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32717         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32718         for (size_t j = 0; j < ret_var.datalen; j++) {
32719                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
32720                 *ret_conv_9_copy = ret_var.data[j];
32721                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
32722                 ret_arr_ptr[j] = ret_conv_9_ref;
32723         }
32724         
32725         FREE(ret_var.data);
32726         return ret_arr;
32727 }
32728
32729 int64_t  CS_LDK_ChainMonitor_get_monitor(int64_t this_arg, int64_t funding_txo) {
32730         LDKChainMonitor this_arg_conv;
32731         this_arg_conv.inner = untag_ptr(this_arg);
32732         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32734         this_arg_conv.is_owned = false;
32735         LDKOutPoint funding_txo_conv;
32736         funding_txo_conv.inner = untag_ptr(funding_txo);
32737         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
32738         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
32739         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
32740         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
32741         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
32742         return tag_ptr(ret_conv, true);
32743 }
32744
32745 int64_tArray  CS_LDK_ChainMonitor_list_monitors(int64_t this_arg) {
32746         LDKChainMonitor this_arg_conv;
32747         this_arg_conv.inner = untag_ptr(this_arg);
32748         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32750         this_arg_conv.is_owned = false;
32751         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
32752         int64_tArray ret_arr = NULL;
32753         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32754         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32755         for (size_t k = 0; k < ret_var.datalen; k++) {
32756                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
32757                 int64_t ret_conv_10_ref = 0;
32758                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
32759                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
32760                 ret_arr_ptr[k] = ret_conv_10_ref;
32761         }
32762         
32763         FREE(ret_var.data);
32764         return ret_arr;
32765 }
32766
32767 int64_tArray  CS_LDK_ChainMonitor_list_pending_monitor_updates(int64_t this_arg) {
32768         LDKChainMonitor this_arg_conv;
32769         this_arg_conv.inner = untag_ptr(this_arg);
32770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32772         this_arg_conv.is_owned = false;
32773         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
32774         int64_tArray ret_arr = NULL;
32775         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32776         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32777         for (size_t p = 0; p < ret_var.datalen; p++) {
32778                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
32779                 *ret_conv_41_conv = ret_var.data[p];
32780                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
32781         }
32782         
32783         FREE(ret_var.data);
32784         return ret_arr;
32785 }
32786
32787 int64_t  CS_LDK_ChainMonitor_channel_monitor_updated(int64_t this_arg, int64_t funding_txo, int64_t completed_update_id) {
32788         LDKChainMonitor this_arg_conv;
32789         this_arg_conv.inner = untag_ptr(this_arg);
32790         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32792         this_arg_conv.is_owned = false;
32793         LDKOutPoint funding_txo_conv;
32794         funding_txo_conv.inner = untag_ptr(funding_txo);
32795         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
32796         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
32797         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
32798         LDKMonitorUpdateId completed_update_id_conv;
32799         completed_update_id_conv.inner = untag_ptr(completed_update_id);
32800         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
32801         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
32802         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
32803         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32804         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
32805         return tag_ptr(ret_conv, true);
32806 }
32807
32808 int64_t  CS_LDK_ChainMonitor_get_update_future(int64_t this_arg) {
32809         LDKChainMonitor this_arg_conv;
32810         this_arg_conv.inner = untag_ptr(this_arg);
32811         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32813         this_arg_conv.is_owned = false;
32814         LDKFuture ret_var = ChainMonitor_get_update_future(&this_arg_conv);
32815         int64_t ret_ref = 0;
32816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32818         return ret_ref;
32819 }
32820
32821 void  CS_LDK_ChainMonitor_rebroadcast_pending_claims(int64_t this_arg) {
32822         LDKChainMonitor this_arg_conv;
32823         this_arg_conv.inner = untag_ptr(this_arg);
32824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32826         this_arg_conv.is_owned = false;
32827         ChainMonitor_rebroadcast_pending_claims(&this_arg_conv);
32828 }
32829
32830 int64_t  CS_LDK_ChainMonitor_as_Listen(int64_t this_arg) {
32831         LDKChainMonitor this_arg_conv;
32832         this_arg_conv.inner = untag_ptr(this_arg);
32833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32835         this_arg_conv.is_owned = false;
32836         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
32837         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
32838         return tag_ptr(ret_ret, true);
32839 }
32840
32841 int64_t  CS_LDK_ChainMonitor_as_Confirm(int64_t this_arg) {
32842         LDKChainMonitor this_arg_conv;
32843         this_arg_conv.inner = untag_ptr(this_arg);
32844         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32846         this_arg_conv.is_owned = false;
32847         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
32848         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
32849         return tag_ptr(ret_ret, true);
32850 }
32851
32852 int64_t  CS_LDK_ChainMonitor_as_Watch(int64_t this_arg) {
32853         LDKChainMonitor this_arg_conv;
32854         this_arg_conv.inner = untag_ptr(this_arg);
32855         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32857         this_arg_conv.is_owned = false;
32858         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
32859         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
32860         return tag_ptr(ret_ret, true);
32861 }
32862
32863 int64_t  CS_LDK_ChainMonitor_as_EventsProvider(int64_t this_arg) {
32864         LDKChainMonitor this_arg_conv;
32865         this_arg_conv.inner = untag_ptr(this_arg);
32866         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32868         this_arg_conv.is_owned = false;
32869         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
32870         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
32871         return tag_ptr(ret_ret, true);
32872 }
32873
32874 void  CS_LDK_ChannelMonitorUpdate_free(int64_t this_obj) {
32875         LDKChannelMonitorUpdate this_obj_conv;
32876         this_obj_conv.inner = untag_ptr(this_obj);
32877         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32879         ChannelMonitorUpdate_free(this_obj_conv);
32880 }
32881
32882 int64_t  CS_LDK_ChannelMonitorUpdate_get_update_id(int64_t this_ptr) {
32883         LDKChannelMonitorUpdate this_ptr_conv;
32884         this_ptr_conv.inner = untag_ptr(this_ptr);
32885         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32887         this_ptr_conv.is_owned = false;
32888         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
32889         return ret_conv;
32890 }
32891
32892 void  CS_LDK_ChannelMonitorUpdate_set_update_id(int64_t this_ptr, int64_t val) {
32893         LDKChannelMonitorUpdate this_ptr_conv;
32894         this_ptr_conv.inner = untag_ptr(this_ptr);
32895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32897         this_ptr_conv.is_owned = false;
32898         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
32899 }
32900
32901 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
32902         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
32903         int64_t ret_ref = 0;
32904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32905         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32906         return ret_ref;
32907 }
32908 int64_t  CS_LDK_ChannelMonitorUpdate_clone_ptr(int64_t arg) {
32909         LDKChannelMonitorUpdate arg_conv;
32910         arg_conv.inner = untag_ptr(arg);
32911         arg_conv.is_owned = ptr_is_owned(arg);
32912         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32913         arg_conv.is_owned = false;
32914         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
32915         return ret_conv;
32916 }
32917
32918 int64_t  CS_LDK_ChannelMonitorUpdate_clone(int64_t orig) {
32919         LDKChannelMonitorUpdate orig_conv;
32920         orig_conv.inner = untag_ptr(orig);
32921         orig_conv.is_owned = ptr_is_owned(orig);
32922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32923         orig_conv.is_owned = false;
32924         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
32925         int64_t ret_ref = 0;
32926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32927         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32928         return ret_ref;
32929 }
32930
32931 jboolean  CS_LDK_ChannelMonitorUpdate_eq(int64_t a, int64_t b) {
32932         LDKChannelMonitorUpdate a_conv;
32933         a_conv.inner = untag_ptr(a);
32934         a_conv.is_owned = ptr_is_owned(a);
32935         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32936         a_conv.is_owned = false;
32937         LDKChannelMonitorUpdate b_conv;
32938         b_conv.inner = untag_ptr(b);
32939         b_conv.is_owned = ptr_is_owned(b);
32940         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32941         b_conv.is_owned = false;
32942         jboolean ret_conv = ChannelMonitorUpdate_eq(&a_conv, &b_conv);
32943         return ret_conv;
32944 }
32945
32946 int8_tArray  CS_LDK_ChannelMonitorUpdate_write(int64_t obj) {
32947         LDKChannelMonitorUpdate obj_conv;
32948         obj_conv.inner = untag_ptr(obj);
32949         obj_conv.is_owned = ptr_is_owned(obj);
32950         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32951         obj_conv.is_owned = false;
32952         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
32953         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32954         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32955         CVec_u8Z_free(ret_var);
32956         return ret_arr;
32957 }
32958
32959 int64_t  CS_LDK_ChannelMonitorUpdate_read(int8_tArray ser) {
32960         LDKu8slice ser_ref;
32961         ser_ref.datalen = ser->arr_len;
32962         ser_ref.data = ser->elems;
32963         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
32964         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
32965         FREE(ser);
32966         return tag_ptr(ret_conv, true);
32967 }
32968
32969 void  CS_LDK_MonitorEvent_free(int64_t this_ptr) {
32970         if (!ptr_is_owned(this_ptr)) return;
32971         void* this_ptr_ptr = untag_ptr(this_ptr);
32972         CHECK_ACCESS(this_ptr_ptr);
32973         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
32974         FREE(untag_ptr(this_ptr));
32975         MonitorEvent_free(this_ptr_conv);
32976 }
32977
32978 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
32979         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
32980         *ret_copy = MonitorEvent_clone(arg);
32981         int64_t ret_ref = tag_ptr(ret_copy, true);
32982         return ret_ref;
32983 }
32984 int64_t  CS_LDK_MonitorEvent_clone_ptr(int64_t arg) {
32985         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
32986         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
32987         return ret_conv;
32988 }
32989
32990 int64_t  CS_LDK_MonitorEvent_clone(int64_t orig) {
32991         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
32992         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
32993         *ret_copy = MonitorEvent_clone(orig_conv);
32994         int64_t ret_ref = tag_ptr(ret_copy, true);
32995         return ret_ref;
32996 }
32997
32998 int64_t  CS_LDK_MonitorEvent_htlcevent(int64_t a) {
32999         LDKHTLCUpdate a_conv;
33000         a_conv.inner = untag_ptr(a);
33001         a_conv.is_owned = ptr_is_owned(a);
33002         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33003         a_conv = HTLCUpdate_clone(&a_conv);
33004         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
33005         *ret_copy = MonitorEvent_htlcevent(a_conv);
33006         int64_t ret_ref = tag_ptr(ret_copy, true);
33007         return ret_ref;
33008 }
33009
33010 int64_t  CS_LDK_MonitorEvent_holder_force_closed(int64_t a) {
33011         LDKOutPoint a_conv;
33012         a_conv.inner = untag_ptr(a);
33013         a_conv.is_owned = ptr_is_owned(a);
33014         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33015         a_conv = OutPoint_clone(&a_conv);
33016         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
33017         *ret_copy = MonitorEvent_holder_force_closed(a_conv);
33018         int64_t ret_ref = tag_ptr(ret_copy, true);
33019         return ret_ref;
33020 }
33021
33022 int64_t  CS_LDK_MonitorEvent_completed(int64_t funding_txo, int64_t monitor_update_id) {
33023         LDKOutPoint funding_txo_conv;
33024         funding_txo_conv.inner = untag_ptr(funding_txo);
33025         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
33026         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
33027         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
33028         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
33029         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
33030         int64_t ret_ref = tag_ptr(ret_copy, true);
33031         return ret_ref;
33032 }
33033
33034 jboolean  CS_LDK_MonitorEvent_eq(int64_t a, int64_t b) {
33035         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
33036         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
33037         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
33038         return ret_conv;
33039 }
33040
33041 int8_tArray  CS_LDK_MonitorEvent_write(int64_t obj) {
33042         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
33043         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
33044         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33045         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33046         CVec_u8Z_free(ret_var);
33047         return ret_arr;
33048 }
33049
33050 int64_t  CS_LDK_MonitorEvent_read(int8_tArray ser) {
33051         LDKu8slice ser_ref;
33052         ser_ref.datalen = ser->arr_len;
33053         ser_ref.data = ser->elems;
33054         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
33055         *ret_conv = MonitorEvent_read(ser_ref);
33056         FREE(ser);
33057         return tag_ptr(ret_conv, true);
33058 }
33059
33060 void  CS_LDK_HTLCUpdate_free(int64_t this_obj) {
33061         LDKHTLCUpdate this_obj_conv;
33062         this_obj_conv.inner = untag_ptr(this_obj);
33063         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33065         HTLCUpdate_free(this_obj_conv);
33066 }
33067
33068 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
33069         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
33070         int64_t ret_ref = 0;
33071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33072         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33073         return ret_ref;
33074 }
33075 int64_t  CS_LDK_HTLCUpdate_clone_ptr(int64_t arg) {
33076         LDKHTLCUpdate arg_conv;
33077         arg_conv.inner = untag_ptr(arg);
33078         arg_conv.is_owned = ptr_is_owned(arg);
33079         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33080         arg_conv.is_owned = false;
33081         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
33082         return ret_conv;
33083 }
33084
33085 int64_t  CS_LDK_HTLCUpdate_clone(int64_t orig) {
33086         LDKHTLCUpdate orig_conv;
33087         orig_conv.inner = untag_ptr(orig);
33088         orig_conv.is_owned = ptr_is_owned(orig);
33089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33090         orig_conv.is_owned = false;
33091         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
33092         int64_t ret_ref = 0;
33093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33095         return ret_ref;
33096 }
33097
33098 jboolean  CS_LDK_HTLCUpdate_eq(int64_t a, int64_t b) {
33099         LDKHTLCUpdate a_conv;
33100         a_conv.inner = untag_ptr(a);
33101         a_conv.is_owned = ptr_is_owned(a);
33102         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33103         a_conv.is_owned = false;
33104         LDKHTLCUpdate b_conv;
33105         b_conv.inner = untag_ptr(b);
33106         b_conv.is_owned = ptr_is_owned(b);
33107         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33108         b_conv.is_owned = false;
33109         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
33110         return ret_conv;
33111 }
33112
33113 int8_tArray  CS_LDK_HTLCUpdate_write(int64_t obj) {
33114         LDKHTLCUpdate obj_conv;
33115         obj_conv.inner = untag_ptr(obj);
33116         obj_conv.is_owned = ptr_is_owned(obj);
33117         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33118         obj_conv.is_owned = false;
33119         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
33120         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33121         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33122         CVec_u8Z_free(ret_var);
33123         return ret_arr;
33124 }
33125
33126 int64_t  CS_LDK_HTLCUpdate_read(int8_tArray ser) {
33127         LDKu8slice ser_ref;
33128         ser_ref.datalen = ser->arr_len;
33129         ser_ref.data = ser->elems;
33130         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
33131         *ret_conv = HTLCUpdate_read(ser_ref);
33132         FREE(ser);
33133         return tag_ptr(ret_conv, true);
33134 }
33135
33136 void  CS_LDK_Balance_free(int64_t this_ptr) {
33137         if (!ptr_is_owned(this_ptr)) return;
33138         void* this_ptr_ptr = untag_ptr(this_ptr);
33139         CHECK_ACCESS(this_ptr_ptr);
33140         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
33141         FREE(untag_ptr(this_ptr));
33142         Balance_free(this_ptr_conv);
33143 }
33144
33145 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
33146         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33147         *ret_copy = Balance_clone(arg);
33148         int64_t ret_ref = tag_ptr(ret_copy, true);
33149         return ret_ref;
33150 }
33151 int64_t  CS_LDK_Balance_clone_ptr(int64_t arg) {
33152         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
33153         int64_t ret_conv = Balance_clone_ptr(arg_conv);
33154         return ret_conv;
33155 }
33156
33157 int64_t  CS_LDK_Balance_clone(int64_t orig) {
33158         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
33159         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33160         *ret_copy = Balance_clone(orig_conv);
33161         int64_t ret_ref = tag_ptr(ret_copy, true);
33162         return ret_ref;
33163 }
33164
33165 int64_t  CS_LDK_Balance_claimable_on_channel_close(int64_t amount_satoshis) {
33166         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33167         *ret_copy = Balance_claimable_on_channel_close(amount_satoshis);
33168         int64_t ret_ref = tag_ptr(ret_copy, true);
33169         return ret_ref;
33170 }
33171
33172 int64_t  CS_LDK_Balance_claimable_awaiting_confirmations(int64_t amount_satoshis, int32_t confirmation_height) {
33173         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33174         *ret_copy = Balance_claimable_awaiting_confirmations(amount_satoshis, confirmation_height);
33175         int64_t ret_ref = tag_ptr(ret_copy, true);
33176         return ret_ref;
33177 }
33178
33179 int64_t  CS_LDK_Balance_contentious_claimable(int64_t amount_satoshis, int32_t timeout_height, int8_tArray payment_hash, int8_tArray payment_preimage) {
33180         LDKThirtyTwoBytes payment_hash_ref;
33181         CHECK(payment_hash->arr_len == 32);
33182         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
33183         LDKThirtyTwoBytes payment_preimage_ref;
33184         CHECK(payment_preimage->arr_len == 32);
33185         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
33186         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33187         *ret_copy = Balance_contentious_claimable(amount_satoshis, timeout_height, payment_hash_ref, payment_preimage_ref);
33188         int64_t ret_ref = tag_ptr(ret_copy, true);
33189         return ret_ref;
33190 }
33191
33192 int64_t  CS_LDK_Balance_maybe_timeout_claimable_htlc(int64_t amount_satoshis, int32_t claimable_height, int8_tArray payment_hash) {
33193         LDKThirtyTwoBytes payment_hash_ref;
33194         CHECK(payment_hash->arr_len == 32);
33195         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
33196         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33197         *ret_copy = Balance_maybe_timeout_claimable_htlc(amount_satoshis, claimable_height, payment_hash_ref);
33198         int64_t ret_ref = tag_ptr(ret_copy, true);
33199         return ret_ref;
33200 }
33201
33202 int64_t  CS_LDK_Balance_maybe_preimage_claimable_htlc(int64_t amount_satoshis, int32_t expiry_height, int8_tArray payment_hash) {
33203         LDKThirtyTwoBytes payment_hash_ref;
33204         CHECK(payment_hash->arr_len == 32);
33205         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
33206         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33207         *ret_copy = Balance_maybe_preimage_claimable_htlc(amount_satoshis, expiry_height, payment_hash_ref);
33208         int64_t ret_ref = tag_ptr(ret_copy, true);
33209         return ret_ref;
33210 }
33211
33212 int64_t  CS_LDK_Balance_counterparty_revoked_output_claimable(int64_t amount_satoshis) {
33213         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33214         *ret_copy = Balance_counterparty_revoked_output_claimable(amount_satoshis);
33215         int64_t ret_ref = tag_ptr(ret_copy, true);
33216         return ret_ref;
33217 }
33218
33219 jboolean  CS_LDK_Balance_eq(int64_t a, int64_t b) {
33220         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
33221         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
33222         jboolean ret_conv = Balance_eq(a_conv, b_conv);
33223         return ret_conv;
33224 }
33225
33226 int64_t  CS_LDK_Balance_claimable_amount_satoshis(int64_t this_arg) {
33227         LDKBalance* this_arg_conv = (LDKBalance*)untag_ptr(this_arg);
33228         int64_t ret_conv = Balance_claimable_amount_satoshis(this_arg_conv);
33229         return ret_conv;
33230 }
33231
33232 void  CS_LDK_ChannelMonitor_free(int64_t this_obj) {
33233         LDKChannelMonitor this_obj_conv;
33234         this_obj_conv.inner = untag_ptr(this_obj);
33235         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33237         ChannelMonitor_free(this_obj_conv);
33238 }
33239
33240 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
33241         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
33242         int64_t ret_ref = 0;
33243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33245         return ret_ref;
33246 }
33247 int64_t  CS_LDK_ChannelMonitor_clone_ptr(int64_t arg) {
33248         LDKChannelMonitor arg_conv;
33249         arg_conv.inner = untag_ptr(arg);
33250         arg_conv.is_owned = ptr_is_owned(arg);
33251         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33252         arg_conv.is_owned = false;
33253         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
33254         return ret_conv;
33255 }
33256
33257 int64_t  CS_LDK_ChannelMonitor_clone(int64_t orig) {
33258         LDKChannelMonitor orig_conv;
33259         orig_conv.inner = untag_ptr(orig);
33260         orig_conv.is_owned = ptr_is_owned(orig);
33261         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33262         orig_conv.is_owned = false;
33263         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
33264         int64_t ret_ref = 0;
33265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33266         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33267         return ret_ref;
33268 }
33269
33270 int8_tArray  CS_LDK_ChannelMonitor_write(int64_t obj) {
33271         LDKChannelMonitor obj_conv;
33272         obj_conv.inner = untag_ptr(obj);
33273         obj_conv.is_owned = ptr_is_owned(obj);
33274         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33275         obj_conv.is_owned = false;
33276         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
33277         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33278         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33279         CVec_u8Z_free(ret_var);
33280         return ret_arr;
33281 }
33282
33283 int64_t  CS_LDK_ChannelMonitor_update_monitor(int64_t this_arg, int64_t updates, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33284         LDKChannelMonitor this_arg_conv;
33285         this_arg_conv.inner = untag_ptr(this_arg);
33286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33288         this_arg_conv.is_owned = false;
33289         LDKChannelMonitorUpdate updates_conv;
33290         updates_conv.inner = untag_ptr(updates);
33291         updates_conv.is_owned = ptr_is_owned(updates);
33292         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
33293         updates_conv.is_owned = false;
33294         void* broadcaster_ptr = untag_ptr(broadcaster);
33295         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
33296         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
33297         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33298         if (ptr_is_owned(fee_estimator)) { CHECK_ACCESS(fee_estimator_ptr); }
33299         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
33300         void* logger_ptr = untag_ptr(logger);
33301         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
33302         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
33303         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
33304         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
33305         return tag_ptr(ret_conv, true);
33306 }
33307
33308 int64_t  CS_LDK_ChannelMonitor_get_latest_update_id(int64_t this_arg) {
33309         LDKChannelMonitor this_arg_conv;
33310         this_arg_conv.inner = untag_ptr(this_arg);
33311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33313         this_arg_conv.is_owned = false;
33314         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
33315         return ret_conv;
33316 }
33317
33318 int64_t  CS_LDK_ChannelMonitor_get_funding_txo(int64_t this_arg) {
33319         LDKChannelMonitor this_arg_conv;
33320         this_arg_conv.inner = untag_ptr(this_arg);
33321         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33323         this_arg_conv.is_owned = false;
33324         LDKC2Tuple_OutPointCVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_u8ZZ), "LDKC2Tuple_OutPointCVec_u8ZZ");
33325         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
33326         return tag_ptr(ret_conv, true);
33327 }
33328
33329 int64_tArray  CS_LDK_ChannelMonitor_get_outputs_to_watch(int64_t this_arg) {
33330         LDKChannelMonitor this_arg_conv;
33331         this_arg_conv.inner = untag_ptr(this_arg);
33332         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33334         this_arg_conv.is_owned = false;
33335         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
33336         int64_tArray ret_arr = NULL;
33337         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33338         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33339         for (size_t a = 0; a < ret_var.datalen; a++) {
33340                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* ret_conv_52_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ");
33341                 *ret_conv_52_conv = ret_var.data[a];
33342                 ret_arr_ptr[a] = tag_ptr(ret_conv_52_conv, true);
33343         }
33344         
33345         FREE(ret_var.data);
33346         return ret_arr;
33347 }
33348
33349 void  CS_LDK_ChannelMonitor_load_outputs_to_watch(int64_t this_arg, int64_t filter) {
33350         LDKChannelMonitor this_arg_conv;
33351         this_arg_conv.inner = untag_ptr(this_arg);
33352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33354         this_arg_conv.is_owned = false;
33355         void* filter_ptr = untag_ptr(filter);
33356         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
33357         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
33358         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
33359 }
33360
33361 int64_tArray  CS_LDK_ChannelMonitor_get_and_clear_pending_monitor_events(int64_t this_arg) {
33362         LDKChannelMonitor this_arg_conv;
33363         this_arg_conv.inner = untag_ptr(this_arg);
33364         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33366         this_arg_conv.is_owned = false;
33367         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
33368         int64_tArray ret_arr = NULL;
33369         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33370         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33371         for (size_t o = 0; o < ret_var.datalen; o++) {
33372                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
33373                 *ret_conv_14_copy = ret_var.data[o];
33374                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
33375                 ret_arr_ptr[o] = ret_conv_14_ref;
33376         }
33377         
33378         FREE(ret_var.data);
33379         return ret_arr;
33380 }
33381
33382 void  CS_LDK_ChannelMonitor_process_pending_events(int64_t this_arg, int64_t handler) {
33383         LDKChannelMonitor this_arg_conv;
33384         this_arg_conv.inner = untag_ptr(this_arg);
33385         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33387         this_arg_conv.is_owned = false;
33388         void* handler_ptr = untag_ptr(handler);
33389         if (ptr_is_owned(handler)) { CHECK_ACCESS(handler_ptr); }
33390         LDKEventHandler* handler_conv = (LDKEventHandler*)handler_ptr;
33391         ChannelMonitor_process_pending_events(&this_arg_conv, handler_conv);
33392 }
33393
33394 int64_t  CS_LDK_ChannelMonitor_initial_counterparty_commitment_tx(int64_t this_arg) {
33395         LDKChannelMonitor this_arg_conv;
33396         this_arg_conv.inner = untag_ptr(this_arg);
33397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33399         this_arg_conv.is_owned = false;
33400         LDKCommitmentTransaction ret_var = ChannelMonitor_initial_counterparty_commitment_tx(&this_arg_conv);
33401         int64_t ret_ref = 0;
33402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33403         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33404         return ret_ref;
33405 }
33406
33407 int64_tArray  CS_LDK_ChannelMonitor_counterparty_commitment_txs_from_update(int64_t this_arg, int64_t update) {
33408         LDKChannelMonitor this_arg_conv;
33409         this_arg_conv.inner = untag_ptr(this_arg);
33410         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33412         this_arg_conv.is_owned = false;
33413         LDKChannelMonitorUpdate update_conv;
33414         update_conv.inner = untag_ptr(update);
33415         update_conv.is_owned = ptr_is_owned(update);
33416         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
33417         update_conv.is_owned = false;
33418         LDKCVec_CommitmentTransactionZ ret_var = ChannelMonitor_counterparty_commitment_txs_from_update(&this_arg_conv, &update_conv);
33419         int64_tArray ret_arr = NULL;
33420         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33421         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33422         for (size_t x = 0; x < ret_var.datalen; x++) {
33423                 LDKCommitmentTransaction ret_conv_23_var = ret_var.data[x];
33424                 int64_t ret_conv_23_ref = 0;
33425                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_23_var);
33426                 ret_conv_23_ref = tag_ptr(ret_conv_23_var.inner, ret_conv_23_var.is_owned);
33427                 ret_arr_ptr[x] = ret_conv_23_ref;
33428         }
33429         
33430         FREE(ret_var.data);
33431         return ret_arr;
33432 }
33433
33434 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) {
33435         LDKChannelMonitor this_arg_conv;
33436         this_arg_conv.inner = untag_ptr(this_arg);
33437         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33439         this_arg_conv.is_owned = false;
33440         LDKTransaction justice_tx_ref;
33441         justice_tx_ref.datalen = justice_tx->arr_len;
33442         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
33443         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
33444         justice_tx_ref.data_is_owned = true;
33445         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
33446         *ret_conv = ChannelMonitor_sign_to_local_justice_tx(&this_arg_conv, justice_tx_ref, input_idx, value, commitment_number);
33447         return tag_ptr(ret_conv, true);
33448 }
33449
33450 int8_tArray  CS_LDK_ChannelMonitor_get_counterparty_node_id(int64_t this_arg) {
33451         LDKChannelMonitor this_arg_conv;
33452         this_arg_conv.inner = untag_ptr(this_arg);
33453         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33455         this_arg_conv.is_owned = false;
33456         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33457         memcpy(ret_arr->elems, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form, 33);
33458         return ret_arr;
33459 }
33460
33461 ptrArray  CS_LDK_ChannelMonitor_get_latest_holder_commitment_txn(int64_t this_arg, int64_t logger) {
33462         LDKChannelMonitor this_arg_conv;
33463         this_arg_conv.inner = untag_ptr(this_arg);
33464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33466         this_arg_conv.is_owned = false;
33467         void* logger_ptr = untag_ptr(logger);
33468         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
33469         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
33470         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
33471         ptrArray ret_arr = NULL;
33472         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
33473         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
33474         for (size_t i = 0; i < ret_var.datalen; i++) {
33475                 LDKTransaction ret_conv_8_var = ret_var.data[i];
33476                 int8_tArray ret_conv_8_arr = init_int8_tArray(ret_conv_8_var.datalen, __LINE__);
33477                 memcpy(ret_conv_8_arr->elems, ret_conv_8_var.data, ret_conv_8_var.datalen);
33478                 Transaction_free(ret_conv_8_var);
33479                 ret_arr_ptr[i] = ret_conv_8_arr;
33480         }
33481         
33482         FREE(ret_var.data);
33483         return ret_arr;
33484 }
33485
33486 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) {
33487         LDKChannelMonitor this_arg_conv;
33488         this_arg_conv.inner = untag_ptr(this_arg);
33489         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33491         this_arg_conv.is_owned = false;
33492         uint8_t header_arr[80];
33493         CHECK(header->arr_len == 80);
33494         memcpy(header_arr, header->elems, 80); FREE(header);
33495         uint8_t (*header_ref)[80] = &header_arr;
33496         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
33497         txdata_constr.datalen = txdata->arr_len;
33498         if (txdata_constr.datalen > 0)
33499                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
33500         else
33501                 txdata_constr.data = NULL;
33502         int64_t* txdata_vals = txdata->elems;
33503         for (size_t c = 0; c < txdata_constr.datalen; c++) {
33504                 int64_t txdata_conv_28 = txdata_vals[c];
33505                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
33506                 CHECK_ACCESS(txdata_conv_28_ptr);
33507                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
33508                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
33509                 txdata_constr.data[c] = txdata_conv_28_conv;
33510         }
33511         FREE(txdata);
33512         void* broadcaster_ptr = untag_ptr(broadcaster);
33513         CHECK_ACCESS(broadcaster_ptr);
33514         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33515         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33516                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33517                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33518         }
33519         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33520         CHECK_ACCESS(fee_estimator_ptr);
33521         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33522         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33523                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33524                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33525         }
33526         void* logger_ptr = untag_ptr(logger);
33527         CHECK_ACCESS(logger_ptr);
33528         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33529         if (logger_conv.free == LDKLogger_JCalls_free) {
33530                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33531                 LDKLogger_JCalls_cloned(&logger_conv);
33532         }
33533         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);
33534         int64_tArray ret_arr = NULL;
33535         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33536         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33537         for (size_t x = 0; x < ret_var.datalen; x++) {
33538                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
33539                 *ret_conv_49_conv = ret_var.data[x];
33540                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
33541         }
33542         
33543         FREE(ret_var.data);
33544         return ret_arr;
33545 }
33546
33547 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) {
33548         LDKChannelMonitor this_arg_conv;
33549         this_arg_conv.inner = untag_ptr(this_arg);
33550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33552         this_arg_conv.is_owned = false;
33553         uint8_t header_arr[80];
33554         CHECK(header->arr_len == 80);
33555         memcpy(header_arr, header->elems, 80); FREE(header);
33556         uint8_t (*header_ref)[80] = &header_arr;
33557         void* broadcaster_ptr = untag_ptr(broadcaster);
33558         CHECK_ACCESS(broadcaster_ptr);
33559         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33560         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33561                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33562                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33563         }
33564         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33565         CHECK_ACCESS(fee_estimator_ptr);
33566         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33567         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33568                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33569                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33570         }
33571         void* logger_ptr = untag_ptr(logger);
33572         CHECK_ACCESS(logger_ptr);
33573         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33574         if (logger_conv.free == LDKLogger_JCalls_free) {
33575                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33576                 LDKLogger_JCalls_cloned(&logger_conv);
33577         }
33578         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
33579 }
33580
33581 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) {
33582         LDKChannelMonitor this_arg_conv;
33583         this_arg_conv.inner = untag_ptr(this_arg);
33584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33586         this_arg_conv.is_owned = false;
33587         uint8_t header_arr[80];
33588         CHECK(header->arr_len == 80);
33589         memcpy(header_arr, header->elems, 80); FREE(header);
33590         uint8_t (*header_ref)[80] = &header_arr;
33591         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
33592         txdata_constr.datalen = txdata->arr_len;
33593         if (txdata_constr.datalen > 0)
33594                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
33595         else
33596                 txdata_constr.data = NULL;
33597         int64_t* txdata_vals = txdata->elems;
33598         for (size_t c = 0; c < txdata_constr.datalen; c++) {
33599                 int64_t txdata_conv_28 = txdata_vals[c];
33600                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
33601                 CHECK_ACCESS(txdata_conv_28_ptr);
33602                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
33603                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
33604                 txdata_constr.data[c] = txdata_conv_28_conv;
33605         }
33606         FREE(txdata);
33607         void* broadcaster_ptr = untag_ptr(broadcaster);
33608         CHECK_ACCESS(broadcaster_ptr);
33609         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33610         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33611                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33612                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33613         }
33614         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33615         CHECK_ACCESS(fee_estimator_ptr);
33616         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33617         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33618                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33619                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33620         }
33621         void* logger_ptr = untag_ptr(logger);
33622         CHECK_ACCESS(logger_ptr);
33623         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33624         if (logger_conv.free == LDKLogger_JCalls_free) {
33625                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33626                 LDKLogger_JCalls_cloned(&logger_conv);
33627         }
33628         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);
33629         int64_tArray ret_arr = NULL;
33630         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33631         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33632         for (size_t x = 0; x < ret_var.datalen; x++) {
33633                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
33634                 *ret_conv_49_conv = ret_var.data[x];
33635                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
33636         }
33637         
33638         FREE(ret_var.data);
33639         return ret_arr;
33640 }
33641
33642 void  CS_LDK_ChannelMonitor_transaction_unconfirmed(int64_t this_arg, int8_tArray txid, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33643         LDKChannelMonitor this_arg_conv;
33644         this_arg_conv.inner = untag_ptr(this_arg);
33645         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33647         this_arg_conv.is_owned = false;
33648         uint8_t txid_arr[32];
33649         CHECK(txid->arr_len == 32);
33650         memcpy(txid_arr, txid->elems, 32); FREE(txid);
33651         uint8_t (*txid_ref)[32] = &txid_arr;
33652         void* broadcaster_ptr = untag_ptr(broadcaster);
33653         CHECK_ACCESS(broadcaster_ptr);
33654         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33655         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33656                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33657                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33658         }
33659         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33660         CHECK_ACCESS(fee_estimator_ptr);
33661         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33662         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33663                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33664                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33665         }
33666         void* logger_ptr = untag_ptr(logger);
33667         CHECK_ACCESS(logger_ptr);
33668         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33669         if (logger_conv.free == LDKLogger_JCalls_free) {
33670                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33671                 LDKLogger_JCalls_cloned(&logger_conv);
33672         }
33673         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
33674 }
33675
33676 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) {
33677         LDKChannelMonitor this_arg_conv;
33678         this_arg_conv.inner = untag_ptr(this_arg);
33679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33681         this_arg_conv.is_owned = false;
33682         uint8_t header_arr[80];
33683         CHECK(header->arr_len == 80);
33684         memcpy(header_arr, header->elems, 80); FREE(header);
33685         uint8_t (*header_ref)[80] = &header_arr;
33686         void* broadcaster_ptr = untag_ptr(broadcaster);
33687         CHECK_ACCESS(broadcaster_ptr);
33688         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33689         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33690                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33691                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33692         }
33693         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33694         CHECK_ACCESS(fee_estimator_ptr);
33695         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33696         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33697                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33698                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33699         }
33700         void* logger_ptr = untag_ptr(logger);
33701         CHECK_ACCESS(logger_ptr);
33702         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33703         if (logger_conv.free == LDKLogger_JCalls_free) {
33704                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33705                 LDKLogger_JCalls_cloned(&logger_conv);
33706         }
33707         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
33708         int64_tArray ret_arr = NULL;
33709         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33710         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33711         for (size_t x = 0; x < ret_var.datalen; x++) {
33712                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
33713                 *ret_conv_49_conv = ret_var.data[x];
33714                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
33715         }
33716         
33717         FREE(ret_var.data);
33718         return ret_arr;
33719 }
33720
33721 int64_tArray  CS_LDK_ChannelMonitor_get_relevant_txids(int64_t this_arg) {
33722         LDKChannelMonitor this_arg_conv;
33723         this_arg_conv.inner = untag_ptr(this_arg);
33724         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33726         this_arg_conv.is_owned = false;
33727         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
33728         int64_tArray ret_arr = NULL;
33729         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33730         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33731         for (size_t x = 0; x < ret_var.datalen; x++) {
33732                 LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
33733                 *ret_conv_49_conv = ret_var.data[x];
33734                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
33735         }
33736         
33737         FREE(ret_var.data);
33738         return ret_arr;
33739 }
33740
33741 int64_t  CS_LDK_ChannelMonitor_current_best_block(int64_t this_arg) {
33742         LDKChannelMonitor this_arg_conv;
33743         this_arg_conv.inner = untag_ptr(this_arg);
33744         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33746         this_arg_conv.is_owned = false;
33747         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
33748         int64_t ret_ref = 0;
33749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33751         return ret_ref;
33752 }
33753
33754 void  CS_LDK_ChannelMonitor_rebroadcast_pending_claims(int64_t this_arg, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33755         LDKChannelMonitor this_arg_conv;
33756         this_arg_conv.inner = untag_ptr(this_arg);
33757         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33759         this_arg_conv.is_owned = false;
33760         void* broadcaster_ptr = untag_ptr(broadcaster);
33761         CHECK_ACCESS(broadcaster_ptr);
33762         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33763         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33764                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33765                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33766         }
33767         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33768         CHECK_ACCESS(fee_estimator_ptr);
33769         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33770         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33771                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33772                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33773         }
33774         void* logger_ptr = untag_ptr(logger);
33775         CHECK_ACCESS(logger_ptr);
33776         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33777         if (logger_conv.free == LDKLogger_JCalls_free) {
33778                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33779                 LDKLogger_JCalls_cloned(&logger_conv);
33780         }
33781         ChannelMonitor_rebroadcast_pending_claims(&this_arg_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
33782 }
33783
33784 int64_tArray  CS_LDK_ChannelMonitor_get_spendable_outputs(int64_t this_arg, int8_tArray tx, int32_t confirmation_height) {
33785         LDKChannelMonitor this_arg_conv;
33786         this_arg_conv.inner = untag_ptr(this_arg);
33787         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33789         this_arg_conv.is_owned = false;
33790         LDKTransaction tx_ref;
33791         tx_ref.datalen = tx->arr_len;
33792         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
33793         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
33794         tx_ref.data_is_owned = true;
33795         LDKCVec_SpendableOutputDescriptorZ ret_var = ChannelMonitor_get_spendable_outputs(&this_arg_conv, tx_ref, confirmation_height);
33796         int64_tArray ret_arr = NULL;
33797         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33798         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33799         for (size_t b = 0; b < ret_var.datalen; b++) {
33800                 LDKSpendableOutputDescriptor *ret_conv_27_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
33801                 *ret_conv_27_copy = ret_var.data[b];
33802                 int64_t ret_conv_27_ref = tag_ptr(ret_conv_27_copy, true);
33803                 ret_arr_ptr[b] = ret_conv_27_ref;
33804         }
33805         
33806         FREE(ret_var.data);
33807         return ret_arr;
33808 }
33809
33810 int64_tArray  CS_LDK_ChannelMonitor_get_claimable_balances(int64_t this_arg) {
33811         LDKChannelMonitor this_arg_conv;
33812         this_arg_conv.inner = untag_ptr(this_arg);
33813         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33815         this_arg_conv.is_owned = false;
33816         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
33817         int64_tArray ret_arr = NULL;
33818         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33819         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33820         for (size_t j = 0; j < ret_var.datalen; j++) {
33821                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33822                 *ret_conv_9_copy = ret_var.data[j];
33823                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
33824                 ret_arr_ptr[j] = ret_conv_9_ref;
33825         }
33826         
33827         FREE(ret_var.data);
33828         return ret_arr;
33829 }
33830
33831 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(int8_tArray ser, int64_t arg_a, int64_t arg_b) {
33832         LDKu8slice ser_ref;
33833         ser_ref.datalen = ser->arr_len;
33834         ser_ref.data = ser->elems;
33835         void* arg_a_ptr = untag_ptr(arg_a);
33836         if (ptr_is_owned(arg_a)) { CHECK_ACCESS(arg_a_ptr); }
33837         LDKEntropySource* arg_a_conv = (LDKEntropySource*)arg_a_ptr;
33838         void* arg_b_ptr = untag_ptr(arg_b);
33839         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
33840         LDKSignerProvider* arg_b_conv = (LDKSignerProvider*)arg_b_ptr;
33841         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
33842         *ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(ser_ref, arg_a_conv, arg_b_conv);
33843         FREE(ser);
33844         return tag_ptr(ret_conv, true);
33845 }
33846
33847 void  CS_LDK_OutPoint_free(int64_t this_obj) {
33848         LDKOutPoint this_obj_conv;
33849         this_obj_conv.inner = untag_ptr(this_obj);
33850         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33852         OutPoint_free(this_obj_conv);
33853 }
33854
33855 int8_tArray  CS_LDK_OutPoint_get_txid(int64_t this_ptr) {
33856         LDKOutPoint this_ptr_conv;
33857         this_ptr_conv.inner = untag_ptr(this_ptr);
33858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33860         this_ptr_conv.is_owned = false;
33861         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33862         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
33863         return ret_arr;
33864 }
33865
33866 void  CS_LDK_OutPoint_set_txid(int64_t this_ptr, int8_tArray val) {
33867         LDKOutPoint this_ptr_conv;
33868         this_ptr_conv.inner = untag_ptr(this_ptr);
33869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33871         this_ptr_conv.is_owned = false;
33872         LDKThirtyTwoBytes val_ref;
33873         CHECK(val->arr_len == 32);
33874         memcpy(val_ref.data, val->elems, 32); FREE(val);
33875         OutPoint_set_txid(&this_ptr_conv, val_ref);
33876 }
33877
33878 int16_t  CS_LDK_OutPoint_get_index(int64_t this_ptr) {
33879         LDKOutPoint this_ptr_conv;
33880         this_ptr_conv.inner = untag_ptr(this_ptr);
33881         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33883         this_ptr_conv.is_owned = false;
33884         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
33885         return ret_conv;
33886 }
33887
33888 void  CS_LDK_OutPoint_set_index(int64_t this_ptr, int16_t val) {
33889         LDKOutPoint this_ptr_conv;
33890         this_ptr_conv.inner = untag_ptr(this_ptr);
33891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33893         this_ptr_conv.is_owned = false;
33894         OutPoint_set_index(&this_ptr_conv, val);
33895 }
33896
33897 int64_t  CS_LDK_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
33898         LDKThirtyTwoBytes txid_arg_ref;
33899         CHECK(txid_arg->arr_len == 32);
33900         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
33901         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
33902         int64_t ret_ref = 0;
33903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33905         return ret_ref;
33906 }
33907
33908 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
33909         LDKOutPoint ret_var = OutPoint_clone(arg);
33910         int64_t ret_ref = 0;
33911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33913         return ret_ref;
33914 }
33915 int64_t  CS_LDK_OutPoint_clone_ptr(int64_t arg) {
33916         LDKOutPoint arg_conv;
33917         arg_conv.inner = untag_ptr(arg);
33918         arg_conv.is_owned = ptr_is_owned(arg);
33919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33920         arg_conv.is_owned = false;
33921         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
33922         return ret_conv;
33923 }
33924
33925 int64_t  CS_LDK_OutPoint_clone(int64_t orig) {
33926         LDKOutPoint orig_conv;
33927         orig_conv.inner = untag_ptr(orig);
33928         orig_conv.is_owned = ptr_is_owned(orig);
33929         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33930         orig_conv.is_owned = false;
33931         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
33932         int64_t ret_ref = 0;
33933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33935         return ret_ref;
33936 }
33937
33938 jboolean  CS_LDK_OutPoint_eq(int64_t a, int64_t b) {
33939         LDKOutPoint a_conv;
33940         a_conv.inner = untag_ptr(a);
33941         a_conv.is_owned = ptr_is_owned(a);
33942         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33943         a_conv.is_owned = false;
33944         LDKOutPoint b_conv;
33945         b_conv.inner = untag_ptr(b);
33946         b_conv.is_owned = ptr_is_owned(b);
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33948         b_conv.is_owned = false;
33949         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
33950         return ret_conv;
33951 }
33952
33953 int64_t  CS_LDK_OutPoint_hash(int64_t o) {
33954         LDKOutPoint o_conv;
33955         o_conv.inner = untag_ptr(o);
33956         o_conv.is_owned = ptr_is_owned(o);
33957         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33958         o_conv.is_owned = false;
33959         int64_t ret_conv = OutPoint_hash(&o_conv);
33960         return ret_conv;
33961 }
33962
33963 int8_tArray  CS_LDK_OutPoint_to_channel_id(int64_t this_arg) {
33964         LDKOutPoint this_arg_conv;
33965         this_arg_conv.inner = untag_ptr(this_arg);
33966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33968         this_arg_conv.is_owned = false;
33969         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33970         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
33971         return ret_arr;
33972 }
33973
33974 int8_tArray  CS_LDK_OutPoint_write(int64_t obj) {
33975         LDKOutPoint obj_conv;
33976         obj_conv.inner = untag_ptr(obj);
33977         obj_conv.is_owned = ptr_is_owned(obj);
33978         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33979         obj_conv.is_owned = false;
33980         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
33981         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33982         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33983         CVec_u8Z_free(ret_var);
33984         return ret_arr;
33985 }
33986
33987 int64_t  CS_LDK_OutPoint_read(int8_tArray ser) {
33988         LDKu8slice ser_ref;
33989         ser_ref.datalen = ser->arr_len;
33990         ser_ref.data = ser->elems;
33991         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
33992         *ret_conv = OutPoint_read(ser_ref);
33993         FREE(ser);
33994         return tag_ptr(ret_conv, true);
33995 }
33996
33997 void  CS_LDK_FailureCode_free(int64_t this_ptr) {
33998         if (!ptr_is_owned(this_ptr)) return;
33999         void* this_ptr_ptr = untag_ptr(this_ptr);
34000         CHECK_ACCESS(this_ptr_ptr);
34001         LDKFailureCode this_ptr_conv = *(LDKFailureCode*)(this_ptr_ptr);
34002         FREE(untag_ptr(this_ptr));
34003         FailureCode_free(this_ptr_conv);
34004 }
34005
34006 static inline uint64_t FailureCode_clone_ptr(LDKFailureCode *NONNULL_PTR arg) {
34007         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34008         *ret_copy = FailureCode_clone(arg);
34009         int64_t ret_ref = tag_ptr(ret_copy, true);
34010         return ret_ref;
34011 }
34012 int64_t  CS_LDK_FailureCode_clone_ptr(int64_t arg) {
34013         LDKFailureCode* arg_conv = (LDKFailureCode*)untag_ptr(arg);
34014         int64_t ret_conv = FailureCode_clone_ptr(arg_conv);
34015         return ret_conv;
34016 }
34017
34018 int64_t  CS_LDK_FailureCode_clone(int64_t orig) {
34019         LDKFailureCode* orig_conv = (LDKFailureCode*)untag_ptr(orig);
34020         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34021         *ret_copy = FailureCode_clone(orig_conv);
34022         int64_t ret_ref = tag_ptr(ret_copy, true);
34023         return ret_ref;
34024 }
34025
34026 int64_t  CS_LDK_FailureCode_temporary_node_failure() {
34027         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34028         *ret_copy = FailureCode_temporary_node_failure();
34029         int64_t ret_ref = tag_ptr(ret_copy, true);
34030         return ret_ref;
34031 }
34032
34033 int64_t  CS_LDK_FailureCode_required_node_feature_missing() {
34034         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34035         *ret_copy = FailureCode_required_node_feature_missing();
34036         int64_t ret_ref = tag_ptr(ret_copy, true);
34037         return ret_ref;
34038 }
34039
34040 int64_t  CS_LDK_FailureCode_incorrect_or_unknown_payment_details() {
34041         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34042         *ret_copy = FailureCode_incorrect_or_unknown_payment_details();
34043         int64_t ret_ref = tag_ptr(ret_copy, true);
34044         return ret_ref;
34045 }
34046
34047 int64_t  CS_LDK_FailureCode_invalid_onion_payload(int64_t a) {
34048         void* a_ptr = untag_ptr(a);
34049         CHECK_ACCESS(a_ptr);
34050         LDKCOption_C2Tuple_u64u16ZZ a_conv = *(LDKCOption_C2Tuple_u64u16ZZ*)(a_ptr);
34051         a_conv = COption_C2Tuple_u64u16ZZ_clone((LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(a));
34052         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34053         *ret_copy = FailureCode_invalid_onion_payload(a_conv);
34054         int64_t ret_ref = tag_ptr(ret_copy, true);
34055         return ret_ref;
34056 }
34057
34058 void  CS_LDK_ChannelManager_free(int64_t this_obj) {
34059         LDKChannelManager this_obj_conv;
34060         this_obj_conv.inner = untag_ptr(this_obj);
34061         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34063         ChannelManager_free(this_obj_conv);
34064 }
34065
34066 void  CS_LDK_ChainParameters_free(int64_t this_obj) {
34067         LDKChainParameters this_obj_conv;
34068         this_obj_conv.inner = untag_ptr(this_obj);
34069         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34071         ChainParameters_free(this_obj_conv);
34072 }
34073
34074 int32_t  CS_LDK_ChainParameters_get_network(int64_t this_ptr) {
34075         LDKChainParameters this_ptr_conv;
34076         this_ptr_conv.inner = untag_ptr(this_ptr);
34077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34079         this_ptr_conv.is_owned = false;
34080         int32_t ret_conv = LDKNetwork_to_cs(ChainParameters_get_network(&this_ptr_conv));
34081         return ret_conv;
34082 }
34083
34084 void  CS_LDK_ChainParameters_set_network(int64_t this_ptr, int32_t val) {
34085         LDKChainParameters this_ptr_conv;
34086         this_ptr_conv.inner = untag_ptr(this_ptr);
34087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34089         this_ptr_conv.is_owned = false;
34090         LDKNetwork val_conv = LDKNetwork_from_cs(val);
34091         ChainParameters_set_network(&this_ptr_conv, val_conv);
34092 }
34093
34094 int64_t  CS_LDK_ChainParameters_get_best_block(int64_t this_ptr) {
34095         LDKChainParameters this_ptr_conv;
34096         this_ptr_conv.inner = untag_ptr(this_ptr);
34097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34099         this_ptr_conv.is_owned = false;
34100         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
34101         int64_t ret_ref = 0;
34102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34104         return ret_ref;
34105 }
34106
34107 void  CS_LDK_ChainParameters_set_best_block(int64_t this_ptr, int64_t val) {
34108         LDKChainParameters this_ptr_conv;
34109         this_ptr_conv.inner = untag_ptr(this_ptr);
34110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34112         this_ptr_conv.is_owned = false;
34113         LDKBestBlock val_conv;
34114         val_conv.inner = untag_ptr(val);
34115         val_conv.is_owned = ptr_is_owned(val);
34116         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34117         val_conv = BestBlock_clone(&val_conv);
34118         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
34119 }
34120
34121 int64_t  CS_LDK_ChainParameters_new(int32_t network_arg, int64_t best_block_arg) {
34122         LDKNetwork network_arg_conv = LDKNetwork_from_cs(network_arg);
34123         LDKBestBlock best_block_arg_conv;
34124         best_block_arg_conv.inner = untag_ptr(best_block_arg);
34125         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
34126         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
34127         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
34128         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
34129         int64_t ret_ref = 0;
34130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34132         return ret_ref;
34133 }
34134
34135 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
34136         LDKChainParameters ret_var = ChainParameters_clone(arg);
34137         int64_t ret_ref = 0;
34138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34140         return ret_ref;
34141 }
34142 int64_t  CS_LDK_ChainParameters_clone_ptr(int64_t arg) {
34143         LDKChainParameters arg_conv;
34144         arg_conv.inner = untag_ptr(arg);
34145         arg_conv.is_owned = ptr_is_owned(arg);
34146         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34147         arg_conv.is_owned = false;
34148         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
34149         return ret_conv;
34150 }
34151
34152 int64_t  CS_LDK_ChainParameters_clone(int64_t orig) {
34153         LDKChainParameters orig_conv;
34154         orig_conv.inner = untag_ptr(orig);
34155         orig_conv.is_owned = ptr_is_owned(orig);
34156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34157         orig_conv.is_owned = false;
34158         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
34159         int64_t ret_ref = 0;
34160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34161         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34162         return ret_ref;
34163 }
34164
34165 void  CS_LDK_CounterpartyForwardingInfo_free(int64_t this_obj) {
34166         LDKCounterpartyForwardingInfo this_obj_conv;
34167         this_obj_conv.inner = untag_ptr(this_obj);
34168         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34170         CounterpartyForwardingInfo_free(this_obj_conv);
34171 }
34172
34173 int32_t  CS_LDK_CounterpartyForwardingInfo_get_fee_base_msat(int64_t this_ptr) {
34174         LDKCounterpartyForwardingInfo this_ptr_conv;
34175         this_ptr_conv.inner = untag_ptr(this_ptr);
34176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34178         this_ptr_conv.is_owned = false;
34179         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
34180         return ret_conv;
34181 }
34182
34183 void  CS_LDK_CounterpartyForwardingInfo_set_fee_base_msat(int64_t this_ptr, int32_t val) {
34184         LDKCounterpartyForwardingInfo this_ptr_conv;
34185         this_ptr_conv.inner = untag_ptr(this_ptr);
34186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34188         this_ptr_conv.is_owned = false;
34189         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
34190 }
34191
34192 int32_t  CS_LDK_CounterpartyForwardingInfo_get_fee_proportional_millionths(int64_t this_ptr) {
34193         LDKCounterpartyForwardingInfo this_ptr_conv;
34194         this_ptr_conv.inner = untag_ptr(this_ptr);
34195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34197         this_ptr_conv.is_owned = false;
34198         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
34199         return ret_conv;
34200 }
34201
34202 void  CS_LDK_CounterpartyForwardingInfo_set_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
34203         LDKCounterpartyForwardingInfo this_ptr_conv;
34204         this_ptr_conv.inner = untag_ptr(this_ptr);
34205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34207         this_ptr_conv.is_owned = false;
34208         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
34209 }
34210
34211 int16_t  CS_LDK_CounterpartyForwardingInfo_get_cltv_expiry_delta(int64_t this_ptr) {
34212         LDKCounterpartyForwardingInfo this_ptr_conv;
34213         this_ptr_conv.inner = untag_ptr(this_ptr);
34214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34216         this_ptr_conv.is_owned = false;
34217         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
34218         return ret_conv;
34219 }
34220
34221 void  CS_LDK_CounterpartyForwardingInfo_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
34222         LDKCounterpartyForwardingInfo this_ptr_conv;
34223         this_ptr_conv.inner = untag_ptr(this_ptr);
34224         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34226         this_ptr_conv.is_owned = false;
34227         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
34228 }
34229
34230 int64_t  CS_LDK_CounterpartyForwardingInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
34231         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
34232         int64_t ret_ref = 0;
34233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34235         return ret_ref;
34236 }
34237
34238 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
34239         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
34240         int64_t ret_ref = 0;
34241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34243         return ret_ref;
34244 }
34245 int64_t  CS_LDK_CounterpartyForwardingInfo_clone_ptr(int64_t arg) {
34246         LDKCounterpartyForwardingInfo arg_conv;
34247         arg_conv.inner = untag_ptr(arg);
34248         arg_conv.is_owned = ptr_is_owned(arg);
34249         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34250         arg_conv.is_owned = false;
34251         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
34252         return ret_conv;
34253 }
34254
34255 int64_t  CS_LDK_CounterpartyForwardingInfo_clone(int64_t orig) {
34256         LDKCounterpartyForwardingInfo orig_conv;
34257         orig_conv.inner = untag_ptr(orig);
34258         orig_conv.is_owned = ptr_is_owned(orig);
34259         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34260         orig_conv.is_owned = false;
34261         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
34262         int64_t ret_ref = 0;
34263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34264         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34265         return ret_ref;
34266 }
34267
34268 void  CS_LDK_ChannelCounterparty_free(int64_t this_obj) {
34269         LDKChannelCounterparty this_obj_conv;
34270         this_obj_conv.inner = untag_ptr(this_obj);
34271         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34273         ChannelCounterparty_free(this_obj_conv);
34274 }
34275
34276 int8_tArray  CS_LDK_ChannelCounterparty_get_node_id(int64_t this_ptr) {
34277         LDKChannelCounterparty this_ptr_conv;
34278         this_ptr_conv.inner = untag_ptr(this_ptr);
34279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34281         this_ptr_conv.is_owned = false;
34282         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34283         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
34284         return ret_arr;
34285 }
34286
34287 void  CS_LDK_ChannelCounterparty_set_node_id(int64_t this_ptr, int8_tArray val) {
34288         LDKChannelCounterparty this_ptr_conv;
34289         this_ptr_conv.inner = untag_ptr(this_ptr);
34290         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34292         this_ptr_conv.is_owned = false;
34293         LDKPublicKey val_ref;
34294         CHECK(val->arr_len == 33);
34295         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34296         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
34297 }
34298
34299 int64_t  CS_LDK_ChannelCounterparty_get_features(int64_t this_ptr) {
34300         LDKChannelCounterparty this_ptr_conv;
34301         this_ptr_conv.inner = untag_ptr(this_ptr);
34302         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34304         this_ptr_conv.is_owned = false;
34305         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
34306         int64_t ret_ref = 0;
34307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34308         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34309         return ret_ref;
34310 }
34311
34312 void  CS_LDK_ChannelCounterparty_set_features(int64_t this_ptr, int64_t val) {
34313         LDKChannelCounterparty this_ptr_conv;
34314         this_ptr_conv.inner = untag_ptr(this_ptr);
34315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34317         this_ptr_conv.is_owned = false;
34318         LDKInitFeatures val_conv;
34319         val_conv.inner = untag_ptr(val);
34320         val_conv.is_owned = ptr_is_owned(val);
34321         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34322         val_conv = InitFeatures_clone(&val_conv);
34323         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
34324 }
34325
34326 int64_t  CS_LDK_ChannelCounterparty_get_unspendable_punishment_reserve(int64_t this_ptr) {
34327         LDKChannelCounterparty this_ptr_conv;
34328         this_ptr_conv.inner = untag_ptr(this_ptr);
34329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34331         this_ptr_conv.is_owned = false;
34332         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
34333         return ret_conv;
34334 }
34335
34336 void  CS_LDK_ChannelCounterparty_set_unspendable_punishment_reserve(int64_t this_ptr, int64_t val) {
34337         LDKChannelCounterparty this_ptr_conv;
34338         this_ptr_conv.inner = untag_ptr(this_ptr);
34339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34341         this_ptr_conv.is_owned = false;
34342         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
34343 }
34344
34345 int64_t  CS_LDK_ChannelCounterparty_get_forwarding_info(int64_t this_ptr) {
34346         LDKChannelCounterparty this_ptr_conv;
34347         this_ptr_conv.inner = untag_ptr(this_ptr);
34348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34350         this_ptr_conv.is_owned = false;
34351         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
34352         int64_t ret_ref = 0;
34353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34354         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34355         return ret_ref;
34356 }
34357
34358 void  CS_LDK_ChannelCounterparty_set_forwarding_info(int64_t this_ptr, int64_t val) {
34359         LDKChannelCounterparty this_ptr_conv;
34360         this_ptr_conv.inner = untag_ptr(this_ptr);
34361         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34363         this_ptr_conv.is_owned = false;
34364         LDKCounterpartyForwardingInfo val_conv;
34365         val_conv.inner = untag_ptr(val);
34366         val_conv.is_owned = ptr_is_owned(val);
34367         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34368         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
34369         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
34370 }
34371
34372 int64_t  CS_LDK_ChannelCounterparty_get_outbound_htlc_minimum_msat(int64_t this_ptr) {
34373         LDKChannelCounterparty this_ptr_conv;
34374         this_ptr_conv.inner = untag_ptr(this_ptr);
34375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34377         this_ptr_conv.is_owned = false;
34378         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34379         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
34380         int64_t ret_ref = tag_ptr(ret_copy, true);
34381         return ret_ref;
34382 }
34383
34384 void  CS_LDK_ChannelCounterparty_set_outbound_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
34385         LDKChannelCounterparty this_ptr_conv;
34386         this_ptr_conv.inner = untag_ptr(this_ptr);
34387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34389         this_ptr_conv.is_owned = false;
34390         void* val_ptr = untag_ptr(val);
34391         CHECK_ACCESS(val_ptr);
34392         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34393         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34394         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
34395 }
34396
34397 int64_t  CS_LDK_ChannelCounterparty_get_outbound_htlc_maximum_msat(int64_t this_ptr) {
34398         LDKChannelCounterparty this_ptr_conv;
34399         this_ptr_conv.inner = untag_ptr(this_ptr);
34400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34402         this_ptr_conv.is_owned = false;
34403         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34404         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
34405         int64_t ret_ref = tag_ptr(ret_copy, true);
34406         return ret_ref;
34407 }
34408
34409 void  CS_LDK_ChannelCounterparty_set_outbound_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
34410         LDKChannelCounterparty this_ptr_conv;
34411         this_ptr_conv.inner = untag_ptr(this_ptr);
34412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34414         this_ptr_conv.is_owned = false;
34415         void* val_ptr = untag_ptr(val);
34416         CHECK_ACCESS(val_ptr);
34417         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34418         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34419         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
34420 }
34421
34422 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) {
34423         LDKPublicKey node_id_arg_ref;
34424         CHECK(node_id_arg->arr_len == 33);
34425         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
34426         LDKInitFeatures features_arg_conv;
34427         features_arg_conv.inner = untag_ptr(features_arg);
34428         features_arg_conv.is_owned = ptr_is_owned(features_arg);
34429         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34430         features_arg_conv = InitFeatures_clone(&features_arg_conv);
34431         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
34432         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
34433         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
34434         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
34435         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
34436         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
34437         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
34438         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
34439         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
34440         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
34441         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
34442         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
34443         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
34444         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);
34445         int64_t ret_ref = 0;
34446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34447         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34448         return ret_ref;
34449 }
34450
34451 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
34452         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
34453         int64_t ret_ref = 0;
34454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34455         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34456         return ret_ref;
34457 }
34458 int64_t  CS_LDK_ChannelCounterparty_clone_ptr(int64_t arg) {
34459         LDKChannelCounterparty arg_conv;
34460         arg_conv.inner = untag_ptr(arg);
34461         arg_conv.is_owned = ptr_is_owned(arg);
34462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34463         arg_conv.is_owned = false;
34464         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
34465         return ret_conv;
34466 }
34467
34468 int64_t  CS_LDK_ChannelCounterparty_clone(int64_t orig) {
34469         LDKChannelCounterparty orig_conv;
34470         orig_conv.inner = untag_ptr(orig);
34471         orig_conv.is_owned = ptr_is_owned(orig);
34472         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34473         orig_conv.is_owned = false;
34474         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
34475         int64_t ret_ref = 0;
34476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34478         return ret_ref;
34479 }
34480
34481 void  CS_LDK_ChannelDetails_free(int64_t this_obj) {
34482         LDKChannelDetails this_obj_conv;
34483         this_obj_conv.inner = untag_ptr(this_obj);
34484         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34486         ChannelDetails_free(this_obj_conv);
34487 }
34488
34489 int8_tArray  CS_LDK_ChannelDetails_get_channel_id(int64_t this_ptr) {
34490         LDKChannelDetails this_ptr_conv;
34491         this_ptr_conv.inner = untag_ptr(this_ptr);
34492         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34494         this_ptr_conv.is_owned = false;
34495         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34496         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
34497         return ret_arr;
34498 }
34499
34500 void  CS_LDK_ChannelDetails_set_channel_id(int64_t this_ptr, int8_tArray val) {
34501         LDKChannelDetails this_ptr_conv;
34502         this_ptr_conv.inner = untag_ptr(this_ptr);
34503         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34505         this_ptr_conv.is_owned = false;
34506         LDKThirtyTwoBytes val_ref;
34507         CHECK(val->arr_len == 32);
34508         memcpy(val_ref.data, val->elems, 32); FREE(val);
34509         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
34510 }
34511
34512 int64_t  CS_LDK_ChannelDetails_get_counterparty(int64_t this_ptr) {
34513         LDKChannelDetails this_ptr_conv;
34514         this_ptr_conv.inner = untag_ptr(this_ptr);
34515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34517         this_ptr_conv.is_owned = false;
34518         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
34519         int64_t ret_ref = 0;
34520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34522         return ret_ref;
34523 }
34524
34525 void  CS_LDK_ChannelDetails_set_counterparty(int64_t this_ptr, int64_t val) {
34526         LDKChannelDetails this_ptr_conv;
34527         this_ptr_conv.inner = untag_ptr(this_ptr);
34528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34530         this_ptr_conv.is_owned = false;
34531         LDKChannelCounterparty val_conv;
34532         val_conv.inner = untag_ptr(val);
34533         val_conv.is_owned = ptr_is_owned(val);
34534         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34535         val_conv = ChannelCounterparty_clone(&val_conv);
34536         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
34537 }
34538
34539 int64_t  CS_LDK_ChannelDetails_get_funding_txo(int64_t this_ptr) {
34540         LDKChannelDetails this_ptr_conv;
34541         this_ptr_conv.inner = untag_ptr(this_ptr);
34542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34544         this_ptr_conv.is_owned = false;
34545         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
34546         int64_t ret_ref = 0;
34547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34548         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34549         return ret_ref;
34550 }
34551
34552 void  CS_LDK_ChannelDetails_set_funding_txo(int64_t this_ptr, int64_t val) {
34553         LDKChannelDetails this_ptr_conv;
34554         this_ptr_conv.inner = untag_ptr(this_ptr);
34555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34557         this_ptr_conv.is_owned = false;
34558         LDKOutPoint val_conv;
34559         val_conv.inner = untag_ptr(val);
34560         val_conv.is_owned = ptr_is_owned(val);
34561         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34562         val_conv = OutPoint_clone(&val_conv);
34563         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
34564 }
34565
34566 int64_t  CS_LDK_ChannelDetails_get_channel_type(int64_t this_ptr) {
34567         LDKChannelDetails this_ptr_conv;
34568         this_ptr_conv.inner = untag_ptr(this_ptr);
34569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34571         this_ptr_conv.is_owned = false;
34572         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
34573         int64_t ret_ref = 0;
34574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34575         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34576         return ret_ref;
34577 }
34578
34579 void  CS_LDK_ChannelDetails_set_channel_type(int64_t this_ptr, int64_t val) {
34580         LDKChannelDetails this_ptr_conv;
34581         this_ptr_conv.inner = untag_ptr(this_ptr);
34582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34584         this_ptr_conv.is_owned = false;
34585         LDKChannelTypeFeatures val_conv;
34586         val_conv.inner = untag_ptr(val);
34587         val_conv.is_owned = ptr_is_owned(val);
34588         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34589         val_conv = ChannelTypeFeatures_clone(&val_conv);
34590         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
34591 }
34592
34593 int64_t  CS_LDK_ChannelDetails_get_short_channel_id(int64_t this_ptr) {
34594         LDKChannelDetails this_ptr_conv;
34595         this_ptr_conv.inner = untag_ptr(this_ptr);
34596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34598         this_ptr_conv.is_owned = false;
34599         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34600         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
34601         int64_t ret_ref = tag_ptr(ret_copy, true);
34602         return ret_ref;
34603 }
34604
34605 void  CS_LDK_ChannelDetails_set_short_channel_id(int64_t this_ptr, int64_t val) {
34606         LDKChannelDetails this_ptr_conv;
34607         this_ptr_conv.inner = untag_ptr(this_ptr);
34608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34610         this_ptr_conv.is_owned = false;
34611         void* val_ptr = untag_ptr(val);
34612         CHECK_ACCESS(val_ptr);
34613         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34614         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34615         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
34616 }
34617
34618 int64_t  CS_LDK_ChannelDetails_get_outbound_scid_alias(int64_t this_ptr) {
34619         LDKChannelDetails this_ptr_conv;
34620         this_ptr_conv.inner = untag_ptr(this_ptr);
34621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34623         this_ptr_conv.is_owned = false;
34624         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34625         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
34626         int64_t ret_ref = tag_ptr(ret_copy, true);
34627         return ret_ref;
34628 }
34629
34630 void  CS_LDK_ChannelDetails_set_outbound_scid_alias(int64_t this_ptr, int64_t val) {
34631         LDKChannelDetails this_ptr_conv;
34632         this_ptr_conv.inner = untag_ptr(this_ptr);
34633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34635         this_ptr_conv.is_owned = false;
34636         void* val_ptr = untag_ptr(val);
34637         CHECK_ACCESS(val_ptr);
34638         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34639         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34640         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
34641 }
34642
34643 int64_t  CS_LDK_ChannelDetails_get_inbound_scid_alias(int64_t this_ptr) {
34644         LDKChannelDetails this_ptr_conv;
34645         this_ptr_conv.inner = untag_ptr(this_ptr);
34646         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34648         this_ptr_conv.is_owned = false;
34649         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34650         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
34651         int64_t ret_ref = tag_ptr(ret_copy, true);
34652         return ret_ref;
34653 }
34654
34655 void  CS_LDK_ChannelDetails_set_inbound_scid_alias(int64_t this_ptr, int64_t val) {
34656         LDKChannelDetails this_ptr_conv;
34657         this_ptr_conv.inner = untag_ptr(this_ptr);
34658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34660         this_ptr_conv.is_owned = false;
34661         void* val_ptr = untag_ptr(val);
34662         CHECK_ACCESS(val_ptr);
34663         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34664         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34665         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
34666 }
34667
34668 int64_t  CS_LDK_ChannelDetails_get_channel_value_satoshis(int64_t this_ptr) {
34669         LDKChannelDetails this_ptr_conv;
34670         this_ptr_conv.inner = untag_ptr(this_ptr);
34671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34673         this_ptr_conv.is_owned = false;
34674         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
34675         return ret_conv;
34676 }
34677
34678 void  CS_LDK_ChannelDetails_set_channel_value_satoshis(int64_t this_ptr, int64_t val) {
34679         LDKChannelDetails this_ptr_conv;
34680         this_ptr_conv.inner = untag_ptr(this_ptr);
34681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34683         this_ptr_conv.is_owned = false;
34684         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
34685 }
34686
34687 int64_t  CS_LDK_ChannelDetails_get_unspendable_punishment_reserve(int64_t this_ptr) {
34688         LDKChannelDetails this_ptr_conv;
34689         this_ptr_conv.inner = untag_ptr(this_ptr);
34690         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34692         this_ptr_conv.is_owned = false;
34693         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34694         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
34695         int64_t ret_ref = tag_ptr(ret_copy, true);
34696         return ret_ref;
34697 }
34698
34699 void  CS_LDK_ChannelDetails_set_unspendable_punishment_reserve(int64_t this_ptr, int64_t val) {
34700         LDKChannelDetails this_ptr_conv;
34701         this_ptr_conv.inner = untag_ptr(this_ptr);
34702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34704         this_ptr_conv.is_owned = false;
34705         void* val_ptr = untag_ptr(val);
34706         CHECK_ACCESS(val_ptr);
34707         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34708         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34709         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
34710 }
34711
34712 int8_tArray  CS_LDK_ChannelDetails_get_user_channel_id(int64_t this_ptr) {
34713         LDKChannelDetails this_ptr_conv;
34714         this_ptr_conv.inner = untag_ptr(this_ptr);
34715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34717         this_ptr_conv.is_owned = false;
34718         int8_tArray ret_arr = init_int8_tArray(16, __LINE__);
34719         memcpy(ret_arr->elems, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes, 16);
34720         return ret_arr;
34721 }
34722
34723 void  CS_LDK_ChannelDetails_set_user_channel_id(int64_t this_ptr, int8_tArray val) {
34724         LDKChannelDetails this_ptr_conv;
34725         this_ptr_conv.inner = untag_ptr(this_ptr);
34726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34728         this_ptr_conv.is_owned = false;
34729         LDKU128 val_ref;
34730         CHECK(val->arr_len == 16);
34731         memcpy(val_ref.le_bytes, val->elems, 16); FREE(val);
34732         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
34733 }
34734
34735 int64_t  CS_LDK_ChannelDetails_get_feerate_sat_per_1000_weight(int64_t this_ptr) {
34736         LDKChannelDetails this_ptr_conv;
34737         this_ptr_conv.inner = untag_ptr(this_ptr);
34738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34740         this_ptr_conv.is_owned = false;
34741         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
34742         *ret_copy = ChannelDetails_get_feerate_sat_per_1000_weight(&this_ptr_conv);
34743         int64_t ret_ref = tag_ptr(ret_copy, true);
34744         return ret_ref;
34745 }
34746
34747 void  CS_LDK_ChannelDetails_set_feerate_sat_per_1000_weight(int64_t this_ptr, int64_t val) {
34748         LDKChannelDetails this_ptr_conv;
34749         this_ptr_conv.inner = untag_ptr(this_ptr);
34750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34752         this_ptr_conv.is_owned = false;
34753         void* val_ptr = untag_ptr(val);
34754         CHECK_ACCESS(val_ptr);
34755         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
34756         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
34757         ChannelDetails_set_feerate_sat_per_1000_weight(&this_ptr_conv, val_conv);
34758 }
34759
34760 int64_t  CS_LDK_ChannelDetails_get_balance_msat(int64_t this_ptr) {
34761         LDKChannelDetails this_ptr_conv;
34762         this_ptr_conv.inner = untag_ptr(this_ptr);
34763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34765         this_ptr_conv.is_owned = false;
34766         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
34767         return ret_conv;
34768 }
34769
34770 void  CS_LDK_ChannelDetails_set_balance_msat(int64_t this_ptr, int64_t val) {
34771         LDKChannelDetails this_ptr_conv;
34772         this_ptr_conv.inner = untag_ptr(this_ptr);
34773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34775         this_ptr_conv.is_owned = false;
34776         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
34777 }
34778
34779 int64_t  CS_LDK_ChannelDetails_get_outbound_capacity_msat(int64_t this_ptr) {
34780         LDKChannelDetails this_ptr_conv;
34781         this_ptr_conv.inner = untag_ptr(this_ptr);
34782         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34784         this_ptr_conv.is_owned = false;
34785         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
34786         return ret_conv;
34787 }
34788
34789 void  CS_LDK_ChannelDetails_set_outbound_capacity_msat(int64_t this_ptr, int64_t val) {
34790         LDKChannelDetails this_ptr_conv;
34791         this_ptr_conv.inner = untag_ptr(this_ptr);
34792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34794         this_ptr_conv.is_owned = false;
34795         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
34796 }
34797
34798 int64_t  CS_LDK_ChannelDetails_get_next_outbound_htlc_limit_msat(int64_t this_ptr) {
34799         LDKChannelDetails this_ptr_conv;
34800         this_ptr_conv.inner = untag_ptr(this_ptr);
34801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34803         this_ptr_conv.is_owned = false;
34804         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
34805         return ret_conv;
34806 }
34807
34808 void  CS_LDK_ChannelDetails_set_next_outbound_htlc_limit_msat(int64_t this_ptr, int64_t val) {
34809         LDKChannelDetails this_ptr_conv;
34810         this_ptr_conv.inner = untag_ptr(this_ptr);
34811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34813         this_ptr_conv.is_owned = false;
34814         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
34815 }
34816
34817 int64_t  CS_LDK_ChannelDetails_get_next_outbound_htlc_minimum_msat(int64_t this_ptr) {
34818         LDKChannelDetails this_ptr_conv;
34819         this_ptr_conv.inner = untag_ptr(this_ptr);
34820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34822         this_ptr_conv.is_owned = false;
34823         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_minimum_msat(&this_ptr_conv);
34824         return ret_conv;
34825 }
34826
34827 void  CS_LDK_ChannelDetails_set_next_outbound_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
34828         LDKChannelDetails this_ptr_conv;
34829         this_ptr_conv.inner = untag_ptr(this_ptr);
34830         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34832         this_ptr_conv.is_owned = false;
34833         ChannelDetails_set_next_outbound_htlc_minimum_msat(&this_ptr_conv, val);
34834 }
34835
34836 int64_t  CS_LDK_ChannelDetails_get_inbound_capacity_msat(int64_t this_ptr) {
34837         LDKChannelDetails this_ptr_conv;
34838         this_ptr_conv.inner = untag_ptr(this_ptr);
34839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34841         this_ptr_conv.is_owned = false;
34842         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
34843         return ret_conv;
34844 }
34845
34846 void  CS_LDK_ChannelDetails_set_inbound_capacity_msat(int64_t this_ptr, int64_t val) {
34847         LDKChannelDetails this_ptr_conv;
34848         this_ptr_conv.inner = untag_ptr(this_ptr);
34849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34851         this_ptr_conv.is_owned = false;
34852         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
34853 }
34854
34855 int64_t  CS_LDK_ChannelDetails_get_confirmations_required(int64_t this_ptr) {
34856         LDKChannelDetails this_ptr_conv;
34857         this_ptr_conv.inner = untag_ptr(this_ptr);
34858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34860         this_ptr_conv.is_owned = false;
34861         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
34862         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
34863         int64_t ret_ref = tag_ptr(ret_copy, true);
34864         return ret_ref;
34865 }
34866
34867 void  CS_LDK_ChannelDetails_set_confirmations_required(int64_t this_ptr, int64_t val) {
34868         LDKChannelDetails this_ptr_conv;
34869         this_ptr_conv.inner = untag_ptr(this_ptr);
34870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34872         this_ptr_conv.is_owned = false;
34873         void* val_ptr = untag_ptr(val);
34874         CHECK_ACCESS(val_ptr);
34875         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
34876         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
34877         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
34878 }
34879
34880 int64_t  CS_LDK_ChannelDetails_get_confirmations(int64_t this_ptr) {
34881         LDKChannelDetails this_ptr_conv;
34882         this_ptr_conv.inner = untag_ptr(this_ptr);
34883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34885         this_ptr_conv.is_owned = false;
34886         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
34887         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
34888         int64_t ret_ref = tag_ptr(ret_copy, true);
34889         return ret_ref;
34890 }
34891
34892 void  CS_LDK_ChannelDetails_set_confirmations(int64_t this_ptr, int64_t val) {
34893         LDKChannelDetails this_ptr_conv;
34894         this_ptr_conv.inner = untag_ptr(this_ptr);
34895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34897         this_ptr_conv.is_owned = false;
34898         void* val_ptr = untag_ptr(val);
34899         CHECK_ACCESS(val_ptr);
34900         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
34901         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
34902         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
34903 }
34904
34905 int64_t  CS_LDK_ChannelDetails_get_force_close_spend_delay(int64_t this_ptr) {
34906         LDKChannelDetails this_ptr_conv;
34907         this_ptr_conv.inner = untag_ptr(this_ptr);
34908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34910         this_ptr_conv.is_owned = false;
34911         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
34912         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
34913         int64_t ret_ref = tag_ptr(ret_copy, true);
34914         return ret_ref;
34915 }
34916
34917 void  CS_LDK_ChannelDetails_set_force_close_spend_delay(int64_t this_ptr, int64_t val) {
34918         LDKChannelDetails this_ptr_conv;
34919         this_ptr_conv.inner = untag_ptr(this_ptr);
34920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34922         this_ptr_conv.is_owned = false;
34923         void* val_ptr = untag_ptr(val);
34924         CHECK_ACCESS(val_ptr);
34925         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
34926         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
34927         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
34928 }
34929
34930 jboolean  CS_LDK_ChannelDetails_get_is_outbound(int64_t this_ptr) {
34931         LDKChannelDetails this_ptr_conv;
34932         this_ptr_conv.inner = untag_ptr(this_ptr);
34933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34935         this_ptr_conv.is_owned = false;
34936         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
34937         return ret_conv;
34938 }
34939
34940 void  CS_LDK_ChannelDetails_set_is_outbound(int64_t this_ptr, jboolean val) {
34941         LDKChannelDetails this_ptr_conv;
34942         this_ptr_conv.inner = untag_ptr(this_ptr);
34943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34945         this_ptr_conv.is_owned = false;
34946         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
34947 }
34948
34949 jboolean  CS_LDK_ChannelDetails_get_is_channel_ready(int64_t this_ptr) {
34950         LDKChannelDetails this_ptr_conv;
34951         this_ptr_conv.inner = untag_ptr(this_ptr);
34952         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34954         this_ptr_conv.is_owned = false;
34955         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
34956         return ret_conv;
34957 }
34958
34959 void  CS_LDK_ChannelDetails_set_is_channel_ready(int64_t this_ptr, jboolean val) {
34960         LDKChannelDetails this_ptr_conv;
34961         this_ptr_conv.inner = untag_ptr(this_ptr);
34962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34964         this_ptr_conv.is_owned = false;
34965         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
34966 }
34967
34968 int64_t  CS_LDK_ChannelDetails_get_channel_shutdown_state(int64_t this_ptr) {
34969         LDKChannelDetails this_ptr_conv;
34970         this_ptr_conv.inner = untag_ptr(this_ptr);
34971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34973         this_ptr_conv.is_owned = false;
34974         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
34975         *ret_copy = ChannelDetails_get_channel_shutdown_state(&this_ptr_conv);
34976         int64_t ret_ref = tag_ptr(ret_copy, true);
34977         return ret_ref;
34978 }
34979
34980 void  CS_LDK_ChannelDetails_set_channel_shutdown_state(int64_t this_ptr, int64_t val) {
34981         LDKChannelDetails this_ptr_conv;
34982         this_ptr_conv.inner = untag_ptr(this_ptr);
34983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34985         this_ptr_conv.is_owned = false;
34986         void* val_ptr = untag_ptr(val);
34987         CHECK_ACCESS(val_ptr);
34988         LDKCOption_ChannelShutdownStateZ val_conv = *(LDKCOption_ChannelShutdownStateZ*)(val_ptr);
34989         val_conv = COption_ChannelShutdownStateZ_clone((LDKCOption_ChannelShutdownStateZ*)untag_ptr(val));
34990         ChannelDetails_set_channel_shutdown_state(&this_ptr_conv, val_conv);
34991 }
34992
34993 jboolean  CS_LDK_ChannelDetails_get_is_usable(int64_t this_ptr) {
34994         LDKChannelDetails this_ptr_conv;
34995         this_ptr_conv.inner = untag_ptr(this_ptr);
34996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34998         this_ptr_conv.is_owned = false;
34999         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
35000         return ret_conv;
35001 }
35002
35003 void  CS_LDK_ChannelDetails_set_is_usable(int64_t this_ptr, jboolean val) {
35004         LDKChannelDetails this_ptr_conv;
35005         this_ptr_conv.inner = untag_ptr(this_ptr);
35006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35008         this_ptr_conv.is_owned = false;
35009         ChannelDetails_set_is_usable(&this_ptr_conv, val);
35010 }
35011
35012 jboolean  CS_LDK_ChannelDetails_get_is_public(int64_t this_ptr) {
35013         LDKChannelDetails this_ptr_conv;
35014         this_ptr_conv.inner = untag_ptr(this_ptr);
35015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35017         this_ptr_conv.is_owned = false;
35018         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
35019         return ret_conv;
35020 }
35021
35022 void  CS_LDK_ChannelDetails_set_is_public(int64_t this_ptr, jboolean val) {
35023         LDKChannelDetails this_ptr_conv;
35024         this_ptr_conv.inner = untag_ptr(this_ptr);
35025         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35027         this_ptr_conv.is_owned = false;
35028         ChannelDetails_set_is_public(&this_ptr_conv, val);
35029 }
35030
35031 int64_t  CS_LDK_ChannelDetails_get_inbound_htlc_minimum_msat(int64_t this_ptr) {
35032         LDKChannelDetails this_ptr_conv;
35033         this_ptr_conv.inner = untag_ptr(this_ptr);
35034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35036         this_ptr_conv.is_owned = false;
35037         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35038         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
35039         int64_t ret_ref = tag_ptr(ret_copy, true);
35040         return ret_ref;
35041 }
35042
35043 void  CS_LDK_ChannelDetails_set_inbound_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
35044         LDKChannelDetails this_ptr_conv;
35045         this_ptr_conv.inner = untag_ptr(this_ptr);
35046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35048         this_ptr_conv.is_owned = false;
35049         void* val_ptr = untag_ptr(val);
35050         CHECK_ACCESS(val_ptr);
35051         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35052         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
35053         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
35054 }
35055
35056 int64_t  CS_LDK_ChannelDetails_get_inbound_htlc_maximum_msat(int64_t this_ptr) {
35057         LDKChannelDetails this_ptr_conv;
35058         this_ptr_conv.inner = untag_ptr(this_ptr);
35059         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35061         this_ptr_conv.is_owned = false;
35062         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35063         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
35064         int64_t ret_ref = tag_ptr(ret_copy, true);
35065         return ret_ref;
35066 }
35067
35068 void  CS_LDK_ChannelDetails_set_inbound_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
35069         LDKChannelDetails this_ptr_conv;
35070         this_ptr_conv.inner = untag_ptr(this_ptr);
35071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35073         this_ptr_conv.is_owned = false;
35074         void* val_ptr = untag_ptr(val);
35075         CHECK_ACCESS(val_ptr);
35076         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35077         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
35078         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
35079 }
35080
35081 int64_t  CS_LDK_ChannelDetails_get_config(int64_t this_ptr) {
35082         LDKChannelDetails this_ptr_conv;
35083         this_ptr_conv.inner = untag_ptr(this_ptr);
35084         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35086         this_ptr_conv.is_owned = false;
35087         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
35088         int64_t ret_ref = 0;
35089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35091         return ret_ref;
35092 }
35093
35094 void  CS_LDK_ChannelDetails_set_config(int64_t this_ptr, int64_t val) {
35095         LDKChannelDetails this_ptr_conv;
35096         this_ptr_conv.inner = untag_ptr(this_ptr);
35097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35099         this_ptr_conv.is_owned = false;
35100         LDKChannelConfig val_conv;
35101         val_conv.inner = untag_ptr(val);
35102         val_conv.is_owned = ptr_is_owned(val);
35103         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35104         val_conv = ChannelConfig_clone(&val_conv);
35105         ChannelDetails_set_config(&this_ptr_conv, val_conv);
35106 }
35107
35108 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) {
35109         LDKThirtyTwoBytes channel_id_arg_ref;
35110         CHECK(channel_id_arg->arr_len == 32);
35111         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
35112         LDKChannelCounterparty counterparty_arg_conv;
35113         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
35114         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
35115         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
35116         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
35117         LDKOutPoint funding_txo_arg_conv;
35118         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
35119         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
35120         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
35121         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
35122         LDKChannelTypeFeatures channel_type_arg_conv;
35123         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
35124         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
35125         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
35126         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
35127         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
35128         CHECK_ACCESS(short_channel_id_arg_ptr);
35129         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
35130         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
35131         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
35132         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
35133         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
35134         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
35135         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
35136         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
35137         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
35138         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
35139         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
35140         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
35141         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
35142         LDKU128 user_channel_id_arg_ref;
35143         CHECK(user_channel_id_arg->arr_len == 16);
35144         memcpy(user_channel_id_arg_ref.le_bytes, user_channel_id_arg->elems, 16); FREE(user_channel_id_arg);
35145         void* feerate_sat_per_1000_weight_arg_ptr = untag_ptr(feerate_sat_per_1000_weight_arg);
35146         CHECK_ACCESS(feerate_sat_per_1000_weight_arg_ptr);
35147         LDKCOption_u32Z feerate_sat_per_1000_weight_arg_conv = *(LDKCOption_u32Z*)(feerate_sat_per_1000_weight_arg_ptr);
35148         feerate_sat_per_1000_weight_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(feerate_sat_per_1000_weight_arg));
35149         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
35150         CHECK_ACCESS(confirmations_required_arg_ptr);
35151         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
35152         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
35153         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
35154         CHECK_ACCESS(confirmations_arg_ptr);
35155         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
35156         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
35157         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
35158         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
35159         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
35160         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
35161         void* channel_shutdown_state_arg_ptr = untag_ptr(channel_shutdown_state_arg);
35162         CHECK_ACCESS(channel_shutdown_state_arg_ptr);
35163         LDKCOption_ChannelShutdownStateZ channel_shutdown_state_arg_conv = *(LDKCOption_ChannelShutdownStateZ*)(channel_shutdown_state_arg_ptr);
35164         channel_shutdown_state_arg_conv = COption_ChannelShutdownStateZ_clone((LDKCOption_ChannelShutdownStateZ*)untag_ptr(channel_shutdown_state_arg));
35165         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
35166         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
35167         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
35168         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
35169         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
35170         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
35171         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
35172         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
35173         LDKChannelConfig config_arg_conv;
35174         config_arg_conv.inner = untag_ptr(config_arg);
35175         config_arg_conv.is_owned = ptr_is_owned(config_arg);
35176         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
35177         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
35178         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);
35179         int64_t ret_ref = 0;
35180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35182         return ret_ref;
35183 }
35184
35185 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
35186         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
35187         int64_t ret_ref = 0;
35188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35190         return ret_ref;
35191 }
35192 int64_t  CS_LDK_ChannelDetails_clone_ptr(int64_t arg) {
35193         LDKChannelDetails arg_conv;
35194         arg_conv.inner = untag_ptr(arg);
35195         arg_conv.is_owned = ptr_is_owned(arg);
35196         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35197         arg_conv.is_owned = false;
35198         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
35199         return ret_conv;
35200 }
35201
35202 int64_t  CS_LDK_ChannelDetails_clone(int64_t orig) {
35203         LDKChannelDetails orig_conv;
35204         orig_conv.inner = untag_ptr(orig);
35205         orig_conv.is_owned = ptr_is_owned(orig);
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35207         orig_conv.is_owned = false;
35208         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
35209         int64_t ret_ref = 0;
35210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35211         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35212         return ret_ref;
35213 }
35214
35215 int64_t  CS_LDK_ChannelDetails_get_inbound_payment_scid(int64_t this_arg) {
35216         LDKChannelDetails this_arg_conv;
35217         this_arg_conv.inner = untag_ptr(this_arg);
35218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35220         this_arg_conv.is_owned = false;
35221         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35222         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
35223         int64_t ret_ref = tag_ptr(ret_copy, true);
35224         return ret_ref;
35225 }
35226
35227 int64_t  CS_LDK_ChannelDetails_get_outbound_payment_scid(int64_t this_arg) {
35228         LDKChannelDetails this_arg_conv;
35229         this_arg_conv.inner = untag_ptr(this_arg);
35230         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35232         this_arg_conv.is_owned = false;
35233         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35234         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
35235         int64_t ret_ref = tag_ptr(ret_copy, true);
35236         return ret_ref;
35237 }
35238
35239 int32_t  CS_LDK_ChannelShutdownState_clone(int64_t orig) {
35240         LDKChannelShutdownState* orig_conv = (LDKChannelShutdownState*)untag_ptr(orig);
35241         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_clone(orig_conv));
35242         return ret_conv;
35243 }
35244
35245 int32_t  CS_LDK_ChannelShutdownState_not_shutting_down() {
35246         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_not_shutting_down());
35247         return ret_conv;
35248 }
35249
35250 int32_t  CS_LDK_ChannelShutdownState_shutdown_initiated() {
35251         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_shutdown_initiated());
35252         return ret_conv;
35253 }
35254
35255 int32_t  CS_LDK_ChannelShutdownState_resolving_htlcs() {
35256         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_resolving_htlcs());
35257         return ret_conv;
35258 }
35259
35260 int32_t  CS_LDK_ChannelShutdownState_negotiating_closing_fee() {
35261         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_negotiating_closing_fee());
35262         return ret_conv;
35263 }
35264
35265 int32_t  CS_LDK_ChannelShutdownState_shutdown_complete() {
35266         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_shutdown_complete());
35267         return ret_conv;
35268 }
35269
35270 jboolean  CS_LDK_ChannelShutdownState_eq(int64_t a, int64_t b) {
35271         LDKChannelShutdownState* a_conv = (LDKChannelShutdownState*)untag_ptr(a);
35272         LDKChannelShutdownState* b_conv = (LDKChannelShutdownState*)untag_ptr(b);
35273         jboolean ret_conv = ChannelShutdownState_eq(a_conv, b_conv);
35274         return ret_conv;
35275 }
35276
35277 void  CS_LDK_RecentPaymentDetails_free(int64_t this_ptr) {
35278         if (!ptr_is_owned(this_ptr)) return;
35279         void* this_ptr_ptr = untag_ptr(this_ptr);
35280         CHECK_ACCESS(this_ptr_ptr);
35281         LDKRecentPaymentDetails this_ptr_conv = *(LDKRecentPaymentDetails*)(this_ptr_ptr);
35282         FREE(untag_ptr(this_ptr));
35283         RecentPaymentDetails_free(this_ptr_conv);
35284 }
35285
35286 static inline uint64_t RecentPaymentDetails_clone_ptr(LDKRecentPaymentDetails *NONNULL_PTR arg) {
35287         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35288         *ret_copy = RecentPaymentDetails_clone(arg);
35289         int64_t ret_ref = tag_ptr(ret_copy, true);
35290         return ret_ref;
35291 }
35292 int64_t  CS_LDK_RecentPaymentDetails_clone_ptr(int64_t arg) {
35293         LDKRecentPaymentDetails* arg_conv = (LDKRecentPaymentDetails*)untag_ptr(arg);
35294         int64_t ret_conv = RecentPaymentDetails_clone_ptr(arg_conv);
35295         return ret_conv;
35296 }
35297
35298 int64_t  CS_LDK_RecentPaymentDetails_clone(int64_t orig) {
35299         LDKRecentPaymentDetails* orig_conv = (LDKRecentPaymentDetails*)untag_ptr(orig);
35300         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35301         *ret_copy = RecentPaymentDetails_clone(orig_conv);
35302         int64_t ret_ref = tag_ptr(ret_copy, true);
35303         return ret_ref;
35304 }
35305
35306 int64_t  CS_LDK_RecentPaymentDetails_awaiting_invoice(int8_tArray payment_id) {
35307         LDKThirtyTwoBytes payment_id_ref;
35308         CHECK(payment_id->arr_len == 32);
35309         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35310         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35311         *ret_copy = RecentPaymentDetails_awaiting_invoice(payment_id_ref);
35312         int64_t ret_ref = tag_ptr(ret_copy, true);
35313         return ret_ref;
35314 }
35315
35316 int64_t  CS_LDK_RecentPaymentDetails_pending(int8_tArray payment_id, int8_tArray payment_hash, int64_t total_msat) {
35317         LDKThirtyTwoBytes payment_id_ref;
35318         CHECK(payment_id->arr_len == 32);
35319         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35320         LDKThirtyTwoBytes payment_hash_ref;
35321         CHECK(payment_hash->arr_len == 32);
35322         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
35323         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35324         *ret_copy = RecentPaymentDetails_pending(payment_id_ref, payment_hash_ref, total_msat);
35325         int64_t ret_ref = tag_ptr(ret_copy, true);
35326         return ret_ref;
35327 }
35328
35329 int64_t  CS_LDK_RecentPaymentDetails_fulfilled(int8_tArray payment_id, int64_t payment_hash) {
35330         LDKThirtyTwoBytes payment_id_ref;
35331         CHECK(payment_id->arr_len == 32);
35332         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35333         void* payment_hash_ptr = untag_ptr(payment_hash);
35334         CHECK_ACCESS(payment_hash_ptr);
35335         LDKCOption_ThirtyTwoBytesZ payment_hash_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_hash_ptr);
35336         payment_hash_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_hash));
35337         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35338         *ret_copy = RecentPaymentDetails_fulfilled(payment_id_ref, payment_hash_conv);
35339         int64_t ret_ref = tag_ptr(ret_copy, true);
35340         return ret_ref;
35341 }
35342
35343 int64_t  CS_LDK_RecentPaymentDetails_abandoned(int8_tArray payment_id, int8_tArray payment_hash) {
35344         LDKThirtyTwoBytes payment_id_ref;
35345         CHECK(payment_id->arr_len == 32);
35346         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35347         LDKThirtyTwoBytes payment_hash_ref;
35348         CHECK(payment_hash->arr_len == 32);
35349         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
35350         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35351         *ret_copy = RecentPaymentDetails_abandoned(payment_id_ref, payment_hash_ref);
35352         int64_t ret_ref = tag_ptr(ret_copy, true);
35353         return ret_ref;
35354 }
35355
35356 void  CS_LDK_PhantomRouteHints_free(int64_t this_obj) {
35357         LDKPhantomRouteHints this_obj_conv;
35358         this_obj_conv.inner = untag_ptr(this_obj);
35359         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35361         PhantomRouteHints_free(this_obj_conv);
35362 }
35363
35364 int64_tArray  CS_LDK_PhantomRouteHints_get_channels(int64_t this_ptr) {
35365         LDKPhantomRouteHints this_ptr_conv;
35366         this_ptr_conv.inner = untag_ptr(this_ptr);
35367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35369         this_ptr_conv.is_owned = false;
35370         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
35371         int64_tArray ret_arr = NULL;
35372         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35373         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35374         for (size_t q = 0; q < ret_var.datalen; q++) {
35375                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
35376                 int64_t ret_conv_16_ref = 0;
35377                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35378                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35379                 ret_arr_ptr[q] = ret_conv_16_ref;
35380         }
35381         
35382         FREE(ret_var.data);
35383         return ret_arr;
35384 }
35385
35386 void  CS_LDK_PhantomRouteHints_set_channels(int64_t this_ptr, int64_tArray val) {
35387         LDKPhantomRouteHints this_ptr_conv;
35388         this_ptr_conv.inner = untag_ptr(this_ptr);
35389         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35391         this_ptr_conv.is_owned = false;
35392         LDKCVec_ChannelDetailsZ val_constr;
35393         val_constr.datalen = val->arr_len;
35394         if (val_constr.datalen > 0)
35395                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
35396         else
35397                 val_constr.data = NULL;
35398         int64_t* val_vals = val->elems;
35399         for (size_t q = 0; q < val_constr.datalen; q++) {
35400                 int64_t val_conv_16 = val_vals[q];
35401                 LDKChannelDetails val_conv_16_conv;
35402                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
35403                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
35404                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
35405                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
35406                 val_constr.data[q] = val_conv_16_conv;
35407         }
35408         FREE(val);
35409         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
35410 }
35411
35412 int64_t  CS_LDK_PhantomRouteHints_get_phantom_scid(int64_t this_ptr) {
35413         LDKPhantomRouteHints this_ptr_conv;
35414         this_ptr_conv.inner = untag_ptr(this_ptr);
35415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35417         this_ptr_conv.is_owned = false;
35418         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
35419         return ret_conv;
35420 }
35421
35422 void  CS_LDK_PhantomRouteHints_set_phantom_scid(int64_t this_ptr, int64_t val) {
35423         LDKPhantomRouteHints this_ptr_conv;
35424         this_ptr_conv.inner = untag_ptr(this_ptr);
35425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35427         this_ptr_conv.is_owned = false;
35428         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
35429 }
35430
35431 int8_tArray  CS_LDK_PhantomRouteHints_get_real_node_pubkey(int64_t this_ptr) {
35432         LDKPhantomRouteHints this_ptr_conv;
35433         this_ptr_conv.inner = untag_ptr(this_ptr);
35434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35436         this_ptr_conv.is_owned = false;
35437         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35438         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
35439         return ret_arr;
35440 }
35441
35442 void  CS_LDK_PhantomRouteHints_set_real_node_pubkey(int64_t this_ptr, int8_tArray val) {
35443         LDKPhantomRouteHints this_ptr_conv;
35444         this_ptr_conv.inner = untag_ptr(this_ptr);
35445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35447         this_ptr_conv.is_owned = false;
35448         LDKPublicKey val_ref;
35449         CHECK(val->arr_len == 33);
35450         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35451         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
35452 }
35453
35454 int64_t  CS_LDK_PhantomRouteHints_new(int64_tArray channels_arg, int64_t phantom_scid_arg, int8_tArray real_node_pubkey_arg) {
35455         LDKCVec_ChannelDetailsZ channels_arg_constr;
35456         channels_arg_constr.datalen = channels_arg->arr_len;
35457         if (channels_arg_constr.datalen > 0)
35458                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
35459         else
35460                 channels_arg_constr.data = NULL;
35461         int64_t* channels_arg_vals = channels_arg->elems;
35462         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
35463                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
35464                 LDKChannelDetails channels_arg_conv_16_conv;
35465                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
35466                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
35467                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
35468                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
35469                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
35470         }
35471         FREE(channels_arg);
35472         LDKPublicKey real_node_pubkey_arg_ref;
35473         CHECK(real_node_pubkey_arg->arr_len == 33);
35474         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
35475         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
35476         int64_t ret_ref = 0;
35477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35479         return ret_ref;
35480 }
35481
35482 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
35483         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
35484         int64_t ret_ref = 0;
35485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35487         return ret_ref;
35488 }
35489 int64_t  CS_LDK_PhantomRouteHints_clone_ptr(int64_t arg) {
35490         LDKPhantomRouteHints arg_conv;
35491         arg_conv.inner = untag_ptr(arg);
35492         arg_conv.is_owned = ptr_is_owned(arg);
35493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35494         arg_conv.is_owned = false;
35495         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
35496         return ret_conv;
35497 }
35498
35499 int64_t  CS_LDK_PhantomRouteHints_clone(int64_t orig) {
35500         LDKPhantomRouteHints orig_conv;
35501         orig_conv.inner = untag_ptr(orig);
35502         orig_conv.is_owned = ptr_is_owned(orig);
35503         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35504         orig_conv.is_owned = false;
35505         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
35506         int64_t ret_ref = 0;
35507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35509         return ret_ref;
35510 }
35511
35512 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) {
35513         void* fee_est_ptr = untag_ptr(fee_est);
35514         CHECK_ACCESS(fee_est_ptr);
35515         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
35516         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
35517                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35518                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
35519         }
35520         void* chain_monitor_ptr = untag_ptr(chain_monitor);
35521         CHECK_ACCESS(chain_monitor_ptr);
35522         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
35523         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
35524                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35525                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
35526         }
35527         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
35528         CHECK_ACCESS(tx_broadcaster_ptr);
35529         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
35530         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
35531                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35532                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
35533         }
35534         void* router_ptr = untag_ptr(router);
35535         CHECK_ACCESS(router_ptr);
35536         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
35537         if (router_conv.free == LDKRouter_JCalls_free) {
35538                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35539                 LDKRouter_JCalls_cloned(&router_conv);
35540         }
35541         void* logger_ptr = untag_ptr(logger);
35542         CHECK_ACCESS(logger_ptr);
35543         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35544         if (logger_conv.free == LDKLogger_JCalls_free) {
35545                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35546                 LDKLogger_JCalls_cloned(&logger_conv);
35547         }
35548         void* entropy_source_ptr = untag_ptr(entropy_source);
35549         CHECK_ACCESS(entropy_source_ptr);
35550         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
35551         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
35552                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35553                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
35554         }
35555         void* node_signer_ptr = untag_ptr(node_signer);
35556         CHECK_ACCESS(node_signer_ptr);
35557         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
35558         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
35559                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35560                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
35561         }
35562         void* signer_provider_ptr = untag_ptr(signer_provider);
35563         CHECK_ACCESS(signer_provider_ptr);
35564         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
35565         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
35566                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35567                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
35568         }
35569         LDKUserConfig config_conv;
35570         config_conv.inner = untag_ptr(config);
35571         config_conv.is_owned = ptr_is_owned(config);
35572         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
35573         config_conv = UserConfig_clone(&config_conv);
35574         LDKChainParameters params_conv;
35575         params_conv.inner = untag_ptr(params);
35576         params_conv.is_owned = ptr_is_owned(params);
35577         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
35578         params_conv = ChainParameters_clone(&params_conv);
35579         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);
35580         int64_t ret_ref = 0;
35581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35582         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35583         return ret_ref;
35584 }
35585
35586 int64_t  CS_LDK_ChannelManager_get_current_default_configuration(int64_t this_arg) {
35587         LDKChannelManager this_arg_conv;
35588         this_arg_conv.inner = untag_ptr(this_arg);
35589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35591         this_arg_conv.is_owned = false;
35592         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
35593         int64_t ret_ref = 0;
35594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35596         return ret_ref;
35597 }
35598
35599 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) {
35600         LDKChannelManager this_arg_conv;
35601         this_arg_conv.inner = untag_ptr(this_arg);
35602         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35604         this_arg_conv.is_owned = false;
35605         LDKPublicKey their_network_key_ref;
35606         CHECK(their_network_key->arr_len == 33);
35607         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
35608         LDKU128 user_channel_id_ref;
35609         CHECK(user_channel_id->arr_len == 16);
35610         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
35611         LDKUserConfig override_config_conv;
35612         override_config_conv.inner = untag_ptr(override_config);
35613         override_config_conv.is_owned = ptr_is_owned(override_config);
35614         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
35615         override_config_conv = UserConfig_clone(&override_config_conv);
35616         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
35617         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
35618         return tag_ptr(ret_conv, true);
35619 }
35620
35621 int64_tArray  CS_LDK_ChannelManager_list_channels(int64_t this_arg) {
35622         LDKChannelManager this_arg_conv;
35623         this_arg_conv.inner = untag_ptr(this_arg);
35624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35626         this_arg_conv.is_owned = false;
35627         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
35628         int64_tArray ret_arr = NULL;
35629         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35630         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35631         for (size_t q = 0; q < ret_var.datalen; q++) {
35632                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
35633                 int64_t ret_conv_16_ref = 0;
35634                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35635                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35636                 ret_arr_ptr[q] = ret_conv_16_ref;
35637         }
35638         
35639         FREE(ret_var.data);
35640         return ret_arr;
35641 }
35642
35643 int64_tArray  CS_LDK_ChannelManager_list_usable_channels(int64_t this_arg) {
35644         LDKChannelManager this_arg_conv;
35645         this_arg_conv.inner = untag_ptr(this_arg);
35646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35648         this_arg_conv.is_owned = false;
35649         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
35650         int64_tArray ret_arr = NULL;
35651         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35652         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35653         for (size_t q = 0; q < ret_var.datalen; q++) {
35654                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
35655                 int64_t ret_conv_16_ref = 0;
35656                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35657                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35658                 ret_arr_ptr[q] = ret_conv_16_ref;
35659         }
35660         
35661         FREE(ret_var.data);
35662         return ret_arr;
35663 }
35664
35665 int64_tArray  CS_LDK_ChannelManager_list_channels_with_counterparty(int64_t this_arg, int8_tArray counterparty_node_id) {
35666         LDKChannelManager this_arg_conv;
35667         this_arg_conv.inner = untag_ptr(this_arg);
35668         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35670         this_arg_conv.is_owned = false;
35671         LDKPublicKey counterparty_node_id_ref;
35672         CHECK(counterparty_node_id->arr_len == 33);
35673         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35674         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels_with_counterparty(&this_arg_conv, counterparty_node_id_ref);
35675         int64_tArray ret_arr = NULL;
35676         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35677         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35678         for (size_t q = 0; q < ret_var.datalen; q++) {
35679                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
35680                 int64_t ret_conv_16_ref = 0;
35681                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35682                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35683                 ret_arr_ptr[q] = ret_conv_16_ref;
35684         }
35685         
35686         FREE(ret_var.data);
35687         return ret_arr;
35688 }
35689
35690 int64_tArray  CS_LDK_ChannelManager_list_recent_payments(int64_t this_arg) {
35691         LDKChannelManager this_arg_conv;
35692         this_arg_conv.inner = untag_ptr(this_arg);
35693         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35695         this_arg_conv.is_owned = false;
35696         LDKCVec_RecentPaymentDetailsZ ret_var = ChannelManager_list_recent_payments(&this_arg_conv);
35697         int64_tArray ret_arr = NULL;
35698         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35699         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35700         for (size_t w = 0; w < ret_var.datalen; w++) {
35701                 LDKRecentPaymentDetails *ret_conv_22_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35702                 *ret_conv_22_copy = ret_var.data[w];
35703                 int64_t ret_conv_22_ref = tag_ptr(ret_conv_22_copy, true);
35704                 ret_arr_ptr[w] = ret_conv_22_ref;
35705         }
35706         
35707         FREE(ret_var.data);
35708         return ret_arr;
35709 }
35710
35711 int64_t  CS_LDK_ChannelManager_close_channel(int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
35712         LDKChannelManager this_arg_conv;
35713         this_arg_conv.inner = untag_ptr(this_arg);
35714         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35716         this_arg_conv.is_owned = false;
35717         uint8_t channel_id_arr[32];
35718         CHECK(channel_id->arr_len == 32);
35719         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
35720         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
35721         LDKPublicKey counterparty_node_id_ref;
35722         CHECK(counterparty_node_id->arr_len == 33);
35723         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35724         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
35725         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
35726         return tag_ptr(ret_conv, true);
35727 }
35728
35729 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) {
35730         LDKChannelManager this_arg_conv;
35731         this_arg_conv.inner = untag_ptr(this_arg);
35732         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35734         this_arg_conv.is_owned = false;
35735         uint8_t channel_id_arr[32];
35736         CHECK(channel_id->arr_len == 32);
35737         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
35738         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
35739         LDKPublicKey counterparty_node_id_ref;
35740         CHECK(counterparty_node_id->arr_len == 33);
35741         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35742         void* target_feerate_sats_per_1000_weight_ptr = untag_ptr(target_feerate_sats_per_1000_weight);
35743         CHECK_ACCESS(target_feerate_sats_per_1000_weight_ptr);
35744         LDKCOption_u32Z target_feerate_sats_per_1000_weight_conv = *(LDKCOption_u32Z*)(target_feerate_sats_per_1000_weight_ptr);
35745         target_feerate_sats_per_1000_weight_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(target_feerate_sats_per_1000_weight));
35746         LDKShutdownScript shutdown_script_conv;
35747         shutdown_script_conv.inner = untag_ptr(shutdown_script);
35748         shutdown_script_conv.is_owned = ptr_is_owned(shutdown_script);
35749         CHECK_INNER_FIELD_ACCESS_OR_NULL(shutdown_script_conv);
35750         shutdown_script_conv = ShutdownScript_clone(&shutdown_script_conv);
35751         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
35752         *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);
35753         return tag_ptr(ret_conv, true);
35754 }
35755
35756 int64_t  CS_LDK_ChannelManager_force_close_broadcasting_latest_txn(int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
35757         LDKChannelManager this_arg_conv;
35758         this_arg_conv.inner = untag_ptr(this_arg);
35759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35761         this_arg_conv.is_owned = false;
35762         uint8_t channel_id_arr[32];
35763         CHECK(channel_id->arr_len == 32);
35764         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
35765         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
35766         LDKPublicKey counterparty_node_id_ref;
35767         CHECK(counterparty_node_id->arr_len == 33);
35768         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35769         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
35770         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
35771         return tag_ptr(ret_conv, true);
35772 }
35773
35774 int64_t  CS_LDK_ChannelManager_force_close_without_broadcasting_txn(int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
35775         LDKChannelManager this_arg_conv;
35776         this_arg_conv.inner = untag_ptr(this_arg);
35777         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35779         this_arg_conv.is_owned = false;
35780         uint8_t channel_id_arr[32];
35781         CHECK(channel_id->arr_len == 32);
35782         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
35783         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
35784         LDKPublicKey counterparty_node_id_ref;
35785         CHECK(counterparty_node_id->arr_len == 33);
35786         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35787         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
35788         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
35789         return tag_ptr(ret_conv, true);
35790 }
35791
35792 void  CS_LDK_ChannelManager_force_close_all_channels_broadcasting_latest_txn(int64_t this_arg) {
35793         LDKChannelManager this_arg_conv;
35794         this_arg_conv.inner = untag_ptr(this_arg);
35795         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35797         this_arg_conv.is_owned = false;
35798         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
35799 }
35800
35801 void  CS_LDK_ChannelManager_force_close_all_channels_without_broadcasting_txn(int64_t this_arg) {
35802         LDKChannelManager this_arg_conv;
35803         this_arg_conv.inner = untag_ptr(this_arg);
35804         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35806         this_arg_conv.is_owned = false;
35807         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
35808 }
35809
35810 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) {
35811         LDKChannelManager this_arg_conv;
35812         this_arg_conv.inner = untag_ptr(this_arg);
35813         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35815         this_arg_conv.is_owned = false;
35816         LDKRoute route_conv;
35817         route_conv.inner = untag_ptr(route);
35818         route_conv.is_owned = ptr_is_owned(route);
35819         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
35820         route_conv.is_owned = false;
35821         LDKThirtyTwoBytes payment_hash_ref;
35822         CHECK(payment_hash->arr_len == 32);
35823         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
35824         LDKRecipientOnionFields recipient_onion_conv;
35825         recipient_onion_conv.inner = untag_ptr(recipient_onion);
35826         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
35827         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
35828         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
35829         LDKThirtyTwoBytes payment_id_ref;
35830         CHECK(payment_id->arr_len == 32);
35831         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35832         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
35833         *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, &route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref);
35834         return tag_ptr(ret_conv, true);
35835 }
35836
35837 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) {
35838         LDKChannelManager this_arg_conv;
35839         this_arg_conv.inner = untag_ptr(this_arg);
35840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35842         this_arg_conv.is_owned = false;
35843         LDKThirtyTwoBytes payment_hash_ref;
35844         CHECK(payment_hash->arr_len == 32);
35845         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
35846         LDKRecipientOnionFields recipient_onion_conv;
35847         recipient_onion_conv.inner = untag_ptr(recipient_onion);
35848         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
35849         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
35850         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
35851         LDKThirtyTwoBytes payment_id_ref;
35852         CHECK(payment_id->arr_len == 32);
35853         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35854         LDKRouteParameters route_params_conv;
35855         route_params_conv.inner = untag_ptr(route_params);
35856         route_params_conv.is_owned = ptr_is_owned(route_params);
35857         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
35858         route_params_conv = RouteParameters_clone(&route_params_conv);
35859         void* retry_strategy_ptr = untag_ptr(retry_strategy);
35860         CHECK_ACCESS(retry_strategy_ptr);
35861         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
35862         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
35863         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
35864         *ret_conv = ChannelManager_send_payment(&this_arg_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
35865         return tag_ptr(ret_conv, true);
35866 }
35867
35868 void  CS_LDK_ChannelManager_abandon_payment(int64_t this_arg, int8_tArray payment_id) {
35869         LDKChannelManager this_arg_conv;
35870         this_arg_conv.inner = untag_ptr(this_arg);
35871         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35873         this_arg_conv.is_owned = false;
35874         LDKThirtyTwoBytes payment_id_ref;
35875         CHECK(payment_id->arr_len == 32);
35876         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35877         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
35878 }
35879
35880 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) {
35881         LDKChannelManager this_arg_conv;
35882         this_arg_conv.inner = untag_ptr(this_arg);
35883         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35885         this_arg_conv.is_owned = false;
35886         LDKRoute route_conv;
35887         route_conv.inner = untag_ptr(route);
35888         route_conv.is_owned = ptr_is_owned(route);
35889         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
35890         route_conv.is_owned = false;
35891         void* payment_preimage_ptr = untag_ptr(payment_preimage);
35892         CHECK_ACCESS(payment_preimage_ptr);
35893         LDKCOption_ThirtyTwoBytesZ payment_preimage_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_preimage_ptr);
35894         payment_preimage_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_preimage));
35895         LDKRecipientOnionFields recipient_onion_conv;
35896         recipient_onion_conv.inner = untag_ptr(recipient_onion);
35897         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
35898         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
35899         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
35900         LDKThirtyTwoBytes payment_id_ref;
35901         CHECK(payment_id->arr_len == 32);
35902         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35903         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
35904         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_conv, recipient_onion_conv, payment_id_ref);
35905         return tag_ptr(ret_conv, true);
35906 }
35907
35908 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) {
35909         LDKChannelManager this_arg_conv;
35910         this_arg_conv.inner = untag_ptr(this_arg);
35911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35913         this_arg_conv.is_owned = false;
35914         void* payment_preimage_ptr = untag_ptr(payment_preimage);
35915         CHECK_ACCESS(payment_preimage_ptr);
35916         LDKCOption_ThirtyTwoBytesZ payment_preimage_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_preimage_ptr);
35917         payment_preimage_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_preimage));
35918         LDKRecipientOnionFields recipient_onion_conv;
35919         recipient_onion_conv.inner = untag_ptr(recipient_onion);
35920         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
35921         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
35922         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
35923         LDKThirtyTwoBytes payment_id_ref;
35924         CHECK(payment_id->arr_len == 32);
35925         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35926         LDKRouteParameters route_params_conv;
35927         route_params_conv.inner = untag_ptr(route_params);
35928         route_params_conv.is_owned = ptr_is_owned(route_params);
35929         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
35930         route_params_conv = RouteParameters_clone(&route_params_conv);
35931         void* retry_strategy_ptr = untag_ptr(retry_strategy);
35932         CHECK_ACCESS(retry_strategy_ptr);
35933         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
35934         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
35935         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
35936         *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);
35937         return tag_ptr(ret_conv, true);
35938 }
35939
35940 int64_t  CS_LDK_ChannelManager_send_probe(int64_t this_arg, int64_t path) {
35941         LDKChannelManager this_arg_conv;
35942         this_arg_conv.inner = untag_ptr(this_arg);
35943         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35945         this_arg_conv.is_owned = false;
35946         LDKPath path_conv;
35947         path_conv.inner = untag_ptr(path);
35948         path_conv.is_owned = ptr_is_owned(path);
35949         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
35950         path_conv = Path_clone(&path_conv);
35951         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
35952         *ret_conv = ChannelManager_send_probe(&this_arg_conv, path_conv);
35953         return tag_ptr(ret_conv, true);
35954 }
35955
35956 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) {
35957         LDKChannelManager this_arg_conv;
35958         this_arg_conv.inner = untag_ptr(this_arg);
35959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35961         this_arg_conv.is_owned = false;
35962         LDKPublicKey node_id_ref;
35963         CHECK(node_id->arr_len == 33);
35964         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
35965         void* liquidity_limit_multiplier_ptr = untag_ptr(liquidity_limit_multiplier);
35966         CHECK_ACCESS(liquidity_limit_multiplier_ptr);
35967         LDKCOption_u64Z liquidity_limit_multiplier_conv = *(LDKCOption_u64Z*)(liquidity_limit_multiplier_ptr);
35968         liquidity_limit_multiplier_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(liquidity_limit_multiplier));
35969         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
35970         *ret_conv = ChannelManager_send_spontaneous_preflight_probes(&this_arg_conv, node_id_ref, amount_msat, final_cltv_expiry_delta, liquidity_limit_multiplier_conv);
35971         return tag_ptr(ret_conv, true);
35972 }
35973
35974 int64_t  CS_LDK_ChannelManager_send_preflight_probes(int64_t this_arg, int64_t route_params, int64_t liquidity_limit_multiplier) {
35975         LDKChannelManager this_arg_conv;
35976         this_arg_conv.inner = untag_ptr(this_arg);
35977         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35979         this_arg_conv.is_owned = false;
35980         LDKRouteParameters route_params_conv;
35981         route_params_conv.inner = untag_ptr(route_params);
35982         route_params_conv.is_owned = ptr_is_owned(route_params);
35983         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
35984         route_params_conv = RouteParameters_clone(&route_params_conv);
35985         void* liquidity_limit_multiplier_ptr = untag_ptr(liquidity_limit_multiplier);
35986         CHECK_ACCESS(liquidity_limit_multiplier_ptr);
35987         LDKCOption_u64Z liquidity_limit_multiplier_conv = *(LDKCOption_u64Z*)(liquidity_limit_multiplier_ptr);
35988         liquidity_limit_multiplier_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(liquidity_limit_multiplier));
35989         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
35990         *ret_conv = ChannelManager_send_preflight_probes(&this_arg_conv, route_params_conv, liquidity_limit_multiplier_conv);
35991         return tag_ptr(ret_conv, true);
35992 }
35993
35994 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) {
35995         LDKChannelManager this_arg_conv;
35996         this_arg_conv.inner = untag_ptr(this_arg);
35997         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35999         this_arg_conv.is_owned = false;
36000         uint8_t temporary_channel_id_arr[32];
36001         CHECK(temporary_channel_id->arr_len == 32);
36002         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
36003         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
36004         LDKPublicKey counterparty_node_id_ref;
36005         CHECK(counterparty_node_id->arr_len == 33);
36006         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36007         LDKTransaction funding_transaction_ref;
36008         funding_transaction_ref.datalen = funding_transaction->arr_len;
36009         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
36010         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
36011         funding_transaction_ref.data_is_owned = true;
36012         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36013         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
36014         return tag_ptr(ret_conv, true);
36015 }
36016
36017 int64_t  CS_LDK_ChannelManager_batch_funding_transaction_generated(int64_t this_arg, int64_tArray temporary_channels, int8_tArray funding_transaction) {
36018         LDKChannelManager this_arg_conv;
36019         this_arg_conv.inner = untag_ptr(this_arg);
36020         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36022         this_arg_conv.is_owned = false;
36023         LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ temporary_channels_constr;
36024         temporary_channels_constr.datalen = temporary_channels->arr_len;
36025         if (temporary_channels_constr.datalen > 0)
36026                 temporary_channels_constr.data = MALLOC(temporary_channels_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ Elements");
36027         else
36028                 temporary_channels_constr.data = NULL;
36029         int64_t* temporary_channels_vals = temporary_channels->elems;
36030         for (size_t j = 0; j < temporary_channels_constr.datalen; j++) {
36031                 int64_t temporary_channels_conv_35 = temporary_channels_vals[j];
36032                 void* temporary_channels_conv_35_ptr = untag_ptr(temporary_channels_conv_35);
36033                 CHECK_ACCESS(temporary_channels_conv_35_ptr);
36034                 LDKC2Tuple_ThirtyTwoBytesPublicKeyZ temporary_channels_conv_35_conv = *(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)(temporary_channels_conv_35_ptr);
36035                 temporary_channels_conv_35_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone((LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(temporary_channels_conv_35));
36036                 temporary_channels_constr.data[j] = temporary_channels_conv_35_conv;
36037         }
36038         FREE(temporary_channels);
36039         LDKTransaction funding_transaction_ref;
36040         funding_transaction_ref.datalen = funding_transaction->arr_len;
36041         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
36042         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
36043         funding_transaction_ref.data_is_owned = true;
36044         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36045         *ret_conv = ChannelManager_batch_funding_transaction_generated(&this_arg_conv, temporary_channels_constr, funding_transaction_ref);
36046         return tag_ptr(ret_conv, true);
36047 }
36048
36049 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) {
36050         LDKChannelManager this_arg_conv;
36051         this_arg_conv.inner = untag_ptr(this_arg);
36052         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36054         this_arg_conv.is_owned = false;
36055         LDKPublicKey counterparty_node_id_ref;
36056         CHECK(counterparty_node_id->arr_len == 33);
36057         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36058         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
36059         channel_ids_constr.datalen = channel_ids->arr_len;
36060         if (channel_ids_constr.datalen > 0)
36061                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
36062         else
36063                 channel_ids_constr.data = NULL;
36064         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
36065         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
36066                 int8_tArray channel_ids_conv_8 = channel_ids_vals[i];
36067                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
36068                 CHECK(channel_ids_conv_8->arr_len == 32);
36069                 memcpy(channel_ids_conv_8_ref.data, channel_ids_conv_8->elems, 32); FREE(channel_ids_conv_8);
36070                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
36071         }
36072         FREE(channel_ids);
36073         LDKChannelConfigUpdate config_update_conv;
36074         config_update_conv.inner = untag_ptr(config_update);
36075         config_update_conv.is_owned = ptr_is_owned(config_update);
36076         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_update_conv);
36077         config_update_conv.is_owned = false;
36078         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36079         *ret_conv = ChannelManager_update_partial_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_update_conv);
36080         return tag_ptr(ret_conv, true);
36081 }
36082
36083 int64_t  CS_LDK_ChannelManager_update_channel_config(int64_t this_arg, int8_tArray counterparty_node_id, ptrArray channel_ids, int64_t config) {
36084         LDKChannelManager this_arg_conv;
36085         this_arg_conv.inner = untag_ptr(this_arg);
36086         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36088         this_arg_conv.is_owned = false;
36089         LDKPublicKey counterparty_node_id_ref;
36090         CHECK(counterparty_node_id->arr_len == 33);
36091         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36092         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
36093         channel_ids_constr.datalen = channel_ids->arr_len;
36094         if (channel_ids_constr.datalen > 0)
36095                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
36096         else
36097                 channel_ids_constr.data = NULL;
36098         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
36099         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
36100                 int8_tArray channel_ids_conv_8 = channel_ids_vals[i];
36101                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
36102                 CHECK(channel_ids_conv_8->arr_len == 32);
36103                 memcpy(channel_ids_conv_8_ref.data, channel_ids_conv_8->elems, 32); FREE(channel_ids_conv_8);
36104                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
36105         }
36106         FREE(channel_ids);
36107         LDKChannelConfig config_conv;
36108         config_conv.inner = untag_ptr(config);
36109         config_conv.is_owned = ptr_is_owned(config);
36110         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
36111         config_conv.is_owned = false;
36112         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36113         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
36114         return tag_ptr(ret_conv, true);
36115 }
36116
36117 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) {
36118         LDKChannelManager this_arg_conv;
36119         this_arg_conv.inner = untag_ptr(this_arg);
36120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36122         this_arg_conv.is_owned = false;
36123         LDKThirtyTwoBytes intercept_id_ref;
36124         CHECK(intercept_id->arr_len == 32);
36125         memcpy(intercept_id_ref.data, intercept_id->elems, 32); FREE(intercept_id);
36126         uint8_t next_hop_channel_id_arr[32];
36127         CHECK(next_hop_channel_id->arr_len == 32);
36128         memcpy(next_hop_channel_id_arr, next_hop_channel_id->elems, 32); FREE(next_hop_channel_id);
36129         uint8_t (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
36130         LDKPublicKey next_node_id_ref;
36131         CHECK(next_node_id->arr_len == 33);
36132         memcpy(next_node_id_ref.compressed_form, next_node_id->elems, 33); FREE(next_node_id);
36133         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36134         *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);
36135         return tag_ptr(ret_conv, true);
36136 }
36137
36138 int64_t  CS_LDK_ChannelManager_fail_intercepted_htlc(int64_t this_arg, int8_tArray intercept_id) {
36139         LDKChannelManager this_arg_conv;
36140         this_arg_conv.inner = untag_ptr(this_arg);
36141         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36143         this_arg_conv.is_owned = false;
36144         LDKThirtyTwoBytes intercept_id_ref;
36145         CHECK(intercept_id->arr_len == 32);
36146         memcpy(intercept_id_ref.data, intercept_id->elems, 32); FREE(intercept_id);
36147         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36148         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
36149         return tag_ptr(ret_conv, true);
36150 }
36151
36152 void  CS_LDK_ChannelManager_process_pending_htlc_forwards(int64_t this_arg) {
36153         LDKChannelManager this_arg_conv;
36154         this_arg_conv.inner = untag_ptr(this_arg);
36155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36157         this_arg_conv.is_owned = false;
36158         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
36159 }
36160
36161 void  CS_LDK_ChannelManager_timer_tick_occurred(int64_t this_arg) {
36162         LDKChannelManager this_arg_conv;
36163         this_arg_conv.inner = untag_ptr(this_arg);
36164         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36166         this_arg_conv.is_owned = false;
36167         ChannelManager_timer_tick_occurred(&this_arg_conv);
36168 }
36169
36170 void  CS_LDK_ChannelManager_fail_htlc_backwards(int64_t this_arg, int8_tArray payment_hash) {
36171         LDKChannelManager this_arg_conv;
36172         this_arg_conv.inner = untag_ptr(this_arg);
36173         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36175         this_arg_conv.is_owned = false;
36176         uint8_t payment_hash_arr[32];
36177         CHECK(payment_hash->arr_len == 32);
36178         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
36179         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
36180         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
36181 }
36182
36183 void  CS_LDK_ChannelManager_fail_htlc_backwards_with_reason(int64_t this_arg, int8_tArray payment_hash, int64_t failure_code) {
36184         LDKChannelManager this_arg_conv;
36185         this_arg_conv.inner = untag_ptr(this_arg);
36186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36188         this_arg_conv.is_owned = false;
36189         uint8_t payment_hash_arr[32];
36190         CHECK(payment_hash->arr_len == 32);
36191         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
36192         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
36193         void* failure_code_ptr = untag_ptr(failure_code);
36194         CHECK_ACCESS(failure_code_ptr);
36195         LDKFailureCode failure_code_conv = *(LDKFailureCode*)(failure_code_ptr);
36196         failure_code_conv = FailureCode_clone((LDKFailureCode*)untag_ptr(failure_code));
36197         ChannelManager_fail_htlc_backwards_with_reason(&this_arg_conv, payment_hash_ref, failure_code_conv);
36198 }
36199
36200 void  CS_LDK_ChannelManager_claim_funds(int64_t this_arg, int8_tArray payment_preimage) {
36201         LDKChannelManager this_arg_conv;
36202         this_arg_conv.inner = untag_ptr(this_arg);
36203         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36205         this_arg_conv.is_owned = false;
36206         LDKThirtyTwoBytes payment_preimage_ref;
36207         CHECK(payment_preimage->arr_len == 32);
36208         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
36209         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
36210 }
36211
36212 void  CS_LDK_ChannelManager_claim_funds_with_known_custom_tlvs(int64_t this_arg, int8_tArray payment_preimage) {
36213         LDKChannelManager this_arg_conv;
36214         this_arg_conv.inner = untag_ptr(this_arg);
36215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36217         this_arg_conv.is_owned = false;
36218         LDKThirtyTwoBytes payment_preimage_ref;
36219         CHECK(payment_preimage->arr_len == 32);
36220         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
36221         ChannelManager_claim_funds_with_known_custom_tlvs(&this_arg_conv, payment_preimage_ref);
36222 }
36223
36224 int8_tArray  CS_LDK_ChannelManager_get_our_node_id(int64_t this_arg) {
36225         LDKChannelManager this_arg_conv;
36226         this_arg_conv.inner = untag_ptr(this_arg);
36227         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36229         this_arg_conv.is_owned = false;
36230         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
36231         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
36232         return ret_arr;
36233 }
36234
36235 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) {
36236         LDKChannelManager this_arg_conv;
36237         this_arg_conv.inner = untag_ptr(this_arg);
36238         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36240         this_arg_conv.is_owned = false;
36241         uint8_t temporary_channel_id_arr[32];
36242         CHECK(temporary_channel_id->arr_len == 32);
36243         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
36244         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
36245         LDKPublicKey counterparty_node_id_ref;
36246         CHECK(counterparty_node_id->arr_len == 33);
36247         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36248         LDKU128 user_channel_id_ref;
36249         CHECK(user_channel_id->arr_len == 16);
36250         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
36251         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36252         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
36253         return tag_ptr(ret_conv, true);
36254 }
36255
36256 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) {
36257         LDKChannelManager this_arg_conv;
36258         this_arg_conv.inner = untag_ptr(this_arg);
36259         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36261         this_arg_conv.is_owned = false;
36262         uint8_t temporary_channel_id_arr[32];
36263         CHECK(temporary_channel_id->arr_len == 32);
36264         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
36265         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
36266         LDKPublicKey counterparty_node_id_ref;
36267         CHECK(counterparty_node_id->arr_len == 33);
36268         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36269         LDKU128 user_channel_id_ref;
36270         CHECK(user_channel_id->arr_len == 16);
36271         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
36272         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36273         *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);
36274         return tag_ptr(ret_conv, true);
36275 }
36276
36277 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) {
36278         LDKChannelManager this_arg_conv;
36279         this_arg_conv.inner = untag_ptr(this_arg);
36280         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36282         this_arg_conv.is_owned = false;
36283         LDKOffer offer_conv;
36284         offer_conv.inner = untag_ptr(offer);
36285         offer_conv.is_owned = ptr_is_owned(offer);
36286         CHECK_INNER_FIELD_ACCESS_OR_NULL(offer_conv);
36287         offer_conv.is_owned = false;
36288         void* quantity_ptr = untag_ptr(quantity);
36289         CHECK_ACCESS(quantity_ptr);
36290         LDKCOption_u64Z quantity_conv = *(LDKCOption_u64Z*)(quantity_ptr);
36291         quantity_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(quantity));
36292         void* amount_msats_ptr = untag_ptr(amount_msats);
36293         CHECK_ACCESS(amount_msats_ptr);
36294         LDKCOption_u64Z amount_msats_conv = *(LDKCOption_u64Z*)(amount_msats_ptr);
36295         amount_msats_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amount_msats));
36296         void* payer_note_ptr = untag_ptr(payer_note);
36297         CHECK_ACCESS(payer_note_ptr);
36298         LDKCOption_StrZ payer_note_conv = *(LDKCOption_StrZ*)(payer_note_ptr);
36299         payer_note_conv = COption_StrZ_clone((LDKCOption_StrZ*)untag_ptr(payer_note));
36300         LDKThirtyTwoBytes payment_id_ref;
36301         CHECK(payment_id->arr_len == 32);
36302         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
36303         void* retry_strategy_ptr = untag_ptr(retry_strategy);
36304         CHECK_ACCESS(retry_strategy_ptr);
36305         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
36306         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
36307         void* max_total_routing_fee_msat_ptr = untag_ptr(max_total_routing_fee_msat);
36308         CHECK_ACCESS(max_total_routing_fee_msat_ptr);
36309         LDKCOption_u64Z max_total_routing_fee_msat_conv = *(LDKCOption_u64Z*)(max_total_routing_fee_msat_ptr);
36310         max_total_routing_fee_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(max_total_routing_fee_msat));
36311         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
36312         *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);
36313         return tag_ptr(ret_conv, true);
36314 }
36315
36316 int64_t  CS_LDK_ChannelManager_request_refund_payment(int64_t this_arg, int64_t refund) {
36317         LDKChannelManager this_arg_conv;
36318         this_arg_conv.inner = untag_ptr(this_arg);
36319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36321         this_arg_conv.is_owned = false;
36322         LDKRefund refund_conv;
36323         refund_conv.inner = untag_ptr(refund);
36324         refund_conv.is_owned = ptr_is_owned(refund);
36325         CHECK_INNER_FIELD_ACCESS_OR_NULL(refund_conv);
36326         refund_conv.is_owned = false;
36327         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
36328         *ret_conv = ChannelManager_request_refund_payment(&this_arg_conv, &refund_conv);
36329         return tag_ptr(ret_conv, true);
36330 }
36331
36332 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) {
36333         LDKChannelManager this_arg_conv;
36334         this_arg_conv.inner = untag_ptr(this_arg);
36335         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36337         this_arg_conv.is_owned = false;
36338         void* min_value_msat_ptr = untag_ptr(min_value_msat);
36339         CHECK_ACCESS(min_value_msat_ptr);
36340         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
36341         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
36342         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
36343         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
36344         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
36345         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
36346         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
36347         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
36348         return tag_ptr(ret_conv, true);
36349 }
36350
36351 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) {
36352         LDKChannelManager this_arg_conv;
36353         this_arg_conv.inner = untag_ptr(this_arg);
36354         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36356         this_arg_conv.is_owned = false;
36357         LDKThirtyTwoBytes payment_hash_ref;
36358         CHECK(payment_hash->arr_len == 32);
36359         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
36360         void* min_value_msat_ptr = untag_ptr(min_value_msat);
36361         CHECK_ACCESS(min_value_msat_ptr);
36362         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
36363         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
36364         void* min_final_cltv_expiry_ptr = untag_ptr(min_final_cltv_expiry);
36365         CHECK_ACCESS(min_final_cltv_expiry_ptr);
36366         LDKCOption_u16Z min_final_cltv_expiry_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_ptr);
36367         min_final_cltv_expiry_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry));
36368         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
36369         *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);
36370         return tag_ptr(ret_conv, true);
36371 }
36372
36373 int64_t  CS_LDK_ChannelManager_get_payment_preimage(int64_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
36374         LDKChannelManager this_arg_conv;
36375         this_arg_conv.inner = untag_ptr(this_arg);
36376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36378         this_arg_conv.is_owned = false;
36379         LDKThirtyTwoBytes payment_hash_ref;
36380         CHECK(payment_hash->arr_len == 32);
36381         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
36382         LDKThirtyTwoBytes payment_secret_ref;
36383         CHECK(payment_secret->arr_len == 32);
36384         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
36385         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
36386         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
36387         return tag_ptr(ret_conv, true);
36388 }
36389
36390 int64_t  CS_LDK_ChannelManager_get_phantom_scid(int64_t this_arg) {
36391         LDKChannelManager this_arg_conv;
36392         this_arg_conv.inner = untag_ptr(this_arg);
36393         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36395         this_arg_conv.is_owned = false;
36396         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
36397         return ret_conv;
36398 }
36399
36400 int64_t  CS_LDK_ChannelManager_get_phantom_route_hints(int64_t this_arg) {
36401         LDKChannelManager this_arg_conv;
36402         this_arg_conv.inner = untag_ptr(this_arg);
36403         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36405         this_arg_conv.is_owned = false;
36406         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
36407         int64_t ret_ref = 0;
36408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36409         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36410         return ret_ref;
36411 }
36412
36413 int64_t  CS_LDK_ChannelManager_get_intercept_scid(int64_t this_arg) {
36414         LDKChannelManager this_arg_conv;
36415         this_arg_conv.inner = untag_ptr(this_arg);
36416         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36418         this_arg_conv.is_owned = false;
36419         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
36420         return ret_conv;
36421 }
36422
36423 int64_t  CS_LDK_ChannelManager_compute_inflight_htlcs(int64_t this_arg) {
36424         LDKChannelManager this_arg_conv;
36425         this_arg_conv.inner = untag_ptr(this_arg);
36426         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36428         this_arg_conv.is_owned = false;
36429         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
36430         int64_t ret_ref = 0;
36431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36432         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36433         return ret_ref;
36434 }
36435
36436 int64_t  CS_LDK_ChannelManager_as_MessageSendEventsProvider(int64_t this_arg) {
36437         LDKChannelManager this_arg_conv;
36438         this_arg_conv.inner = untag_ptr(this_arg);
36439         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36441         this_arg_conv.is_owned = false;
36442         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36443         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
36444         return tag_ptr(ret_ret, true);
36445 }
36446
36447 int64_t  CS_LDK_ChannelManager_as_EventsProvider(int64_t this_arg) {
36448         LDKChannelManager this_arg_conv;
36449         this_arg_conv.inner = untag_ptr(this_arg);
36450         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36452         this_arg_conv.is_owned = false;
36453         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
36454         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
36455         return tag_ptr(ret_ret, true);
36456 }
36457
36458 int64_t  CS_LDK_ChannelManager_as_Listen(int64_t this_arg) {
36459         LDKChannelManager this_arg_conv;
36460         this_arg_conv.inner = untag_ptr(this_arg);
36461         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36463         this_arg_conv.is_owned = false;
36464         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
36465         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
36466         return tag_ptr(ret_ret, true);
36467 }
36468
36469 int64_t  CS_LDK_ChannelManager_as_Confirm(int64_t this_arg) {
36470         LDKChannelManager this_arg_conv;
36471         this_arg_conv.inner = untag_ptr(this_arg);
36472         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36474         this_arg_conv.is_owned = false;
36475         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
36476         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
36477         return tag_ptr(ret_ret, true);
36478 }
36479
36480 int64_t  CS_LDK_ChannelManager_get_event_or_persistence_needed_future(int64_t this_arg) {
36481         LDKChannelManager this_arg_conv;
36482         this_arg_conv.inner = untag_ptr(this_arg);
36483         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36485         this_arg_conv.is_owned = false;
36486         LDKFuture ret_var = ChannelManager_get_event_or_persistence_needed_future(&this_arg_conv);
36487         int64_t ret_ref = 0;
36488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36489         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36490         return ret_ref;
36491 }
36492
36493 jboolean  CS_LDK_ChannelManager_get_and_clear_needs_persistence(int64_t this_arg) {
36494         LDKChannelManager this_arg_conv;
36495         this_arg_conv.inner = untag_ptr(this_arg);
36496         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36498         this_arg_conv.is_owned = false;
36499         jboolean ret_conv = ChannelManager_get_and_clear_needs_persistence(&this_arg_conv);
36500         return ret_conv;
36501 }
36502
36503 int64_t  CS_LDK_ChannelManager_current_best_block(int64_t this_arg) {
36504         LDKChannelManager this_arg_conv;
36505         this_arg_conv.inner = untag_ptr(this_arg);
36506         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36508         this_arg_conv.is_owned = false;
36509         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
36510         int64_t ret_ref = 0;
36511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36513         return ret_ref;
36514 }
36515
36516 int64_t  CS_LDK_ChannelManager_node_features(int64_t this_arg) {
36517         LDKChannelManager this_arg_conv;
36518         this_arg_conv.inner = untag_ptr(this_arg);
36519         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36521         this_arg_conv.is_owned = false;
36522         LDKNodeFeatures ret_var = ChannelManager_node_features(&this_arg_conv);
36523         int64_t ret_ref = 0;
36524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36525         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36526         return ret_ref;
36527 }
36528
36529 int64_t  CS_LDK_ChannelManager_channel_features(int64_t this_arg) {
36530         LDKChannelManager this_arg_conv;
36531         this_arg_conv.inner = untag_ptr(this_arg);
36532         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36534         this_arg_conv.is_owned = false;
36535         LDKChannelFeatures ret_var = ChannelManager_channel_features(&this_arg_conv);
36536         int64_t ret_ref = 0;
36537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36539         return ret_ref;
36540 }
36541
36542 int64_t  CS_LDK_ChannelManager_channel_type_features(int64_t this_arg) {
36543         LDKChannelManager this_arg_conv;
36544         this_arg_conv.inner = untag_ptr(this_arg);
36545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36547         this_arg_conv.is_owned = false;
36548         LDKChannelTypeFeatures ret_var = ChannelManager_channel_type_features(&this_arg_conv);
36549         int64_t ret_ref = 0;
36550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36552         return ret_ref;
36553 }
36554
36555 int64_t  CS_LDK_ChannelManager_init_features(int64_t this_arg) {
36556         LDKChannelManager this_arg_conv;
36557         this_arg_conv.inner = untag_ptr(this_arg);
36558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36560         this_arg_conv.is_owned = false;
36561         LDKInitFeatures ret_var = ChannelManager_init_features(&this_arg_conv);
36562         int64_t ret_ref = 0;
36563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36564         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36565         return ret_ref;
36566 }
36567
36568 int64_t  CS_LDK_ChannelManager_as_ChannelMessageHandler(int64_t this_arg) {
36569         LDKChannelManager this_arg_conv;
36570         this_arg_conv.inner = untag_ptr(this_arg);
36571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36573         this_arg_conv.is_owned = false;
36574         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
36575         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
36576         return tag_ptr(ret_ret, true);
36577 }
36578
36579 int64_t  CS_LDK_ChannelManager_as_OffersMessageHandler(int64_t this_arg) {
36580         LDKChannelManager this_arg_conv;
36581         this_arg_conv.inner = untag_ptr(this_arg);
36582         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36584         this_arg_conv.is_owned = false;
36585         LDKOffersMessageHandler* ret_ret = MALLOC(sizeof(LDKOffersMessageHandler), "LDKOffersMessageHandler");
36586         *ret_ret = ChannelManager_as_OffersMessageHandler(&this_arg_conv);
36587         return tag_ptr(ret_ret, true);
36588 }
36589
36590 int64_t  CS_LDK_provided_init_features(int64_t config) {
36591         LDKUserConfig config_conv;
36592         config_conv.inner = untag_ptr(config);
36593         config_conv.is_owned = ptr_is_owned(config);
36594         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
36595         config_conv.is_owned = false;
36596         LDKInitFeatures ret_var = provided_init_features(&config_conv);
36597         int64_t ret_ref = 0;
36598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36599         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36600         return ret_ref;
36601 }
36602
36603 int8_tArray  CS_LDK_CounterpartyForwardingInfo_write(int64_t obj) {
36604         LDKCounterpartyForwardingInfo obj_conv;
36605         obj_conv.inner = untag_ptr(obj);
36606         obj_conv.is_owned = ptr_is_owned(obj);
36607         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36608         obj_conv.is_owned = false;
36609         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
36610         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36611         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36612         CVec_u8Z_free(ret_var);
36613         return ret_arr;
36614 }
36615
36616 int64_t  CS_LDK_CounterpartyForwardingInfo_read(int8_tArray ser) {
36617         LDKu8slice ser_ref;
36618         ser_ref.datalen = ser->arr_len;
36619         ser_ref.data = ser->elems;
36620         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
36621         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
36622         FREE(ser);
36623         return tag_ptr(ret_conv, true);
36624 }
36625
36626 int8_tArray  CS_LDK_ChannelCounterparty_write(int64_t obj) {
36627         LDKChannelCounterparty obj_conv;
36628         obj_conv.inner = untag_ptr(obj);
36629         obj_conv.is_owned = ptr_is_owned(obj);
36630         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36631         obj_conv.is_owned = false;
36632         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
36633         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36634         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36635         CVec_u8Z_free(ret_var);
36636         return ret_arr;
36637 }
36638
36639 int64_t  CS_LDK_ChannelCounterparty_read(int8_tArray ser) {
36640         LDKu8slice ser_ref;
36641         ser_ref.datalen = ser->arr_len;
36642         ser_ref.data = ser->elems;
36643         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
36644         *ret_conv = ChannelCounterparty_read(ser_ref);
36645         FREE(ser);
36646         return tag_ptr(ret_conv, true);
36647 }
36648
36649 int8_tArray  CS_LDK_ChannelDetails_write(int64_t obj) {
36650         LDKChannelDetails obj_conv;
36651         obj_conv.inner = untag_ptr(obj);
36652         obj_conv.is_owned = ptr_is_owned(obj);
36653         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36654         obj_conv.is_owned = false;
36655         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
36656         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36657         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36658         CVec_u8Z_free(ret_var);
36659         return ret_arr;
36660 }
36661
36662 int64_t  CS_LDK_ChannelDetails_read(int8_tArray ser) {
36663         LDKu8slice ser_ref;
36664         ser_ref.datalen = ser->arr_len;
36665         ser_ref.data = ser->elems;
36666         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
36667         *ret_conv = ChannelDetails_read(ser_ref);
36668         FREE(ser);
36669         return tag_ptr(ret_conv, true);
36670 }
36671
36672 int8_tArray  CS_LDK_PhantomRouteHints_write(int64_t obj) {
36673         LDKPhantomRouteHints obj_conv;
36674         obj_conv.inner = untag_ptr(obj);
36675         obj_conv.is_owned = ptr_is_owned(obj);
36676         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36677         obj_conv.is_owned = false;
36678         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
36679         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36680         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36681         CVec_u8Z_free(ret_var);
36682         return ret_arr;
36683 }
36684
36685 int64_t  CS_LDK_PhantomRouteHints_read(int8_tArray ser) {
36686         LDKu8slice ser_ref;
36687         ser_ref.datalen = ser->arr_len;
36688         ser_ref.data = ser->elems;
36689         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
36690         *ret_conv = PhantomRouteHints_read(ser_ref);
36691         FREE(ser);
36692         return tag_ptr(ret_conv, true);
36693 }
36694
36695 int8_tArray  CS_LDK_ChannelManager_write(int64_t obj) {
36696         LDKChannelManager obj_conv;
36697         obj_conv.inner = untag_ptr(obj);
36698         obj_conv.is_owned = ptr_is_owned(obj);
36699         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36700         obj_conv.is_owned = false;
36701         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
36702         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36703         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36704         CVec_u8Z_free(ret_var);
36705         return ret_arr;
36706 }
36707
36708 int8_tArray  CS_LDK_ChannelShutdownState_write(int64_t obj) {
36709         LDKChannelShutdownState* obj_conv = (LDKChannelShutdownState*)untag_ptr(obj);
36710         LDKCVec_u8Z ret_var = ChannelShutdownState_write(obj_conv);
36711         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36712         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36713         CVec_u8Z_free(ret_var);
36714         return ret_arr;
36715 }
36716
36717 int64_t  CS_LDK_ChannelShutdownState_read(int8_tArray ser) {
36718         LDKu8slice ser_ref;
36719         ser_ref.datalen = ser->arr_len;
36720         ser_ref.data = ser->elems;
36721         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
36722         *ret_conv = ChannelShutdownState_read(ser_ref);
36723         FREE(ser);
36724         return tag_ptr(ret_conv, true);
36725 }
36726
36727 void  CS_LDK_ChannelManagerReadArgs_free(int64_t this_obj) {
36728         LDKChannelManagerReadArgs this_obj_conv;
36729         this_obj_conv.inner = untag_ptr(this_obj);
36730         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36732         ChannelManagerReadArgs_free(this_obj_conv);
36733 }
36734
36735 int64_t  CS_LDK_ChannelManagerReadArgs_get_entropy_source(int64_t this_ptr) {
36736         LDKChannelManagerReadArgs this_ptr_conv;
36737         this_ptr_conv.inner = untag_ptr(this_ptr);
36738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36740         this_ptr_conv.is_owned = false;
36741         // WARNING: This object doesn't live past this scope, needs clone!
36742         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_entropy_source(&this_ptr_conv), false);
36743         return ret_ret;
36744 }
36745
36746 void  CS_LDK_ChannelManagerReadArgs_set_entropy_source(int64_t this_ptr, int64_t val) {
36747         LDKChannelManagerReadArgs this_ptr_conv;
36748         this_ptr_conv.inner = untag_ptr(this_ptr);
36749         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36751         this_ptr_conv.is_owned = false;
36752         void* val_ptr = untag_ptr(val);
36753         CHECK_ACCESS(val_ptr);
36754         LDKEntropySource val_conv = *(LDKEntropySource*)(val_ptr);
36755         if (val_conv.free == LDKEntropySource_JCalls_free) {
36756                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36757                 LDKEntropySource_JCalls_cloned(&val_conv);
36758         }
36759         ChannelManagerReadArgs_set_entropy_source(&this_ptr_conv, val_conv);
36760 }
36761
36762 int64_t  CS_LDK_ChannelManagerReadArgs_get_node_signer(int64_t this_ptr) {
36763         LDKChannelManagerReadArgs this_ptr_conv;
36764         this_ptr_conv.inner = untag_ptr(this_ptr);
36765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36767         this_ptr_conv.is_owned = false;
36768         // WARNING: This object doesn't live past this scope, needs clone!
36769         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_node_signer(&this_ptr_conv), false);
36770         return ret_ret;
36771 }
36772
36773 void  CS_LDK_ChannelManagerReadArgs_set_node_signer(int64_t this_ptr, int64_t val) {
36774         LDKChannelManagerReadArgs this_ptr_conv;
36775         this_ptr_conv.inner = untag_ptr(this_ptr);
36776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36778         this_ptr_conv.is_owned = false;
36779         void* val_ptr = untag_ptr(val);
36780         CHECK_ACCESS(val_ptr);
36781         LDKNodeSigner val_conv = *(LDKNodeSigner*)(val_ptr);
36782         if (val_conv.free == LDKNodeSigner_JCalls_free) {
36783                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36784                 LDKNodeSigner_JCalls_cloned(&val_conv);
36785         }
36786         ChannelManagerReadArgs_set_node_signer(&this_ptr_conv, val_conv);
36787 }
36788
36789 int64_t  CS_LDK_ChannelManagerReadArgs_get_signer_provider(int64_t this_ptr) {
36790         LDKChannelManagerReadArgs this_ptr_conv;
36791         this_ptr_conv.inner = untag_ptr(this_ptr);
36792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36794         this_ptr_conv.is_owned = false;
36795         // WARNING: This object doesn't live past this scope, needs clone!
36796         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_signer_provider(&this_ptr_conv), false);
36797         return ret_ret;
36798 }
36799
36800 void  CS_LDK_ChannelManagerReadArgs_set_signer_provider(int64_t this_ptr, int64_t val) {
36801         LDKChannelManagerReadArgs this_ptr_conv;
36802         this_ptr_conv.inner = untag_ptr(this_ptr);
36803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36805         this_ptr_conv.is_owned = false;
36806         void* val_ptr = untag_ptr(val);
36807         CHECK_ACCESS(val_ptr);
36808         LDKSignerProvider val_conv = *(LDKSignerProvider*)(val_ptr);
36809         if (val_conv.free == LDKSignerProvider_JCalls_free) {
36810                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36811                 LDKSignerProvider_JCalls_cloned(&val_conv);
36812         }
36813         ChannelManagerReadArgs_set_signer_provider(&this_ptr_conv, val_conv);
36814 }
36815
36816 int64_t  CS_LDK_ChannelManagerReadArgs_get_fee_estimator(int64_t this_ptr) {
36817         LDKChannelManagerReadArgs this_ptr_conv;
36818         this_ptr_conv.inner = untag_ptr(this_ptr);
36819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36821         this_ptr_conv.is_owned = false;
36822         // WARNING: This object doesn't live past this scope, needs clone!
36823         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
36824         return ret_ret;
36825 }
36826
36827 void  CS_LDK_ChannelManagerReadArgs_set_fee_estimator(int64_t this_ptr, int64_t val) {
36828         LDKChannelManagerReadArgs this_ptr_conv;
36829         this_ptr_conv.inner = untag_ptr(this_ptr);
36830         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36832         this_ptr_conv.is_owned = false;
36833         void* val_ptr = untag_ptr(val);
36834         CHECK_ACCESS(val_ptr);
36835         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
36836         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
36837                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36838                 LDKFeeEstimator_JCalls_cloned(&val_conv);
36839         }
36840         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
36841 }
36842
36843 int64_t  CS_LDK_ChannelManagerReadArgs_get_chain_monitor(int64_t this_ptr) {
36844         LDKChannelManagerReadArgs this_ptr_conv;
36845         this_ptr_conv.inner = untag_ptr(this_ptr);
36846         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36848         this_ptr_conv.is_owned = false;
36849         // WARNING: This object doesn't live past this scope, needs clone!
36850         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
36851         return ret_ret;
36852 }
36853
36854 void  CS_LDK_ChannelManagerReadArgs_set_chain_monitor(int64_t this_ptr, int64_t val) {
36855         LDKChannelManagerReadArgs this_ptr_conv;
36856         this_ptr_conv.inner = untag_ptr(this_ptr);
36857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36859         this_ptr_conv.is_owned = false;
36860         void* val_ptr = untag_ptr(val);
36861         CHECK_ACCESS(val_ptr);
36862         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
36863         if (val_conv.free == LDKWatch_JCalls_free) {
36864                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36865                 LDKWatch_JCalls_cloned(&val_conv);
36866         }
36867         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
36868 }
36869
36870 int64_t  CS_LDK_ChannelManagerReadArgs_get_tx_broadcaster(int64_t this_ptr) {
36871         LDKChannelManagerReadArgs this_ptr_conv;
36872         this_ptr_conv.inner = untag_ptr(this_ptr);
36873         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36875         this_ptr_conv.is_owned = false;
36876         // WARNING: This object doesn't live past this scope, needs clone!
36877         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
36878         return ret_ret;
36879 }
36880
36881 void  CS_LDK_ChannelManagerReadArgs_set_tx_broadcaster(int64_t this_ptr, int64_t val) {
36882         LDKChannelManagerReadArgs this_ptr_conv;
36883         this_ptr_conv.inner = untag_ptr(this_ptr);
36884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36886         this_ptr_conv.is_owned = false;
36887         void* val_ptr = untag_ptr(val);
36888         CHECK_ACCESS(val_ptr);
36889         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
36890         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
36891                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36892                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
36893         }
36894         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
36895 }
36896
36897 int64_t  CS_LDK_ChannelManagerReadArgs_get_router(int64_t this_ptr) {
36898         LDKChannelManagerReadArgs this_ptr_conv;
36899         this_ptr_conv.inner = untag_ptr(this_ptr);
36900         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36902         this_ptr_conv.is_owned = false;
36903         // WARNING: This object doesn't live past this scope, needs clone!
36904         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_router(&this_ptr_conv), false);
36905         return ret_ret;
36906 }
36907
36908 void  CS_LDK_ChannelManagerReadArgs_set_router(int64_t this_ptr, int64_t val) {
36909         LDKChannelManagerReadArgs this_ptr_conv;
36910         this_ptr_conv.inner = untag_ptr(this_ptr);
36911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36913         this_ptr_conv.is_owned = false;
36914         void* val_ptr = untag_ptr(val);
36915         CHECK_ACCESS(val_ptr);
36916         LDKRouter val_conv = *(LDKRouter*)(val_ptr);
36917         if (val_conv.free == LDKRouter_JCalls_free) {
36918                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36919                 LDKRouter_JCalls_cloned(&val_conv);
36920         }
36921         ChannelManagerReadArgs_set_router(&this_ptr_conv, val_conv);
36922 }
36923
36924 int64_t  CS_LDK_ChannelManagerReadArgs_get_logger(int64_t this_ptr) {
36925         LDKChannelManagerReadArgs this_ptr_conv;
36926         this_ptr_conv.inner = untag_ptr(this_ptr);
36927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36929         this_ptr_conv.is_owned = false;
36930         // WARNING: This object doesn't live past this scope, needs clone!
36931         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
36932         return ret_ret;
36933 }
36934
36935 void  CS_LDK_ChannelManagerReadArgs_set_logger(int64_t this_ptr, int64_t val) {
36936         LDKChannelManagerReadArgs this_ptr_conv;
36937         this_ptr_conv.inner = untag_ptr(this_ptr);
36938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36940         this_ptr_conv.is_owned = false;
36941         void* val_ptr = untag_ptr(val);
36942         CHECK_ACCESS(val_ptr);
36943         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
36944         if (val_conv.free == LDKLogger_JCalls_free) {
36945                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36946                 LDKLogger_JCalls_cloned(&val_conv);
36947         }
36948         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
36949 }
36950
36951 int64_t  CS_LDK_ChannelManagerReadArgs_get_default_config(int64_t this_ptr) {
36952         LDKChannelManagerReadArgs this_ptr_conv;
36953         this_ptr_conv.inner = untag_ptr(this_ptr);
36954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36956         this_ptr_conv.is_owned = false;
36957         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
36958         int64_t ret_ref = 0;
36959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36961         return ret_ref;
36962 }
36963
36964 void  CS_LDK_ChannelManagerReadArgs_set_default_config(int64_t this_ptr, int64_t val) {
36965         LDKChannelManagerReadArgs this_ptr_conv;
36966         this_ptr_conv.inner = untag_ptr(this_ptr);
36967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36969         this_ptr_conv.is_owned = false;
36970         LDKUserConfig val_conv;
36971         val_conv.inner = untag_ptr(val);
36972         val_conv.is_owned = ptr_is_owned(val);
36973         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36974         val_conv = UserConfig_clone(&val_conv);
36975         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
36976 }
36977
36978 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) {
36979         void* entropy_source_ptr = untag_ptr(entropy_source);
36980         CHECK_ACCESS(entropy_source_ptr);
36981         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
36982         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
36983                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36984                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
36985         }
36986         void* node_signer_ptr = untag_ptr(node_signer);
36987         CHECK_ACCESS(node_signer_ptr);
36988         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
36989         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
36990                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36991                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
36992         }
36993         void* signer_provider_ptr = untag_ptr(signer_provider);
36994         CHECK_ACCESS(signer_provider_ptr);
36995         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
36996         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
36997                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36998                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
36999         }
37000         void* fee_estimator_ptr = untag_ptr(fee_estimator);
37001         CHECK_ACCESS(fee_estimator_ptr);
37002         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
37003         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
37004                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37005                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
37006         }
37007         void* chain_monitor_ptr = untag_ptr(chain_monitor);
37008         CHECK_ACCESS(chain_monitor_ptr);
37009         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
37010         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
37011                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37012                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
37013         }
37014         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
37015         CHECK_ACCESS(tx_broadcaster_ptr);
37016         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
37017         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
37018                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37019                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
37020         }
37021         void* router_ptr = untag_ptr(router);
37022         CHECK_ACCESS(router_ptr);
37023         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
37024         if (router_conv.free == LDKRouter_JCalls_free) {
37025                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37026                 LDKRouter_JCalls_cloned(&router_conv);
37027         }
37028         void* logger_ptr = untag_ptr(logger);
37029         CHECK_ACCESS(logger_ptr);
37030         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37031         if (logger_conv.free == LDKLogger_JCalls_free) {
37032                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37033                 LDKLogger_JCalls_cloned(&logger_conv);
37034         }
37035         LDKUserConfig default_config_conv;
37036         default_config_conv.inner = untag_ptr(default_config);
37037         default_config_conv.is_owned = ptr_is_owned(default_config);
37038         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
37039         default_config_conv = UserConfig_clone(&default_config_conv);
37040         LDKCVec_ChannelMonitorZ channel_monitors_constr;
37041         channel_monitors_constr.datalen = channel_monitors->arr_len;
37042         if (channel_monitors_constr.datalen > 0)
37043                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
37044         else
37045                 channel_monitors_constr.data = NULL;
37046         int64_t* channel_monitors_vals = channel_monitors->elems;
37047         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
37048                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
37049                 LDKChannelMonitor channel_monitors_conv_16_conv;
37050                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
37051                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
37052                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
37053                 channel_monitors_conv_16_conv.is_owned = false;
37054                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
37055         }
37056         FREE(channel_monitors);
37057         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);
37058         int64_t ret_ref = 0;
37059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37060         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37061         return ret_ref;
37062 }
37063
37064 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_read(int8_tArray ser, int64_t arg) {
37065         LDKu8slice ser_ref;
37066         ser_ref.datalen = ser->arr_len;
37067         ser_ref.data = ser->elems;
37068         LDKChannelManagerReadArgs arg_conv;
37069         arg_conv.inner = untag_ptr(arg);
37070         arg_conv.is_owned = ptr_is_owned(arg);
37071         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37072         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
37073         
37074         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ");
37075         *ret_conv = C2Tuple_ThirtyTwoBytesChannelManagerZ_read(ser_ref, arg_conv);
37076         FREE(ser);
37077         return tag_ptr(ret_conv, true);
37078 }
37079
37080 void  CS_LDK_ExpandedKey_free(int64_t this_obj) {
37081         LDKExpandedKey this_obj_conv;
37082         this_obj_conv.inner = untag_ptr(this_obj);
37083         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37085         ExpandedKey_free(this_obj_conv);
37086 }
37087
37088 int64_t  CS_LDK_ExpandedKey_new(int8_tArray key_material) {
37089         uint8_t key_material_arr[32];
37090         CHECK(key_material->arr_len == 32);
37091         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
37092         uint8_t (*key_material_ref)[32] = &key_material_arr;
37093         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
37094         int64_t ret_ref = 0;
37095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37097         return ret_ref;
37098 }
37099
37100 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) {
37101         LDKExpandedKey keys_conv;
37102         keys_conv.inner = untag_ptr(keys);
37103         keys_conv.is_owned = ptr_is_owned(keys);
37104         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
37105         keys_conv.is_owned = false;
37106         void* min_value_msat_ptr = untag_ptr(min_value_msat);
37107         CHECK_ACCESS(min_value_msat_ptr);
37108         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
37109         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
37110         void* entropy_source_ptr = untag_ptr(entropy_source);
37111         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
37112         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
37113         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
37114         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
37115         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
37116         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
37117         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
37118         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, entropy_source_conv, current_time, min_final_cltv_expiry_delta_conv);
37119         return tag_ptr(ret_conv, true);
37120 }
37121
37122 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) {
37123         LDKExpandedKey keys_conv;
37124         keys_conv.inner = untag_ptr(keys);
37125         keys_conv.is_owned = ptr_is_owned(keys);
37126         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
37127         keys_conv.is_owned = false;
37128         void* min_value_msat_ptr = untag_ptr(min_value_msat);
37129         CHECK_ACCESS(min_value_msat_ptr);
37130         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
37131         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
37132         LDKThirtyTwoBytes payment_hash_ref;
37133         CHECK(payment_hash->arr_len == 32);
37134         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
37135         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
37136         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
37137         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
37138         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
37139         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
37140         *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);
37141         return tag_ptr(ret_conv, true);
37142 }
37143
37144 void  CS_LDK_DecodeError_free(int64_t this_ptr) {
37145         if (!ptr_is_owned(this_ptr)) return;
37146         void* this_ptr_ptr = untag_ptr(this_ptr);
37147         CHECK_ACCESS(this_ptr_ptr);
37148         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
37149         FREE(untag_ptr(this_ptr));
37150         DecodeError_free(this_ptr_conv);
37151 }
37152
37153 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
37154         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37155         *ret_copy = DecodeError_clone(arg);
37156         int64_t ret_ref = tag_ptr(ret_copy, true);
37157         return ret_ref;
37158 }
37159 int64_t  CS_LDK_DecodeError_clone_ptr(int64_t arg) {
37160         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
37161         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
37162         return ret_conv;
37163 }
37164
37165 int64_t  CS_LDK_DecodeError_clone(int64_t orig) {
37166         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
37167         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37168         *ret_copy = DecodeError_clone(orig_conv);
37169         int64_t ret_ref = tag_ptr(ret_copy, true);
37170         return ret_ref;
37171 }
37172
37173 int64_t  CS_LDK_DecodeError_unknown_version() {
37174         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37175         *ret_copy = DecodeError_unknown_version();
37176         int64_t ret_ref = tag_ptr(ret_copy, true);
37177         return ret_ref;
37178 }
37179
37180 int64_t  CS_LDK_DecodeError_unknown_required_feature() {
37181         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37182         *ret_copy = DecodeError_unknown_required_feature();
37183         int64_t ret_ref = tag_ptr(ret_copy, true);
37184         return ret_ref;
37185 }
37186
37187 int64_t  CS_LDK_DecodeError_invalid_value() {
37188         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37189         *ret_copy = DecodeError_invalid_value();
37190         int64_t ret_ref = tag_ptr(ret_copy, true);
37191         return ret_ref;
37192 }
37193
37194 int64_t  CS_LDK_DecodeError_short_read() {
37195         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37196         *ret_copy = DecodeError_short_read();
37197         int64_t ret_ref = tag_ptr(ret_copy, true);
37198         return ret_ref;
37199 }
37200
37201 int64_t  CS_LDK_DecodeError_bad_length_descriptor() {
37202         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37203         *ret_copy = DecodeError_bad_length_descriptor();
37204         int64_t ret_ref = tag_ptr(ret_copy, true);
37205         return ret_ref;
37206 }
37207
37208 int64_t  CS_LDK_DecodeError_io(int32_t a) {
37209         LDKIOError a_conv = LDKIOError_from_cs(a);
37210         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37211         *ret_copy = DecodeError_io(a_conv);
37212         int64_t ret_ref = tag_ptr(ret_copy, true);
37213         return ret_ref;
37214 }
37215
37216 int64_t  CS_LDK_DecodeError_unsupported_compression() {
37217         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37218         *ret_copy = DecodeError_unsupported_compression();
37219         int64_t ret_ref = tag_ptr(ret_copy, true);
37220         return ret_ref;
37221 }
37222
37223 jboolean  CS_LDK_DecodeError_eq(int64_t a, int64_t b) {
37224         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
37225         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
37226         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
37227         return ret_conv;
37228 }
37229
37230 void  CS_LDK_Init_free(int64_t this_obj) {
37231         LDKInit this_obj_conv;
37232         this_obj_conv.inner = untag_ptr(this_obj);
37233         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37235         Init_free(this_obj_conv);
37236 }
37237
37238 int64_t  CS_LDK_Init_get_features(int64_t this_ptr) {
37239         LDKInit this_ptr_conv;
37240         this_ptr_conv.inner = untag_ptr(this_ptr);
37241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37243         this_ptr_conv.is_owned = false;
37244         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
37245         int64_t ret_ref = 0;
37246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37247         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37248         return ret_ref;
37249 }
37250
37251 void  CS_LDK_Init_set_features(int64_t this_ptr, int64_t val) {
37252         LDKInit this_ptr_conv;
37253         this_ptr_conv.inner = untag_ptr(this_ptr);
37254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37256         this_ptr_conv.is_owned = false;
37257         LDKInitFeatures val_conv;
37258         val_conv.inner = untag_ptr(val);
37259         val_conv.is_owned = ptr_is_owned(val);
37260         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37261         val_conv = InitFeatures_clone(&val_conv);
37262         Init_set_features(&this_ptr_conv, val_conv);
37263 }
37264
37265 int64_t  CS_LDK_Init_get_networks(int64_t this_ptr) {
37266         LDKInit this_ptr_conv;
37267         this_ptr_conv.inner = untag_ptr(this_ptr);
37268         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37270         this_ptr_conv.is_owned = false;
37271         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
37272         *ret_copy = Init_get_networks(&this_ptr_conv);
37273         int64_t ret_ref = tag_ptr(ret_copy, true);
37274         return ret_ref;
37275 }
37276
37277 void  CS_LDK_Init_set_networks(int64_t this_ptr, int64_t val) {
37278         LDKInit this_ptr_conv;
37279         this_ptr_conv.inner = untag_ptr(this_ptr);
37280         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37282         this_ptr_conv.is_owned = false;
37283         void* val_ptr = untag_ptr(val);
37284         CHECK_ACCESS(val_ptr);
37285         LDKCOption_CVec_ThirtyTwoBytesZZ val_conv = *(LDKCOption_CVec_ThirtyTwoBytesZZ*)(val_ptr);
37286         val_conv = COption_CVec_ThirtyTwoBytesZZ_clone((LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(val));
37287         Init_set_networks(&this_ptr_conv, val_conv);
37288 }
37289
37290 int64_t  CS_LDK_Init_get_remote_network_address(int64_t this_ptr) {
37291         LDKInit this_ptr_conv;
37292         this_ptr_conv.inner = untag_ptr(this_ptr);
37293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37295         this_ptr_conv.is_owned = false;
37296         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
37297         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
37298         int64_t ret_ref = tag_ptr(ret_copy, true);
37299         return ret_ref;
37300 }
37301
37302 void  CS_LDK_Init_set_remote_network_address(int64_t this_ptr, int64_t val) {
37303         LDKInit this_ptr_conv;
37304         this_ptr_conv.inner = untag_ptr(this_ptr);
37305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37307         this_ptr_conv.is_owned = false;
37308         void* val_ptr = untag_ptr(val);
37309         CHECK_ACCESS(val_ptr);
37310         LDKCOption_SocketAddressZ val_conv = *(LDKCOption_SocketAddressZ*)(val_ptr);
37311         val_conv = COption_SocketAddressZ_clone((LDKCOption_SocketAddressZ*)untag_ptr(val));
37312         Init_set_remote_network_address(&this_ptr_conv, val_conv);
37313 }
37314
37315 int64_t  CS_LDK_Init_new(int64_t features_arg, int64_t networks_arg, int64_t remote_network_address_arg) {
37316         LDKInitFeatures features_arg_conv;
37317         features_arg_conv.inner = untag_ptr(features_arg);
37318         features_arg_conv.is_owned = ptr_is_owned(features_arg);
37319         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37320         features_arg_conv = InitFeatures_clone(&features_arg_conv);
37321         void* networks_arg_ptr = untag_ptr(networks_arg);
37322         CHECK_ACCESS(networks_arg_ptr);
37323         LDKCOption_CVec_ThirtyTwoBytesZZ networks_arg_conv = *(LDKCOption_CVec_ThirtyTwoBytesZZ*)(networks_arg_ptr);
37324         networks_arg_conv = COption_CVec_ThirtyTwoBytesZZ_clone((LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(networks_arg));
37325         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
37326         CHECK_ACCESS(remote_network_address_arg_ptr);
37327         LDKCOption_SocketAddressZ remote_network_address_arg_conv = *(LDKCOption_SocketAddressZ*)(remote_network_address_arg_ptr);
37328         LDKInit ret_var = Init_new(features_arg_conv, networks_arg_conv, remote_network_address_arg_conv);
37329         int64_t ret_ref = 0;
37330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37332         return ret_ref;
37333 }
37334
37335 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
37336         LDKInit ret_var = Init_clone(arg);
37337         int64_t ret_ref = 0;
37338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37340         return ret_ref;
37341 }
37342 int64_t  CS_LDK_Init_clone_ptr(int64_t arg) {
37343         LDKInit arg_conv;
37344         arg_conv.inner = untag_ptr(arg);
37345         arg_conv.is_owned = ptr_is_owned(arg);
37346         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37347         arg_conv.is_owned = false;
37348         int64_t ret_conv = Init_clone_ptr(&arg_conv);
37349         return ret_conv;
37350 }
37351
37352 int64_t  CS_LDK_Init_clone(int64_t orig) {
37353         LDKInit orig_conv;
37354         orig_conv.inner = untag_ptr(orig);
37355         orig_conv.is_owned = ptr_is_owned(orig);
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37357         orig_conv.is_owned = false;
37358         LDKInit ret_var = Init_clone(&orig_conv);
37359         int64_t ret_ref = 0;
37360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37362         return ret_ref;
37363 }
37364
37365 jboolean  CS_LDK_Init_eq(int64_t a, int64_t b) {
37366         LDKInit a_conv;
37367         a_conv.inner = untag_ptr(a);
37368         a_conv.is_owned = ptr_is_owned(a);
37369         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37370         a_conv.is_owned = false;
37371         LDKInit b_conv;
37372         b_conv.inner = untag_ptr(b);
37373         b_conv.is_owned = ptr_is_owned(b);
37374         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37375         b_conv.is_owned = false;
37376         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
37377         return ret_conv;
37378 }
37379
37380 void  CS_LDK_ErrorMessage_free(int64_t this_obj) {
37381         LDKErrorMessage this_obj_conv;
37382         this_obj_conv.inner = untag_ptr(this_obj);
37383         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37385         ErrorMessage_free(this_obj_conv);
37386 }
37387
37388 int8_tArray  CS_LDK_ErrorMessage_get_channel_id(int64_t this_ptr) {
37389         LDKErrorMessage this_ptr_conv;
37390         this_ptr_conv.inner = untag_ptr(this_ptr);
37391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37393         this_ptr_conv.is_owned = false;
37394         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37395         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
37396         return ret_arr;
37397 }
37398
37399 void  CS_LDK_ErrorMessage_set_channel_id(int64_t this_ptr, int8_tArray val) {
37400         LDKErrorMessage this_ptr_conv;
37401         this_ptr_conv.inner = untag_ptr(this_ptr);
37402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37404         this_ptr_conv.is_owned = false;
37405         LDKThirtyTwoBytes val_ref;
37406         CHECK(val->arr_len == 32);
37407         memcpy(val_ref.data, val->elems, 32); FREE(val);
37408         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
37409 }
37410
37411 jstring  CS_LDK_ErrorMessage_get_data(int64_t this_ptr) {
37412         LDKErrorMessage this_ptr_conv;
37413         this_ptr_conv.inner = untag_ptr(this_ptr);
37414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37416         this_ptr_conv.is_owned = false;
37417         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
37418         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
37419         Str_free(ret_str);
37420         return ret_conv;
37421 }
37422
37423 void  CS_LDK_ErrorMessage_set_data(int64_t this_ptr, jstring val) {
37424         LDKErrorMessage this_ptr_conv;
37425         this_ptr_conv.inner = untag_ptr(this_ptr);
37426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37428         this_ptr_conv.is_owned = false;
37429         LDKStr val_conv = str_ref_to_owned_c(val);
37430         ErrorMessage_set_data(&this_ptr_conv, val_conv);
37431 }
37432
37433 int64_t  CS_LDK_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
37434         LDKThirtyTwoBytes channel_id_arg_ref;
37435         CHECK(channel_id_arg->arr_len == 32);
37436         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
37437         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
37438         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
37439         int64_t ret_ref = 0;
37440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37441         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37442         return ret_ref;
37443 }
37444
37445 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
37446         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
37447         int64_t ret_ref = 0;
37448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37449         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37450         return ret_ref;
37451 }
37452 int64_t  CS_LDK_ErrorMessage_clone_ptr(int64_t arg) {
37453         LDKErrorMessage arg_conv;
37454         arg_conv.inner = untag_ptr(arg);
37455         arg_conv.is_owned = ptr_is_owned(arg);
37456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37457         arg_conv.is_owned = false;
37458         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
37459         return ret_conv;
37460 }
37461
37462 int64_t  CS_LDK_ErrorMessage_clone(int64_t orig) {
37463         LDKErrorMessage orig_conv;
37464         orig_conv.inner = untag_ptr(orig);
37465         orig_conv.is_owned = ptr_is_owned(orig);
37466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37467         orig_conv.is_owned = false;
37468         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
37469         int64_t ret_ref = 0;
37470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37472         return ret_ref;
37473 }
37474
37475 jboolean  CS_LDK_ErrorMessage_eq(int64_t a, int64_t b) {
37476         LDKErrorMessage a_conv;
37477         a_conv.inner = untag_ptr(a);
37478         a_conv.is_owned = ptr_is_owned(a);
37479         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37480         a_conv.is_owned = false;
37481         LDKErrorMessage b_conv;
37482         b_conv.inner = untag_ptr(b);
37483         b_conv.is_owned = ptr_is_owned(b);
37484         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37485         b_conv.is_owned = false;
37486         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
37487         return ret_conv;
37488 }
37489
37490 void  CS_LDK_WarningMessage_free(int64_t this_obj) {
37491         LDKWarningMessage this_obj_conv;
37492         this_obj_conv.inner = untag_ptr(this_obj);
37493         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37495         WarningMessage_free(this_obj_conv);
37496 }
37497
37498 int8_tArray  CS_LDK_WarningMessage_get_channel_id(int64_t this_ptr) {
37499         LDKWarningMessage this_ptr_conv;
37500         this_ptr_conv.inner = untag_ptr(this_ptr);
37501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37503         this_ptr_conv.is_owned = false;
37504         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37505         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
37506         return ret_arr;
37507 }
37508
37509 void  CS_LDK_WarningMessage_set_channel_id(int64_t this_ptr, int8_tArray val) {
37510         LDKWarningMessage this_ptr_conv;
37511         this_ptr_conv.inner = untag_ptr(this_ptr);
37512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37514         this_ptr_conv.is_owned = false;
37515         LDKThirtyTwoBytes val_ref;
37516         CHECK(val->arr_len == 32);
37517         memcpy(val_ref.data, val->elems, 32); FREE(val);
37518         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
37519 }
37520
37521 jstring  CS_LDK_WarningMessage_get_data(int64_t this_ptr) {
37522         LDKWarningMessage this_ptr_conv;
37523         this_ptr_conv.inner = untag_ptr(this_ptr);
37524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37526         this_ptr_conv.is_owned = false;
37527         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
37528         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
37529         Str_free(ret_str);
37530         return ret_conv;
37531 }
37532
37533 void  CS_LDK_WarningMessage_set_data(int64_t this_ptr, jstring val) {
37534         LDKWarningMessage this_ptr_conv;
37535         this_ptr_conv.inner = untag_ptr(this_ptr);
37536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37538         this_ptr_conv.is_owned = false;
37539         LDKStr val_conv = str_ref_to_owned_c(val);
37540         WarningMessage_set_data(&this_ptr_conv, val_conv);
37541 }
37542
37543 int64_t  CS_LDK_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
37544         LDKThirtyTwoBytes channel_id_arg_ref;
37545         CHECK(channel_id_arg->arr_len == 32);
37546         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
37547         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
37548         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
37549         int64_t ret_ref = 0;
37550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37552         return ret_ref;
37553 }
37554
37555 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
37556         LDKWarningMessage ret_var = WarningMessage_clone(arg);
37557         int64_t ret_ref = 0;
37558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37560         return ret_ref;
37561 }
37562 int64_t  CS_LDK_WarningMessage_clone_ptr(int64_t arg) {
37563         LDKWarningMessage arg_conv;
37564         arg_conv.inner = untag_ptr(arg);
37565         arg_conv.is_owned = ptr_is_owned(arg);
37566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37567         arg_conv.is_owned = false;
37568         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
37569         return ret_conv;
37570 }
37571
37572 int64_t  CS_LDK_WarningMessage_clone(int64_t orig) {
37573         LDKWarningMessage orig_conv;
37574         orig_conv.inner = untag_ptr(orig);
37575         orig_conv.is_owned = ptr_is_owned(orig);
37576         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37577         orig_conv.is_owned = false;
37578         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
37579         int64_t ret_ref = 0;
37580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37582         return ret_ref;
37583 }
37584
37585 jboolean  CS_LDK_WarningMessage_eq(int64_t a, int64_t b) {
37586         LDKWarningMessage a_conv;
37587         a_conv.inner = untag_ptr(a);
37588         a_conv.is_owned = ptr_is_owned(a);
37589         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37590         a_conv.is_owned = false;
37591         LDKWarningMessage b_conv;
37592         b_conv.inner = untag_ptr(b);
37593         b_conv.is_owned = ptr_is_owned(b);
37594         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37595         b_conv.is_owned = false;
37596         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
37597         return ret_conv;
37598 }
37599
37600 void  CS_LDK_Ping_free(int64_t this_obj) {
37601         LDKPing this_obj_conv;
37602         this_obj_conv.inner = untag_ptr(this_obj);
37603         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37605         Ping_free(this_obj_conv);
37606 }
37607
37608 int16_t  CS_LDK_Ping_get_ponglen(int64_t this_ptr) {
37609         LDKPing this_ptr_conv;
37610         this_ptr_conv.inner = untag_ptr(this_ptr);
37611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37613         this_ptr_conv.is_owned = false;
37614         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
37615         return ret_conv;
37616 }
37617
37618 void  CS_LDK_Ping_set_ponglen(int64_t this_ptr, int16_t val) {
37619         LDKPing this_ptr_conv;
37620         this_ptr_conv.inner = untag_ptr(this_ptr);
37621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37623         this_ptr_conv.is_owned = false;
37624         Ping_set_ponglen(&this_ptr_conv, val);
37625 }
37626
37627 int16_t  CS_LDK_Ping_get_byteslen(int64_t this_ptr) {
37628         LDKPing this_ptr_conv;
37629         this_ptr_conv.inner = untag_ptr(this_ptr);
37630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37632         this_ptr_conv.is_owned = false;
37633         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
37634         return ret_conv;
37635 }
37636
37637 void  CS_LDK_Ping_set_byteslen(int64_t this_ptr, int16_t val) {
37638         LDKPing this_ptr_conv;
37639         this_ptr_conv.inner = untag_ptr(this_ptr);
37640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37642         this_ptr_conv.is_owned = false;
37643         Ping_set_byteslen(&this_ptr_conv, val);
37644 }
37645
37646 int64_t  CS_LDK_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
37647         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
37648         int64_t ret_ref = 0;
37649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37651         return ret_ref;
37652 }
37653
37654 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
37655         LDKPing ret_var = Ping_clone(arg);
37656         int64_t ret_ref = 0;
37657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37658         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37659         return ret_ref;
37660 }
37661 int64_t  CS_LDK_Ping_clone_ptr(int64_t arg) {
37662         LDKPing arg_conv;
37663         arg_conv.inner = untag_ptr(arg);
37664         arg_conv.is_owned = ptr_is_owned(arg);
37665         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37666         arg_conv.is_owned = false;
37667         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
37668         return ret_conv;
37669 }
37670
37671 int64_t  CS_LDK_Ping_clone(int64_t orig) {
37672         LDKPing orig_conv;
37673         orig_conv.inner = untag_ptr(orig);
37674         orig_conv.is_owned = ptr_is_owned(orig);
37675         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37676         orig_conv.is_owned = false;
37677         LDKPing ret_var = Ping_clone(&orig_conv);
37678         int64_t ret_ref = 0;
37679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37680         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37681         return ret_ref;
37682 }
37683
37684 jboolean  CS_LDK_Ping_eq(int64_t a, int64_t b) {
37685         LDKPing a_conv;
37686         a_conv.inner = untag_ptr(a);
37687         a_conv.is_owned = ptr_is_owned(a);
37688         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37689         a_conv.is_owned = false;
37690         LDKPing b_conv;
37691         b_conv.inner = untag_ptr(b);
37692         b_conv.is_owned = ptr_is_owned(b);
37693         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37694         b_conv.is_owned = false;
37695         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
37696         return ret_conv;
37697 }
37698
37699 void  CS_LDK_Pong_free(int64_t this_obj) {
37700         LDKPong this_obj_conv;
37701         this_obj_conv.inner = untag_ptr(this_obj);
37702         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37704         Pong_free(this_obj_conv);
37705 }
37706
37707 int16_t  CS_LDK_Pong_get_byteslen(int64_t this_ptr) {
37708         LDKPong this_ptr_conv;
37709         this_ptr_conv.inner = untag_ptr(this_ptr);
37710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37712         this_ptr_conv.is_owned = false;
37713         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
37714         return ret_conv;
37715 }
37716
37717 void  CS_LDK_Pong_set_byteslen(int64_t this_ptr, int16_t val) {
37718         LDKPong this_ptr_conv;
37719         this_ptr_conv.inner = untag_ptr(this_ptr);
37720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37722         this_ptr_conv.is_owned = false;
37723         Pong_set_byteslen(&this_ptr_conv, val);
37724 }
37725
37726 int64_t  CS_LDK_Pong_new(int16_t byteslen_arg) {
37727         LDKPong ret_var = Pong_new(byteslen_arg);
37728         int64_t ret_ref = 0;
37729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37731         return ret_ref;
37732 }
37733
37734 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
37735         LDKPong ret_var = Pong_clone(arg);
37736         int64_t ret_ref = 0;
37737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37738         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37739         return ret_ref;
37740 }
37741 int64_t  CS_LDK_Pong_clone_ptr(int64_t arg) {
37742         LDKPong arg_conv;
37743         arg_conv.inner = untag_ptr(arg);
37744         arg_conv.is_owned = ptr_is_owned(arg);
37745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37746         arg_conv.is_owned = false;
37747         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
37748         return ret_conv;
37749 }
37750
37751 int64_t  CS_LDK_Pong_clone(int64_t orig) {
37752         LDKPong orig_conv;
37753         orig_conv.inner = untag_ptr(orig);
37754         orig_conv.is_owned = ptr_is_owned(orig);
37755         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37756         orig_conv.is_owned = false;
37757         LDKPong ret_var = Pong_clone(&orig_conv);
37758         int64_t ret_ref = 0;
37759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37760         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37761         return ret_ref;
37762 }
37763
37764 jboolean  CS_LDK_Pong_eq(int64_t a, int64_t b) {
37765         LDKPong a_conv;
37766         a_conv.inner = untag_ptr(a);
37767         a_conv.is_owned = ptr_is_owned(a);
37768         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37769         a_conv.is_owned = false;
37770         LDKPong b_conv;
37771         b_conv.inner = untag_ptr(b);
37772         b_conv.is_owned = ptr_is_owned(b);
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37774         b_conv.is_owned = false;
37775         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
37776         return ret_conv;
37777 }
37778
37779 void  CS_LDK_OpenChannel_free(int64_t this_obj) {
37780         LDKOpenChannel this_obj_conv;
37781         this_obj_conv.inner = untag_ptr(this_obj);
37782         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37784         OpenChannel_free(this_obj_conv);
37785 }
37786
37787 int8_tArray  CS_LDK_OpenChannel_get_chain_hash(int64_t this_ptr) {
37788         LDKOpenChannel this_ptr_conv;
37789         this_ptr_conv.inner = untag_ptr(this_ptr);
37790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37792         this_ptr_conv.is_owned = false;
37793         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37794         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
37795         return ret_arr;
37796 }
37797
37798 void  CS_LDK_OpenChannel_set_chain_hash(int64_t this_ptr, int8_tArray val) {
37799         LDKOpenChannel this_ptr_conv;
37800         this_ptr_conv.inner = untag_ptr(this_ptr);
37801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37803         this_ptr_conv.is_owned = false;
37804         LDKThirtyTwoBytes val_ref;
37805         CHECK(val->arr_len == 32);
37806         memcpy(val_ref.data, val->elems, 32); FREE(val);
37807         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
37808 }
37809
37810 int8_tArray  CS_LDK_OpenChannel_get_temporary_channel_id(int64_t this_ptr) {
37811         LDKOpenChannel this_ptr_conv;
37812         this_ptr_conv.inner = untag_ptr(this_ptr);
37813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37815         this_ptr_conv.is_owned = false;
37816         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37817         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
37818         return ret_arr;
37819 }
37820
37821 void  CS_LDK_OpenChannel_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
37822         LDKOpenChannel this_ptr_conv;
37823         this_ptr_conv.inner = untag_ptr(this_ptr);
37824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37826         this_ptr_conv.is_owned = false;
37827         LDKThirtyTwoBytes val_ref;
37828         CHECK(val->arr_len == 32);
37829         memcpy(val_ref.data, val->elems, 32); FREE(val);
37830         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
37831 }
37832
37833 int64_t  CS_LDK_OpenChannel_get_funding_satoshis(int64_t this_ptr) {
37834         LDKOpenChannel this_ptr_conv;
37835         this_ptr_conv.inner = untag_ptr(this_ptr);
37836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37838         this_ptr_conv.is_owned = false;
37839         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
37840         return ret_conv;
37841 }
37842
37843 void  CS_LDK_OpenChannel_set_funding_satoshis(int64_t this_ptr, int64_t val) {
37844         LDKOpenChannel this_ptr_conv;
37845         this_ptr_conv.inner = untag_ptr(this_ptr);
37846         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37848         this_ptr_conv.is_owned = false;
37849         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
37850 }
37851
37852 int64_t  CS_LDK_OpenChannel_get_push_msat(int64_t this_ptr) {
37853         LDKOpenChannel this_ptr_conv;
37854         this_ptr_conv.inner = untag_ptr(this_ptr);
37855         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37857         this_ptr_conv.is_owned = false;
37858         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
37859         return ret_conv;
37860 }
37861
37862 void  CS_LDK_OpenChannel_set_push_msat(int64_t this_ptr, int64_t val) {
37863         LDKOpenChannel this_ptr_conv;
37864         this_ptr_conv.inner = untag_ptr(this_ptr);
37865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37867         this_ptr_conv.is_owned = false;
37868         OpenChannel_set_push_msat(&this_ptr_conv, val);
37869 }
37870
37871 int64_t  CS_LDK_OpenChannel_get_dust_limit_satoshis(int64_t this_ptr) {
37872         LDKOpenChannel this_ptr_conv;
37873         this_ptr_conv.inner = untag_ptr(this_ptr);
37874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37876         this_ptr_conv.is_owned = false;
37877         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
37878         return ret_conv;
37879 }
37880
37881 void  CS_LDK_OpenChannel_set_dust_limit_satoshis(int64_t this_ptr, int64_t val) {
37882         LDKOpenChannel this_ptr_conv;
37883         this_ptr_conv.inner = untag_ptr(this_ptr);
37884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37886         this_ptr_conv.is_owned = false;
37887         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
37888 }
37889
37890 int64_t  CS_LDK_OpenChannel_get_max_htlc_value_in_flight_msat(int64_t this_ptr) {
37891         LDKOpenChannel this_ptr_conv;
37892         this_ptr_conv.inner = untag_ptr(this_ptr);
37893         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37895         this_ptr_conv.is_owned = false;
37896         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
37897         return ret_conv;
37898 }
37899
37900 void  CS_LDK_OpenChannel_set_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
37901         LDKOpenChannel this_ptr_conv;
37902         this_ptr_conv.inner = untag_ptr(this_ptr);
37903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37905         this_ptr_conv.is_owned = false;
37906         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
37907 }
37908
37909 int64_t  CS_LDK_OpenChannel_get_channel_reserve_satoshis(int64_t this_ptr) {
37910         LDKOpenChannel this_ptr_conv;
37911         this_ptr_conv.inner = untag_ptr(this_ptr);
37912         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37914         this_ptr_conv.is_owned = false;
37915         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
37916         return ret_conv;
37917 }
37918
37919 void  CS_LDK_OpenChannel_set_channel_reserve_satoshis(int64_t this_ptr, int64_t val) {
37920         LDKOpenChannel this_ptr_conv;
37921         this_ptr_conv.inner = untag_ptr(this_ptr);
37922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37924         this_ptr_conv.is_owned = false;
37925         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
37926 }
37927
37928 int64_t  CS_LDK_OpenChannel_get_htlc_minimum_msat(int64_t this_ptr) {
37929         LDKOpenChannel this_ptr_conv;
37930         this_ptr_conv.inner = untag_ptr(this_ptr);
37931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37933         this_ptr_conv.is_owned = false;
37934         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
37935         return ret_conv;
37936 }
37937
37938 void  CS_LDK_OpenChannel_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
37939         LDKOpenChannel this_ptr_conv;
37940         this_ptr_conv.inner = untag_ptr(this_ptr);
37941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37943         this_ptr_conv.is_owned = false;
37944         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
37945 }
37946
37947 int32_t  CS_LDK_OpenChannel_get_feerate_per_kw(int64_t this_ptr) {
37948         LDKOpenChannel this_ptr_conv;
37949         this_ptr_conv.inner = untag_ptr(this_ptr);
37950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37952         this_ptr_conv.is_owned = false;
37953         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
37954         return ret_conv;
37955 }
37956
37957 void  CS_LDK_OpenChannel_set_feerate_per_kw(int64_t this_ptr, int32_t val) {
37958         LDKOpenChannel this_ptr_conv;
37959         this_ptr_conv.inner = untag_ptr(this_ptr);
37960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37962         this_ptr_conv.is_owned = false;
37963         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
37964 }
37965
37966 int16_t  CS_LDK_OpenChannel_get_to_self_delay(int64_t this_ptr) {
37967         LDKOpenChannel this_ptr_conv;
37968         this_ptr_conv.inner = untag_ptr(this_ptr);
37969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37971         this_ptr_conv.is_owned = false;
37972         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
37973         return ret_conv;
37974 }
37975
37976 void  CS_LDK_OpenChannel_set_to_self_delay(int64_t this_ptr, int16_t val) {
37977         LDKOpenChannel this_ptr_conv;
37978         this_ptr_conv.inner = untag_ptr(this_ptr);
37979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37981         this_ptr_conv.is_owned = false;
37982         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
37983 }
37984
37985 int16_t  CS_LDK_OpenChannel_get_max_accepted_htlcs(int64_t this_ptr) {
37986         LDKOpenChannel this_ptr_conv;
37987         this_ptr_conv.inner = untag_ptr(this_ptr);
37988         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37990         this_ptr_conv.is_owned = false;
37991         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
37992         return ret_conv;
37993 }
37994
37995 void  CS_LDK_OpenChannel_set_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
37996         LDKOpenChannel this_ptr_conv;
37997         this_ptr_conv.inner = untag_ptr(this_ptr);
37998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38000         this_ptr_conv.is_owned = false;
38001         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
38002 }
38003
38004 int8_tArray  CS_LDK_OpenChannel_get_funding_pubkey(int64_t this_ptr) {
38005         LDKOpenChannel this_ptr_conv;
38006         this_ptr_conv.inner = untag_ptr(this_ptr);
38007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38009         this_ptr_conv.is_owned = false;
38010         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38011         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
38012         return ret_arr;
38013 }
38014
38015 void  CS_LDK_OpenChannel_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
38016         LDKOpenChannel this_ptr_conv;
38017         this_ptr_conv.inner = untag_ptr(this_ptr);
38018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38020         this_ptr_conv.is_owned = false;
38021         LDKPublicKey val_ref;
38022         CHECK(val->arr_len == 33);
38023         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38024         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
38025 }
38026
38027 int8_tArray  CS_LDK_OpenChannel_get_revocation_basepoint(int64_t this_ptr) {
38028         LDKOpenChannel this_ptr_conv;
38029         this_ptr_conv.inner = untag_ptr(this_ptr);
38030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38032         this_ptr_conv.is_owned = false;
38033         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38034         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
38035         return ret_arr;
38036 }
38037
38038 void  CS_LDK_OpenChannel_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
38039         LDKOpenChannel this_ptr_conv;
38040         this_ptr_conv.inner = untag_ptr(this_ptr);
38041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38043         this_ptr_conv.is_owned = false;
38044         LDKPublicKey val_ref;
38045         CHECK(val->arr_len == 33);
38046         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38047         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
38048 }
38049
38050 int8_tArray  CS_LDK_OpenChannel_get_payment_point(int64_t this_ptr) {
38051         LDKOpenChannel this_ptr_conv;
38052         this_ptr_conv.inner = untag_ptr(this_ptr);
38053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38055         this_ptr_conv.is_owned = false;
38056         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38057         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
38058         return ret_arr;
38059 }
38060
38061 void  CS_LDK_OpenChannel_set_payment_point(int64_t this_ptr, int8_tArray val) {
38062         LDKOpenChannel this_ptr_conv;
38063         this_ptr_conv.inner = untag_ptr(this_ptr);
38064         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38066         this_ptr_conv.is_owned = false;
38067         LDKPublicKey val_ref;
38068         CHECK(val->arr_len == 33);
38069         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38070         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
38071 }
38072
38073 int8_tArray  CS_LDK_OpenChannel_get_delayed_payment_basepoint(int64_t this_ptr) {
38074         LDKOpenChannel this_ptr_conv;
38075         this_ptr_conv.inner = untag_ptr(this_ptr);
38076         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38078         this_ptr_conv.is_owned = false;
38079         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38080         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
38081         return ret_arr;
38082 }
38083
38084 void  CS_LDK_OpenChannel_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
38085         LDKOpenChannel this_ptr_conv;
38086         this_ptr_conv.inner = untag_ptr(this_ptr);
38087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38089         this_ptr_conv.is_owned = false;
38090         LDKPublicKey val_ref;
38091         CHECK(val->arr_len == 33);
38092         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38093         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
38094 }
38095
38096 int8_tArray  CS_LDK_OpenChannel_get_htlc_basepoint(int64_t this_ptr) {
38097         LDKOpenChannel this_ptr_conv;
38098         this_ptr_conv.inner = untag_ptr(this_ptr);
38099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38101         this_ptr_conv.is_owned = false;
38102         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38103         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
38104         return ret_arr;
38105 }
38106
38107 void  CS_LDK_OpenChannel_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
38108         LDKOpenChannel this_ptr_conv;
38109         this_ptr_conv.inner = untag_ptr(this_ptr);
38110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38112         this_ptr_conv.is_owned = false;
38113         LDKPublicKey val_ref;
38114         CHECK(val->arr_len == 33);
38115         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38116         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
38117 }
38118
38119 int8_tArray  CS_LDK_OpenChannel_get_first_per_commitment_point(int64_t this_ptr) {
38120         LDKOpenChannel this_ptr_conv;
38121         this_ptr_conv.inner = untag_ptr(this_ptr);
38122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38124         this_ptr_conv.is_owned = false;
38125         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38126         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
38127         return ret_arr;
38128 }
38129
38130 void  CS_LDK_OpenChannel_set_first_per_commitment_point(int64_t this_ptr, int8_tArray val) {
38131         LDKOpenChannel this_ptr_conv;
38132         this_ptr_conv.inner = untag_ptr(this_ptr);
38133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38135         this_ptr_conv.is_owned = false;
38136         LDKPublicKey val_ref;
38137         CHECK(val->arr_len == 33);
38138         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38139         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
38140 }
38141
38142 int8_t  CS_LDK_OpenChannel_get_channel_flags(int64_t this_ptr) {
38143         LDKOpenChannel this_ptr_conv;
38144         this_ptr_conv.inner = untag_ptr(this_ptr);
38145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38147         this_ptr_conv.is_owned = false;
38148         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
38149         return ret_conv;
38150 }
38151
38152 void  CS_LDK_OpenChannel_set_channel_flags(int64_t this_ptr, int8_t val) {
38153         LDKOpenChannel this_ptr_conv;
38154         this_ptr_conv.inner = untag_ptr(this_ptr);
38155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38157         this_ptr_conv.is_owned = false;
38158         OpenChannel_set_channel_flags(&this_ptr_conv, val);
38159 }
38160
38161 int64_t  CS_LDK_OpenChannel_get_shutdown_scriptpubkey(int64_t this_ptr) {
38162         LDKOpenChannel this_ptr_conv;
38163         this_ptr_conv.inner = untag_ptr(this_ptr);
38164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38166         this_ptr_conv.is_owned = false;
38167         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
38168         *ret_copy = OpenChannel_get_shutdown_scriptpubkey(&this_ptr_conv);
38169         int64_t ret_ref = tag_ptr(ret_copy, true);
38170         return ret_ref;
38171 }
38172
38173 void  CS_LDK_OpenChannel_set_shutdown_scriptpubkey(int64_t this_ptr, int64_t val) {
38174         LDKOpenChannel this_ptr_conv;
38175         this_ptr_conv.inner = untag_ptr(this_ptr);
38176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38178         this_ptr_conv.is_owned = false;
38179         void* val_ptr = untag_ptr(val);
38180         CHECK_ACCESS(val_ptr);
38181         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
38182         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
38183         OpenChannel_set_shutdown_scriptpubkey(&this_ptr_conv, val_conv);
38184 }
38185
38186 int64_t  CS_LDK_OpenChannel_get_channel_type(int64_t this_ptr) {
38187         LDKOpenChannel this_ptr_conv;
38188         this_ptr_conv.inner = untag_ptr(this_ptr);
38189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38191         this_ptr_conv.is_owned = false;
38192         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
38193         int64_t ret_ref = 0;
38194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38195         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38196         return ret_ref;
38197 }
38198
38199 void  CS_LDK_OpenChannel_set_channel_type(int64_t this_ptr, int64_t val) {
38200         LDKOpenChannel this_ptr_conv;
38201         this_ptr_conv.inner = untag_ptr(this_ptr);
38202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38204         this_ptr_conv.is_owned = false;
38205         LDKChannelTypeFeatures val_conv;
38206         val_conv.inner = untag_ptr(val);
38207         val_conv.is_owned = ptr_is_owned(val);
38208         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38209         val_conv = ChannelTypeFeatures_clone(&val_conv);
38210         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
38211 }
38212
38213 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) {
38214         LDKThirtyTwoBytes chain_hash_arg_ref;
38215         CHECK(chain_hash_arg->arr_len == 32);
38216         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
38217         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
38218         CHECK(temporary_channel_id_arg->arr_len == 32);
38219         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
38220         LDKPublicKey funding_pubkey_arg_ref;
38221         CHECK(funding_pubkey_arg->arr_len == 33);
38222         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
38223         LDKPublicKey revocation_basepoint_arg_ref;
38224         CHECK(revocation_basepoint_arg->arr_len == 33);
38225         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
38226         LDKPublicKey payment_point_arg_ref;
38227         CHECK(payment_point_arg->arr_len == 33);
38228         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
38229         LDKPublicKey delayed_payment_basepoint_arg_ref;
38230         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
38231         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
38232         LDKPublicKey htlc_basepoint_arg_ref;
38233         CHECK(htlc_basepoint_arg->arr_len == 33);
38234         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
38235         LDKPublicKey first_per_commitment_point_arg_ref;
38236         CHECK(first_per_commitment_point_arg->arr_len == 33);
38237         memcpy(first_per_commitment_point_arg_ref.compressed_form, first_per_commitment_point_arg->elems, 33); FREE(first_per_commitment_point_arg);
38238         void* shutdown_scriptpubkey_arg_ptr = untag_ptr(shutdown_scriptpubkey_arg);
38239         CHECK_ACCESS(shutdown_scriptpubkey_arg_ptr);
38240         LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg_conv = *(LDKCOption_CVec_u8ZZ*)(shutdown_scriptpubkey_arg_ptr);
38241         shutdown_scriptpubkey_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(shutdown_scriptpubkey_arg));
38242         LDKChannelTypeFeatures channel_type_arg_conv;
38243         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
38244         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
38245         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
38246         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
38247         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);
38248         int64_t ret_ref = 0;
38249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38251         return ret_ref;
38252 }
38253
38254 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
38255         LDKOpenChannel ret_var = OpenChannel_clone(arg);
38256         int64_t ret_ref = 0;
38257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38259         return ret_ref;
38260 }
38261 int64_t  CS_LDK_OpenChannel_clone_ptr(int64_t arg) {
38262         LDKOpenChannel arg_conv;
38263         arg_conv.inner = untag_ptr(arg);
38264         arg_conv.is_owned = ptr_is_owned(arg);
38265         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38266         arg_conv.is_owned = false;
38267         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
38268         return ret_conv;
38269 }
38270
38271 int64_t  CS_LDK_OpenChannel_clone(int64_t orig) {
38272         LDKOpenChannel orig_conv;
38273         orig_conv.inner = untag_ptr(orig);
38274         orig_conv.is_owned = ptr_is_owned(orig);
38275         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38276         orig_conv.is_owned = false;
38277         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
38278         int64_t ret_ref = 0;
38279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38280         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38281         return ret_ref;
38282 }
38283
38284 jboolean  CS_LDK_OpenChannel_eq(int64_t a, int64_t b) {
38285         LDKOpenChannel a_conv;
38286         a_conv.inner = untag_ptr(a);
38287         a_conv.is_owned = ptr_is_owned(a);
38288         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38289         a_conv.is_owned = false;
38290         LDKOpenChannel b_conv;
38291         b_conv.inner = untag_ptr(b);
38292         b_conv.is_owned = ptr_is_owned(b);
38293         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38294         b_conv.is_owned = false;
38295         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
38296         return ret_conv;
38297 }
38298
38299 void  CS_LDK_OpenChannelV2_free(int64_t this_obj) {
38300         LDKOpenChannelV2 this_obj_conv;
38301         this_obj_conv.inner = untag_ptr(this_obj);
38302         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38304         OpenChannelV2_free(this_obj_conv);
38305 }
38306
38307 int8_tArray  CS_LDK_OpenChannelV2_get_chain_hash(int64_t this_ptr) {
38308         LDKOpenChannelV2 this_ptr_conv;
38309         this_ptr_conv.inner = untag_ptr(this_ptr);
38310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38312         this_ptr_conv.is_owned = false;
38313         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
38314         memcpy(ret_arr->elems, *OpenChannelV2_get_chain_hash(&this_ptr_conv), 32);
38315         return ret_arr;
38316 }
38317
38318 void  CS_LDK_OpenChannelV2_set_chain_hash(int64_t this_ptr, int8_tArray val) {
38319         LDKOpenChannelV2 this_ptr_conv;
38320         this_ptr_conv.inner = untag_ptr(this_ptr);
38321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38323         this_ptr_conv.is_owned = false;
38324         LDKThirtyTwoBytes val_ref;
38325         CHECK(val->arr_len == 32);
38326         memcpy(val_ref.data, val->elems, 32); FREE(val);
38327         OpenChannelV2_set_chain_hash(&this_ptr_conv, val_ref);
38328 }
38329
38330 int8_tArray  CS_LDK_OpenChannelV2_get_temporary_channel_id(int64_t this_ptr) {
38331         LDKOpenChannelV2 this_ptr_conv;
38332         this_ptr_conv.inner = untag_ptr(this_ptr);
38333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38335         this_ptr_conv.is_owned = false;
38336         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
38337         memcpy(ret_arr->elems, *OpenChannelV2_get_temporary_channel_id(&this_ptr_conv), 32);
38338         return ret_arr;
38339 }
38340
38341 void  CS_LDK_OpenChannelV2_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
38342         LDKOpenChannelV2 this_ptr_conv;
38343         this_ptr_conv.inner = untag_ptr(this_ptr);
38344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38346         this_ptr_conv.is_owned = false;
38347         LDKThirtyTwoBytes val_ref;
38348         CHECK(val->arr_len == 32);
38349         memcpy(val_ref.data, val->elems, 32); FREE(val);
38350         OpenChannelV2_set_temporary_channel_id(&this_ptr_conv, val_ref);
38351 }
38352
38353 int32_t  CS_LDK_OpenChannelV2_get_funding_feerate_sat_per_1000_weight(int64_t this_ptr) {
38354         LDKOpenChannelV2 this_ptr_conv;
38355         this_ptr_conv.inner = untag_ptr(this_ptr);
38356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38358         this_ptr_conv.is_owned = false;
38359         int32_t ret_conv = OpenChannelV2_get_funding_feerate_sat_per_1000_weight(&this_ptr_conv);
38360         return ret_conv;
38361 }
38362
38363 void  CS_LDK_OpenChannelV2_set_funding_feerate_sat_per_1000_weight(int64_t this_ptr, int32_t val) {
38364         LDKOpenChannelV2 this_ptr_conv;
38365         this_ptr_conv.inner = untag_ptr(this_ptr);
38366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38368         this_ptr_conv.is_owned = false;
38369         OpenChannelV2_set_funding_feerate_sat_per_1000_weight(&this_ptr_conv, val);
38370 }
38371
38372 int32_t  CS_LDK_OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(int64_t this_ptr) {
38373         LDKOpenChannelV2 this_ptr_conv;
38374         this_ptr_conv.inner = untag_ptr(this_ptr);
38375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38377         this_ptr_conv.is_owned = false;
38378         int32_t ret_conv = OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(&this_ptr_conv);
38379         return ret_conv;
38380 }
38381
38382 void  CS_LDK_OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(int64_t this_ptr, int32_t val) {
38383         LDKOpenChannelV2 this_ptr_conv;
38384         this_ptr_conv.inner = untag_ptr(this_ptr);
38385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38387         this_ptr_conv.is_owned = false;
38388         OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(&this_ptr_conv, val);
38389 }
38390
38391 int64_t  CS_LDK_OpenChannelV2_get_funding_satoshis(int64_t this_ptr) {
38392         LDKOpenChannelV2 this_ptr_conv;
38393         this_ptr_conv.inner = untag_ptr(this_ptr);
38394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38396         this_ptr_conv.is_owned = false;
38397         int64_t ret_conv = OpenChannelV2_get_funding_satoshis(&this_ptr_conv);
38398         return ret_conv;
38399 }
38400
38401 void  CS_LDK_OpenChannelV2_set_funding_satoshis(int64_t this_ptr, int64_t val) {
38402         LDKOpenChannelV2 this_ptr_conv;
38403         this_ptr_conv.inner = untag_ptr(this_ptr);
38404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38406         this_ptr_conv.is_owned = false;
38407         OpenChannelV2_set_funding_satoshis(&this_ptr_conv, val);
38408 }
38409
38410 int64_t  CS_LDK_OpenChannelV2_get_dust_limit_satoshis(int64_t this_ptr) {
38411         LDKOpenChannelV2 this_ptr_conv;
38412         this_ptr_conv.inner = untag_ptr(this_ptr);
38413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38415         this_ptr_conv.is_owned = false;
38416         int64_t ret_conv = OpenChannelV2_get_dust_limit_satoshis(&this_ptr_conv);
38417         return ret_conv;
38418 }
38419
38420 void  CS_LDK_OpenChannelV2_set_dust_limit_satoshis(int64_t this_ptr, int64_t val) {
38421         LDKOpenChannelV2 this_ptr_conv;
38422         this_ptr_conv.inner = untag_ptr(this_ptr);
38423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38425         this_ptr_conv.is_owned = false;
38426         OpenChannelV2_set_dust_limit_satoshis(&this_ptr_conv, val);
38427 }
38428
38429 int64_t  CS_LDK_OpenChannelV2_get_max_htlc_value_in_flight_msat(int64_t this_ptr) {
38430         LDKOpenChannelV2 this_ptr_conv;
38431         this_ptr_conv.inner = untag_ptr(this_ptr);
38432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38434         this_ptr_conv.is_owned = false;
38435         int64_t ret_conv = OpenChannelV2_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
38436         return ret_conv;
38437 }
38438
38439 void  CS_LDK_OpenChannelV2_set_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
38440         LDKOpenChannelV2 this_ptr_conv;
38441         this_ptr_conv.inner = untag_ptr(this_ptr);
38442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38444         this_ptr_conv.is_owned = false;
38445         OpenChannelV2_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
38446 }
38447
38448 int64_t  CS_LDK_OpenChannelV2_get_htlc_minimum_msat(int64_t this_ptr) {
38449         LDKOpenChannelV2 this_ptr_conv;
38450         this_ptr_conv.inner = untag_ptr(this_ptr);
38451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38453         this_ptr_conv.is_owned = false;
38454         int64_t ret_conv = OpenChannelV2_get_htlc_minimum_msat(&this_ptr_conv);
38455         return ret_conv;
38456 }
38457
38458 void  CS_LDK_OpenChannelV2_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
38459         LDKOpenChannelV2 this_ptr_conv;
38460         this_ptr_conv.inner = untag_ptr(this_ptr);
38461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38463         this_ptr_conv.is_owned = false;
38464         OpenChannelV2_set_htlc_minimum_msat(&this_ptr_conv, val);
38465 }
38466
38467 int16_t  CS_LDK_OpenChannelV2_get_to_self_delay(int64_t this_ptr) {
38468         LDKOpenChannelV2 this_ptr_conv;
38469         this_ptr_conv.inner = untag_ptr(this_ptr);
38470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38472         this_ptr_conv.is_owned = false;
38473         int16_t ret_conv = OpenChannelV2_get_to_self_delay(&this_ptr_conv);
38474         return ret_conv;
38475 }
38476
38477 void  CS_LDK_OpenChannelV2_set_to_self_delay(int64_t this_ptr, int16_t val) {
38478         LDKOpenChannelV2 this_ptr_conv;
38479         this_ptr_conv.inner = untag_ptr(this_ptr);
38480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38482         this_ptr_conv.is_owned = false;
38483         OpenChannelV2_set_to_self_delay(&this_ptr_conv, val);
38484 }
38485
38486 int16_t  CS_LDK_OpenChannelV2_get_max_accepted_htlcs(int64_t this_ptr) {
38487         LDKOpenChannelV2 this_ptr_conv;
38488         this_ptr_conv.inner = untag_ptr(this_ptr);
38489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38491         this_ptr_conv.is_owned = false;
38492         int16_t ret_conv = OpenChannelV2_get_max_accepted_htlcs(&this_ptr_conv);
38493         return ret_conv;
38494 }
38495
38496 void  CS_LDK_OpenChannelV2_set_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
38497         LDKOpenChannelV2 this_ptr_conv;
38498         this_ptr_conv.inner = untag_ptr(this_ptr);
38499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38501         this_ptr_conv.is_owned = false;
38502         OpenChannelV2_set_max_accepted_htlcs(&this_ptr_conv, val);
38503 }
38504
38505 int32_t  CS_LDK_OpenChannelV2_get_locktime(int64_t this_ptr) {
38506         LDKOpenChannelV2 this_ptr_conv;
38507         this_ptr_conv.inner = untag_ptr(this_ptr);
38508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38510         this_ptr_conv.is_owned = false;
38511         int32_t ret_conv = OpenChannelV2_get_locktime(&this_ptr_conv);
38512         return ret_conv;
38513 }
38514
38515 void  CS_LDK_OpenChannelV2_set_locktime(int64_t this_ptr, int32_t val) {
38516         LDKOpenChannelV2 this_ptr_conv;
38517         this_ptr_conv.inner = untag_ptr(this_ptr);
38518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38520         this_ptr_conv.is_owned = false;
38521         OpenChannelV2_set_locktime(&this_ptr_conv, val);
38522 }
38523
38524 int8_tArray  CS_LDK_OpenChannelV2_get_funding_pubkey(int64_t this_ptr) {
38525         LDKOpenChannelV2 this_ptr_conv;
38526         this_ptr_conv.inner = untag_ptr(this_ptr);
38527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38529         this_ptr_conv.is_owned = false;
38530         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38531         memcpy(ret_arr->elems, OpenChannelV2_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
38532         return ret_arr;
38533 }
38534
38535 void  CS_LDK_OpenChannelV2_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
38536         LDKOpenChannelV2 this_ptr_conv;
38537         this_ptr_conv.inner = untag_ptr(this_ptr);
38538         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38540         this_ptr_conv.is_owned = false;
38541         LDKPublicKey val_ref;
38542         CHECK(val->arr_len == 33);
38543         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38544         OpenChannelV2_set_funding_pubkey(&this_ptr_conv, val_ref);
38545 }
38546
38547 int8_tArray  CS_LDK_OpenChannelV2_get_revocation_basepoint(int64_t this_ptr) {
38548         LDKOpenChannelV2 this_ptr_conv;
38549         this_ptr_conv.inner = untag_ptr(this_ptr);
38550         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38552         this_ptr_conv.is_owned = false;
38553         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38554         memcpy(ret_arr->elems, OpenChannelV2_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
38555         return ret_arr;
38556 }
38557
38558 void  CS_LDK_OpenChannelV2_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
38559         LDKOpenChannelV2 this_ptr_conv;
38560         this_ptr_conv.inner = untag_ptr(this_ptr);
38561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38563         this_ptr_conv.is_owned = false;
38564         LDKPublicKey val_ref;
38565         CHECK(val->arr_len == 33);
38566         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38567         OpenChannelV2_set_revocation_basepoint(&this_ptr_conv, val_ref);
38568 }
38569
38570 int8_tArray  CS_LDK_OpenChannelV2_get_payment_basepoint(int64_t this_ptr) {
38571         LDKOpenChannelV2 this_ptr_conv;
38572         this_ptr_conv.inner = untag_ptr(this_ptr);
38573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38575         this_ptr_conv.is_owned = false;
38576         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38577         memcpy(ret_arr->elems, OpenChannelV2_get_payment_basepoint(&this_ptr_conv).compressed_form, 33);
38578         return ret_arr;
38579 }
38580
38581 void  CS_LDK_OpenChannelV2_set_payment_basepoint(int64_t this_ptr, int8_tArray val) {
38582         LDKOpenChannelV2 this_ptr_conv;
38583         this_ptr_conv.inner = untag_ptr(this_ptr);
38584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38586         this_ptr_conv.is_owned = false;
38587         LDKPublicKey val_ref;
38588         CHECK(val->arr_len == 33);
38589         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38590         OpenChannelV2_set_payment_basepoint(&this_ptr_conv, val_ref);
38591 }
38592
38593 int8_tArray  CS_LDK_OpenChannelV2_get_delayed_payment_basepoint(int64_t this_ptr) {
38594         LDKOpenChannelV2 this_ptr_conv;
38595         this_ptr_conv.inner = untag_ptr(this_ptr);
38596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38598         this_ptr_conv.is_owned = false;
38599         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38600         memcpy(ret_arr->elems, OpenChannelV2_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
38601         return ret_arr;
38602 }
38603
38604 void  CS_LDK_OpenChannelV2_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
38605         LDKOpenChannelV2 this_ptr_conv;
38606         this_ptr_conv.inner = untag_ptr(this_ptr);
38607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38609         this_ptr_conv.is_owned = false;
38610         LDKPublicKey val_ref;
38611         CHECK(val->arr_len == 33);
38612         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38613         OpenChannelV2_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
38614 }
38615
38616 int8_tArray  CS_LDK_OpenChannelV2_get_htlc_basepoint(int64_t this_ptr) {
38617         LDKOpenChannelV2 this_ptr_conv;
38618         this_ptr_conv.inner = untag_ptr(this_ptr);
38619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38621         this_ptr_conv.is_owned = false;
38622         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38623         memcpy(ret_arr->elems, OpenChannelV2_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
38624         return ret_arr;
38625 }
38626
38627 void  CS_LDK_OpenChannelV2_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
38628         LDKOpenChannelV2 this_ptr_conv;
38629         this_ptr_conv.inner = untag_ptr(this_ptr);
38630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38632         this_ptr_conv.is_owned = false;
38633         LDKPublicKey val_ref;
38634         CHECK(val->arr_len == 33);
38635         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38636         OpenChannelV2_set_htlc_basepoint(&this_ptr_conv, val_ref);
38637 }
38638
38639 int8_tArray  CS_LDK_OpenChannelV2_get_first_per_commitment_point(int64_t this_ptr) {
38640         LDKOpenChannelV2 this_ptr_conv;
38641         this_ptr_conv.inner = untag_ptr(this_ptr);
38642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38644         this_ptr_conv.is_owned = false;
38645         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38646         memcpy(ret_arr->elems, OpenChannelV2_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
38647         return ret_arr;
38648 }
38649
38650 void  CS_LDK_OpenChannelV2_set_first_per_commitment_point(int64_t this_ptr, int8_tArray val) {
38651         LDKOpenChannelV2 this_ptr_conv;
38652         this_ptr_conv.inner = untag_ptr(this_ptr);
38653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38655         this_ptr_conv.is_owned = false;
38656         LDKPublicKey val_ref;
38657         CHECK(val->arr_len == 33);
38658         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38659         OpenChannelV2_set_first_per_commitment_point(&this_ptr_conv, val_ref);
38660 }
38661
38662 int8_tArray  CS_LDK_OpenChannelV2_get_second_per_commitment_point(int64_t this_ptr) {
38663         LDKOpenChannelV2 this_ptr_conv;
38664         this_ptr_conv.inner = untag_ptr(this_ptr);
38665         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38667         this_ptr_conv.is_owned = false;
38668         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38669         memcpy(ret_arr->elems, OpenChannelV2_get_second_per_commitment_point(&this_ptr_conv).compressed_form, 33);
38670         return ret_arr;
38671 }
38672
38673 void  CS_LDK_OpenChannelV2_set_second_per_commitment_point(int64_t this_ptr, int8_tArray val) {
38674         LDKOpenChannelV2 this_ptr_conv;
38675         this_ptr_conv.inner = untag_ptr(this_ptr);
38676         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38678         this_ptr_conv.is_owned = false;
38679         LDKPublicKey val_ref;
38680         CHECK(val->arr_len == 33);
38681         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38682         OpenChannelV2_set_second_per_commitment_point(&this_ptr_conv, val_ref);
38683 }
38684
38685 int8_t  CS_LDK_OpenChannelV2_get_channel_flags(int64_t this_ptr) {
38686         LDKOpenChannelV2 this_ptr_conv;
38687         this_ptr_conv.inner = untag_ptr(this_ptr);
38688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38690         this_ptr_conv.is_owned = false;
38691         int8_t ret_conv = OpenChannelV2_get_channel_flags(&this_ptr_conv);
38692         return ret_conv;
38693 }
38694
38695 void  CS_LDK_OpenChannelV2_set_channel_flags(int64_t this_ptr, int8_t val) {
38696         LDKOpenChannelV2 this_ptr_conv;
38697         this_ptr_conv.inner = untag_ptr(this_ptr);
38698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38700         this_ptr_conv.is_owned = false;
38701         OpenChannelV2_set_channel_flags(&this_ptr_conv, val);
38702 }
38703
38704 int64_t  CS_LDK_OpenChannelV2_get_shutdown_scriptpubkey(int64_t this_ptr) {
38705         LDKOpenChannelV2 this_ptr_conv;
38706         this_ptr_conv.inner = untag_ptr(this_ptr);
38707         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38709         this_ptr_conv.is_owned = false;
38710         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
38711         *ret_copy = OpenChannelV2_get_shutdown_scriptpubkey(&this_ptr_conv);
38712         int64_t ret_ref = tag_ptr(ret_copy, true);
38713         return ret_ref;
38714 }
38715
38716 void  CS_LDK_OpenChannelV2_set_shutdown_scriptpubkey(int64_t this_ptr, int64_t val) {
38717         LDKOpenChannelV2 this_ptr_conv;
38718         this_ptr_conv.inner = untag_ptr(this_ptr);
38719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38721         this_ptr_conv.is_owned = false;
38722         void* val_ptr = untag_ptr(val);
38723         CHECK_ACCESS(val_ptr);
38724         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
38725         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
38726         OpenChannelV2_set_shutdown_scriptpubkey(&this_ptr_conv, val_conv);
38727 }
38728
38729 int64_t  CS_LDK_OpenChannelV2_get_channel_type(int64_t this_ptr) {
38730         LDKOpenChannelV2 this_ptr_conv;
38731         this_ptr_conv.inner = untag_ptr(this_ptr);
38732         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38734         this_ptr_conv.is_owned = false;
38735         LDKChannelTypeFeatures ret_var = OpenChannelV2_get_channel_type(&this_ptr_conv);
38736         int64_t ret_ref = 0;
38737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38738         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38739         return ret_ref;
38740 }
38741
38742 void  CS_LDK_OpenChannelV2_set_channel_type(int64_t this_ptr, int64_t val) {
38743         LDKOpenChannelV2 this_ptr_conv;
38744         this_ptr_conv.inner = untag_ptr(this_ptr);
38745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38747         this_ptr_conv.is_owned = false;
38748         LDKChannelTypeFeatures val_conv;
38749         val_conv.inner = untag_ptr(val);
38750         val_conv.is_owned = ptr_is_owned(val);
38751         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38752         val_conv = ChannelTypeFeatures_clone(&val_conv);
38753         OpenChannelV2_set_channel_type(&this_ptr_conv, val_conv);
38754 }
38755
38756 int32_t  CS_LDK_OpenChannelV2_get_require_confirmed_inputs(int64_t this_ptr) {
38757         LDKOpenChannelV2 this_ptr_conv;
38758         this_ptr_conv.inner = untag_ptr(this_ptr);
38759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38761         this_ptr_conv.is_owned = false;
38762         int32_t ret_conv = LDKCOption_NoneZ_to_cs(OpenChannelV2_get_require_confirmed_inputs(&this_ptr_conv));
38763         return ret_conv;
38764 }
38765
38766 void  CS_LDK_OpenChannelV2_set_require_confirmed_inputs(int64_t this_ptr, int32_t val) {
38767         LDKOpenChannelV2 this_ptr_conv;
38768         this_ptr_conv.inner = untag_ptr(this_ptr);
38769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38771         this_ptr_conv.is_owned = false;
38772         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_cs(val);
38773         OpenChannelV2_set_require_confirmed_inputs(&this_ptr_conv, val_conv);
38774 }
38775
38776 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) {
38777         LDKThirtyTwoBytes chain_hash_arg_ref;
38778         CHECK(chain_hash_arg->arr_len == 32);
38779         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
38780         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
38781         CHECK(temporary_channel_id_arg->arr_len == 32);
38782         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
38783         LDKPublicKey funding_pubkey_arg_ref;
38784         CHECK(funding_pubkey_arg->arr_len == 33);
38785         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
38786         LDKPublicKey revocation_basepoint_arg_ref;
38787         CHECK(revocation_basepoint_arg->arr_len == 33);
38788         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
38789         LDKPublicKey payment_basepoint_arg_ref;
38790         CHECK(payment_basepoint_arg->arr_len == 33);
38791         memcpy(payment_basepoint_arg_ref.compressed_form, payment_basepoint_arg->elems, 33); FREE(payment_basepoint_arg);
38792         LDKPublicKey delayed_payment_basepoint_arg_ref;
38793         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
38794         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
38795         LDKPublicKey htlc_basepoint_arg_ref;
38796         CHECK(htlc_basepoint_arg->arr_len == 33);
38797         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
38798         LDKPublicKey first_per_commitment_point_arg_ref;
38799         CHECK(first_per_commitment_point_arg->arr_len == 33);
38800         memcpy(first_per_commitment_point_arg_ref.compressed_form, first_per_commitment_point_arg->elems, 33); FREE(first_per_commitment_point_arg);
38801         LDKPublicKey second_per_commitment_point_arg_ref;
38802         CHECK(second_per_commitment_point_arg->arr_len == 33);
38803         memcpy(second_per_commitment_point_arg_ref.compressed_form, second_per_commitment_point_arg->elems, 33); FREE(second_per_commitment_point_arg);
38804         void* shutdown_scriptpubkey_arg_ptr = untag_ptr(shutdown_scriptpubkey_arg);
38805         CHECK_ACCESS(shutdown_scriptpubkey_arg_ptr);
38806         LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg_conv = *(LDKCOption_CVec_u8ZZ*)(shutdown_scriptpubkey_arg_ptr);
38807         shutdown_scriptpubkey_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(shutdown_scriptpubkey_arg));
38808         LDKChannelTypeFeatures channel_type_arg_conv;
38809         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
38810         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
38811         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
38812         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
38813         LDKCOption_NoneZ require_confirmed_inputs_arg_conv = LDKCOption_NoneZ_from_cs(require_confirmed_inputs_arg);
38814         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);
38815         int64_t ret_ref = 0;
38816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38818         return ret_ref;
38819 }
38820
38821 static inline uint64_t OpenChannelV2_clone_ptr(LDKOpenChannelV2 *NONNULL_PTR arg) {
38822         LDKOpenChannelV2 ret_var = OpenChannelV2_clone(arg);
38823         int64_t ret_ref = 0;
38824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38825         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38826         return ret_ref;
38827 }
38828 int64_t  CS_LDK_OpenChannelV2_clone_ptr(int64_t arg) {
38829         LDKOpenChannelV2 arg_conv;
38830         arg_conv.inner = untag_ptr(arg);
38831         arg_conv.is_owned = ptr_is_owned(arg);
38832         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38833         arg_conv.is_owned = false;
38834         int64_t ret_conv = OpenChannelV2_clone_ptr(&arg_conv);
38835         return ret_conv;
38836 }
38837
38838 int64_t  CS_LDK_OpenChannelV2_clone(int64_t orig) {
38839         LDKOpenChannelV2 orig_conv;
38840         orig_conv.inner = untag_ptr(orig);
38841         orig_conv.is_owned = ptr_is_owned(orig);
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38843         orig_conv.is_owned = false;
38844         LDKOpenChannelV2 ret_var = OpenChannelV2_clone(&orig_conv);
38845         int64_t ret_ref = 0;
38846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38848         return ret_ref;
38849 }
38850
38851 jboolean  CS_LDK_OpenChannelV2_eq(int64_t a, int64_t b) {
38852         LDKOpenChannelV2 a_conv;
38853         a_conv.inner = untag_ptr(a);
38854         a_conv.is_owned = ptr_is_owned(a);
38855         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38856         a_conv.is_owned = false;
38857         LDKOpenChannelV2 b_conv;
38858         b_conv.inner = untag_ptr(b);
38859         b_conv.is_owned = ptr_is_owned(b);
38860         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38861         b_conv.is_owned = false;
38862         jboolean ret_conv = OpenChannelV2_eq(&a_conv, &b_conv);
38863         return ret_conv;
38864 }
38865
38866 void  CS_LDK_AcceptChannel_free(int64_t this_obj) {
38867         LDKAcceptChannel this_obj_conv;
38868         this_obj_conv.inner = untag_ptr(this_obj);
38869         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38871         AcceptChannel_free(this_obj_conv);
38872 }
38873
38874 int8_tArray  CS_LDK_AcceptChannel_get_temporary_channel_id(int64_t this_ptr) {
38875         LDKAcceptChannel this_ptr_conv;
38876         this_ptr_conv.inner = untag_ptr(this_ptr);
38877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38879         this_ptr_conv.is_owned = false;
38880         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
38881         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
38882         return ret_arr;
38883 }
38884
38885 void  CS_LDK_AcceptChannel_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
38886         LDKAcceptChannel this_ptr_conv;
38887         this_ptr_conv.inner = untag_ptr(this_ptr);
38888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38890         this_ptr_conv.is_owned = false;
38891         LDKThirtyTwoBytes val_ref;
38892         CHECK(val->arr_len == 32);
38893         memcpy(val_ref.data, val->elems, 32); FREE(val);
38894         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
38895 }
38896
38897 int64_t  CS_LDK_AcceptChannel_get_dust_limit_satoshis(int64_t this_ptr) {
38898         LDKAcceptChannel this_ptr_conv;
38899         this_ptr_conv.inner = untag_ptr(this_ptr);
38900         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38902         this_ptr_conv.is_owned = false;
38903         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
38904         return ret_conv;
38905 }
38906
38907 void  CS_LDK_AcceptChannel_set_dust_limit_satoshis(int64_t this_ptr, int64_t val) {
38908         LDKAcceptChannel this_ptr_conv;
38909         this_ptr_conv.inner = untag_ptr(this_ptr);
38910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38912         this_ptr_conv.is_owned = false;
38913         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
38914 }
38915
38916 int64_t  CS_LDK_AcceptChannel_get_max_htlc_value_in_flight_msat(int64_t this_ptr) {
38917         LDKAcceptChannel this_ptr_conv;
38918         this_ptr_conv.inner = untag_ptr(this_ptr);
38919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38921         this_ptr_conv.is_owned = false;
38922         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
38923         return ret_conv;
38924 }
38925
38926 void  CS_LDK_AcceptChannel_set_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
38927         LDKAcceptChannel this_ptr_conv;
38928         this_ptr_conv.inner = untag_ptr(this_ptr);
38929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38931         this_ptr_conv.is_owned = false;
38932         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
38933 }
38934
38935 int64_t  CS_LDK_AcceptChannel_get_channel_reserve_satoshis(int64_t this_ptr) {
38936         LDKAcceptChannel this_ptr_conv;
38937         this_ptr_conv.inner = untag_ptr(this_ptr);
38938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38940         this_ptr_conv.is_owned = false;
38941         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
38942         return ret_conv;
38943 }
38944
38945 void  CS_LDK_AcceptChannel_set_channel_reserve_satoshis(int64_t this_ptr, int64_t val) {
38946         LDKAcceptChannel this_ptr_conv;
38947         this_ptr_conv.inner = untag_ptr(this_ptr);
38948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38950         this_ptr_conv.is_owned = false;
38951         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
38952 }
38953
38954 int64_t  CS_LDK_AcceptChannel_get_htlc_minimum_msat(int64_t this_ptr) {
38955         LDKAcceptChannel this_ptr_conv;
38956         this_ptr_conv.inner = untag_ptr(this_ptr);
38957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38959         this_ptr_conv.is_owned = false;
38960         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
38961         return ret_conv;
38962 }
38963
38964 void  CS_LDK_AcceptChannel_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
38965         LDKAcceptChannel this_ptr_conv;
38966         this_ptr_conv.inner = untag_ptr(this_ptr);
38967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38969         this_ptr_conv.is_owned = false;
38970         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
38971 }
38972
38973 int32_t  CS_LDK_AcceptChannel_get_minimum_depth(int64_t this_ptr) {
38974         LDKAcceptChannel this_ptr_conv;
38975         this_ptr_conv.inner = untag_ptr(this_ptr);
38976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38978         this_ptr_conv.is_owned = false;
38979         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
38980         return ret_conv;
38981 }
38982
38983 void  CS_LDK_AcceptChannel_set_minimum_depth(int64_t this_ptr, int32_t val) {
38984         LDKAcceptChannel this_ptr_conv;
38985         this_ptr_conv.inner = untag_ptr(this_ptr);
38986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38988         this_ptr_conv.is_owned = false;
38989         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
38990 }
38991
38992 int16_t  CS_LDK_AcceptChannel_get_to_self_delay(int64_t this_ptr) {
38993         LDKAcceptChannel this_ptr_conv;
38994         this_ptr_conv.inner = untag_ptr(this_ptr);
38995         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38997         this_ptr_conv.is_owned = false;
38998         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
38999         return ret_conv;
39000 }
39001
39002 void  CS_LDK_AcceptChannel_set_to_self_delay(int64_t this_ptr, int16_t val) {
39003         LDKAcceptChannel this_ptr_conv;
39004         this_ptr_conv.inner = untag_ptr(this_ptr);
39005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39007         this_ptr_conv.is_owned = false;
39008         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
39009 }
39010
39011 int16_t  CS_LDK_AcceptChannel_get_max_accepted_htlcs(int64_t this_ptr) {
39012         LDKAcceptChannel this_ptr_conv;
39013         this_ptr_conv.inner = untag_ptr(this_ptr);
39014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39016         this_ptr_conv.is_owned = false;
39017         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
39018         return ret_conv;
39019 }
39020
39021 void  CS_LDK_AcceptChannel_set_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
39022         LDKAcceptChannel this_ptr_conv;
39023         this_ptr_conv.inner = untag_ptr(this_ptr);
39024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39026         this_ptr_conv.is_owned = false;
39027         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
39028 }
39029
39030 int8_tArray  CS_LDK_AcceptChannel_get_funding_pubkey(int64_t this_ptr) {
39031         LDKAcceptChannel this_ptr_conv;
39032         this_ptr_conv.inner = untag_ptr(this_ptr);
39033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39035         this_ptr_conv.is_owned = false;
39036         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39037         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
39038         return ret_arr;
39039 }
39040
39041 void  CS_LDK_AcceptChannel_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
39042         LDKAcceptChannel this_ptr_conv;
39043         this_ptr_conv.inner = untag_ptr(this_ptr);
39044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39046         this_ptr_conv.is_owned = false;
39047         LDKPublicKey val_ref;
39048         CHECK(val->arr_len == 33);
39049         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39050         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
39051 }
39052
39053 int8_tArray  CS_LDK_AcceptChannel_get_revocation_basepoint(int64_t this_ptr) {
39054         LDKAcceptChannel this_ptr_conv;
39055         this_ptr_conv.inner = untag_ptr(this_ptr);
39056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39058         this_ptr_conv.is_owned = false;
39059         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39060         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
39061         return ret_arr;
39062 }
39063
39064 void  CS_LDK_AcceptChannel_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
39065         LDKAcceptChannel this_ptr_conv;
39066         this_ptr_conv.inner = untag_ptr(this_ptr);
39067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39069         this_ptr_conv.is_owned = false;
39070         LDKPublicKey val_ref;
39071         CHECK(val->arr_len == 33);
39072         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39073         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
39074 }
39075
39076 int8_tArray  CS_LDK_AcceptChannel_get_payment_point(int64_t this_ptr) {
39077         LDKAcceptChannel this_ptr_conv;
39078         this_ptr_conv.inner = untag_ptr(this_ptr);
39079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39081         this_ptr_conv.is_owned = false;
39082         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39083         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
39084         return ret_arr;
39085 }
39086
39087 void  CS_LDK_AcceptChannel_set_payment_point(int64_t this_ptr, int8_tArray val) {
39088         LDKAcceptChannel this_ptr_conv;
39089         this_ptr_conv.inner = untag_ptr(this_ptr);
39090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39092         this_ptr_conv.is_owned = false;
39093         LDKPublicKey val_ref;
39094         CHECK(val->arr_len == 33);
39095         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39096         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
39097 }
39098
39099 int8_tArray  CS_LDK_AcceptChannel_get_delayed_payment_basepoint(int64_t this_ptr) {
39100         LDKAcceptChannel this_ptr_conv;
39101         this_ptr_conv.inner = untag_ptr(this_ptr);
39102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39104         this_ptr_conv.is_owned = false;
39105         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39106         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
39107         return ret_arr;
39108 }
39109
39110 void  CS_LDK_AcceptChannel_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
39111         LDKAcceptChannel this_ptr_conv;
39112         this_ptr_conv.inner = untag_ptr(this_ptr);
39113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39115         this_ptr_conv.is_owned = false;
39116         LDKPublicKey val_ref;
39117         CHECK(val->arr_len == 33);
39118         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39119         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39120 }
39121
39122 int8_tArray  CS_LDK_AcceptChannel_get_htlc_basepoint(int64_t this_ptr) {
39123         LDKAcceptChannel this_ptr_conv;
39124         this_ptr_conv.inner = untag_ptr(this_ptr);
39125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39127         this_ptr_conv.is_owned = false;
39128         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39129         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
39130         return ret_arr;
39131 }
39132
39133 void  CS_LDK_AcceptChannel_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
39134         LDKAcceptChannel this_ptr_conv;
39135         this_ptr_conv.inner = untag_ptr(this_ptr);
39136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39138         this_ptr_conv.is_owned = false;
39139         LDKPublicKey val_ref;
39140         CHECK(val->arr_len == 33);
39141         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39142         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
39143 }
39144
39145 int8_tArray  CS_LDK_AcceptChannel_get_first_per_commitment_point(int64_t this_ptr) {
39146         LDKAcceptChannel this_ptr_conv;
39147         this_ptr_conv.inner = untag_ptr(this_ptr);
39148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39150         this_ptr_conv.is_owned = false;
39151         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39152         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
39153         return ret_arr;
39154 }
39155
39156 void  CS_LDK_AcceptChannel_set_first_per_commitment_point(int64_t this_ptr, int8_tArray val) {
39157         LDKAcceptChannel this_ptr_conv;
39158         this_ptr_conv.inner = untag_ptr(this_ptr);
39159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39161         this_ptr_conv.is_owned = false;
39162         LDKPublicKey val_ref;
39163         CHECK(val->arr_len == 33);
39164         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39165         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
39166 }
39167
39168 int64_t  CS_LDK_AcceptChannel_get_shutdown_scriptpubkey(int64_t this_ptr) {
39169         LDKAcceptChannel this_ptr_conv;
39170         this_ptr_conv.inner = untag_ptr(this_ptr);
39171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39173         this_ptr_conv.is_owned = false;
39174         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
39175         *ret_copy = AcceptChannel_get_shutdown_scriptpubkey(&this_ptr_conv);
39176         int64_t ret_ref = tag_ptr(ret_copy, true);
39177         return ret_ref;
39178 }
39179
39180 void  CS_LDK_AcceptChannel_set_shutdown_scriptpubkey(int64_t this_ptr, int64_t val) {
39181         LDKAcceptChannel this_ptr_conv;
39182         this_ptr_conv.inner = untag_ptr(this_ptr);
39183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39185         this_ptr_conv.is_owned = false;
39186         void* val_ptr = untag_ptr(val);
39187         CHECK_ACCESS(val_ptr);
39188         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
39189         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
39190         AcceptChannel_set_shutdown_scriptpubkey(&this_ptr_conv, val_conv);
39191 }
39192
39193 int64_t  CS_LDK_AcceptChannel_get_channel_type(int64_t this_ptr) {
39194         LDKAcceptChannel this_ptr_conv;
39195         this_ptr_conv.inner = untag_ptr(this_ptr);
39196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39198         this_ptr_conv.is_owned = false;
39199         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
39200         int64_t ret_ref = 0;
39201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39203         return ret_ref;
39204 }
39205
39206 void  CS_LDK_AcceptChannel_set_channel_type(int64_t this_ptr, int64_t val) {
39207         LDKAcceptChannel this_ptr_conv;
39208         this_ptr_conv.inner = untag_ptr(this_ptr);
39209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39211         this_ptr_conv.is_owned = false;
39212         LDKChannelTypeFeatures val_conv;
39213         val_conv.inner = untag_ptr(val);
39214         val_conv.is_owned = ptr_is_owned(val);
39215         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39216         val_conv = ChannelTypeFeatures_clone(&val_conv);
39217         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
39218 }
39219
39220 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) {
39221         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
39222         CHECK(temporary_channel_id_arg->arr_len == 32);
39223         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
39224         LDKPublicKey funding_pubkey_arg_ref;
39225         CHECK(funding_pubkey_arg->arr_len == 33);
39226         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
39227         LDKPublicKey revocation_basepoint_arg_ref;
39228         CHECK(revocation_basepoint_arg->arr_len == 33);
39229         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
39230         LDKPublicKey payment_point_arg_ref;
39231         CHECK(payment_point_arg->arr_len == 33);
39232         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
39233         LDKPublicKey delayed_payment_basepoint_arg_ref;
39234         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
39235         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
39236         LDKPublicKey htlc_basepoint_arg_ref;
39237         CHECK(htlc_basepoint_arg->arr_len == 33);
39238         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
39239         LDKPublicKey first_per_commitment_point_arg_ref;
39240         CHECK(first_per_commitment_point_arg->arr_len == 33);
39241         memcpy(first_per_commitment_point_arg_ref.compressed_form, first_per_commitment_point_arg->elems, 33); FREE(first_per_commitment_point_arg);
39242         void* shutdown_scriptpubkey_arg_ptr = untag_ptr(shutdown_scriptpubkey_arg);
39243         CHECK_ACCESS(shutdown_scriptpubkey_arg_ptr);
39244         LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg_conv = *(LDKCOption_CVec_u8ZZ*)(shutdown_scriptpubkey_arg_ptr);
39245         shutdown_scriptpubkey_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(shutdown_scriptpubkey_arg));
39246         LDKChannelTypeFeatures channel_type_arg_conv;
39247         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
39248         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
39249         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
39250         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
39251         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);
39252         int64_t ret_ref = 0;
39253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39255         return ret_ref;
39256 }
39257
39258 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
39259         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
39260         int64_t ret_ref = 0;
39261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39262         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39263         return ret_ref;
39264 }
39265 int64_t  CS_LDK_AcceptChannel_clone_ptr(int64_t arg) {
39266         LDKAcceptChannel arg_conv;
39267         arg_conv.inner = untag_ptr(arg);
39268         arg_conv.is_owned = ptr_is_owned(arg);
39269         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39270         arg_conv.is_owned = false;
39271         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
39272         return ret_conv;
39273 }
39274
39275 int64_t  CS_LDK_AcceptChannel_clone(int64_t orig) {
39276         LDKAcceptChannel orig_conv;
39277         orig_conv.inner = untag_ptr(orig);
39278         orig_conv.is_owned = ptr_is_owned(orig);
39279         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39280         orig_conv.is_owned = false;
39281         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
39282         int64_t ret_ref = 0;
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39285         return ret_ref;
39286 }
39287
39288 jboolean  CS_LDK_AcceptChannel_eq(int64_t a, int64_t b) {
39289         LDKAcceptChannel a_conv;
39290         a_conv.inner = untag_ptr(a);
39291         a_conv.is_owned = ptr_is_owned(a);
39292         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39293         a_conv.is_owned = false;
39294         LDKAcceptChannel b_conv;
39295         b_conv.inner = untag_ptr(b);
39296         b_conv.is_owned = ptr_is_owned(b);
39297         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39298         b_conv.is_owned = false;
39299         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
39300         return ret_conv;
39301 }
39302
39303 void  CS_LDK_AcceptChannelV2_free(int64_t this_obj) {
39304         LDKAcceptChannelV2 this_obj_conv;
39305         this_obj_conv.inner = untag_ptr(this_obj);
39306         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39308         AcceptChannelV2_free(this_obj_conv);
39309 }
39310
39311 int8_tArray  CS_LDK_AcceptChannelV2_get_temporary_channel_id(int64_t this_ptr) {
39312         LDKAcceptChannelV2 this_ptr_conv;
39313         this_ptr_conv.inner = untag_ptr(this_ptr);
39314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39316         this_ptr_conv.is_owned = false;
39317         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39318         memcpy(ret_arr->elems, *AcceptChannelV2_get_temporary_channel_id(&this_ptr_conv), 32);
39319         return ret_arr;
39320 }
39321
39322 void  CS_LDK_AcceptChannelV2_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
39323         LDKAcceptChannelV2 this_ptr_conv;
39324         this_ptr_conv.inner = untag_ptr(this_ptr);
39325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39327         this_ptr_conv.is_owned = false;
39328         LDKThirtyTwoBytes val_ref;
39329         CHECK(val->arr_len == 32);
39330         memcpy(val_ref.data, val->elems, 32); FREE(val);
39331         AcceptChannelV2_set_temporary_channel_id(&this_ptr_conv, val_ref);
39332 }
39333
39334 int64_t  CS_LDK_AcceptChannelV2_get_funding_satoshis(int64_t this_ptr) {
39335         LDKAcceptChannelV2 this_ptr_conv;
39336         this_ptr_conv.inner = untag_ptr(this_ptr);
39337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39339         this_ptr_conv.is_owned = false;
39340         int64_t ret_conv = AcceptChannelV2_get_funding_satoshis(&this_ptr_conv);
39341         return ret_conv;
39342 }
39343
39344 void  CS_LDK_AcceptChannelV2_set_funding_satoshis(int64_t this_ptr, int64_t val) {
39345         LDKAcceptChannelV2 this_ptr_conv;
39346         this_ptr_conv.inner = untag_ptr(this_ptr);
39347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39349         this_ptr_conv.is_owned = false;
39350         AcceptChannelV2_set_funding_satoshis(&this_ptr_conv, val);
39351 }
39352
39353 int64_t  CS_LDK_AcceptChannelV2_get_dust_limit_satoshis(int64_t this_ptr) {
39354         LDKAcceptChannelV2 this_ptr_conv;
39355         this_ptr_conv.inner = untag_ptr(this_ptr);
39356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39358         this_ptr_conv.is_owned = false;
39359         int64_t ret_conv = AcceptChannelV2_get_dust_limit_satoshis(&this_ptr_conv);
39360         return ret_conv;
39361 }
39362
39363 void  CS_LDK_AcceptChannelV2_set_dust_limit_satoshis(int64_t this_ptr, int64_t val) {
39364         LDKAcceptChannelV2 this_ptr_conv;
39365         this_ptr_conv.inner = untag_ptr(this_ptr);
39366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39368         this_ptr_conv.is_owned = false;
39369         AcceptChannelV2_set_dust_limit_satoshis(&this_ptr_conv, val);
39370 }
39371
39372 int64_t  CS_LDK_AcceptChannelV2_get_max_htlc_value_in_flight_msat(int64_t this_ptr) {
39373         LDKAcceptChannelV2 this_ptr_conv;
39374         this_ptr_conv.inner = untag_ptr(this_ptr);
39375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39377         this_ptr_conv.is_owned = false;
39378         int64_t ret_conv = AcceptChannelV2_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
39379         return ret_conv;
39380 }
39381
39382 void  CS_LDK_AcceptChannelV2_set_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
39383         LDKAcceptChannelV2 this_ptr_conv;
39384         this_ptr_conv.inner = untag_ptr(this_ptr);
39385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39387         this_ptr_conv.is_owned = false;
39388         AcceptChannelV2_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
39389 }
39390
39391 int64_t  CS_LDK_AcceptChannelV2_get_htlc_minimum_msat(int64_t this_ptr) {
39392         LDKAcceptChannelV2 this_ptr_conv;
39393         this_ptr_conv.inner = untag_ptr(this_ptr);
39394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39396         this_ptr_conv.is_owned = false;
39397         int64_t ret_conv = AcceptChannelV2_get_htlc_minimum_msat(&this_ptr_conv);
39398         return ret_conv;
39399 }
39400
39401 void  CS_LDK_AcceptChannelV2_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
39402         LDKAcceptChannelV2 this_ptr_conv;
39403         this_ptr_conv.inner = untag_ptr(this_ptr);
39404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39406         this_ptr_conv.is_owned = false;
39407         AcceptChannelV2_set_htlc_minimum_msat(&this_ptr_conv, val);
39408 }
39409
39410 int32_t  CS_LDK_AcceptChannelV2_get_minimum_depth(int64_t this_ptr) {
39411         LDKAcceptChannelV2 this_ptr_conv;
39412         this_ptr_conv.inner = untag_ptr(this_ptr);
39413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39415         this_ptr_conv.is_owned = false;
39416         int32_t ret_conv = AcceptChannelV2_get_minimum_depth(&this_ptr_conv);
39417         return ret_conv;
39418 }
39419
39420 void  CS_LDK_AcceptChannelV2_set_minimum_depth(int64_t this_ptr, int32_t val) {
39421         LDKAcceptChannelV2 this_ptr_conv;
39422         this_ptr_conv.inner = untag_ptr(this_ptr);
39423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39425         this_ptr_conv.is_owned = false;
39426         AcceptChannelV2_set_minimum_depth(&this_ptr_conv, val);
39427 }
39428
39429 int16_t  CS_LDK_AcceptChannelV2_get_to_self_delay(int64_t this_ptr) {
39430         LDKAcceptChannelV2 this_ptr_conv;
39431         this_ptr_conv.inner = untag_ptr(this_ptr);
39432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39434         this_ptr_conv.is_owned = false;
39435         int16_t ret_conv = AcceptChannelV2_get_to_self_delay(&this_ptr_conv);
39436         return ret_conv;
39437 }
39438
39439 void  CS_LDK_AcceptChannelV2_set_to_self_delay(int64_t this_ptr, int16_t val) {
39440         LDKAcceptChannelV2 this_ptr_conv;
39441         this_ptr_conv.inner = untag_ptr(this_ptr);
39442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39444         this_ptr_conv.is_owned = false;
39445         AcceptChannelV2_set_to_self_delay(&this_ptr_conv, val);
39446 }
39447
39448 int16_t  CS_LDK_AcceptChannelV2_get_max_accepted_htlcs(int64_t this_ptr) {
39449         LDKAcceptChannelV2 this_ptr_conv;
39450         this_ptr_conv.inner = untag_ptr(this_ptr);
39451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39453         this_ptr_conv.is_owned = false;
39454         int16_t ret_conv = AcceptChannelV2_get_max_accepted_htlcs(&this_ptr_conv);
39455         return ret_conv;
39456 }
39457
39458 void  CS_LDK_AcceptChannelV2_set_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
39459         LDKAcceptChannelV2 this_ptr_conv;
39460         this_ptr_conv.inner = untag_ptr(this_ptr);
39461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39463         this_ptr_conv.is_owned = false;
39464         AcceptChannelV2_set_max_accepted_htlcs(&this_ptr_conv, val);
39465 }
39466
39467 int8_tArray  CS_LDK_AcceptChannelV2_get_funding_pubkey(int64_t this_ptr) {
39468         LDKAcceptChannelV2 this_ptr_conv;
39469         this_ptr_conv.inner = untag_ptr(this_ptr);
39470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39472         this_ptr_conv.is_owned = false;
39473         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39474         memcpy(ret_arr->elems, AcceptChannelV2_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
39475         return ret_arr;
39476 }
39477
39478 void  CS_LDK_AcceptChannelV2_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
39479         LDKAcceptChannelV2 this_ptr_conv;
39480         this_ptr_conv.inner = untag_ptr(this_ptr);
39481         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39483         this_ptr_conv.is_owned = false;
39484         LDKPublicKey val_ref;
39485         CHECK(val->arr_len == 33);
39486         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39487         AcceptChannelV2_set_funding_pubkey(&this_ptr_conv, val_ref);
39488 }
39489
39490 int8_tArray  CS_LDK_AcceptChannelV2_get_revocation_basepoint(int64_t this_ptr) {
39491         LDKAcceptChannelV2 this_ptr_conv;
39492         this_ptr_conv.inner = untag_ptr(this_ptr);
39493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39495         this_ptr_conv.is_owned = false;
39496         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39497         memcpy(ret_arr->elems, AcceptChannelV2_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
39498         return ret_arr;
39499 }
39500
39501 void  CS_LDK_AcceptChannelV2_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
39502         LDKAcceptChannelV2 this_ptr_conv;
39503         this_ptr_conv.inner = untag_ptr(this_ptr);
39504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39506         this_ptr_conv.is_owned = false;
39507         LDKPublicKey val_ref;
39508         CHECK(val->arr_len == 33);
39509         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39510         AcceptChannelV2_set_revocation_basepoint(&this_ptr_conv, val_ref);
39511 }
39512
39513 int8_tArray  CS_LDK_AcceptChannelV2_get_payment_basepoint(int64_t this_ptr) {
39514         LDKAcceptChannelV2 this_ptr_conv;
39515         this_ptr_conv.inner = untag_ptr(this_ptr);
39516         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39518         this_ptr_conv.is_owned = false;
39519         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39520         memcpy(ret_arr->elems, AcceptChannelV2_get_payment_basepoint(&this_ptr_conv).compressed_form, 33);
39521         return ret_arr;
39522 }
39523
39524 void  CS_LDK_AcceptChannelV2_set_payment_basepoint(int64_t this_ptr, int8_tArray val) {
39525         LDKAcceptChannelV2 this_ptr_conv;
39526         this_ptr_conv.inner = untag_ptr(this_ptr);
39527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39529         this_ptr_conv.is_owned = false;
39530         LDKPublicKey val_ref;
39531         CHECK(val->arr_len == 33);
39532         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39533         AcceptChannelV2_set_payment_basepoint(&this_ptr_conv, val_ref);
39534 }
39535
39536 int8_tArray  CS_LDK_AcceptChannelV2_get_delayed_payment_basepoint(int64_t this_ptr) {
39537         LDKAcceptChannelV2 this_ptr_conv;
39538         this_ptr_conv.inner = untag_ptr(this_ptr);
39539         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39541         this_ptr_conv.is_owned = false;
39542         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39543         memcpy(ret_arr->elems, AcceptChannelV2_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
39544         return ret_arr;
39545 }
39546
39547 void  CS_LDK_AcceptChannelV2_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
39548         LDKAcceptChannelV2 this_ptr_conv;
39549         this_ptr_conv.inner = untag_ptr(this_ptr);
39550         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39552         this_ptr_conv.is_owned = false;
39553         LDKPublicKey val_ref;
39554         CHECK(val->arr_len == 33);
39555         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39556         AcceptChannelV2_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39557 }
39558
39559 int8_tArray  CS_LDK_AcceptChannelV2_get_htlc_basepoint(int64_t this_ptr) {
39560         LDKAcceptChannelV2 this_ptr_conv;
39561         this_ptr_conv.inner = untag_ptr(this_ptr);
39562         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39564         this_ptr_conv.is_owned = false;
39565         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39566         memcpy(ret_arr->elems, AcceptChannelV2_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
39567         return ret_arr;
39568 }
39569
39570 void  CS_LDK_AcceptChannelV2_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
39571         LDKAcceptChannelV2 this_ptr_conv;
39572         this_ptr_conv.inner = untag_ptr(this_ptr);
39573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39575         this_ptr_conv.is_owned = false;
39576         LDKPublicKey val_ref;
39577         CHECK(val->arr_len == 33);
39578         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39579         AcceptChannelV2_set_htlc_basepoint(&this_ptr_conv, val_ref);
39580 }
39581
39582 int8_tArray  CS_LDK_AcceptChannelV2_get_first_per_commitment_point(int64_t this_ptr) {
39583         LDKAcceptChannelV2 this_ptr_conv;
39584         this_ptr_conv.inner = untag_ptr(this_ptr);
39585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39587         this_ptr_conv.is_owned = false;
39588         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39589         memcpy(ret_arr->elems, AcceptChannelV2_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
39590         return ret_arr;
39591 }
39592
39593 void  CS_LDK_AcceptChannelV2_set_first_per_commitment_point(int64_t this_ptr, int8_tArray val) {
39594         LDKAcceptChannelV2 this_ptr_conv;
39595         this_ptr_conv.inner = untag_ptr(this_ptr);
39596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39598         this_ptr_conv.is_owned = false;
39599         LDKPublicKey val_ref;
39600         CHECK(val->arr_len == 33);
39601         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39602         AcceptChannelV2_set_first_per_commitment_point(&this_ptr_conv, val_ref);
39603 }
39604
39605 int8_tArray  CS_LDK_AcceptChannelV2_get_second_per_commitment_point(int64_t this_ptr) {
39606         LDKAcceptChannelV2 this_ptr_conv;
39607         this_ptr_conv.inner = untag_ptr(this_ptr);
39608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39610         this_ptr_conv.is_owned = false;
39611         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39612         memcpy(ret_arr->elems, AcceptChannelV2_get_second_per_commitment_point(&this_ptr_conv).compressed_form, 33);
39613         return ret_arr;
39614 }
39615
39616 void  CS_LDK_AcceptChannelV2_set_second_per_commitment_point(int64_t this_ptr, int8_tArray val) {
39617         LDKAcceptChannelV2 this_ptr_conv;
39618         this_ptr_conv.inner = untag_ptr(this_ptr);
39619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39621         this_ptr_conv.is_owned = false;
39622         LDKPublicKey val_ref;
39623         CHECK(val->arr_len == 33);
39624         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39625         AcceptChannelV2_set_second_per_commitment_point(&this_ptr_conv, val_ref);
39626 }
39627
39628 int64_t  CS_LDK_AcceptChannelV2_get_shutdown_scriptpubkey(int64_t this_ptr) {
39629         LDKAcceptChannelV2 this_ptr_conv;
39630         this_ptr_conv.inner = untag_ptr(this_ptr);
39631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39633         this_ptr_conv.is_owned = false;
39634         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
39635         *ret_copy = AcceptChannelV2_get_shutdown_scriptpubkey(&this_ptr_conv);
39636         int64_t ret_ref = tag_ptr(ret_copy, true);
39637         return ret_ref;
39638 }
39639
39640 void  CS_LDK_AcceptChannelV2_set_shutdown_scriptpubkey(int64_t this_ptr, int64_t val) {
39641         LDKAcceptChannelV2 this_ptr_conv;
39642         this_ptr_conv.inner = untag_ptr(this_ptr);
39643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39645         this_ptr_conv.is_owned = false;
39646         void* val_ptr = untag_ptr(val);
39647         CHECK_ACCESS(val_ptr);
39648         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
39649         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
39650         AcceptChannelV2_set_shutdown_scriptpubkey(&this_ptr_conv, val_conv);
39651 }
39652
39653 int64_t  CS_LDK_AcceptChannelV2_get_channel_type(int64_t this_ptr) {
39654         LDKAcceptChannelV2 this_ptr_conv;
39655         this_ptr_conv.inner = untag_ptr(this_ptr);
39656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39658         this_ptr_conv.is_owned = false;
39659         LDKChannelTypeFeatures ret_var = AcceptChannelV2_get_channel_type(&this_ptr_conv);
39660         int64_t ret_ref = 0;
39661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39662         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39663         return ret_ref;
39664 }
39665
39666 void  CS_LDK_AcceptChannelV2_set_channel_type(int64_t this_ptr, int64_t val) {
39667         LDKAcceptChannelV2 this_ptr_conv;
39668         this_ptr_conv.inner = untag_ptr(this_ptr);
39669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39671         this_ptr_conv.is_owned = false;
39672         LDKChannelTypeFeatures val_conv;
39673         val_conv.inner = untag_ptr(val);
39674         val_conv.is_owned = ptr_is_owned(val);
39675         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39676         val_conv = ChannelTypeFeatures_clone(&val_conv);
39677         AcceptChannelV2_set_channel_type(&this_ptr_conv, val_conv);
39678 }
39679
39680 int32_t  CS_LDK_AcceptChannelV2_get_require_confirmed_inputs(int64_t this_ptr) {
39681         LDKAcceptChannelV2 this_ptr_conv;
39682         this_ptr_conv.inner = untag_ptr(this_ptr);
39683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39685         this_ptr_conv.is_owned = false;
39686         int32_t ret_conv = LDKCOption_NoneZ_to_cs(AcceptChannelV2_get_require_confirmed_inputs(&this_ptr_conv));
39687         return ret_conv;
39688 }
39689
39690 void  CS_LDK_AcceptChannelV2_set_require_confirmed_inputs(int64_t this_ptr, int32_t val) {
39691         LDKAcceptChannelV2 this_ptr_conv;
39692         this_ptr_conv.inner = untag_ptr(this_ptr);
39693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39695         this_ptr_conv.is_owned = false;
39696         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_cs(val);
39697         AcceptChannelV2_set_require_confirmed_inputs(&this_ptr_conv, val_conv);
39698 }
39699
39700 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) {
39701         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
39702         CHECK(temporary_channel_id_arg->arr_len == 32);
39703         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
39704         LDKPublicKey funding_pubkey_arg_ref;
39705         CHECK(funding_pubkey_arg->arr_len == 33);
39706         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
39707         LDKPublicKey revocation_basepoint_arg_ref;
39708         CHECK(revocation_basepoint_arg->arr_len == 33);
39709         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
39710         LDKPublicKey payment_basepoint_arg_ref;
39711         CHECK(payment_basepoint_arg->arr_len == 33);
39712         memcpy(payment_basepoint_arg_ref.compressed_form, payment_basepoint_arg->elems, 33); FREE(payment_basepoint_arg);
39713         LDKPublicKey delayed_payment_basepoint_arg_ref;
39714         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
39715         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
39716         LDKPublicKey htlc_basepoint_arg_ref;
39717         CHECK(htlc_basepoint_arg->arr_len == 33);
39718         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
39719         LDKPublicKey first_per_commitment_point_arg_ref;
39720         CHECK(first_per_commitment_point_arg->arr_len == 33);
39721         memcpy(first_per_commitment_point_arg_ref.compressed_form, first_per_commitment_point_arg->elems, 33); FREE(first_per_commitment_point_arg);
39722         LDKPublicKey second_per_commitment_point_arg_ref;
39723         CHECK(second_per_commitment_point_arg->arr_len == 33);
39724         memcpy(second_per_commitment_point_arg_ref.compressed_form, second_per_commitment_point_arg->elems, 33); FREE(second_per_commitment_point_arg);
39725         void* shutdown_scriptpubkey_arg_ptr = untag_ptr(shutdown_scriptpubkey_arg);
39726         CHECK_ACCESS(shutdown_scriptpubkey_arg_ptr);
39727         LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg_conv = *(LDKCOption_CVec_u8ZZ*)(shutdown_scriptpubkey_arg_ptr);
39728         shutdown_scriptpubkey_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(shutdown_scriptpubkey_arg));
39729         LDKChannelTypeFeatures channel_type_arg_conv;
39730         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
39731         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
39732         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
39733         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
39734         LDKCOption_NoneZ require_confirmed_inputs_arg_conv = LDKCOption_NoneZ_from_cs(require_confirmed_inputs_arg);
39735         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);
39736         int64_t ret_ref = 0;
39737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39738         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39739         return ret_ref;
39740 }
39741
39742 static inline uint64_t AcceptChannelV2_clone_ptr(LDKAcceptChannelV2 *NONNULL_PTR arg) {
39743         LDKAcceptChannelV2 ret_var = AcceptChannelV2_clone(arg);
39744         int64_t ret_ref = 0;
39745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39747         return ret_ref;
39748 }
39749 int64_t  CS_LDK_AcceptChannelV2_clone_ptr(int64_t arg) {
39750         LDKAcceptChannelV2 arg_conv;
39751         arg_conv.inner = untag_ptr(arg);
39752         arg_conv.is_owned = ptr_is_owned(arg);
39753         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39754         arg_conv.is_owned = false;
39755         int64_t ret_conv = AcceptChannelV2_clone_ptr(&arg_conv);
39756         return ret_conv;
39757 }
39758
39759 int64_t  CS_LDK_AcceptChannelV2_clone(int64_t orig) {
39760         LDKAcceptChannelV2 orig_conv;
39761         orig_conv.inner = untag_ptr(orig);
39762         orig_conv.is_owned = ptr_is_owned(orig);
39763         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39764         orig_conv.is_owned = false;
39765         LDKAcceptChannelV2 ret_var = AcceptChannelV2_clone(&orig_conv);
39766         int64_t ret_ref = 0;
39767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39768         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39769         return ret_ref;
39770 }
39771
39772 jboolean  CS_LDK_AcceptChannelV2_eq(int64_t a, int64_t b) {
39773         LDKAcceptChannelV2 a_conv;
39774         a_conv.inner = untag_ptr(a);
39775         a_conv.is_owned = ptr_is_owned(a);
39776         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39777         a_conv.is_owned = false;
39778         LDKAcceptChannelV2 b_conv;
39779         b_conv.inner = untag_ptr(b);
39780         b_conv.is_owned = ptr_is_owned(b);
39781         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39782         b_conv.is_owned = false;
39783         jboolean ret_conv = AcceptChannelV2_eq(&a_conv, &b_conv);
39784         return ret_conv;
39785 }
39786
39787 void  CS_LDK_FundingCreated_free(int64_t this_obj) {
39788         LDKFundingCreated this_obj_conv;
39789         this_obj_conv.inner = untag_ptr(this_obj);
39790         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39792         FundingCreated_free(this_obj_conv);
39793 }
39794
39795 int8_tArray  CS_LDK_FundingCreated_get_temporary_channel_id(int64_t this_ptr) {
39796         LDKFundingCreated this_ptr_conv;
39797         this_ptr_conv.inner = untag_ptr(this_ptr);
39798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39800         this_ptr_conv.is_owned = false;
39801         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39802         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
39803         return ret_arr;
39804 }
39805
39806 void  CS_LDK_FundingCreated_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
39807         LDKFundingCreated this_ptr_conv;
39808         this_ptr_conv.inner = untag_ptr(this_ptr);
39809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39811         this_ptr_conv.is_owned = false;
39812         LDKThirtyTwoBytes val_ref;
39813         CHECK(val->arr_len == 32);
39814         memcpy(val_ref.data, val->elems, 32); FREE(val);
39815         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
39816 }
39817
39818 int8_tArray  CS_LDK_FundingCreated_get_funding_txid(int64_t this_ptr) {
39819         LDKFundingCreated this_ptr_conv;
39820         this_ptr_conv.inner = untag_ptr(this_ptr);
39821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39823         this_ptr_conv.is_owned = false;
39824         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39825         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
39826         return ret_arr;
39827 }
39828
39829 void  CS_LDK_FundingCreated_set_funding_txid(int64_t this_ptr, int8_tArray val) {
39830         LDKFundingCreated this_ptr_conv;
39831         this_ptr_conv.inner = untag_ptr(this_ptr);
39832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39834         this_ptr_conv.is_owned = false;
39835         LDKThirtyTwoBytes val_ref;
39836         CHECK(val->arr_len == 32);
39837         memcpy(val_ref.data, val->elems, 32); FREE(val);
39838         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
39839 }
39840
39841 int16_t  CS_LDK_FundingCreated_get_funding_output_index(int64_t this_ptr) {
39842         LDKFundingCreated this_ptr_conv;
39843         this_ptr_conv.inner = untag_ptr(this_ptr);
39844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39846         this_ptr_conv.is_owned = false;
39847         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
39848         return ret_conv;
39849 }
39850
39851 void  CS_LDK_FundingCreated_set_funding_output_index(int64_t this_ptr, int16_t val) {
39852         LDKFundingCreated this_ptr_conv;
39853         this_ptr_conv.inner = untag_ptr(this_ptr);
39854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39856         this_ptr_conv.is_owned = false;
39857         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
39858 }
39859
39860 int8_tArray  CS_LDK_FundingCreated_get_signature(int64_t this_ptr) {
39861         LDKFundingCreated this_ptr_conv;
39862         this_ptr_conv.inner = untag_ptr(this_ptr);
39863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39865         this_ptr_conv.is_owned = false;
39866         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
39867         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
39868         return ret_arr;
39869 }
39870
39871 void  CS_LDK_FundingCreated_set_signature(int64_t this_ptr, int8_tArray val) {
39872         LDKFundingCreated this_ptr_conv;
39873         this_ptr_conv.inner = untag_ptr(this_ptr);
39874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39876         this_ptr_conv.is_owned = false;
39877         LDKECDSASignature val_ref;
39878         CHECK(val->arr_len == 64);
39879         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
39880         FundingCreated_set_signature(&this_ptr_conv, val_ref);
39881 }
39882
39883 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) {
39884         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
39885         CHECK(temporary_channel_id_arg->arr_len == 32);
39886         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
39887         LDKThirtyTwoBytes funding_txid_arg_ref;
39888         CHECK(funding_txid_arg->arr_len == 32);
39889         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
39890         LDKECDSASignature signature_arg_ref;
39891         CHECK(signature_arg->arr_len == 64);
39892         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
39893         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
39894         int64_t ret_ref = 0;
39895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39897         return ret_ref;
39898 }
39899
39900 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
39901         LDKFundingCreated ret_var = FundingCreated_clone(arg);
39902         int64_t ret_ref = 0;
39903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39905         return ret_ref;
39906 }
39907 int64_t  CS_LDK_FundingCreated_clone_ptr(int64_t arg) {
39908         LDKFundingCreated arg_conv;
39909         arg_conv.inner = untag_ptr(arg);
39910         arg_conv.is_owned = ptr_is_owned(arg);
39911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39912         arg_conv.is_owned = false;
39913         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
39914         return ret_conv;
39915 }
39916
39917 int64_t  CS_LDK_FundingCreated_clone(int64_t orig) {
39918         LDKFundingCreated orig_conv;
39919         orig_conv.inner = untag_ptr(orig);
39920         orig_conv.is_owned = ptr_is_owned(orig);
39921         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39922         orig_conv.is_owned = false;
39923         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
39924         int64_t ret_ref = 0;
39925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39926         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39927         return ret_ref;
39928 }
39929
39930 jboolean  CS_LDK_FundingCreated_eq(int64_t a, int64_t b) {
39931         LDKFundingCreated a_conv;
39932         a_conv.inner = untag_ptr(a);
39933         a_conv.is_owned = ptr_is_owned(a);
39934         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39935         a_conv.is_owned = false;
39936         LDKFundingCreated b_conv;
39937         b_conv.inner = untag_ptr(b);
39938         b_conv.is_owned = ptr_is_owned(b);
39939         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39940         b_conv.is_owned = false;
39941         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
39942         return ret_conv;
39943 }
39944
39945 void  CS_LDK_FundingSigned_free(int64_t this_obj) {
39946         LDKFundingSigned this_obj_conv;
39947         this_obj_conv.inner = untag_ptr(this_obj);
39948         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39950         FundingSigned_free(this_obj_conv);
39951 }
39952
39953 int8_tArray  CS_LDK_FundingSigned_get_channel_id(int64_t this_ptr) {
39954         LDKFundingSigned this_ptr_conv;
39955         this_ptr_conv.inner = untag_ptr(this_ptr);
39956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39958         this_ptr_conv.is_owned = false;
39959         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39960         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
39961         return ret_arr;
39962 }
39963
39964 void  CS_LDK_FundingSigned_set_channel_id(int64_t this_ptr, int8_tArray val) {
39965         LDKFundingSigned this_ptr_conv;
39966         this_ptr_conv.inner = untag_ptr(this_ptr);
39967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39969         this_ptr_conv.is_owned = false;
39970         LDKThirtyTwoBytes val_ref;
39971         CHECK(val->arr_len == 32);
39972         memcpy(val_ref.data, val->elems, 32); FREE(val);
39973         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
39974 }
39975
39976 int8_tArray  CS_LDK_FundingSigned_get_signature(int64_t this_ptr) {
39977         LDKFundingSigned this_ptr_conv;
39978         this_ptr_conv.inner = untag_ptr(this_ptr);
39979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39981         this_ptr_conv.is_owned = false;
39982         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
39983         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
39984         return ret_arr;
39985 }
39986
39987 void  CS_LDK_FundingSigned_set_signature(int64_t this_ptr, int8_tArray val) {
39988         LDKFundingSigned this_ptr_conv;
39989         this_ptr_conv.inner = untag_ptr(this_ptr);
39990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39992         this_ptr_conv.is_owned = false;
39993         LDKECDSASignature val_ref;
39994         CHECK(val->arr_len == 64);
39995         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
39996         FundingSigned_set_signature(&this_ptr_conv, val_ref);
39997 }
39998
39999 int64_t  CS_LDK_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
40000         LDKThirtyTwoBytes channel_id_arg_ref;
40001         CHECK(channel_id_arg->arr_len == 32);
40002         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40003         LDKECDSASignature signature_arg_ref;
40004         CHECK(signature_arg->arr_len == 64);
40005         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
40006         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
40007         int64_t ret_ref = 0;
40008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40009         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40010         return ret_ref;
40011 }
40012
40013 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
40014         LDKFundingSigned ret_var = FundingSigned_clone(arg);
40015         int64_t ret_ref = 0;
40016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40017         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40018         return ret_ref;
40019 }
40020 int64_t  CS_LDK_FundingSigned_clone_ptr(int64_t arg) {
40021         LDKFundingSigned arg_conv;
40022         arg_conv.inner = untag_ptr(arg);
40023         arg_conv.is_owned = ptr_is_owned(arg);
40024         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40025         arg_conv.is_owned = false;
40026         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
40027         return ret_conv;
40028 }
40029
40030 int64_t  CS_LDK_FundingSigned_clone(int64_t orig) {
40031         LDKFundingSigned orig_conv;
40032         orig_conv.inner = untag_ptr(orig);
40033         orig_conv.is_owned = ptr_is_owned(orig);
40034         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40035         orig_conv.is_owned = false;
40036         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
40037         int64_t ret_ref = 0;
40038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40039         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40040         return ret_ref;
40041 }
40042
40043 jboolean  CS_LDK_FundingSigned_eq(int64_t a, int64_t b) {
40044         LDKFundingSigned a_conv;
40045         a_conv.inner = untag_ptr(a);
40046         a_conv.is_owned = ptr_is_owned(a);
40047         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40048         a_conv.is_owned = false;
40049         LDKFundingSigned b_conv;
40050         b_conv.inner = untag_ptr(b);
40051         b_conv.is_owned = ptr_is_owned(b);
40052         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40053         b_conv.is_owned = false;
40054         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
40055         return ret_conv;
40056 }
40057
40058 void  CS_LDK_ChannelReady_free(int64_t this_obj) {
40059         LDKChannelReady this_obj_conv;
40060         this_obj_conv.inner = untag_ptr(this_obj);
40061         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40063         ChannelReady_free(this_obj_conv);
40064 }
40065
40066 int8_tArray  CS_LDK_ChannelReady_get_channel_id(int64_t this_ptr) {
40067         LDKChannelReady this_ptr_conv;
40068         this_ptr_conv.inner = untag_ptr(this_ptr);
40069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40071         this_ptr_conv.is_owned = false;
40072         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40073         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
40074         return ret_arr;
40075 }
40076
40077 void  CS_LDK_ChannelReady_set_channel_id(int64_t this_ptr, int8_tArray val) {
40078         LDKChannelReady this_ptr_conv;
40079         this_ptr_conv.inner = untag_ptr(this_ptr);
40080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40082         this_ptr_conv.is_owned = false;
40083         LDKThirtyTwoBytes val_ref;
40084         CHECK(val->arr_len == 32);
40085         memcpy(val_ref.data, val->elems, 32); FREE(val);
40086         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
40087 }
40088
40089 int8_tArray  CS_LDK_ChannelReady_get_next_per_commitment_point(int64_t this_ptr) {
40090         LDKChannelReady this_ptr_conv;
40091         this_ptr_conv.inner = untag_ptr(this_ptr);
40092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40094         this_ptr_conv.is_owned = false;
40095         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40096         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
40097         return ret_arr;
40098 }
40099
40100 void  CS_LDK_ChannelReady_set_next_per_commitment_point(int64_t this_ptr, int8_tArray val) {
40101         LDKChannelReady this_ptr_conv;
40102         this_ptr_conv.inner = untag_ptr(this_ptr);
40103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40105         this_ptr_conv.is_owned = false;
40106         LDKPublicKey val_ref;
40107         CHECK(val->arr_len == 33);
40108         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40109         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
40110 }
40111
40112 int64_t  CS_LDK_ChannelReady_get_short_channel_id_alias(int64_t this_ptr) {
40113         LDKChannelReady this_ptr_conv;
40114         this_ptr_conv.inner = untag_ptr(this_ptr);
40115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40117         this_ptr_conv.is_owned = false;
40118         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40119         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
40120         int64_t ret_ref = tag_ptr(ret_copy, true);
40121         return ret_ref;
40122 }
40123
40124 void  CS_LDK_ChannelReady_set_short_channel_id_alias(int64_t this_ptr, int64_t val) {
40125         LDKChannelReady this_ptr_conv;
40126         this_ptr_conv.inner = untag_ptr(this_ptr);
40127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40129         this_ptr_conv.is_owned = false;
40130         void* val_ptr = untag_ptr(val);
40131         CHECK_ACCESS(val_ptr);
40132         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40133         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
40134         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
40135 }
40136
40137 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) {
40138         LDKThirtyTwoBytes channel_id_arg_ref;
40139         CHECK(channel_id_arg->arr_len == 32);
40140         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40141         LDKPublicKey next_per_commitment_point_arg_ref;
40142         CHECK(next_per_commitment_point_arg->arr_len == 33);
40143         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
40144         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
40145         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
40146         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
40147         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
40148         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
40149         int64_t ret_ref = 0;
40150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40151         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40152         return ret_ref;
40153 }
40154
40155 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
40156         LDKChannelReady ret_var = ChannelReady_clone(arg);
40157         int64_t ret_ref = 0;
40158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40160         return ret_ref;
40161 }
40162 int64_t  CS_LDK_ChannelReady_clone_ptr(int64_t arg) {
40163         LDKChannelReady arg_conv;
40164         arg_conv.inner = untag_ptr(arg);
40165         arg_conv.is_owned = ptr_is_owned(arg);
40166         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40167         arg_conv.is_owned = false;
40168         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
40169         return ret_conv;
40170 }
40171
40172 int64_t  CS_LDK_ChannelReady_clone(int64_t orig) {
40173         LDKChannelReady orig_conv;
40174         orig_conv.inner = untag_ptr(orig);
40175         orig_conv.is_owned = ptr_is_owned(orig);
40176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40177         orig_conv.is_owned = false;
40178         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
40179         int64_t ret_ref = 0;
40180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40182         return ret_ref;
40183 }
40184
40185 jboolean  CS_LDK_ChannelReady_eq(int64_t a, int64_t b) {
40186         LDKChannelReady a_conv;
40187         a_conv.inner = untag_ptr(a);
40188         a_conv.is_owned = ptr_is_owned(a);
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40190         a_conv.is_owned = false;
40191         LDKChannelReady b_conv;
40192         b_conv.inner = untag_ptr(b);
40193         b_conv.is_owned = ptr_is_owned(b);
40194         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40195         b_conv.is_owned = false;
40196         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
40197         return ret_conv;
40198 }
40199
40200 void  CS_LDK_TxAddInput_free(int64_t this_obj) {
40201         LDKTxAddInput this_obj_conv;
40202         this_obj_conv.inner = untag_ptr(this_obj);
40203         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40205         TxAddInput_free(this_obj_conv);
40206 }
40207
40208 int8_tArray  CS_LDK_TxAddInput_get_channel_id(int64_t this_ptr) {
40209         LDKTxAddInput this_ptr_conv;
40210         this_ptr_conv.inner = untag_ptr(this_ptr);
40211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40213         this_ptr_conv.is_owned = false;
40214         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40215         memcpy(ret_arr->elems, *TxAddInput_get_channel_id(&this_ptr_conv), 32);
40216         return ret_arr;
40217 }
40218
40219 void  CS_LDK_TxAddInput_set_channel_id(int64_t this_ptr, int8_tArray val) {
40220         LDKTxAddInput this_ptr_conv;
40221         this_ptr_conv.inner = untag_ptr(this_ptr);
40222         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40224         this_ptr_conv.is_owned = false;
40225         LDKThirtyTwoBytes val_ref;
40226         CHECK(val->arr_len == 32);
40227         memcpy(val_ref.data, val->elems, 32); FREE(val);
40228         TxAddInput_set_channel_id(&this_ptr_conv, val_ref);
40229 }
40230
40231 int64_t  CS_LDK_TxAddInput_get_serial_id(int64_t this_ptr) {
40232         LDKTxAddInput this_ptr_conv;
40233         this_ptr_conv.inner = untag_ptr(this_ptr);
40234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40236         this_ptr_conv.is_owned = false;
40237         int64_t ret_conv = TxAddInput_get_serial_id(&this_ptr_conv);
40238         return ret_conv;
40239 }
40240
40241 void  CS_LDK_TxAddInput_set_serial_id(int64_t this_ptr, int64_t val) {
40242         LDKTxAddInput this_ptr_conv;
40243         this_ptr_conv.inner = untag_ptr(this_ptr);
40244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40246         this_ptr_conv.is_owned = false;
40247         TxAddInput_set_serial_id(&this_ptr_conv, val);
40248 }
40249
40250 int64_t  CS_LDK_TxAddInput_get_prevtx(int64_t this_ptr) {
40251         LDKTxAddInput this_ptr_conv;
40252         this_ptr_conv.inner = untag_ptr(this_ptr);
40253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40255         this_ptr_conv.is_owned = false;
40256         LDKTransactionU16LenLimited ret_var = TxAddInput_get_prevtx(&this_ptr_conv);
40257         int64_t ret_ref = 0;
40258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40260         return ret_ref;
40261 }
40262
40263 void  CS_LDK_TxAddInput_set_prevtx(int64_t this_ptr, int64_t val) {
40264         LDKTxAddInput this_ptr_conv;
40265         this_ptr_conv.inner = untag_ptr(this_ptr);
40266         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40268         this_ptr_conv.is_owned = false;
40269         LDKTransactionU16LenLimited val_conv;
40270         val_conv.inner = untag_ptr(val);
40271         val_conv.is_owned = ptr_is_owned(val);
40272         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40273         val_conv = TransactionU16LenLimited_clone(&val_conv);
40274         TxAddInput_set_prevtx(&this_ptr_conv, val_conv);
40275 }
40276
40277 int32_t  CS_LDK_TxAddInput_get_prevtx_out(int64_t this_ptr) {
40278         LDKTxAddInput this_ptr_conv;
40279         this_ptr_conv.inner = untag_ptr(this_ptr);
40280         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40282         this_ptr_conv.is_owned = false;
40283         int32_t ret_conv = TxAddInput_get_prevtx_out(&this_ptr_conv);
40284         return ret_conv;
40285 }
40286
40287 void  CS_LDK_TxAddInput_set_prevtx_out(int64_t this_ptr, int32_t val) {
40288         LDKTxAddInput this_ptr_conv;
40289         this_ptr_conv.inner = untag_ptr(this_ptr);
40290         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40292         this_ptr_conv.is_owned = false;
40293         TxAddInput_set_prevtx_out(&this_ptr_conv, val);
40294 }
40295
40296 int32_t  CS_LDK_TxAddInput_get_sequence(int64_t this_ptr) {
40297         LDKTxAddInput this_ptr_conv;
40298         this_ptr_conv.inner = untag_ptr(this_ptr);
40299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40301         this_ptr_conv.is_owned = false;
40302         int32_t ret_conv = TxAddInput_get_sequence(&this_ptr_conv);
40303         return ret_conv;
40304 }
40305
40306 void  CS_LDK_TxAddInput_set_sequence(int64_t this_ptr, int32_t val) {
40307         LDKTxAddInput this_ptr_conv;
40308         this_ptr_conv.inner = untag_ptr(this_ptr);
40309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40311         this_ptr_conv.is_owned = false;
40312         TxAddInput_set_sequence(&this_ptr_conv, val);
40313 }
40314
40315 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) {
40316         LDKThirtyTwoBytes channel_id_arg_ref;
40317         CHECK(channel_id_arg->arr_len == 32);
40318         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40319         LDKTransactionU16LenLimited prevtx_arg_conv;
40320         prevtx_arg_conv.inner = untag_ptr(prevtx_arg);
40321         prevtx_arg_conv.is_owned = ptr_is_owned(prevtx_arg);
40322         CHECK_INNER_FIELD_ACCESS_OR_NULL(prevtx_arg_conv);
40323         prevtx_arg_conv = TransactionU16LenLimited_clone(&prevtx_arg_conv);
40324         LDKTxAddInput ret_var = TxAddInput_new(channel_id_arg_ref, serial_id_arg, prevtx_arg_conv, prevtx_out_arg, sequence_arg);
40325         int64_t ret_ref = 0;
40326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40327         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40328         return ret_ref;
40329 }
40330
40331 static inline uint64_t TxAddInput_clone_ptr(LDKTxAddInput *NONNULL_PTR arg) {
40332         LDKTxAddInput ret_var = TxAddInput_clone(arg);
40333         int64_t ret_ref = 0;
40334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40336         return ret_ref;
40337 }
40338 int64_t  CS_LDK_TxAddInput_clone_ptr(int64_t arg) {
40339         LDKTxAddInput arg_conv;
40340         arg_conv.inner = untag_ptr(arg);
40341         arg_conv.is_owned = ptr_is_owned(arg);
40342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40343         arg_conv.is_owned = false;
40344         int64_t ret_conv = TxAddInput_clone_ptr(&arg_conv);
40345         return ret_conv;
40346 }
40347
40348 int64_t  CS_LDK_TxAddInput_clone(int64_t orig) {
40349         LDKTxAddInput orig_conv;
40350         orig_conv.inner = untag_ptr(orig);
40351         orig_conv.is_owned = ptr_is_owned(orig);
40352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40353         orig_conv.is_owned = false;
40354         LDKTxAddInput ret_var = TxAddInput_clone(&orig_conv);
40355         int64_t ret_ref = 0;
40356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40358         return ret_ref;
40359 }
40360
40361 jboolean  CS_LDK_TxAddInput_eq(int64_t a, int64_t b) {
40362         LDKTxAddInput a_conv;
40363         a_conv.inner = untag_ptr(a);
40364         a_conv.is_owned = ptr_is_owned(a);
40365         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40366         a_conv.is_owned = false;
40367         LDKTxAddInput b_conv;
40368         b_conv.inner = untag_ptr(b);
40369         b_conv.is_owned = ptr_is_owned(b);
40370         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40371         b_conv.is_owned = false;
40372         jboolean ret_conv = TxAddInput_eq(&a_conv, &b_conv);
40373         return ret_conv;
40374 }
40375
40376 void  CS_LDK_TxAddOutput_free(int64_t this_obj) {
40377         LDKTxAddOutput this_obj_conv;
40378         this_obj_conv.inner = untag_ptr(this_obj);
40379         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40381         TxAddOutput_free(this_obj_conv);
40382 }
40383
40384 int8_tArray  CS_LDK_TxAddOutput_get_channel_id(int64_t this_ptr) {
40385         LDKTxAddOutput this_ptr_conv;
40386         this_ptr_conv.inner = untag_ptr(this_ptr);
40387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40389         this_ptr_conv.is_owned = false;
40390         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40391         memcpy(ret_arr->elems, *TxAddOutput_get_channel_id(&this_ptr_conv), 32);
40392         return ret_arr;
40393 }
40394
40395 void  CS_LDK_TxAddOutput_set_channel_id(int64_t this_ptr, int8_tArray val) {
40396         LDKTxAddOutput this_ptr_conv;
40397         this_ptr_conv.inner = untag_ptr(this_ptr);
40398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40400         this_ptr_conv.is_owned = false;
40401         LDKThirtyTwoBytes val_ref;
40402         CHECK(val->arr_len == 32);
40403         memcpy(val_ref.data, val->elems, 32); FREE(val);
40404         TxAddOutput_set_channel_id(&this_ptr_conv, val_ref);
40405 }
40406
40407 int64_t  CS_LDK_TxAddOutput_get_serial_id(int64_t this_ptr) {
40408         LDKTxAddOutput this_ptr_conv;
40409         this_ptr_conv.inner = untag_ptr(this_ptr);
40410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40412         this_ptr_conv.is_owned = false;
40413         int64_t ret_conv = TxAddOutput_get_serial_id(&this_ptr_conv);
40414         return ret_conv;
40415 }
40416
40417 void  CS_LDK_TxAddOutput_set_serial_id(int64_t this_ptr, int64_t val) {
40418         LDKTxAddOutput this_ptr_conv;
40419         this_ptr_conv.inner = untag_ptr(this_ptr);
40420         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40422         this_ptr_conv.is_owned = false;
40423         TxAddOutput_set_serial_id(&this_ptr_conv, val);
40424 }
40425
40426 int64_t  CS_LDK_TxAddOutput_get_sats(int64_t this_ptr) {
40427         LDKTxAddOutput this_ptr_conv;
40428         this_ptr_conv.inner = untag_ptr(this_ptr);
40429         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40431         this_ptr_conv.is_owned = false;
40432         int64_t ret_conv = TxAddOutput_get_sats(&this_ptr_conv);
40433         return ret_conv;
40434 }
40435
40436 void  CS_LDK_TxAddOutput_set_sats(int64_t this_ptr, int64_t val) {
40437         LDKTxAddOutput this_ptr_conv;
40438         this_ptr_conv.inner = untag_ptr(this_ptr);
40439         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40441         this_ptr_conv.is_owned = false;
40442         TxAddOutput_set_sats(&this_ptr_conv, val);
40443 }
40444
40445 int8_tArray  CS_LDK_TxAddOutput_get_script(int64_t this_ptr) {
40446         LDKTxAddOutput this_ptr_conv;
40447         this_ptr_conv.inner = untag_ptr(this_ptr);
40448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40450         this_ptr_conv.is_owned = false;
40451         LDKu8slice ret_var = TxAddOutput_get_script(&this_ptr_conv);
40452         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40453         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40454         return ret_arr;
40455 }
40456
40457 void  CS_LDK_TxAddOutput_set_script(int64_t this_ptr, int8_tArray val) {
40458         LDKTxAddOutput this_ptr_conv;
40459         this_ptr_conv.inner = untag_ptr(this_ptr);
40460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40462         this_ptr_conv.is_owned = false;
40463         LDKCVec_u8Z val_ref;
40464         val_ref.datalen = val->arr_len;
40465         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
40466         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
40467         TxAddOutput_set_script(&this_ptr_conv, val_ref);
40468 }
40469
40470 int64_t  CS_LDK_TxAddOutput_new(int8_tArray channel_id_arg, int64_t serial_id_arg, int64_t sats_arg, int8_tArray script_arg) {
40471         LDKThirtyTwoBytes channel_id_arg_ref;
40472         CHECK(channel_id_arg->arr_len == 32);
40473         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40474         LDKCVec_u8Z script_arg_ref;
40475         script_arg_ref.datalen = script_arg->arr_len;
40476         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
40477         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
40478         LDKTxAddOutput ret_var = TxAddOutput_new(channel_id_arg_ref, serial_id_arg, sats_arg, script_arg_ref);
40479         int64_t ret_ref = 0;
40480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40481         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40482         return ret_ref;
40483 }
40484
40485 static inline uint64_t TxAddOutput_clone_ptr(LDKTxAddOutput *NONNULL_PTR arg) {
40486         LDKTxAddOutput ret_var = TxAddOutput_clone(arg);
40487         int64_t ret_ref = 0;
40488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40489         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40490         return ret_ref;
40491 }
40492 int64_t  CS_LDK_TxAddOutput_clone_ptr(int64_t arg) {
40493         LDKTxAddOutput arg_conv;
40494         arg_conv.inner = untag_ptr(arg);
40495         arg_conv.is_owned = ptr_is_owned(arg);
40496         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40497         arg_conv.is_owned = false;
40498         int64_t ret_conv = TxAddOutput_clone_ptr(&arg_conv);
40499         return ret_conv;
40500 }
40501
40502 int64_t  CS_LDK_TxAddOutput_clone(int64_t orig) {
40503         LDKTxAddOutput orig_conv;
40504         orig_conv.inner = untag_ptr(orig);
40505         orig_conv.is_owned = ptr_is_owned(orig);
40506         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40507         orig_conv.is_owned = false;
40508         LDKTxAddOutput ret_var = TxAddOutput_clone(&orig_conv);
40509         int64_t ret_ref = 0;
40510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40512         return ret_ref;
40513 }
40514
40515 jboolean  CS_LDK_TxAddOutput_eq(int64_t a, int64_t b) {
40516         LDKTxAddOutput a_conv;
40517         a_conv.inner = untag_ptr(a);
40518         a_conv.is_owned = ptr_is_owned(a);
40519         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40520         a_conv.is_owned = false;
40521         LDKTxAddOutput b_conv;
40522         b_conv.inner = untag_ptr(b);
40523         b_conv.is_owned = ptr_is_owned(b);
40524         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40525         b_conv.is_owned = false;
40526         jboolean ret_conv = TxAddOutput_eq(&a_conv, &b_conv);
40527         return ret_conv;
40528 }
40529
40530 void  CS_LDK_TxRemoveInput_free(int64_t this_obj) {
40531         LDKTxRemoveInput this_obj_conv;
40532         this_obj_conv.inner = untag_ptr(this_obj);
40533         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40535         TxRemoveInput_free(this_obj_conv);
40536 }
40537
40538 int8_tArray  CS_LDK_TxRemoveInput_get_channel_id(int64_t this_ptr) {
40539         LDKTxRemoveInput this_ptr_conv;
40540         this_ptr_conv.inner = untag_ptr(this_ptr);
40541         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40543         this_ptr_conv.is_owned = false;
40544         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40545         memcpy(ret_arr->elems, *TxRemoveInput_get_channel_id(&this_ptr_conv), 32);
40546         return ret_arr;
40547 }
40548
40549 void  CS_LDK_TxRemoveInput_set_channel_id(int64_t this_ptr, int8_tArray val) {
40550         LDKTxRemoveInput this_ptr_conv;
40551         this_ptr_conv.inner = untag_ptr(this_ptr);
40552         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40554         this_ptr_conv.is_owned = false;
40555         LDKThirtyTwoBytes val_ref;
40556         CHECK(val->arr_len == 32);
40557         memcpy(val_ref.data, val->elems, 32); FREE(val);
40558         TxRemoveInput_set_channel_id(&this_ptr_conv, val_ref);
40559 }
40560
40561 int64_t  CS_LDK_TxRemoveInput_get_serial_id(int64_t this_ptr) {
40562         LDKTxRemoveInput this_ptr_conv;
40563         this_ptr_conv.inner = untag_ptr(this_ptr);
40564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40566         this_ptr_conv.is_owned = false;
40567         int64_t ret_conv = TxRemoveInput_get_serial_id(&this_ptr_conv);
40568         return ret_conv;
40569 }
40570
40571 void  CS_LDK_TxRemoveInput_set_serial_id(int64_t this_ptr, int64_t val) {
40572         LDKTxRemoveInput this_ptr_conv;
40573         this_ptr_conv.inner = untag_ptr(this_ptr);
40574         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40576         this_ptr_conv.is_owned = false;
40577         TxRemoveInput_set_serial_id(&this_ptr_conv, val);
40578 }
40579
40580 int64_t  CS_LDK_TxRemoveInput_new(int8_tArray channel_id_arg, int64_t serial_id_arg) {
40581         LDKThirtyTwoBytes channel_id_arg_ref;
40582         CHECK(channel_id_arg->arr_len == 32);
40583         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40584         LDKTxRemoveInput ret_var = TxRemoveInput_new(channel_id_arg_ref, serial_id_arg);
40585         int64_t ret_ref = 0;
40586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40588         return ret_ref;
40589 }
40590
40591 static inline uint64_t TxRemoveInput_clone_ptr(LDKTxRemoveInput *NONNULL_PTR arg) {
40592         LDKTxRemoveInput ret_var = TxRemoveInput_clone(arg);
40593         int64_t ret_ref = 0;
40594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40596         return ret_ref;
40597 }
40598 int64_t  CS_LDK_TxRemoveInput_clone_ptr(int64_t arg) {
40599         LDKTxRemoveInput arg_conv;
40600         arg_conv.inner = untag_ptr(arg);
40601         arg_conv.is_owned = ptr_is_owned(arg);
40602         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40603         arg_conv.is_owned = false;
40604         int64_t ret_conv = TxRemoveInput_clone_ptr(&arg_conv);
40605         return ret_conv;
40606 }
40607
40608 int64_t  CS_LDK_TxRemoveInput_clone(int64_t orig) {
40609         LDKTxRemoveInput orig_conv;
40610         orig_conv.inner = untag_ptr(orig);
40611         orig_conv.is_owned = ptr_is_owned(orig);
40612         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40613         orig_conv.is_owned = false;
40614         LDKTxRemoveInput ret_var = TxRemoveInput_clone(&orig_conv);
40615         int64_t ret_ref = 0;
40616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40618         return ret_ref;
40619 }
40620
40621 jboolean  CS_LDK_TxRemoveInput_eq(int64_t a, int64_t b) {
40622         LDKTxRemoveInput a_conv;
40623         a_conv.inner = untag_ptr(a);
40624         a_conv.is_owned = ptr_is_owned(a);
40625         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40626         a_conv.is_owned = false;
40627         LDKTxRemoveInput b_conv;
40628         b_conv.inner = untag_ptr(b);
40629         b_conv.is_owned = ptr_is_owned(b);
40630         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40631         b_conv.is_owned = false;
40632         jboolean ret_conv = TxRemoveInput_eq(&a_conv, &b_conv);
40633         return ret_conv;
40634 }
40635
40636 void  CS_LDK_TxRemoveOutput_free(int64_t this_obj) {
40637         LDKTxRemoveOutput this_obj_conv;
40638         this_obj_conv.inner = untag_ptr(this_obj);
40639         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40641         TxRemoveOutput_free(this_obj_conv);
40642 }
40643
40644 int8_tArray  CS_LDK_TxRemoveOutput_get_channel_id(int64_t this_ptr) {
40645         LDKTxRemoveOutput this_ptr_conv;
40646         this_ptr_conv.inner = untag_ptr(this_ptr);
40647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40649         this_ptr_conv.is_owned = false;
40650         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40651         memcpy(ret_arr->elems, *TxRemoveOutput_get_channel_id(&this_ptr_conv), 32);
40652         return ret_arr;
40653 }
40654
40655 void  CS_LDK_TxRemoveOutput_set_channel_id(int64_t this_ptr, int8_tArray val) {
40656         LDKTxRemoveOutput this_ptr_conv;
40657         this_ptr_conv.inner = untag_ptr(this_ptr);
40658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40660         this_ptr_conv.is_owned = false;
40661         LDKThirtyTwoBytes val_ref;
40662         CHECK(val->arr_len == 32);
40663         memcpy(val_ref.data, val->elems, 32); FREE(val);
40664         TxRemoveOutput_set_channel_id(&this_ptr_conv, val_ref);
40665 }
40666
40667 int64_t  CS_LDK_TxRemoveOutput_get_serial_id(int64_t this_ptr) {
40668         LDKTxRemoveOutput this_ptr_conv;
40669         this_ptr_conv.inner = untag_ptr(this_ptr);
40670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40672         this_ptr_conv.is_owned = false;
40673         int64_t ret_conv = TxRemoveOutput_get_serial_id(&this_ptr_conv);
40674         return ret_conv;
40675 }
40676
40677 void  CS_LDK_TxRemoveOutput_set_serial_id(int64_t this_ptr, int64_t val) {
40678         LDKTxRemoveOutput this_ptr_conv;
40679         this_ptr_conv.inner = untag_ptr(this_ptr);
40680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40682         this_ptr_conv.is_owned = false;
40683         TxRemoveOutput_set_serial_id(&this_ptr_conv, val);
40684 }
40685
40686 int64_t  CS_LDK_TxRemoveOutput_new(int8_tArray channel_id_arg, int64_t serial_id_arg) {
40687         LDKThirtyTwoBytes channel_id_arg_ref;
40688         CHECK(channel_id_arg->arr_len == 32);
40689         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40690         LDKTxRemoveOutput ret_var = TxRemoveOutput_new(channel_id_arg_ref, serial_id_arg);
40691         int64_t ret_ref = 0;
40692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40694         return ret_ref;
40695 }
40696
40697 static inline uint64_t TxRemoveOutput_clone_ptr(LDKTxRemoveOutput *NONNULL_PTR arg) {
40698         LDKTxRemoveOutput ret_var = TxRemoveOutput_clone(arg);
40699         int64_t ret_ref = 0;
40700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40701         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40702         return ret_ref;
40703 }
40704 int64_t  CS_LDK_TxRemoveOutput_clone_ptr(int64_t arg) {
40705         LDKTxRemoveOutput arg_conv;
40706         arg_conv.inner = untag_ptr(arg);
40707         arg_conv.is_owned = ptr_is_owned(arg);
40708         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40709         arg_conv.is_owned = false;
40710         int64_t ret_conv = TxRemoveOutput_clone_ptr(&arg_conv);
40711         return ret_conv;
40712 }
40713
40714 int64_t  CS_LDK_TxRemoveOutput_clone(int64_t orig) {
40715         LDKTxRemoveOutput orig_conv;
40716         orig_conv.inner = untag_ptr(orig);
40717         orig_conv.is_owned = ptr_is_owned(orig);
40718         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40719         orig_conv.is_owned = false;
40720         LDKTxRemoveOutput ret_var = TxRemoveOutput_clone(&orig_conv);
40721         int64_t ret_ref = 0;
40722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40723         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40724         return ret_ref;
40725 }
40726
40727 jboolean  CS_LDK_TxRemoveOutput_eq(int64_t a, int64_t b) {
40728         LDKTxRemoveOutput a_conv;
40729         a_conv.inner = untag_ptr(a);
40730         a_conv.is_owned = ptr_is_owned(a);
40731         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40732         a_conv.is_owned = false;
40733         LDKTxRemoveOutput b_conv;
40734         b_conv.inner = untag_ptr(b);
40735         b_conv.is_owned = ptr_is_owned(b);
40736         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40737         b_conv.is_owned = false;
40738         jboolean ret_conv = TxRemoveOutput_eq(&a_conv, &b_conv);
40739         return ret_conv;
40740 }
40741
40742 void  CS_LDK_TxComplete_free(int64_t this_obj) {
40743         LDKTxComplete this_obj_conv;
40744         this_obj_conv.inner = untag_ptr(this_obj);
40745         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40747         TxComplete_free(this_obj_conv);
40748 }
40749
40750 int8_tArray  CS_LDK_TxComplete_get_channel_id(int64_t this_ptr) {
40751         LDKTxComplete this_ptr_conv;
40752         this_ptr_conv.inner = untag_ptr(this_ptr);
40753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40755         this_ptr_conv.is_owned = false;
40756         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40757         memcpy(ret_arr->elems, *TxComplete_get_channel_id(&this_ptr_conv), 32);
40758         return ret_arr;
40759 }
40760
40761 void  CS_LDK_TxComplete_set_channel_id(int64_t this_ptr, int8_tArray val) {
40762         LDKTxComplete this_ptr_conv;
40763         this_ptr_conv.inner = untag_ptr(this_ptr);
40764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40766         this_ptr_conv.is_owned = false;
40767         LDKThirtyTwoBytes val_ref;
40768         CHECK(val->arr_len == 32);
40769         memcpy(val_ref.data, val->elems, 32); FREE(val);
40770         TxComplete_set_channel_id(&this_ptr_conv, val_ref);
40771 }
40772
40773 int64_t  CS_LDK_TxComplete_new(int8_tArray channel_id_arg) {
40774         LDKThirtyTwoBytes channel_id_arg_ref;
40775         CHECK(channel_id_arg->arr_len == 32);
40776         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40777         LDKTxComplete ret_var = TxComplete_new(channel_id_arg_ref);
40778         int64_t ret_ref = 0;
40779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40780         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40781         return ret_ref;
40782 }
40783
40784 static inline uint64_t TxComplete_clone_ptr(LDKTxComplete *NONNULL_PTR arg) {
40785         LDKTxComplete ret_var = TxComplete_clone(arg);
40786         int64_t ret_ref = 0;
40787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40788         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40789         return ret_ref;
40790 }
40791 int64_t  CS_LDK_TxComplete_clone_ptr(int64_t arg) {
40792         LDKTxComplete arg_conv;
40793         arg_conv.inner = untag_ptr(arg);
40794         arg_conv.is_owned = ptr_is_owned(arg);
40795         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40796         arg_conv.is_owned = false;
40797         int64_t ret_conv = TxComplete_clone_ptr(&arg_conv);
40798         return ret_conv;
40799 }
40800
40801 int64_t  CS_LDK_TxComplete_clone(int64_t orig) {
40802         LDKTxComplete orig_conv;
40803         orig_conv.inner = untag_ptr(orig);
40804         orig_conv.is_owned = ptr_is_owned(orig);
40805         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40806         orig_conv.is_owned = false;
40807         LDKTxComplete ret_var = TxComplete_clone(&orig_conv);
40808         int64_t ret_ref = 0;
40809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40811         return ret_ref;
40812 }
40813
40814 jboolean  CS_LDK_TxComplete_eq(int64_t a, int64_t b) {
40815         LDKTxComplete a_conv;
40816         a_conv.inner = untag_ptr(a);
40817         a_conv.is_owned = ptr_is_owned(a);
40818         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40819         a_conv.is_owned = false;
40820         LDKTxComplete b_conv;
40821         b_conv.inner = untag_ptr(b);
40822         b_conv.is_owned = ptr_is_owned(b);
40823         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40824         b_conv.is_owned = false;
40825         jboolean ret_conv = TxComplete_eq(&a_conv, &b_conv);
40826         return ret_conv;
40827 }
40828
40829 void  CS_LDK_TxSignatures_free(int64_t this_obj) {
40830         LDKTxSignatures this_obj_conv;
40831         this_obj_conv.inner = untag_ptr(this_obj);
40832         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40834         TxSignatures_free(this_obj_conv);
40835 }
40836
40837 int8_tArray  CS_LDK_TxSignatures_get_channel_id(int64_t this_ptr) {
40838         LDKTxSignatures this_ptr_conv;
40839         this_ptr_conv.inner = untag_ptr(this_ptr);
40840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40842         this_ptr_conv.is_owned = false;
40843         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40844         memcpy(ret_arr->elems, *TxSignatures_get_channel_id(&this_ptr_conv), 32);
40845         return ret_arr;
40846 }
40847
40848 void  CS_LDK_TxSignatures_set_channel_id(int64_t this_ptr, int8_tArray val) {
40849         LDKTxSignatures this_ptr_conv;
40850         this_ptr_conv.inner = untag_ptr(this_ptr);
40851         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40853         this_ptr_conv.is_owned = false;
40854         LDKThirtyTwoBytes val_ref;
40855         CHECK(val->arr_len == 32);
40856         memcpy(val_ref.data, val->elems, 32); FREE(val);
40857         TxSignatures_set_channel_id(&this_ptr_conv, val_ref);
40858 }
40859
40860 int8_tArray  CS_LDK_TxSignatures_get_tx_hash(int64_t this_ptr) {
40861         LDKTxSignatures this_ptr_conv;
40862         this_ptr_conv.inner = untag_ptr(this_ptr);
40863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40865         this_ptr_conv.is_owned = false;
40866         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40867         memcpy(ret_arr->elems, *TxSignatures_get_tx_hash(&this_ptr_conv), 32);
40868         return ret_arr;
40869 }
40870
40871 void  CS_LDK_TxSignatures_set_tx_hash(int64_t this_ptr, int8_tArray val) {
40872         LDKTxSignatures this_ptr_conv;
40873         this_ptr_conv.inner = untag_ptr(this_ptr);
40874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40876         this_ptr_conv.is_owned = false;
40877         LDKThirtyTwoBytes val_ref;
40878         CHECK(val->arr_len == 32);
40879         memcpy(val_ref.data, val->elems, 32); FREE(val);
40880         TxSignatures_set_tx_hash(&this_ptr_conv, val_ref);
40881 }
40882
40883 ptrArray  CS_LDK_TxSignatures_get_witnesses(int64_t this_ptr) {
40884         LDKTxSignatures this_ptr_conv;
40885         this_ptr_conv.inner = untag_ptr(this_ptr);
40886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40888         this_ptr_conv.is_owned = false;
40889         LDKCVec_WitnessZ ret_var = TxSignatures_get_witnesses(&this_ptr_conv);
40890         ptrArray ret_arr = NULL;
40891         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
40892         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
40893         for (size_t i = 0; i < ret_var.datalen; i++) {
40894                 LDKWitness ret_conv_8_var = ret_var.data[i];
40895                 int8_tArray ret_conv_8_arr = init_int8_tArray(ret_conv_8_var.datalen, __LINE__);
40896                 memcpy(ret_conv_8_arr->elems, ret_conv_8_var.data, ret_conv_8_var.datalen);
40897                 Witness_free(ret_conv_8_var);
40898                 ret_arr_ptr[i] = ret_conv_8_arr;
40899         }
40900         
40901         FREE(ret_var.data);
40902         return ret_arr;
40903 }
40904
40905 void  CS_LDK_TxSignatures_set_witnesses(int64_t this_ptr, ptrArray val) {
40906         LDKTxSignatures this_ptr_conv;
40907         this_ptr_conv.inner = untag_ptr(this_ptr);
40908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40910         this_ptr_conv.is_owned = false;
40911         LDKCVec_WitnessZ val_constr;
40912         val_constr.datalen = val->arr_len;
40913         if (val_constr.datalen > 0)
40914                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKWitness), "LDKCVec_WitnessZ Elements");
40915         else
40916                 val_constr.data = NULL;
40917         int8_tArray* val_vals = (void*) val->elems;
40918         for (size_t i = 0; i < val_constr.datalen; i++) {
40919                 int8_tArray val_conv_8 = val_vals[i];
40920                 LDKWitness val_conv_8_ref;
40921                 val_conv_8_ref.datalen = val_conv_8->arr_len;
40922                 val_conv_8_ref.data = MALLOC(val_conv_8_ref.datalen, "LDKWitness Bytes");
40923                 memcpy(val_conv_8_ref.data, val_conv_8->elems, val_conv_8_ref.datalen); FREE(val_conv_8);
40924                 val_conv_8_ref.data_is_owned = true;
40925                 val_constr.data[i] = val_conv_8_ref;
40926         }
40927         FREE(val);
40928         TxSignatures_set_witnesses(&this_ptr_conv, val_constr);
40929 }
40930
40931 int64_t  CS_LDK_TxSignatures_new(int8_tArray channel_id_arg, int8_tArray tx_hash_arg, ptrArray witnesses_arg) {
40932         LDKThirtyTwoBytes channel_id_arg_ref;
40933         CHECK(channel_id_arg->arr_len == 32);
40934         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40935         LDKThirtyTwoBytes tx_hash_arg_ref;
40936         CHECK(tx_hash_arg->arr_len == 32);
40937         memcpy(tx_hash_arg_ref.data, tx_hash_arg->elems, 32); FREE(tx_hash_arg);
40938         LDKCVec_WitnessZ witnesses_arg_constr;
40939         witnesses_arg_constr.datalen = witnesses_arg->arr_len;
40940         if (witnesses_arg_constr.datalen > 0)
40941                 witnesses_arg_constr.data = MALLOC(witnesses_arg_constr.datalen * sizeof(LDKWitness), "LDKCVec_WitnessZ Elements");
40942         else
40943                 witnesses_arg_constr.data = NULL;
40944         int8_tArray* witnesses_arg_vals = (void*) witnesses_arg->elems;
40945         for (size_t i = 0; i < witnesses_arg_constr.datalen; i++) {
40946                 int8_tArray witnesses_arg_conv_8 = witnesses_arg_vals[i];
40947                 LDKWitness witnesses_arg_conv_8_ref;
40948                 witnesses_arg_conv_8_ref.datalen = witnesses_arg_conv_8->arr_len;
40949                 witnesses_arg_conv_8_ref.data = MALLOC(witnesses_arg_conv_8_ref.datalen, "LDKWitness Bytes");
40950                 memcpy(witnesses_arg_conv_8_ref.data, witnesses_arg_conv_8->elems, witnesses_arg_conv_8_ref.datalen); FREE(witnesses_arg_conv_8);
40951                 witnesses_arg_conv_8_ref.data_is_owned = true;
40952                 witnesses_arg_constr.data[i] = witnesses_arg_conv_8_ref;
40953         }
40954         FREE(witnesses_arg);
40955         LDKTxSignatures ret_var = TxSignatures_new(channel_id_arg_ref, tx_hash_arg_ref, witnesses_arg_constr);
40956         int64_t ret_ref = 0;
40957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40959         return ret_ref;
40960 }
40961
40962 static inline uint64_t TxSignatures_clone_ptr(LDKTxSignatures *NONNULL_PTR arg) {
40963         LDKTxSignatures ret_var = TxSignatures_clone(arg);
40964         int64_t ret_ref = 0;
40965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40967         return ret_ref;
40968 }
40969 int64_t  CS_LDK_TxSignatures_clone_ptr(int64_t arg) {
40970         LDKTxSignatures arg_conv;
40971         arg_conv.inner = untag_ptr(arg);
40972         arg_conv.is_owned = ptr_is_owned(arg);
40973         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40974         arg_conv.is_owned = false;
40975         int64_t ret_conv = TxSignatures_clone_ptr(&arg_conv);
40976         return ret_conv;
40977 }
40978
40979 int64_t  CS_LDK_TxSignatures_clone(int64_t orig) {
40980         LDKTxSignatures orig_conv;
40981         orig_conv.inner = untag_ptr(orig);
40982         orig_conv.is_owned = ptr_is_owned(orig);
40983         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40984         orig_conv.is_owned = false;
40985         LDKTxSignatures ret_var = TxSignatures_clone(&orig_conv);
40986         int64_t ret_ref = 0;
40987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40989         return ret_ref;
40990 }
40991
40992 jboolean  CS_LDK_TxSignatures_eq(int64_t a, int64_t b) {
40993         LDKTxSignatures a_conv;
40994         a_conv.inner = untag_ptr(a);
40995         a_conv.is_owned = ptr_is_owned(a);
40996         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40997         a_conv.is_owned = false;
40998         LDKTxSignatures b_conv;
40999         b_conv.inner = untag_ptr(b);
41000         b_conv.is_owned = ptr_is_owned(b);
41001         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41002         b_conv.is_owned = false;
41003         jboolean ret_conv = TxSignatures_eq(&a_conv, &b_conv);
41004         return ret_conv;
41005 }
41006
41007 void  CS_LDK_TxInitRbf_free(int64_t this_obj) {
41008         LDKTxInitRbf this_obj_conv;
41009         this_obj_conv.inner = untag_ptr(this_obj);
41010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41012         TxInitRbf_free(this_obj_conv);
41013 }
41014
41015 int8_tArray  CS_LDK_TxInitRbf_get_channel_id(int64_t this_ptr) {
41016         LDKTxInitRbf this_ptr_conv;
41017         this_ptr_conv.inner = untag_ptr(this_ptr);
41018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41020         this_ptr_conv.is_owned = false;
41021         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41022         memcpy(ret_arr->elems, *TxInitRbf_get_channel_id(&this_ptr_conv), 32);
41023         return ret_arr;
41024 }
41025
41026 void  CS_LDK_TxInitRbf_set_channel_id(int64_t this_ptr, int8_tArray val) {
41027         LDKTxInitRbf this_ptr_conv;
41028         this_ptr_conv.inner = untag_ptr(this_ptr);
41029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41031         this_ptr_conv.is_owned = false;
41032         LDKThirtyTwoBytes val_ref;
41033         CHECK(val->arr_len == 32);
41034         memcpy(val_ref.data, val->elems, 32); FREE(val);
41035         TxInitRbf_set_channel_id(&this_ptr_conv, val_ref);
41036 }
41037
41038 int32_t  CS_LDK_TxInitRbf_get_locktime(int64_t this_ptr) {
41039         LDKTxInitRbf this_ptr_conv;
41040         this_ptr_conv.inner = untag_ptr(this_ptr);
41041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41043         this_ptr_conv.is_owned = false;
41044         int32_t ret_conv = TxInitRbf_get_locktime(&this_ptr_conv);
41045         return ret_conv;
41046 }
41047
41048 void  CS_LDK_TxInitRbf_set_locktime(int64_t this_ptr, int32_t val) {
41049         LDKTxInitRbf this_ptr_conv;
41050         this_ptr_conv.inner = untag_ptr(this_ptr);
41051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41053         this_ptr_conv.is_owned = false;
41054         TxInitRbf_set_locktime(&this_ptr_conv, val);
41055 }
41056
41057 int32_t  CS_LDK_TxInitRbf_get_feerate_sat_per_1000_weight(int64_t this_ptr) {
41058         LDKTxInitRbf this_ptr_conv;
41059         this_ptr_conv.inner = untag_ptr(this_ptr);
41060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41062         this_ptr_conv.is_owned = false;
41063         int32_t ret_conv = TxInitRbf_get_feerate_sat_per_1000_weight(&this_ptr_conv);
41064         return ret_conv;
41065 }
41066
41067 void  CS_LDK_TxInitRbf_set_feerate_sat_per_1000_weight(int64_t this_ptr, int32_t val) {
41068         LDKTxInitRbf this_ptr_conv;
41069         this_ptr_conv.inner = untag_ptr(this_ptr);
41070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41072         this_ptr_conv.is_owned = false;
41073         TxInitRbf_set_feerate_sat_per_1000_weight(&this_ptr_conv, val);
41074 }
41075
41076 int64_t  CS_LDK_TxInitRbf_get_funding_output_contribution(int64_t this_ptr) {
41077         LDKTxInitRbf this_ptr_conv;
41078         this_ptr_conv.inner = untag_ptr(this_ptr);
41079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41081         this_ptr_conv.is_owned = false;
41082         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
41083         *ret_copy = TxInitRbf_get_funding_output_contribution(&this_ptr_conv);
41084         int64_t ret_ref = tag_ptr(ret_copy, true);
41085         return ret_ref;
41086 }
41087
41088 void  CS_LDK_TxInitRbf_set_funding_output_contribution(int64_t this_ptr, int64_t val) {
41089         LDKTxInitRbf this_ptr_conv;
41090         this_ptr_conv.inner = untag_ptr(this_ptr);
41091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41093         this_ptr_conv.is_owned = false;
41094         void* val_ptr = untag_ptr(val);
41095         CHECK_ACCESS(val_ptr);
41096         LDKCOption_i64Z val_conv = *(LDKCOption_i64Z*)(val_ptr);
41097         val_conv = COption_i64Z_clone((LDKCOption_i64Z*)untag_ptr(val));
41098         TxInitRbf_set_funding_output_contribution(&this_ptr_conv, val_conv);
41099 }
41100
41101 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) {
41102         LDKThirtyTwoBytes channel_id_arg_ref;
41103         CHECK(channel_id_arg->arr_len == 32);
41104         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41105         void* funding_output_contribution_arg_ptr = untag_ptr(funding_output_contribution_arg);
41106         CHECK_ACCESS(funding_output_contribution_arg_ptr);
41107         LDKCOption_i64Z funding_output_contribution_arg_conv = *(LDKCOption_i64Z*)(funding_output_contribution_arg_ptr);
41108         funding_output_contribution_arg_conv = COption_i64Z_clone((LDKCOption_i64Z*)untag_ptr(funding_output_contribution_arg));
41109         LDKTxInitRbf ret_var = TxInitRbf_new(channel_id_arg_ref, locktime_arg, feerate_sat_per_1000_weight_arg, funding_output_contribution_arg_conv);
41110         int64_t ret_ref = 0;
41111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41113         return ret_ref;
41114 }
41115
41116 static inline uint64_t TxInitRbf_clone_ptr(LDKTxInitRbf *NONNULL_PTR arg) {
41117         LDKTxInitRbf ret_var = TxInitRbf_clone(arg);
41118         int64_t ret_ref = 0;
41119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41120         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41121         return ret_ref;
41122 }
41123 int64_t  CS_LDK_TxInitRbf_clone_ptr(int64_t arg) {
41124         LDKTxInitRbf arg_conv;
41125         arg_conv.inner = untag_ptr(arg);
41126         arg_conv.is_owned = ptr_is_owned(arg);
41127         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41128         arg_conv.is_owned = false;
41129         int64_t ret_conv = TxInitRbf_clone_ptr(&arg_conv);
41130         return ret_conv;
41131 }
41132
41133 int64_t  CS_LDK_TxInitRbf_clone(int64_t orig) {
41134         LDKTxInitRbf orig_conv;
41135         orig_conv.inner = untag_ptr(orig);
41136         orig_conv.is_owned = ptr_is_owned(orig);
41137         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41138         orig_conv.is_owned = false;
41139         LDKTxInitRbf ret_var = TxInitRbf_clone(&orig_conv);
41140         int64_t ret_ref = 0;
41141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41142         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41143         return ret_ref;
41144 }
41145
41146 jboolean  CS_LDK_TxInitRbf_eq(int64_t a, int64_t b) {
41147         LDKTxInitRbf a_conv;
41148         a_conv.inner = untag_ptr(a);
41149         a_conv.is_owned = ptr_is_owned(a);
41150         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41151         a_conv.is_owned = false;
41152         LDKTxInitRbf b_conv;
41153         b_conv.inner = untag_ptr(b);
41154         b_conv.is_owned = ptr_is_owned(b);
41155         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41156         b_conv.is_owned = false;
41157         jboolean ret_conv = TxInitRbf_eq(&a_conv, &b_conv);
41158         return ret_conv;
41159 }
41160
41161 void  CS_LDK_TxAckRbf_free(int64_t this_obj) {
41162         LDKTxAckRbf this_obj_conv;
41163         this_obj_conv.inner = untag_ptr(this_obj);
41164         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41166         TxAckRbf_free(this_obj_conv);
41167 }
41168
41169 int8_tArray  CS_LDK_TxAckRbf_get_channel_id(int64_t this_ptr) {
41170         LDKTxAckRbf this_ptr_conv;
41171         this_ptr_conv.inner = untag_ptr(this_ptr);
41172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41174         this_ptr_conv.is_owned = false;
41175         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41176         memcpy(ret_arr->elems, *TxAckRbf_get_channel_id(&this_ptr_conv), 32);
41177         return ret_arr;
41178 }
41179
41180 void  CS_LDK_TxAckRbf_set_channel_id(int64_t this_ptr, int8_tArray val) {
41181         LDKTxAckRbf this_ptr_conv;
41182         this_ptr_conv.inner = untag_ptr(this_ptr);
41183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41185         this_ptr_conv.is_owned = false;
41186         LDKThirtyTwoBytes val_ref;
41187         CHECK(val->arr_len == 32);
41188         memcpy(val_ref.data, val->elems, 32); FREE(val);
41189         TxAckRbf_set_channel_id(&this_ptr_conv, val_ref);
41190 }
41191
41192 int64_t  CS_LDK_TxAckRbf_get_funding_output_contribution(int64_t this_ptr) {
41193         LDKTxAckRbf this_ptr_conv;
41194         this_ptr_conv.inner = untag_ptr(this_ptr);
41195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41197         this_ptr_conv.is_owned = false;
41198         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
41199         *ret_copy = TxAckRbf_get_funding_output_contribution(&this_ptr_conv);
41200         int64_t ret_ref = tag_ptr(ret_copy, true);
41201         return ret_ref;
41202 }
41203
41204 void  CS_LDK_TxAckRbf_set_funding_output_contribution(int64_t this_ptr, int64_t val) {
41205         LDKTxAckRbf this_ptr_conv;
41206         this_ptr_conv.inner = untag_ptr(this_ptr);
41207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41209         this_ptr_conv.is_owned = false;
41210         void* val_ptr = untag_ptr(val);
41211         CHECK_ACCESS(val_ptr);
41212         LDKCOption_i64Z val_conv = *(LDKCOption_i64Z*)(val_ptr);
41213         val_conv = COption_i64Z_clone((LDKCOption_i64Z*)untag_ptr(val));
41214         TxAckRbf_set_funding_output_contribution(&this_ptr_conv, val_conv);
41215 }
41216
41217 int64_t  CS_LDK_TxAckRbf_new(int8_tArray channel_id_arg, int64_t funding_output_contribution_arg) {
41218         LDKThirtyTwoBytes channel_id_arg_ref;
41219         CHECK(channel_id_arg->arr_len == 32);
41220         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41221         void* funding_output_contribution_arg_ptr = untag_ptr(funding_output_contribution_arg);
41222         CHECK_ACCESS(funding_output_contribution_arg_ptr);
41223         LDKCOption_i64Z funding_output_contribution_arg_conv = *(LDKCOption_i64Z*)(funding_output_contribution_arg_ptr);
41224         funding_output_contribution_arg_conv = COption_i64Z_clone((LDKCOption_i64Z*)untag_ptr(funding_output_contribution_arg));
41225         LDKTxAckRbf ret_var = TxAckRbf_new(channel_id_arg_ref, funding_output_contribution_arg_conv);
41226         int64_t ret_ref = 0;
41227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41229         return ret_ref;
41230 }
41231
41232 static inline uint64_t TxAckRbf_clone_ptr(LDKTxAckRbf *NONNULL_PTR arg) {
41233         LDKTxAckRbf ret_var = TxAckRbf_clone(arg);
41234         int64_t ret_ref = 0;
41235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41237         return ret_ref;
41238 }
41239 int64_t  CS_LDK_TxAckRbf_clone_ptr(int64_t arg) {
41240         LDKTxAckRbf arg_conv;
41241         arg_conv.inner = untag_ptr(arg);
41242         arg_conv.is_owned = ptr_is_owned(arg);
41243         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41244         arg_conv.is_owned = false;
41245         int64_t ret_conv = TxAckRbf_clone_ptr(&arg_conv);
41246         return ret_conv;
41247 }
41248
41249 int64_t  CS_LDK_TxAckRbf_clone(int64_t orig) {
41250         LDKTxAckRbf orig_conv;
41251         orig_conv.inner = untag_ptr(orig);
41252         orig_conv.is_owned = ptr_is_owned(orig);
41253         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41254         orig_conv.is_owned = false;
41255         LDKTxAckRbf ret_var = TxAckRbf_clone(&orig_conv);
41256         int64_t ret_ref = 0;
41257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41259         return ret_ref;
41260 }
41261
41262 jboolean  CS_LDK_TxAckRbf_eq(int64_t a, int64_t b) {
41263         LDKTxAckRbf a_conv;
41264         a_conv.inner = untag_ptr(a);
41265         a_conv.is_owned = ptr_is_owned(a);
41266         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41267         a_conv.is_owned = false;
41268         LDKTxAckRbf b_conv;
41269         b_conv.inner = untag_ptr(b);
41270         b_conv.is_owned = ptr_is_owned(b);
41271         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41272         b_conv.is_owned = false;
41273         jboolean ret_conv = TxAckRbf_eq(&a_conv, &b_conv);
41274         return ret_conv;
41275 }
41276
41277 void  CS_LDK_TxAbort_free(int64_t this_obj) {
41278         LDKTxAbort this_obj_conv;
41279         this_obj_conv.inner = untag_ptr(this_obj);
41280         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41282         TxAbort_free(this_obj_conv);
41283 }
41284
41285 int8_tArray  CS_LDK_TxAbort_get_channel_id(int64_t this_ptr) {
41286         LDKTxAbort this_ptr_conv;
41287         this_ptr_conv.inner = untag_ptr(this_ptr);
41288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41290         this_ptr_conv.is_owned = false;
41291         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41292         memcpy(ret_arr->elems, *TxAbort_get_channel_id(&this_ptr_conv), 32);
41293         return ret_arr;
41294 }
41295
41296 void  CS_LDK_TxAbort_set_channel_id(int64_t this_ptr, int8_tArray val) {
41297         LDKTxAbort this_ptr_conv;
41298         this_ptr_conv.inner = untag_ptr(this_ptr);
41299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41301         this_ptr_conv.is_owned = false;
41302         LDKThirtyTwoBytes val_ref;
41303         CHECK(val->arr_len == 32);
41304         memcpy(val_ref.data, val->elems, 32); FREE(val);
41305         TxAbort_set_channel_id(&this_ptr_conv, val_ref);
41306 }
41307
41308 int8_tArray  CS_LDK_TxAbort_get_data(int64_t this_ptr) {
41309         LDKTxAbort this_ptr_conv;
41310         this_ptr_conv.inner = untag_ptr(this_ptr);
41311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41313         this_ptr_conv.is_owned = false;
41314         LDKCVec_u8Z ret_var = TxAbort_get_data(&this_ptr_conv);
41315         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41316         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41317         CVec_u8Z_free(ret_var);
41318         return ret_arr;
41319 }
41320
41321 void  CS_LDK_TxAbort_set_data(int64_t this_ptr, int8_tArray val) {
41322         LDKTxAbort this_ptr_conv;
41323         this_ptr_conv.inner = untag_ptr(this_ptr);
41324         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41326         this_ptr_conv.is_owned = false;
41327         LDKCVec_u8Z val_ref;
41328         val_ref.datalen = val->arr_len;
41329         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
41330         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
41331         TxAbort_set_data(&this_ptr_conv, val_ref);
41332 }
41333
41334 int64_t  CS_LDK_TxAbort_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
41335         LDKThirtyTwoBytes channel_id_arg_ref;
41336         CHECK(channel_id_arg->arr_len == 32);
41337         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41338         LDKCVec_u8Z data_arg_ref;
41339         data_arg_ref.datalen = data_arg->arr_len;
41340         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
41341         memcpy(data_arg_ref.data, data_arg->elems, data_arg_ref.datalen); FREE(data_arg);
41342         LDKTxAbort ret_var = TxAbort_new(channel_id_arg_ref, data_arg_ref);
41343         int64_t ret_ref = 0;
41344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41346         return ret_ref;
41347 }
41348
41349 static inline uint64_t TxAbort_clone_ptr(LDKTxAbort *NONNULL_PTR arg) {
41350         LDKTxAbort ret_var = TxAbort_clone(arg);
41351         int64_t ret_ref = 0;
41352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41353         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41354         return ret_ref;
41355 }
41356 int64_t  CS_LDK_TxAbort_clone_ptr(int64_t arg) {
41357         LDKTxAbort arg_conv;
41358         arg_conv.inner = untag_ptr(arg);
41359         arg_conv.is_owned = ptr_is_owned(arg);
41360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41361         arg_conv.is_owned = false;
41362         int64_t ret_conv = TxAbort_clone_ptr(&arg_conv);
41363         return ret_conv;
41364 }
41365
41366 int64_t  CS_LDK_TxAbort_clone(int64_t orig) {
41367         LDKTxAbort orig_conv;
41368         orig_conv.inner = untag_ptr(orig);
41369         orig_conv.is_owned = ptr_is_owned(orig);
41370         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41371         orig_conv.is_owned = false;
41372         LDKTxAbort ret_var = TxAbort_clone(&orig_conv);
41373         int64_t ret_ref = 0;
41374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41375         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41376         return ret_ref;
41377 }
41378
41379 jboolean  CS_LDK_TxAbort_eq(int64_t a, int64_t b) {
41380         LDKTxAbort a_conv;
41381         a_conv.inner = untag_ptr(a);
41382         a_conv.is_owned = ptr_is_owned(a);
41383         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41384         a_conv.is_owned = false;
41385         LDKTxAbort b_conv;
41386         b_conv.inner = untag_ptr(b);
41387         b_conv.is_owned = ptr_is_owned(b);
41388         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41389         b_conv.is_owned = false;
41390         jboolean ret_conv = TxAbort_eq(&a_conv, &b_conv);
41391         return ret_conv;
41392 }
41393
41394 void  CS_LDK_Shutdown_free(int64_t this_obj) {
41395         LDKShutdown this_obj_conv;
41396         this_obj_conv.inner = untag_ptr(this_obj);
41397         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41399         Shutdown_free(this_obj_conv);
41400 }
41401
41402 int8_tArray  CS_LDK_Shutdown_get_channel_id(int64_t this_ptr) {
41403         LDKShutdown this_ptr_conv;
41404         this_ptr_conv.inner = untag_ptr(this_ptr);
41405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41407         this_ptr_conv.is_owned = false;
41408         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41409         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
41410         return ret_arr;
41411 }
41412
41413 void  CS_LDK_Shutdown_set_channel_id(int64_t this_ptr, int8_tArray val) {
41414         LDKShutdown this_ptr_conv;
41415         this_ptr_conv.inner = untag_ptr(this_ptr);
41416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41418         this_ptr_conv.is_owned = false;
41419         LDKThirtyTwoBytes val_ref;
41420         CHECK(val->arr_len == 32);
41421         memcpy(val_ref.data, val->elems, 32); FREE(val);
41422         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
41423 }
41424
41425 int8_tArray  CS_LDK_Shutdown_get_scriptpubkey(int64_t this_ptr) {
41426         LDKShutdown this_ptr_conv;
41427         this_ptr_conv.inner = untag_ptr(this_ptr);
41428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41430         this_ptr_conv.is_owned = false;
41431         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
41432         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41433         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41434         return ret_arr;
41435 }
41436
41437 void  CS_LDK_Shutdown_set_scriptpubkey(int64_t this_ptr, int8_tArray val) {
41438         LDKShutdown this_ptr_conv;
41439         this_ptr_conv.inner = untag_ptr(this_ptr);
41440         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41442         this_ptr_conv.is_owned = false;
41443         LDKCVec_u8Z val_ref;
41444         val_ref.datalen = val->arr_len;
41445         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
41446         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
41447         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
41448 }
41449
41450 int64_t  CS_LDK_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
41451         LDKThirtyTwoBytes channel_id_arg_ref;
41452         CHECK(channel_id_arg->arr_len == 32);
41453         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41454         LDKCVec_u8Z scriptpubkey_arg_ref;
41455         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
41456         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
41457         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
41458         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
41459         int64_t ret_ref = 0;
41460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41462         return ret_ref;
41463 }
41464
41465 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
41466         LDKShutdown ret_var = Shutdown_clone(arg);
41467         int64_t ret_ref = 0;
41468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41470         return ret_ref;
41471 }
41472 int64_t  CS_LDK_Shutdown_clone_ptr(int64_t arg) {
41473         LDKShutdown arg_conv;
41474         arg_conv.inner = untag_ptr(arg);
41475         arg_conv.is_owned = ptr_is_owned(arg);
41476         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41477         arg_conv.is_owned = false;
41478         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
41479         return ret_conv;
41480 }
41481
41482 int64_t  CS_LDK_Shutdown_clone(int64_t orig) {
41483         LDKShutdown orig_conv;
41484         orig_conv.inner = untag_ptr(orig);
41485         orig_conv.is_owned = ptr_is_owned(orig);
41486         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41487         orig_conv.is_owned = false;
41488         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
41489         int64_t ret_ref = 0;
41490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41492         return ret_ref;
41493 }
41494
41495 jboolean  CS_LDK_Shutdown_eq(int64_t a, int64_t b) {
41496         LDKShutdown a_conv;
41497         a_conv.inner = untag_ptr(a);
41498         a_conv.is_owned = ptr_is_owned(a);
41499         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41500         a_conv.is_owned = false;
41501         LDKShutdown b_conv;
41502         b_conv.inner = untag_ptr(b);
41503         b_conv.is_owned = ptr_is_owned(b);
41504         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41505         b_conv.is_owned = false;
41506         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
41507         return ret_conv;
41508 }
41509
41510 void  CS_LDK_ClosingSignedFeeRange_free(int64_t this_obj) {
41511         LDKClosingSignedFeeRange this_obj_conv;
41512         this_obj_conv.inner = untag_ptr(this_obj);
41513         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41515         ClosingSignedFeeRange_free(this_obj_conv);
41516 }
41517
41518 int64_t  CS_LDK_ClosingSignedFeeRange_get_min_fee_satoshis(int64_t this_ptr) {
41519         LDKClosingSignedFeeRange this_ptr_conv;
41520         this_ptr_conv.inner = untag_ptr(this_ptr);
41521         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41523         this_ptr_conv.is_owned = false;
41524         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
41525         return ret_conv;
41526 }
41527
41528 void  CS_LDK_ClosingSignedFeeRange_set_min_fee_satoshis(int64_t this_ptr, int64_t val) {
41529         LDKClosingSignedFeeRange this_ptr_conv;
41530         this_ptr_conv.inner = untag_ptr(this_ptr);
41531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41533         this_ptr_conv.is_owned = false;
41534         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
41535 }
41536
41537 int64_t  CS_LDK_ClosingSignedFeeRange_get_max_fee_satoshis(int64_t this_ptr) {
41538         LDKClosingSignedFeeRange this_ptr_conv;
41539         this_ptr_conv.inner = untag_ptr(this_ptr);
41540         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41542         this_ptr_conv.is_owned = false;
41543         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
41544         return ret_conv;
41545 }
41546
41547 void  CS_LDK_ClosingSignedFeeRange_set_max_fee_satoshis(int64_t this_ptr, int64_t val) {
41548         LDKClosingSignedFeeRange this_ptr_conv;
41549         this_ptr_conv.inner = untag_ptr(this_ptr);
41550         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41552         this_ptr_conv.is_owned = false;
41553         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
41554 }
41555
41556 int64_t  CS_LDK_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
41557         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
41558         int64_t ret_ref = 0;
41559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41561         return ret_ref;
41562 }
41563
41564 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
41565         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
41566         int64_t ret_ref = 0;
41567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41568         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41569         return ret_ref;
41570 }
41571 int64_t  CS_LDK_ClosingSignedFeeRange_clone_ptr(int64_t arg) {
41572         LDKClosingSignedFeeRange arg_conv;
41573         arg_conv.inner = untag_ptr(arg);
41574         arg_conv.is_owned = ptr_is_owned(arg);
41575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41576         arg_conv.is_owned = false;
41577         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
41578         return ret_conv;
41579 }
41580
41581 int64_t  CS_LDK_ClosingSignedFeeRange_clone(int64_t orig) {
41582         LDKClosingSignedFeeRange orig_conv;
41583         orig_conv.inner = untag_ptr(orig);
41584         orig_conv.is_owned = ptr_is_owned(orig);
41585         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41586         orig_conv.is_owned = false;
41587         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
41588         int64_t ret_ref = 0;
41589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41591         return ret_ref;
41592 }
41593
41594 jboolean  CS_LDK_ClosingSignedFeeRange_eq(int64_t a, int64_t b) {
41595         LDKClosingSignedFeeRange a_conv;
41596         a_conv.inner = untag_ptr(a);
41597         a_conv.is_owned = ptr_is_owned(a);
41598         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41599         a_conv.is_owned = false;
41600         LDKClosingSignedFeeRange b_conv;
41601         b_conv.inner = untag_ptr(b);
41602         b_conv.is_owned = ptr_is_owned(b);
41603         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41604         b_conv.is_owned = false;
41605         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
41606         return ret_conv;
41607 }
41608
41609 void  CS_LDK_ClosingSigned_free(int64_t this_obj) {
41610         LDKClosingSigned this_obj_conv;
41611         this_obj_conv.inner = untag_ptr(this_obj);
41612         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41614         ClosingSigned_free(this_obj_conv);
41615 }
41616
41617 int8_tArray  CS_LDK_ClosingSigned_get_channel_id(int64_t this_ptr) {
41618         LDKClosingSigned this_ptr_conv;
41619         this_ptr_conv.inner = untag_ptr(this_ptr);
41620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41622         this_ptr_conv.is_owned = false;
41623         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41624         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
41625         return ret_arr;
41626 }
41627
41628 void  CS_LDK_ClosingSigned_set_channel_id(int64_t this_ptr, int8_tArray val) {
41629         LDKClosingSigned this_ptr_conv;
41630         this_ptr_conv.inner = untag_ptr(this_ptr);
41631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41633         this_ptr_conv.is_owned = false;
41634         LDKThirtyTwoBytes val_ref;
41635         CHECK(val->arr_len == 32);
41636         memcpy(val_ref.data, val->elems, 32); FREE(val);
41637         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
41638 }
41639
41640 int64_t  CS_LDK_ClosingSigned_get_fee_satoshis(int64_t this_ptr) {
41641         LDKClosingSigned this_ptr_conv;
41642         this_ptr_conv.inner = untag_ptr(this_ptr);
41643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41645         this_ptr_conv.is_owned = false;
41646         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
41647         return ret_conv;
41648 }
41649
41650 void  CS_LDK_ClosingSigned_set_fee_satoshis(int64_t this_ptr, int64_t val) {
41651         LDKClosingSigned this_ptr_conv;
41652         this_ptr_conv.inner = untag_ptr(this_ptr);
41653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41655         this_ptr_conv.is_owned = false;
41656         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
41657 }
41658
41659 int8_tArray  CS_LDK_ClosingSigned_get_signature(int64_t this_ptr) {
41660         LDKClosingSigned this_ptr_conv;
41661         this_ptr_conv.inner = untag_ptr(this_ptr);
41662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41664         this_ptr_conv.is_owned = false;
41665         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
41666         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
41667         return ret_arr;
41668 }
41669
41670 void  CS_LDK_ClosingSigned_set_signature(int64_t this_ptr, int8_tArray val) {
41671         LDKClosingSigned this_ptr_conv;
41672         this_ptr_conv.inner = untag_ptr(this_ptr);
41673         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41675         this_ptr_conv.is_owned = false;
41676         LDKECDSASignature val_ref;
41677         CHECK(val->arr_len == 64);
41678         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
41679         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
41680 }
41681
41682 int64_t  CS_LDK_ClosingSigned_get_fee_range(int64_t this_ptr) {
41683         LDKClosingSigned this_ptr_conv;
41684         this_ptr_conv.inner = untag_ptr(this_ptr);
41685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41687         this_ptr_conv.is_owned = false;
41688         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
41689         int64_t ret_ref = 0;
41690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41692         return ret_ref;
41693 }
41694
41695 void  CS_LDK_ClosingSigned_set_fee_range(int64_t this_ptr, int64_t val) {
41696         LDKClosingSigned this_ptr_conv;
41697         this_ptr_conv.inner = untag_ptr(this_ptr);
41698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41700         this_ptr_conv.is_owned = false;
41701         LDKClosingSignedFeeRange val_conv;
41702         val_conv.inner = untag_ptr(val);
41703         val_conv.is_owned = ptr_is_owned(val);
41704         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41705         val_conv = ClosingSignedFeeRange_clone(&val_conv);
41706         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
41707 }
41708
41709 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) {
41710         LDKThirtyTwoBytes channel_id_arg_ref;
41711         CHECK(channel_id_arg->arr_len == 32);
41712         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41713         LDKECDSASignature signature_arg_ref;
41714         CHECK(signature_arg->arr_len == 64);
41715         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
41716         LDKClosingSignedFeeRange fee_range_arg_conv;
41717         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
41718         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
41719         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
41720         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
41721         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
41722         int64_t ret_ref = 0;
41723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41725         return ret_ref;
41726 }
41727
41728 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
41729         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
41730         int64_t ret_ref = 0;
41731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41733         return ret_ref;
41734 }
41735 int64_t  CS_LDK_ClosingSigned_clone_ptr(int64_t arg) {
41736         LDKClosingSigned arg_conv;
41737         arg_conv.inner = untag_ptr(arg);
41738         arg_conv.is_owned = ptr_is_owned(arg);
41739         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41740         arg_conv.is_owned = false;
41741         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
41742         return ret_conv;
41743 }
41744
41745 int64_t  CS_LDK_ClosingSigned_clone(int64_t orig) {
41746         LDKClosingSigned orig_conv;
41747         orig_conv.inner = untag_ptr(orig);
41748         orig_conv.is_owned = ptr_is_owned(orig);
41749         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41750         orig_conv.is_owned = false;
41751         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
41752         int64_t ret_ref = 0;
41753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41754         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41755         return ret_ref;
41756 }
41757
41758 jboolean  CS_LDK_ClosingSigned_eq(int64_t a, int64_t b) {
41759         LDKClosingSigned a_conv;
41760         a_conv.inner = untag_ptr(a);
41761         a_conv.is_owned = ptr_is_owned(a);
41762         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41763         a_conv.is_owned = false;
41764         LDKClosingSigned b_conv;
41765         b_conv.inner = untag_ptr(b);
41766         b_conv.is_owned = ptr_is_owned(b);
41767         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41768         b_conv.is_owned = false;
41769         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
41770         return ret_conv;
41771 }
41772
41773 void  CS_LDK_UpdateAddHTLC_free(int64_t this_obj) {
41774         LDKUpdateAddHTLC this_obj_conv;
41775         this_obj_conv.inner = untag_ptr(this_obj);
41776         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41778         UpdateAddHTLC_free(this_obj_conv);
41779 }
41780
41781 int8_tArray  CS_LDK_UpdateAddHTLC_get_channel_id(int64_t this_ptr) {
41782         LDKUpdateAddHTLC this_ptr_conv;
41783         this_ptr_conv.inner = untag_ptr(this_ptr);
41784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41786         this_ptr_conv.is_owned = false;
41787         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41788         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
41789         return ret_arr;
41790 }
41791
41792 void  CS_LDK_UpdateAddHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
41793         LDKUpdateAddHTLC this_ptr_conv;
41794         this_ptr_conv.inner = untag_ptr(this_ptr);
41795         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41797         this_ptr_conv.is_owned = false;
41798         LDKThirtyTwoBytes val_ref;
41799         CHECK(val->arr_len == 32);
41800         memcpy(val_ref.data, val->elems, 32); FREE(val);
41801         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
41802 }
41803
41804 int64_t  CS_LDK_UpdateAddHTLC_get_htlc_id(int64_t this_ptr) {
41805         LDKUpdateAddHTLC this_ptr_conv;
41806         this_ptr_conv.inner = untag_ptr(this_ptr);
41807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41809         this_ptr_conv.is_owned = false;
41810         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
41811         return ret_conv;
41812 }
41813
41814 void  CS_LDK_UpdateAddHTLC_set_htlc_id(int64_t this_ptr, int64_t val) {
41815         LDKUpdateAddHTLC this_ptr_conv;
41816         this_ptr_conv.inner = untag_ptr(this_ptr);
41817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41819         this_ptr_conv.is_owned = false;
41820         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
41821 }
41822
41823 int64_t  CS_LDK_UpdateAddHTLC_get_amount_msat(int64_t this_ptr) {
41824         LDKUpdateAddHTLC this_ptr_conv;
41825         this_ptr_conv.inner = untag_ptr(this_ptr);
41826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41828         this_ptr_conv.is_owned = false;
41829         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
41830         return ret_conv;
41831 }
41832
41833 void  CS_LDK_UpdateAddHTLC_set_amount_msat(int64_t this_ptr, int64_t val) {
41834         LDKUpdateAddHTLC this_ptr_conv;
41835         this_ptr_conv.inner = untag_ptr(this_ptr);
41836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41838         this_ptr_conv.is_owned = false;
41839         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
41840 }
41841
41842 int8_tArray  CS_LDK_UpdateAddHTLC_get_payment_hash(int64_t this_ptr) {
41843         LDKUpdateAddHTLC this_ptr_conv;
41844         this_ptr_conv.inner = untag_ptr(this_ptr);
41845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41847         this_ptr_conv.is_owned = false;
41848         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41849         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
41850         return ret_arr;
41851 }
41852
41853 void  CS_LDK_UpdateAddHTLC_set_payment_hash(int64_t this_ptr, int8_tArray val) {
41854         LDKUpdateAddHTLC this_ptr_conv;
41855         this_ptr_conv.inner = untag_ptr(this_ptr);
41856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41858         this_ptr_conv.is_owned = false;
41859         LDKThirtyTwoBytes val_ref;
41860         CHECK(val->arr_len == 32);
41861         memcpy(val_ref.data, val->elems, 32); FREE(val);
41862         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
41863 }
41864
41865 int32_t  CS_LDK_UpdateAddHTLC_get_cltv_expiry(int64_t this_ptr) {
41866         LDKUpdateAddHTLC this_ptr_conv;
41867         this_ptr_conv.inner = untag_ptr(this_ptr);
41868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41870         this_ptr_conv.is_owned = false;
41871         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
41872         return ret_conv;
41873 }
41874
41875 void  CS_LDK_UpdateAddHTLC_set_cltv_expiry(int64_t this_ptr, int32_t val) {
41876         LDKUpdateAddHTLC this_ptr_conv;
41877         this_ptr_conv.inner = untag_ptr(this_ptr);
41878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41880         this_ptr_conv.is_owned = false;
41881         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
41882 }
41883
41884 int64_t  CS_LDK_UpdateAddHTLC_get_skimmed_fee_msat(int64_t this_ptr) {
41885         LDKUpdateAddHTLC this_ptr_conv;
41886         this_ptr_conv.inner = untag_ptr(this_ptr);
41887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41889         this_ptr_conv.is_owned = false;
41890         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41891         *ret_copy = UpdateAddHTLC_get_skimmed_fee_msat(&this_ptr_conv);
41892         int64_t ret_ref = tag_ptr(ret_copy, true);
41893         return ret_ref;
41894 }
41895
41896 void  CS_LDK_UpdateAddHTLC_set_skimmed_fee_msat(int64_t this_ptr, int64_t val) {
41897         LDKUpdateAddHTLC this_ptr_conv;
41898         this_ptr_conv.inner = untag_ptr(this_ptr);
41899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41901         this_ptr_conv.is_owned = false;
41902         void* val_ptr = untag_ptr(val);
41903         CHECK_ACCESS(val_ptr);
41904         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41905         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
41906         UpdateAddHTLC_set_skimmed_fee_msat(&this_ptr_conv, val_conv);
41907 }
41908
41909 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
41910         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
41911         int64_t ret_ref = 0;
41912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41914         return ret_ref;
41915 }
41916 int64_t  CS_LDK_UpdateAddHTLC_clone_ptr(int64_t arg) {
41917         LDKUpdateAddHTLC arg_conv;
41918         arg_conv.inner = untag_ptr(arg);
41919         arg_conv.is_owned = ptr_is_owned(arg);
41920         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41921         arg_conv.is_owned = false;
41922         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
41923         return ret_conv;
41924 }
41925
41926 int64_t  CS_LDK_UpdateAddHTLC_clone(int64_t orig) {
41927         LDKUpdateAddHTLC orig_conv;
41928         orig_conv.inner = untag_ptr(orig);
41929         orig_conv.is_owned = ptr_is_owned(orig);
41930         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41931         orig_conv.is_owned = false;
41932         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
41933         int64_t ret_ref = 0;
41934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41936         return ret_ref;
41937 }
41938
41939 jboolean  CS_LDK_UpdateAddHTLC_eq(int64_t a, int64_t b) {
41940         LDKUpdateAddHTLC a_conv;
41941         a_conv.inner = untag_ptr(a);
41942         a_conv.is_owned = ptr_is_owned(a);
41943         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41944         a_conv.is_owned = false;
41945         LDKUpdateAddHTLC b_conv;
41946         b_conv.inner = untag_ptr(b);
41947         b_conv.is_owned = ptr_is_owned(b);
41948         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41949         b_conv.is_owned = false;
41950         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
41951         return ret_conv;
41952 }
41953
41954 void  CS_LDK_OnionMessage_free(int64_t this_obj) {
41955         LDKOnionMessage this_obj_conv;
41956         this_obj_conv.inner = untag_ptr(this_obj);
41957         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41959         OnionMessage_free(this_obj_conv);
41960 }
41961
41962 int8_tArray  CS_LDK_OnionMessage_get_blinding_point(int64_t this_ptr) {
41963         LDKOnionMessage this_ptr_conv;
41964         this_ptr_conv.inner = untag_ptr(this_ptr);
41965         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41967         this_ptr_conv.is_owned = false;
41968         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41969         memcpy(ret_arr->elems, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form, 33);
41970         return ret_arr;
41971 }
41972
41973 void  CS_LDK_OnionMessage_set_blinding_point(int64_t this_ptr, int8_tArray val) {
41974         LDKOnionMessage this_ptr_conv;
41975         this_ptr_conv.inner = untag_ptr(this_ptr);
41976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41978         this_ptr_conv.is_owned = false;
41979         LDKPublicKey val_ref;
41980         CHECK(val->arr_len == 33);
41981         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41982         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
41983 }
41984
41985 int64_t  CS_LDK_OnionMessage_get_onion_routing_packet(int64_t this_ptr) {
41986         LDKOnionMessage this_ptr_conv;
41987         this_ptr_conv.inner = untag_ptr(this_ptr);
41988         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41990         this_ptr_conv.is_owned = false;
41991         LDKPacket ret_var = OnionMessage_get_onion_routing_packet(&this_ptr_conv);
41992         int64_t ret_ref = 0;
41993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41994         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41995         return ret_ref;
41996 }
41997
41998 void  CS_LDK_OnionMessage_set_onion_routing_packet(int64_t this_ptr, int64_t val) {
41999         LDKOnionMessage this_ptr_conv;
42000         this_ptr_conv.inner = untag_ptr(this_ptr);
42001         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42003         this_ptr_conv.is_owned = false;
42004         LDKPacket val_conv;
42005         val_conv.inner = untag_ptr(val);
42006         val_conv.is_owned = ptr_is_owned(val);
42007         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42008         val_conv = Packet_clone(&val_conv);
42009         OnionMessage_set_onion_routing_packet(&this_ptr_conv, val_conv);
42010 }
42011
42012 int64_t  CS_LDK_OnionMessage_new(int8_tArray blinding_point_arg, int64_t onion_routing_packet_arg) {
42013         LDKPublicKey blinding_point_arg_ref;
42014         CHECK(blinding_point_arg->arr_len == 33);
42015         memcpy(blinding_point_arg_ref.compressed_form, blinding_point_arg->elems, 33); FREE(blinding_point_arg);
42016         LDKPacket onion_routing_packet_arg_conv;
42017         onion_routing_packet_arg_conv.inner = untag_ptr(onion_routing_packet_arg);
42018         onion_routing_packet_arg_conv.is_owned = ptr_is_owned(onion_routing_packet_arg);
42019         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_routing_packet_arg_conv);
42020         onion_routing_packet_arg_conv = Packet_clone(&onion_routing_packet_arg_conv);
42021         LDKOnionMessage ret_var = OnionMessage_new(blinding_point_arg_ref, onion_routing_packet_arg_conv);
42022         int64_t ret_ref = 0;
42023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42024         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42025         return ret_ref;
42026 }
42027
42028 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
42029         LDKOnionMessage ret_var = OnionMessage_clone(arg);
42030         int64_t ret_ref = 0;
42031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42032         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42033         return ret_ref;
42034 }
42035 int64_t  CS_LDK_OnionMessage_clone_ptr(int64_t arg) {
42036         LDKOnionMessage arg_conv;
42037         arg_conv.inner = untag_ptr(arg);
42038         arg_conv.is_owned = ptr_is_owned(arg);
42039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42040         arg_conv.is_owned = false;
42041         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
42042         return ret_conv;
42043 }
42044
42045 int64_t  CS_LDK_OnionMessage_clone(int64_t orig) {
42046         LDKOnionMessage orig_conv;
42047         orig_conv.inner = untag_ptr(orig);
42048         orig_conv.is_owned = ptr_is_owned(orig);
42049         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42050         orig_conv.is_owned = false;
42051         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
42052         int64_t ret_ref = 0;
42053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42054         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42055         return ret_ref;
42056 }
42057
42058 jboolean  CS_LDK_OnionMessage_eq(int64_t a, int64_t b) {
42059         LDKOnionMessage a_conv;
42060         a_conv.inner = untag_ptr(a);
42061         a_conv.is_owned = ptr_is_owned(a);
42062         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42063         a_conv.is_owned = false;
42064         LDKOnionMessage b_conv;
42065         b_conv.inner = untag_ptr(b);
42066         b_conv.is_owned = ptr_is_owned(b);
42067         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42068         b_conv.is_owned = false;
42069         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
42070         return ret_conv;
42071 }
42072
42073 void  CS_LDK_UpdateFulfillHTLC_free(int64_t this_obj) {
42074         LDKUpdateFulfillHTLC this_obj_conv;
42075         this_obj_conv.inner = untag_ptr(this_obj);
42076         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42078         UpdateFulfillHTLC_free(this_obj_conv);
42079 }
42080
42081 int8_tArray  CS_LDK_UpdateFulfillHTLC_get_channel_id(int64_t this_ptr) {
42082         LDKUpdateFulfillHTLC this_ptr_conv;
42083         this_ptr_conv.inner = untag_ptr(this_ptr);
42084         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42086         this_ptr_conv.is_owned = false;
42087         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42088         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
42089         return ret_arr;
42090 }
42091
42092 void  CS_LDK_UpdateFulfillHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
42093         LDKUpdateFulfillHTLC this_ptr_conv;
42094         this_ptr_conv.inner = untag_ptr(this_ptr);
42095         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42097         this_ptr_conv.is_owned = false;
42098         LDKThirtyTwoBytes val_ref;
42099         CHECK(val->arr_len == 32);
42100         memcpy(val_ref.data, val->elems, 32); FREE(val);
42101         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
42102 }
42103
42104 int64_t  CS_LDK_UpdateFulfillHTLC_get_htlc_id(int64_t this_ptr) {
42105         LDKUpdateFulfillHTLC this_ptr_conv;
42106         this_ptr_conv.inner = untag_ptr(this_ptr);
42107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42109         this_ptr_conv.is_owned = false;
42110         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
42111         return ret_conv;
42112 }
42113
42114 void  CS_LDK_UpdateFulfillHTLC_set_htlc_id(int64_t this_ptr, int64_t val) {
42115         LDKUpdateFulfillHTLC this_ptr_conv;
42116         this_ptr_conv.inner = untag_ptr(this_ptr);
42117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42119         this_ptr_conv.is_owned = false;
42120         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
42121 }
42122
42123 int8_tArray  CS_LDK_UpdateFulfillHTLC_get_payment_preimage(int64_t this_ptr) {
42124         LDKUpdateFulfillHTLC this_ptr_conv;
42125         this_ptr_conv.inner = untag_ptr(this_ptr);
42126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42128         this_ptr_conv.is_owned = false;
42129         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42130         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
42131         return ret_arr;
42132 }
42133
42134 void  CS_LDK_UpdateFulfillHTLC_set_payment_preimage(int64_t this_ptr, int8_tArray val) {
42135         LDKUpdateFulfillHTLC this_ptr_conv;
42136         this_ptr_conv.inner = untag_ptr(this_ptr);
42137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42139         this_ptr_conv.is_owned = false;
42140         LDKThirtyTwoBytes val_ref;
42141         CHECK(val->arr_len == 32);
42142         memcpy(val_ref.data, val->elems, 32); FREE(val);
42143         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
42144 }
42145
42146 int64_t  CS_LDK_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
42147         LDKThirtyTwoBytes channel_id_arg_ref;
42148         CHECK(channel_id_arg->arr_len == 32);
42149         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42150         LDKThirtyTwoBytes payment_preimage_arg_ref;
42151         CHECK(payment_preimage_arg->arr_len == 32);
42152         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
42153         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
42154         int64_t ret_ref = 0;
42155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42156         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42157         return ret_ref;
42158 }
42159
42160 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
42161         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
42162         int64_t ret_ref = 0;
42163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42165         return ret_ref;
42166 }
42167 int64_t  CS_LDK_UpdateFulfillHTLC_clone_ptr(int64_t arg) {
42168         LDKUpdateFulfillHTLC arg_conv;
42169         arg_conv.inner = untag_ptr(arg);
42170         arg_conv.is_owned = ptr_is_owned(arg);
42171         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42172         arg_conv.is_owned = false;
42173         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
42174         return ret_conv;
42175 }
42176
42177 int64_t  CS_LDK_UpdateFulfillHTLC_clone(int64_t orig) {
42178         LDKUpdateFulfillHTLC orig_conv;
42179         orig_conv.inner = untag_ptr(orig);
42180         orig_conv.is_owned = ptr_is_owned(orig);
42181         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42182         orig_conv.is_owned = false;
42183         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
42184         int64_t ret_ref = 0;
42185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42186         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42187         return ret_ref;
42188 }
42189
42190 jboolean  CS_LDK_UpdateFulfillHTLC_eq(int64_t a, int64_t b) {
42191         LDKUpdateFulfillHTLC a_conv;
42192         a_conv.inner = untag_ptr(a);
42193         a_conv.is_owned = ptr_is_owned(a);
42194         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42195         a_conv.is_owned = false;
42196         LDKUpdateFulfillHTLC b_conv;
42197         b_conv.inner = untag_ptr(b);
42198         b_conv.is_owned = ptr_is_owned(b);
42199         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42200         b_conv.is_owned = false;
42201         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
42202         return ret_conv;
42203 }
42204
42205 void  CS_LDK_UpdateFailHTLC_free(int64_t this_obj) {
42206         LDKUpdateFailHTLC this_obj_conv;
42207         this_obj_conv.inner = untag_ptr(this_obj);
42208         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42210         UpdateFailHTLC_free(this_obj_conv);
42211 }
42212
42213 int8_tArray  CS_LDK_UpdateFailHTLC_get_channel_id(int64_t this_ptr) {
42214         LDKUpdateFailHTLC this_ptr_conv;
42215         this_ptr_conv.inner = untag_ptr(this_ptr);
42216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42218         this_ptr_conv.is_owned = false;
42219         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42220         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
42221         return ret_arr;
42222 }
42223
42224 void  CS_LDK_UpdateFailHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
42225         LDKUpdateFailHTLC this_ptr_conv;
42226         this_ptr_conv.inner = untag_ptr(this_ptr);
42227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42229         this_ptr_conv.is_owned = false;
42230         LDKThirtyTwoBytes val_ref;
42231         CHECK(val->arr_len == 32);
42232         memcpy(val_ref.data, val->elems, 32); FREE(val);
42233         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
42234 }
42235
42236 int64_t  CS_LDK_UpdateFailHTLC_get_htlc_id(int64_t this_ptr) {
42237         LDKUpdateFailHTLC this_ptr_conv;
42238         this_ptr_conv.inner = untag_ptr(this_ptr);
42239         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42241         this_ptr_conv.is_owned = false;
42242         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
42243         return ret_conv;
42244 }
42245
42246 void  CS_LDK_UpdateFailHTLC_set_htlc_id(int64_t this_ptr, int64_t val) {
42247         LDKUpdateFailHTLC this_ptr_conv;
42248         this_ptr_conv.inner = untag_ptr(this_ptr);
42249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42251         this_ptr_conv.is_owned = false;
42252         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
42253 }
42254
42255 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
42256         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
42257         int64_t ret_ref = 0;
42258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42260         return ret_ref;
42261 }
42262 int64_t  CS_LDK_UpdateFailHTLC_clone_ptr(int64_t arg) {
42263         LDKUpdateFailHTLC arg_conv;
42264         arg_conv.inner = untag_ptr(arg);
42265         arg_conv.is_owned = ptr_is_owned(arg);
42266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42267         arg_conv.is_owned = false;
42268         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
42269         return ret_conv;
42270 }
42271
42272 int64_t  CS_LDK_UpdateFailHTLC_clone(int64_t orig) {
42273         LDKUpdateFailHTLC orig_conv;
42274         orig_conv.inner = untag_ptr(orig);
42275         orig_conv.is_owned = ptr_is_owned(orig);
42276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42277         orig_conv.is_owned = false;
42278         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
42279         int64_t ret_ref = 0;
42280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42282         return ret_ref;
42283 }
42284
42285 jboolean  CS_LDK_UpdateFailHTLC_eq(int64_t a, int64_t b) {
42286         LDKUpdateFailHTLC a_conv;
42287         a_conv.inner = untag_ptr(a);
42288         a_conv.is_owned = ptr_is_owned(a);
42289         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42290         a_conv.is_owned = false;
42291         LDKUpdateFailHTLC b_conv;
42292         b_conv.inner = untag_ptr(b);
42293         b_conv.is_owned = ptr_is_owned(b);
42294         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42295         b_conv.is_owned = false;
42296         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
42297         return ret_conv;
42298 }
42299
42300 void  CS_LDK_UpdateFailMalformedHTLC_free(int64_t this_obj) {
42301         LDKUpdateFailMalformedHTLC this_obj_conv;
42302         this_obj_conv.inner = untag_ptr(this_obj);
42303         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42305         UpdateFailMalformedHTLC_free(this_obj_conv);
42306 }
42307
42308 int8_tArray  CS_LDK_UpdateFailMalformedHTLC_get_channel_id(int64_t this_ptr) {
42309         LDKUpdateFailMalformedHTLC this_ptr_conv;
42310         this_ptr_conv.inner = untag_ptr(this_ptr);
42311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42313         this_ptr_conv.is_owned = false;
42314         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42315         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
42316         return ret_arr;
42317 }
42318
42319 void  CS_LDK_UpdateFailMalformedHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
42320         LDKUpdateFailMalformedHTLC this_ptr_conv;
42321         this_ptr_conv.inner = untag_ptr(this_ptr);
42322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42324         this_ptr_conv.is_owned = false;
42325         LDKThirtyTwoBytes val_ref;
42326         CHECK(val->arr_len == 32);
42327         memcpy(val_ref.data, val->elems, 32); FREE(val);
42328         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
42329 }
42330
42331 int64_t  CS_LDK_UpdateFailMalformedHTLC_get_htlc_id(int64_t this_ptr) {
42332         LDKUpdateFailMalformedHTLC this_ptr_conv;
42333         this_ptr_conv.inner = untag_ptr(this_ptr);
42334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42336         this_ptr_conv.is_owned = false;
42337         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
42338         return ret_conv;
42339 }
42340
42341 void  CS_LDK_UpdateFailMalformedHTLC_set_htlc_id(int64_t this_ptr, int64_t val) {
42342         LDKUpdateFailMalformedHTLC this_ptr_conv;
42343         this_ptr_conv.inner = untag_ptr(this_ptr);
42344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42346         this_ptr_conv.is_owned = false;
42347         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
42348 }
42349
42350 int16_t  CS_LDK_UpdateFailMalformedHTLC_get_failure_code(int64_t this_ptr) {
42351         LDKUpdateFailMalformedHTLC this_ptr_conv;
42352         this_ptr_conv.inner = untag_ptr(this_ptr);
42353         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42355         this_ptr_conv.is_owned = false;
42356         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
42357         return ret_conv;
42358 }
42359
42360 void  CS_LDK_UpdateFailMalformedHTLC_set_failure_code(int64_t this_ptr, int16_t val) {
42361         LDKUpdateFailMalformedHTLC this_ptr_conv;
42362         this_ptr_conv.inner = untag_ptr(this_ptr);
42363         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42365         this_ptr_conv.is_owned = false;
42366         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
42367 }
42368
42369 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
42370         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
42371         int64_t ret_ref = 0;
42372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42374         return ret_ref;
42375 }
42376 int64_t  CS_LDK_UpdateFailMalformedHTLC_clone_ptr(int64_t arg) {
42377         LDKUpdateFailMalformedHTLC arg_conv;
42378         arg_conv.inner = untag_ptr(arg);
42379         arg_conv.is_owned = ptr_is_owned(arg);
42380         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42381         arg_conv.is_owned = false;
42382         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
42383         return ret_conv;
42384 }
42385
42386 int64_t  CS_LDK_UpdateFailMalformedHTLC_clone(int64_t orig) {
42387         LDKUpdateFailMalformedHTLC orig_conv;
42388         orig_conv.inner = untag_ptr(orig);
42389         orig_conv.is_owned = ptr_is_owned(orig);
42390         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42391         orig_conv.is_owned = false;
42392         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
42393         int64_t ret_ref = 0;
42394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42396         return ret_ref;
42397 }
42398
42399 jboolean  CS_LDK_UpdateFailMalformedHTLC_eq(int64_t a, int64_t b) {
42400         LDKUpdateFailMalformedHTLC a_conv;
42401         a_conv.inner = untag_ptr(a);
42402         a_conv.is_owned = ptr_is_owned(a);
42403         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42404         a_conv.is_owned = false;
42405         LDKUpdateFailMalformedHTLC b_conv;
42406         b_conv.inner = untag_ptr(b);
42407         b_conv.is_owned = ptr_is_owned(b);
42408         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42409         b_conv.is_owned = false;
42410         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
42411         return ret_conv;
42412 }
42413
42414 void  CS_LDK_CommitmentSigned_free(int64_t this_obj) {
42415         LDKCommitmentSigned this_obj_conv;
42416         this_obj_conv.inner = untag_ptr(this_obj);
42417         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42419         CommitmentSigned_free(this_obj_conv);
42420 }
42421
42422 int8_tArray  CS_LDK_CommitmentSigned_get_channel_id(int64_t this_ptr) {
42423         LDKCommitmentSigned this_ptr_conv;
42424         this_ptr_conv.inner = untag_ptr(this_ptr);
42425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42427         this_ptr_conv.is_owned = false;
42428         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42429         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
42430         return ret_arr;
42431 }
42432
42433 void  CS_LDK_CommitmentSigned_set_channel_id(int64_t this_ptr, int8_tArray val) {
42434         LDKCommitmentSigned this_ptr_conv;
42435         this_ptr_conv.inner = untag_ptr(this_ptr);
42436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42438         this_ptr_conv.is_owned = false;
42439         LDKThirtyTwoBytes val_ref;
42440         CHECK(val->arr_len == 32);
42441         memcpy(val_ref.data, val->elems, 32); FREE(val);
42442         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
42443 }
42444
42445 int8_tArray  CS_LDK_CommitmentSigned_get_signature(int64_t this_ptr) {
42446         LDKCommitmentSigned this_ptr_conv;
42447         this_ptr_conv.inner = untag_ptr(this_ptr);
42448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42450         this_ptr_conv.is_owned = false;
42451         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
42452         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
42453         return ret_arr;
42454 }
42455
42456 void  CS_LDK_CommitmentSigned_set_signature(int64_t this_ptr, int8_tArray val) {
42457         LDKCommitmentSigned this_ptr_conv;
42458         this_ptr_conv.inner = untag_ptr(this_ptr);
42459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42461         this_ptr_conv.is_owned = false;
42462         LDKECDSASignature val_ref;
42463         CHECK(val->arr_len == 64);
42464         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
42465         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
42466 }
42467
42468 ptrArray  CS_LDK_CommitmentSigned_get_htlc_signatures(int64_t this_ptr) {
42469         LDKCommitmentSigned this_ptr_conv;
42470         this_ptr_conv.inner = untag_ptr(this_ptr);
42471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42473         this_ptr_conv.is_owned = false;
42474         LDKCVec_ECDSASignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
42475         ptrArray ret_arr = NULL;
42476         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
42477         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
42478         for (size_t i = 0; i < ret_var.datalen; i++) {
42479                 int8_tArray ret_conv_8_arr = init_int8_tArray(64, __LINE__);
42480                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compact_form, 64);
42481                 ret_arr_ptr[i] = ret_conv_8_arr;
42482         }
42483         
42484         FREE(ret_var.data);
42485         return ret_arr;
42486 }
42487
42488 void  CS_LDK_CommitmentSigned_set_htlc_signatures(int64_t this_ptr, ptrArray val) {
42489         LDKCommitmentSigned this_ptr_conv;
42490         this_ptr_conv.inner = untag_ptr(this_ptr);
42491         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42493         this_ptr_conv.is_owned = false;
42494         LDKCVec_ECDSASignatureZ val_constr;
42495         val_constr.datalen = val->arr_len;
42496         if (val_constr.datalen > 0)
42497                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
42498         else
42499                 val_constr.data = NULL;
42500         int8_tArray* val_vals = (void*) val->elems;
42501         for (size_t i = 0; i < val_constr.datalen; i++) {
42502                 int8_tArray val_conv_8 = val_vals[i];
42503                 LDKECDSASignature val_conv_8_ref;
42504                 CHECK(val_conv_8->arr_len == 64);
42505                 memcpy(val_conv_8_ref.compact_form, val_conv_8->elems, 64); FREE(val_conv_8);
42506                 val_constr.data[i] = val_conv_8_ref;
42507         }
42508         FREE(val);
42509         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
42510 }
42511
42512 int64_t  CS_LDK_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
42513         LDKThirtyTwoBytes channel_id_arg_ref;
42514         CHECK(channel_id_arg->arr_len == 32);
42515         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42516         LDKECDSASignature signature_arg_ref;
42517         CHECK(signature_arg->arr_len == 64);
42518         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
42519         LDKCVec_ECDSASignatureZ htlc_signatures_arg_constr;
42520         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
42521         if (htlc_signatures_arg_constr.datalen > 0)
42522                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
42523         else
42524                 htlc_signatures_arg_constr.data = NULL;
42525         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
42526         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
42527                 int8_tArray htlc_signatures_arg_conv_8 = htlc_signatures_arg_vals[i];
42528                 LDKECDSASignature htlc_signatures_arg_conv_8_ref;
42529                 CHECK(htlc_signatures_arg_conv_8->arr_len == 64);
42530                 memcpy(htlc_signatures_arg_conv_8_ref.compact_form, htlc_signatures_arg_conv_8->elems, 64); FREE(htlc_signatures_arg_conv_8);
42531                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
42532         }
42533         FREE(htlc_signatures_arg);
42534         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
42535         int64_t ret_ref = 0;
42536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42537         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42538         return ret_ref;
42539 }
42540
42541 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
42542         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
42543         int64_t ret_ref = 0;
42544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42545         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42546         return ret_ref;
42547 }
42548 int64_t  CS_LDK_CommitmentSigned_clone_ptr(int64_t arg) {
42549         LDKCommitmentSigned arg_conv;
42550         arg_conv.inner = untag_ptr(arg);
42551         arg_conv.is_owned = ptr_is_owned(arg);
42552         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42553         arg_conv.is_owned = false;
42554         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
42555         return ret_conv;
42556 }
42557
42558 int64_t  CS_LDK_CommitmentSigned_clone(int64_t orig) {
42559         LDKCommitmentSigned orig_conv;
42560         orig_conv.inner = untag_ptr(orig);
42561         orig_conv.is_owned = ptr_is_owned(orig);
42562         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42563         orig_conv.is_owned = false;
42564         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
42565         int64_t ret_ref = 0;
42566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42567         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42568         return ret_ref;
42569 }
42570
42571 jboolean  CS_LDK_CommitmentSigned_eq(int64_t a, int64_t b) {
42572         LDKCommitmentSigned a_conv;
42573         a_conv.inner = untag_ptr(a);
42574         a_conv.is_owned = ptr_is_owned(a);
42575         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42576         a_conv.is_owned = false;
42577         LDKCommitmentSigned b_conv;
42578         b_conv.inner = untag_ptr(b);
42579         b_conv.is_owned = ptr_is_owned(b);
42580         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42581         b_conv.is_owned = false;
42582         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
42583         return ret_conv;
42584 }
42585
42586 void  CS_LDK_RevokeAndACK_free(int64_t this_obj) {
42587         LDKRevokeAndACK this_obj_conv;
42588         this_obj_conv.inner = untag_ptr(this_obj);
42589         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42591         RevokeAndACK_free(this_obj_conv);
42592 }
42593
42594 int8_tArray  CS_LDK_RevokeAndACK_get_channel_id(int64_t this_ptr) {
42595         LDKRevokeAndACK this_ptr_conv;
42596         this_ptr_conv.inner = untag_ptr(this_ptr);
42597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42599         this_ptr_conv.is_owned = false;
42600         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42601         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
42602         return ret_arr;
42603 }
42604
42605 void  CS_LDK_RevokeAndACK_set_channel_id(int64_t this_ptr, int8_tArray val) {
42606         LDKRevokeAndACK this_ptr_conv;
42607         this_ptr_conv.inner = untag_ptr(this_ptr);
42608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42610         this_ptr_conv.is_owned = false;
42611         LDKThirtyTwoBytes val_ref;
42612         CHECK(val->arr_len == 32);
42613         memcpy(val_ref.data, val->elems, 32); FREE(val);
42614         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
42615 }
42616
42617 int8_tArray  CS_LDK_RevokeAndACK_get_per_commitment_secret(int64_t this_ptr) {
42618         LDKRevokeAndACK this_ptr_conv;
42619         this_ptr_conv.inner = untag_ptr(this_ptr);
42620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42622         this_ptr_conv.is_owned = false;
42623         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42624         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
42625         return ret_arr;
42626 }
42627
42628 void  CS_LDK_RevokeAndACK_set_per_commitment_secret(int64_t this_ptr, int8_tArray val) {
42629         LDKRevokeAndACK this_ptr_conv;
42630         this_ptr_conv.inner = untag_ptr(this_ptr);
42631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42633         this_ptr_conv.is_owned = false;
42634         LDKThirtyTwoBytes val_ref;
42635         CHECK(val->arr_len == 32);
42636         memcpy(val_ref.data, val->elems, 32); FREE(val);
42637         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
42638 }
42639
42640 int8_tArray  CS_LDK_RevokeAndACK_get_next_per_commitment_point(int64_t this_ptr) {
42641         LDKRevokeAndACK this_ptr_conv;
42642         this_ptr_conv.inner = untag_ptr(this_ptr);
42643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42645         this_ptr_conv.is_owned = false;
42646         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42647         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
42648         return ret_arr;
42649 }
42650
42651 void  CS_LDK_RevokeAndACK_set_next_per_commitment_point(int64_t this_ptr, int8_tArray val) {
42652         LDKRevokeAndACK this_ptr_conv;
42653         this_ptr_conv.inner = untag_ptr(this_ptr);
42654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42656         this_ptr_conv.is_owned = false;
42657         LDKPublicKey val_ref;
42658         CHECK(val->arr_len == 33);
42659         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42660         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
42661 }
42662
42663 int64_t  CS_LDK_RevokeAndACK_new(int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
42664         LDKThirtyTwoBytes channel_id_arg_ref;
42665         CHECK(channel_id_arg->arr_len == 32);
42666         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42667         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
42668         CHECK(per_commitment_secret_arg->arr_len == 32);
42669         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
42670         LDKPublicKey next_per_commitment_point_arg_ref;
42671         CHECK(next_per_commitment_point_arg->arr_len == 33);
42672         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
42673         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
42674         int64_t ret_ref = 0;
42675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42676         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42677         return ret_ref;
42678 }
42679
42680 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
42681         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
42682         int64_t ret_ref = 0;
42683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42684         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42685         return ret_ref;
42686 }
42687 int64_t  CS_LDK_RevokeAndACK_clone_ptr(int64_t arg) {
42688         LDKRevokeAndACK arg_conv;
42689         arg_conv.inner = untag_ptr(arg);
42690         arg_conv.is_owned = ptr_is_owned(arg);
42691         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42692         arg_conv.is_owned = false;
42693         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
42694         return ret_conv;
42695 }
42696
42697 int64_t  CS_LDK_RevokeAndACK_clone(int64_t orig) {
42698         LDKRevokeAndACK orig_conv;
42699         orig_conv.inner = untag_ptr(orig);
42700         orig_conv.is_owned = ptr_is_owned(orig);
42701         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42702         orig_conv.is_owned = false;
42703         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
42704         int64_t ret_ref = 0;
42705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42707         return ret_ref;
42708 }
42709
42710 jboolean  CS_LDK_RevokeAndACK_eq(int64_t a, int64_t b) {
42711         LDKRevokeAndACK a_conv;
42712         a_conv.inner = untag_ptr(a);
42713         a_conv.is_owned = ptr_is_owned(a);
42714         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42715         a_conv.is_owned = false;
42716         LDKRevokeAndACK b_conv;
42717         b_conv.inner = untag_ptr(b);
42718         b_conv.is_owned = ptr_is_owned(b);
42719         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42720         b_conv.is_owned = false;
42721         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
42722         return ret_conv;
42723 }
42724
42725 void  CS_LDK_UpdateFee_free(int64_t this_obj) {
42726         LDKUpdateFee this_obj_conv;
42727         this_obj_conv.inner = untag_ptr(this_obj);
42728         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42730         UpdateFee_free(this_obj_conv);
42731 }
42732
42733 int8_tArray  CS_LDK_UpdateFee_get_channel_id(int64_t this_ptr) {
42734         LDKUpdateFee this_ptr_conv;
42735         this_ptr_conv.inner = untag_ptr(this_ptr);
42736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42738         this_ptr_conv.is_owned = false;
42739         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42740         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
42741         return ret_arr;
42742 }
42743
42744 void  CS_LDK_UpdateFee_set_channel_id(int64_t this_ptr, int8_tArray val) {
42745         LDKUpdateFee this_ptr_conv;
42746         this_ptr_conv.inner = untag_ptr(this_ptr);
42747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42749         this_ptr_conv.is_owned = false;
42750         LDKThirtyTwoBytes val_ref;
42751         CHECK(val->arr_len == 32);
42752         memcpy(val_ref.data, val->elems, 32); FREE(val);
42753         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
42754 }
42755
42756 int32_t  CS_LDK_UpdateFee_get_feerate_per_kw(int64_t this_ptr) {
42757         LDKUpdateFee this_ptr_conv;
42758         this_ptr_conv.inner = untag_ptr(this_ptr);
42759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42761         this_ptr_conv.is_owned = false;
42762         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
42763         return ret_conv;
42764 }
42765
42766 void  CS_LDK_UpdateFee_set_feerate_per_kw(int64_t this_ptr, int32_t val) {
42767         LDKUpdateFee this_ptr_conv;
42768         this_ptr_conv.inner = untag_ptr(this_ptr);
42769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42771         this_ptr_conv.is_owned = false;
42772         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
42773 }
42774
42775 int64_t  CS_LDK_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
42776         LDKThirtyTwoBytes channel_id_arg_ref;
42777         CHECK(channel_id_arg->arr_len == 32);
42778         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42779         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
42780         int64_t ret_ref = 0;
42781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42783         return ret_ref;
42784 }
42785
42786 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
42787         LDKUpdateFee ret_var = UpdateFee_clone(arg);
42788         int64_t ret_ref = 0;
42789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42791         return ret_ref;
42792 }
42793 int64_t  CS_LDK_UpdateFee_clone_ptr(int64_t arg) {
42794         LDKUpdateFee arg_conv;
42795         arg_conv.inner = untag_ptr(arg);
42796         arg_conv.is_owned = ptr_is_owned(arg);
42797         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42798         arg_conv.is_owned = false;
42799         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
42800         return ret_conv;
42801 }
42802
42803 int64_t  CS_LDK_UpdateFee_clone(int64_t orig) {
42804         LDKUpdateFee orig_conv;
42805         orig_conv.inner = untag_ptr(orig);
42806         orig_conv.is_owned = ptr_is_owned(orig);
42807         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42808         orig_conv.is_owned = false;
42809         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
42810         int64_t ret_ref = 0;
42811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42813         return ret_ref;
42814 }
42815
42816 jboolean  CS_LDK_UpdateFee_eq(int64_t a, int64_t b) {
42817         LDKUpdateFee a_conv;
42818         a_conv.inner = untag_ptr(a);
42819         a_conv.is_owned = ptr_is_owned(a);
42820         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42821         a_conv.is_owned = false;
42822         LDKUpdateFee b_conv;
42823         b_conv.inner = untag_ptr(b);
42824         b_conv.is_owned = ptr_is_owned(b);
42825         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42826         b_conv.is_owned = false;
42827         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
42828         return ret_conv;
42829 }
42830
42831 void  CS_LDK_ChannelReestablish_free(int64_t this_obj) {
42832         LDKChannelReestablish this_obj_conv;
42833         this_obj_conv.inner = untag_ptr(this_obj);
42834         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42836         ChannelReestablish_free(this_obj_conv);
42837 }
42838
42839 int8_tArray  CS_LDK_ChannelReestablish_get_channel_id(int64_t this_ptr) {
42840         LDKChannelReestablish this_ptr_conv;
42841         this_ptr_conv.inner = untag_ptr(this_ptr);
42842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42844         this_ptr_conv.is_owned = false;
42845         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42846         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
42847         return ret_arr;
42848 }
42849
42850 void  CS_LDK_ChannelReestablish_set_channel_id(int64_t this_ptr, int8_tArray val) {
42851         LDKChannelReestablish this_ptr_conv;
42852         this_ptr_conv.inner = untag_ptr(this_ptr);
42853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42855         this_ptr_conv.is_owned = false;
42856         LDKThirtyTwoBytes val_ref;
42857         CHECK(val->arr_len == 32);
42858         memcpy(val_ref.data, val->elems, 32); FREE(val);
42859         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
42860 }
42861
42862 int64_t  CS_LDK_ChannelReestablish_get_next_local_commitment_number(int64_t this_ptr) {
42863         LDKChannelReestablish this_ptr_conv;
42864         this_ptr_conv.inner = untag_ptr(this_ptr);
42865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42867         this_ptr_conv.is_owned = false;
42868         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
42869         return ret_conv;
42870 }
42871
42872 void  CS_LDK_ChannelReestablish_set_next_local_commitment_number(int64_t this_ptr, int64_t val) {
42873         LDKChannelReestablish this_ptr_conv;
42874         this_ptr_conv.inner = untag_ptr(this_ptr);
42875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42877         this_ptr_conv.is_owned = false;
42878         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
42879 }
42880
42881 int64_t  CS_LDK_ChannelReestablish_get_next_remote_commitment_number(int64_t this_ptr) {
42882         LDKChannelReestablish this_ptr_conv;
42883         this_ptr_conv.inner = untag_ptr(this_ptr);
42884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42886         this_ptr_conv.is_owned = false;
42887         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
42888         return ret_conv;
42889 }
42890
42891 void  CS_LDK_ChannelReestablish_set_next_remote_commitment_number(int64_t this_ptr, int64_t val) {
42892         LDKChannelReestablish this_ptr_conv;
42893         this_ptr_conv.inner = untag_ptr(this_ptr);
42894         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42896         this_ptr_conv.is_owned = false;
42897         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
42898 }
42899
42900 int8_tArray  CS_LDK_ChannelReestablish_get_your_last_per_commitment_secret(int64_t this_ptr) {
42901         LDKChannelReestablish this_ptr_conv;
42902         this_ptr_conv.inner = untag_ptr(this_ptr);
42903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42905         this_ptr_conv.is_owned = false;
42906         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42907         memcpy(ret_arr->elems, *ChannelReestablish_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
42908         return ret_arr;
42909 }
42910
42911 void  CS_LDK_ChannelReestablish_set_your_last_per_commitment_secret(int64_t this_ptr, int8_tArray val) {
42912         LDKChannelReestablish this_ptr_conv;
42913         this_ptr_conv.inner = untag_ptr(this_ptr);
42914         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42916         this_ptr_conv.is_owned = false;
42917         LDKThirtyTwoBytes val_ref;
42918         CHECK(val->arr_len == 32);
42919         memcpy(val_ref.data, val->elems, 32); FREE(val);
42920         ChannelReestablish_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
42921 }
42922
42923 int8_tArray  CS_LDK_ChannelReestablish_get_my_current_per_commitment_point(int64_t this_ptr) {
42924         LDKChannelReestablish this_ptr_conv;
42925         this_ptr_conv.inner = untag_ptr(this_ptr);
42926         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42928         this_ptr_conv.is_owned = false;
42929         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42930         memcpy(ret_arr->elems, ChannelReestablish_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
42931         return ret_arr;
42932 }
42933
42934 void  CS_LDK_ChannelReestablish_set_my_current_per_commitment_point(int64_t this_ptr, int8_tArray val) {
42935         LDKChannelReestablish this_ptr_conv;
42936         this_ptr_conv.inner = untag_ptr(this_ptr);
42937         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42939         this_ptr_conv.is_owned = false;
42940         LDKPublicKey val_ref;
42941         CHECK(val->arr_len == 33);
42942         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42943         ChannelReestablish_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
42944 }
42945
42946 int64_t  CS_LDK_ChannelReestablish_get_next_funding_txid(int64_t this_ptr) {
42947         LDKChannelReestablish this_ptr_conv;
42948         this_ptr_conv.inner = untag_ptr(this_ptr);
42949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42951         this_ptr_conv.is_owned = false;
42952         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
42953         *ret_copy = ChannelReestablish_get_next_funding_txid(&this_ptr_conv);
42954         int64_t ret_ref = tag_ptr(ret_copy, true);
42955         return ret_ref;
42956 }
42957
42958 void  CS_LDK_ChannelReestablish_set_next_funding_txid(int64_t this_ptr, int64_t val) {
42959         LDKChannelReestablish this_ptr_conv;
42960         this_ptr_conv.inner = untag_ptr(this_ptr);
42961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42963         this_ptr_conv.is_owned = false;
42964         void* val_ptr = untag_ptr(val);
42965         CHECK_ACCESS(val_ptr);
42966         LDKCOption_ThirtyTwoBytesZ val_conv = *(LDKCOption_ThirtyTwoBytesZ*)(val_ptr);
42967         val_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(val));
42968         ChannelReestablish_set_next_funding_txid(&this_ptr_conv, val_conv);
42969 }
42970
42971 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) {
42972         LDKThirtyTwoBytes channel_id_arg_ref;
42973         CHECK(channel_id_arg->arr_len == 32);
42974         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42975         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
42976         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
42977         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
42978         LDKPublicKey my_current_per_commitment_point_arg_ref;
42979         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
42980         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);
42981         void* next_funding_txid_arg_ptr = untag_ptr(next_funding_txid_arg);
42982         CHECK_ACCESS(next_funding_txid_arg_ptr);
42983         LDKCOption_ThirtyTwoBytesZ next_funding_txid_arg_conv = *(LDKCOption_ThirtyTwoBytesZ*)(next_funding_txid_arg_ptr);
42984         next_funding_txid_arg_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(next_funding_txid_arg));
42985         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);
42986         int64_t ret_ref = 0;
42987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42989         return ret_ref;
42990 }
42991
42992 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
42993         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
42994         int64_t ret_ref = 0;
42995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42997         return ret_ref;
42998 }
42999 int64_t  CS_LDK_ChannelReestablish_clone_ptr(int64_t arg) {
43000         LDKChannelReestablish arg_conv;
43001         arg_conv.inner = untag_ptr(arg);
43002         arg_conv.is_owned = ptr_is_owned(arg);
43003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43004         arg_conv.is_owned = false;
43005         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
43006         return ret_conv;
43007 }
43008
43009 int64_t  CS_LDK_ChannelReestablish_clone(int64_t orig) {
43010         LDKChannelReestablish orig_conv;
43011         orig_conv.inner = untag_ptr(orig);
43012         orig_conv.is_owned = ptr_is_owned(orig);
43013         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43014         orig_conv.is_owned = false;
43015         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
43016         int64_t ret_ref = 0;
43017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43019         return ret_ref;
43020 }
43021
43022 jboolean  CS_LDK_ChannelReestablish_eq(int64_t a, int64_t b) {
43023         LDKChannelReestablish a_conv;
43024         a_conv.inner = untag_ptr(a);
43025         a_conv.is_owned = ptr_is_owned(a);
43026         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43027         a_conv.is_owned = false;
43028         LDKChannelReestablish b_conv;
43029         b_conv.inner = untag_ptr(b);
43030         b_conv.is_owned = ptr_is_owned(b);
43031         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43032         b_conv.is_owned = false;
43033         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
43034         return ret_conv;
43035 }
43036
43037 void  CS_LDK_AnnouncementSignatures_free(int64_t this_obj) {
43038         LDKAnnouncementSignatures this_obj_conv;
43039         this_obj_conv.inner = untag_ptr(this_obj);
43040         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43042         AnnouncementSignatures_free(this_obj_conv);
43043 }
43044
43045 int8_tArray  CS_LDK_AnnouncementSignatures_get_channel_id(int64_t this_ptr) {
43046         LDKAnnouncementSignatures this_ptr_conv;
43047         this_ptr_conv.inner = untag_ptr(this_ptr);
43048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43050         this_ptr_conv.is_owned = false;
43051         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43052         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
43053         return ret_arr;
43054 }
43055
43056 void  CS_LDK_AnnouncementSignatures_set_channel_id(int64_t this_ptr, int8_tArray val) {
43057         LDKAnnouncementSignatures this_ptr_conv;
43058         this_ptr_conv.inner = untag_ptr(this_ptr);
43059         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43061         this_ptr_conv.is_owned = false;
43062         LDKThirtyTwoBytes val_ref;
43063         CHECK(val->arr_len == 32);
43064         memcpy(val_ref.data, val->elems, 32); FREE(val);
43065         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
43066 }
43067
43068 int64_t  CS_LDK_AnnouncementSignatures_get_short_channel_id(int64_t this_ptr) {
43069         LDKAnnouncementSignatures this_ptr_conv;
43070         this_ptr_conv.inner = untag_ptr(this_ptr);
43071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43073         this_ptr_conv.is_owned = false;
43074         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
43075         return ret_conv;
43076 }
43077
43078 void  CS_LDK_AnnouncementSignatures_set_short_channel_id(int64_t this_ptr, int64_t val) {
43079         LDKAnnouncementSignatures this_ptr_conv;
43080         this_ptr_conv.inner = untag_ptr(this_ptr);
43081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43083         this_ptr_conv.is_owned = false;
43084         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
43085 }
43086
43087 int8_tArray  CS_LDK_AnnouncementSignatures_get_node_signature(int64_t this_ptr) {
43088         LDKAnnouncementSignatures this_ptr_conv;
43089         this_ptr_conv.inner = untag_ptr(this_ptr);
43090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43092         this_ptr_conv.is_owned = false;
43093         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
43094         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
43095         return ret_arr;
43096 }
43097
43098 void  CS_LDK_AnnouncementSignatures_set_node_signature(int64_t this_ptr, int8_tArray val) {
43099         LDKAnnouncementSignatures this_ptr_conv;
43100         this_ptr_conv.inner = untag_ptr(this_ptr);
43101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43103         this_ptr_conv.is_owned = false;
43104         LDKECDSASignature val_ref;
43105         CHECK(val->arr_len == 64);
43106         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
43107         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
43108 }
43109
43110 int8_tArray  CS_LDK_AnnouncementSignatures_get_bitcoin_signature(int64_t this_ptr) {
43111         LDKAnnouncementSignatures this_ptr_conv;
43112         this_ptr_conv.inner = untag_ptr(this_ptr);
43113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43115         this_ptr_conv.is_owned = false;
43116         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
43117         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
43118         return ret_arr;
43119 }
43120
43121 void  CS_LDK_AnnouncementSignatures_set_bitcoin_signature(int64_t this_ptr, int8_tArray val) {
43122         LDKAnnouncementSignatures this_ptr_conv;
43123         this_ptr_conv.inner = untag_ptr(this_ptr);
43124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43126         this_ptr_conv.is_owned = false;
43127         LDKECDSASignature val_ref;
43128         CHECK(val->arr_len == 64);
43129         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
43130         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
43131 }
43132
43133 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) {
43134         LDKThirtyTwoBytes channel_id_arg_ref;
43135         CHECK(channel_id_arg->arr_len == 32);
43136         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
43137         LDKECDSASignature node_signature_arg_ref;
43138         CHECK(node_signature_arg->arr_len == 64);
43139         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
43140         LDKECDSASignature bitcoin_signature_arg_ref;
43141         CHECK(bitcoin_signature_arg->arr_len == 64);
43142         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
43143         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
43144         int64_t ret_ref = 0;
43145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43147         return ret_ref;
43148 }
43149
43150 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
43151         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
43152         int64_t ret_ref = 0;
43153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43155         return ret_ref;
43156 }
43157 int64_t  CS_LDK_AnnouncementSignatures_clone_ptr(int64_t arg) {
43158         LDKAnnouncementSignatures arg_conv;
43159         arg_conv.inner = untag_ptr(arg);
43160         arg_conv.is_owned = ptr_is_owned(arg);
43161         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43162         arg_conv.is_owned = false;
43163         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
43164         return ret_conv;
43165 }
43166
43167 int64_t  CS_LDK_AnnouncementSignatures_clone(int64_t orig) {
43168         LDKAnnouncementSignatures orig_conv;
43169         orig_conv.inner = untag_ptr(orig);
43170         orig_conv.is_owned = ptr_is_owned(orig);
43171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43172         orig_conv.is_owned = false;
43173         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
43174         int64_t ret_ref = 0;
43175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43177         return ret_ref;
43178 }
43179
43180 jboolean  CS_LDK_AnnouncementSignatures_eq(int64_t a, int64_t b) {
43181         LDKAnnouncementSignatures a_conv;
43182         a_conv.inner = untag_ptr(a);
43183         a_conv.is_owned = ptr_is_owned(a);
43184         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43185         a_conv.is_owned = false;
43186         LDKAnnouncementSignatures b_conv;
43187         b_conv.inner = untag_ptr(b);
43188         b_conv.is_owned = ptr_is_owned(b);
43189         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43190         b_conv.is_owned = false;
43191         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
43192         return ret_conv;
43193 }
43194
43195 void  CS_LDK_SocketAddress_free(int64_t this_ptr) {
43196         if (!ptr_is_owned(this_ptr)) return;
43197         void* this_ptr_ptr = untag_ptr(this_ptr);
43198         CHECK_ACCESS(this_ptr_ptr);
43199         LDKSocketAddress this_ptr_conv = *(LDKSocketAddress*)(this_ptr_ptr);
43200         FREE(untag_ptr(this_ptr));
43201         SocketAddress_free(this_ptr_conv);
43202 }
43203
43204 static inline uint64_t SocketAddress_clone_ptr(LDKSocketAddress *NONNULL_PTR arg) {
43205         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43206         *ret_copy = SocketAddress_clone(arg);
43207         int64_t ret_ref = tag_ptr(ret_copy, true);
43208         return ret_ref;
43209 }
43210 int64_t  CS_LDK_SocketAddress_clone_ptr(int64_t arg) {
43211         LDKSocketAddress* arg_conv = (LDKSocketAddress*)untag_ptr(arg);
43212         int64_t ret_conv = SocketAddress_clone_ptr(arg_conv);
43213         return ret_conv;
43214 }
43215
43216 int64_t  CS_LDK_SocketAddress_clone(int64_t orig) {
43217         LDKSocketAddress* orig_conv = (LDKSocketAddress*)untag_ptr(orig);
43218         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43219         *ret_copy = SocketAddress_clone(orig_conv);
43220         int64_t ret_ref = tag_ptr(ret_copy, true);
43221         return ret_ref;
43222 }
43223
43224 int64_t  CS_LDK_SocketAddress_tcp_ip_v4(int8_tArray addr, int16_t port) {
43225         LDKFourBytes addr_ref;
43226         CHECK(addr->arr_len == 4);
43227         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
43228         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43229         *ret_copy = SocketAddress_tcp_ip_v4(addr_ref, port);
43230         int64_t ret_ref = tag_ptr(ret_copy, true);
43231         return ret_ref;
43232 }
43233
43234 int64_t  CS_LDK_SocketAddress_tcp_ip_v6(int8_tArray addr, int16_t port) {
43235         LDKSixteenBytes addr_ref;
43236         CHECK(addr->arr_len == 16);
43237         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
43238         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43239         *ret_copy = SocketAddress_tcp_ip_v6(addr_ref, port);
43240         int64_t ret_ref = tag_ptr(ret_copy, true);
43241         return ret_ref;
43242 }
43243
43244 int64_t  CS_LDK_SocketAddress_onion_v2(int8_tArray a) {
43245         LDKTwelveBytes a_ref;
43246         CHECK(a->arr_len == 12);
43247         memcpy(a_ref.data, a->elems, 12); FREE(a);
43248         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43249         *ret_copy = SocketAddress_onion_v2(a_ref);
43250         int64_t ret_ref = tag_ptr(ret_copy, true);
43251         return ret_ref;
43252 }
43253
43254 int64_t  CS_LDK_SocketAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
43255         LDKThirtyTwoBytes ed25519_pubkey_ref;
43256         CHECK(ed25519_pubkey->arr_len == 32);
43257         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
43258         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43259         *ret_copy = SocketAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
43260         int64_t ret_ref = tag_ptr(ret_copy, true);
43261         return ret_ref;
43262 }
43263
43264 int64_t  CS_LDK_SocketAddress_hostname(int64_t hostname, int16_t port) {
43265         LDKHostname hostname_conv;
43266         hostname_conv.inner = untag_ptr(hostname);
43267         hostname_conv.is_owned = ptr_is_owned(hostname);
43268         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
43269         hostname_conv = Hostname_clone(&hostname_conv);
43270         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43271         *ret_copy = SocketAddress_hostname(hostname_conv, port);
43272         int64_t ret_ref = tag_ptr(ret_copy, true);
43273         return ret_ref;
43274 }
43275
43276 jboolean  CS_LDK_SocketAddress_eq(int64_t a, int64_t b) {
43277         LDKSocketAddress* a_conv = (LDKSocketAddress*)untag_ptr(a);
43278         LDKSocketAddress* b_conv = (LDKSocketAddress*)untag_ptr(b);
43279         jboolean ret_conv = SocketAddress_eq(a_conv, b_conv);
43280         return ret_conv;
43281 }
43282
43283 int8_tArray  CS_LDK_SocketAddress_write(int64_t obj) {
43284         LDKSocketAddress* obj_conv = (LDKSocketAddress*)untag_ptr(obj);
43285         LDKCVec_u8Z ret_var = SocketAddress_write(obj_conv);
43286         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43287         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43288         CVec_u8Z_free(ret_var);
43289         return ret_arr;
43290 }
43291
43292 int64_t  CS_LDK_SocketAddress_read(int8_tArray ser) {
43293         LDKu8slice ser_ref;
43294         ser_ref.datalen = ser->arr_len;
43295         ser_ref.data = ser->elems;
43296         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
43297         *ret_conv = SocketAddress_read(ser_ref);
43298         FREE(ser);
43299         return tag_ptr(ret_conv, true);
43300 }
43301
43302 int32_t  CS_LDK_SocketAddressParseError_clone(int64_t orig) {
43303         LDKSocketAddressParseError* orig_conv = (LDKSocketAddressParseError*)untag_ptr(orig);
43304         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_clone(orig_conv));
43305         return ret_conv;
43306 }
43307
43308 int32_t  CS_LDK_SocketAddressParseError_socket_addr_parse() {
43309         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_socket_addr_parse());
43310         return ret_conv;
43311 }
43312
43313 int32_t  CS_LDK_SocketAddressParseError_invalid_input() {
43314         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_invalid_input());
43315         return ret_conv;
43316 }
43317
43318 int32_t  CS_LDK_SocketAddressParseError_invalid_port() {
43319         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_invalid_port());
43320         return ret_conv;
43321 }
43322
43323 int32_t  CS_LDK_SocketAddressParseError_invalid_onion_v3() {
43324         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_invalid_onion_v3());
43325         return ret_conv;
43326 }
43327
43328 jboolean  CS_LDK_SocketAddressParseError_eq(int64_t a, int64_t b) {
43329         LDKSocketAddressParseError* a_conv = (LDKSocketAddressParseError*)untag_ptr(a);
43330         LDKSocketAddressParseError* b_conv = (LDKSocketAddressParseError*)untag_ptr(b);
43331         jboolean ret_conv = SocketAddressParseError_eq(a_conv, b_conv);
43332         return ret_conv;
43333 }
43334
43335 int64_t  CS_LDK_parse_onion_address(jstring host, int16_t port) {
43336         LDKStr host_conv = str_ref_to_owned_c(host);
43337         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
43338         *ret_conv = parse_onion_address(host_conv, port);
43339         return tag_ptr(ret_conv, true);
43340 }
43341
43342 jstring  CS_LDK_SocketAddress_to_str(int64_t o) {
43343         LDKSocketAddress* o_conv = (LDKSocketAddress*)untag_ptr(o);
43344         LDKStr ret_str = SocketAddress_to_str(o_conv);
43345         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
43346         Str_free(ret_str);
43347         return ret_conv;
43348 }
43349
43350 int64_t  CS_LDK_SocketAddress_from_str(jstring s) {
43351         LDKStr s_conv = str_ref_to_owned_c(s);
43352         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
43353         *ret_conv = SocketAddress_from_str(s_conv);
43354         return tag_ptr(ret_conv, true);
43355 }
43356
43357 void  CS_LDK_UnsignedGossipMessage_free(int64_t this_ptr) {
43358         if (!ptr_is_owned(this_ptr)) return;
43359         void* this_ptr_ptr = untag_ptr(this_ptr);
43360         CHECK_ACCESS(this_ptr_ptr);
43361         LDKUnsignedGossipMessage this_ptr_conv = *(LDKUnsignedGossipMessage*)(this_ptr_ptr);
43362         FREE(untag_ptr(this_ptr));
43363         UnsignedGossipMessage_free(this_ptr_conv);
43364 }
43365
43366 static inline uint64_t UnsignedGossipMessage_clone_ptr(LDKUnsignedGossipMessage *NONNULL_PTR arg) {
43367         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43368         *ret_copy = UnsignedGossipMessage_clone(arg);
43369         int64_t ret_ref = tag_ptr(ret_copy, true);
43370         return ret_ref;
43371 }
43372 int64_t  CS_LDK_UnsignedGossipMessage_clone_ptr(int64_t arg) {
43373         LDKUnsignedGossipMessage* arg_conv = (LDKUnsignedGossipMessage*)untag_ptr(arg);
43374         int64_t ret_conv = UnsignedGossipMessage_clone_ptr(arg_conv);
43375         return ret_conv;
43376 }
43377
43378 int64_t  CS_LDK_UnsignedGossipMessage_clone(int64_t orig) {
43379         LDKUnsignedGossipMessage* orig_conv = (LDKUnsignedGossipMessage*)untag_ptr(orig);
43380         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43381         *ret_copy = UnsignedGossipMessage_clone(orig_conv);
43382         int64_t ret_ref = tag_ptr(ret_copy, true);
43383         return ret_ref;
43384 }
43385
43386 int64_t  CS_LDK_UnsignedGossipMessage_channel_announcement(int64_t a) {
43387         LDKUnsignedChannelAnnouncement a_conv;
43388         a_conv.inner = untag_ptr(a);
43389         a_conv.is_owned = ptr_is_owned(a);
43390         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43391         a_conv = UnsignedChannelAnnouncement_clone(&a_conv);
43392         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43393         *ret_copy = UnsignedGossipMessage_channel_announcement(a_conv);
43394         int64_t ret_ref = tag_ptr(ret_copy, true);
43395         return ret_ref;
43396 }
43397
43398 int64_t  CS_LDK_UnsignedGossipMessage_channel_update(int64_t a) {
43399         LDKUnsignedChannelUpdate a_conv;
43400         a_conv.inner = untag_ptr(a);
43401         a_conv.is_owned = ptr_is_owned(a);
43402         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43403         a_conv = UnsignedChannelUpdate_clone(&a_conv);
43404         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43405         *ret_copy = UnsignedGossipMessage_channel_update(a_conv);
43406         int64_t ret_ref = tag_ptr(ret_copy, true);
43407         return ret_ref;
43408 }
43409
43410 int64_t  CS_LDK_UnsignedGossipMessage_node_announcement(int64_t a) {
43411         LDKUnsignedNodeAnnouncement a_conv;
43412         a_conv.inner = untag_ptr(a);
43413         a_conv.is_owned = ptr_is_owned(a);
43414         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43415         a_conv = UnsignedNodeAnnouncement_clone(&a_conv);
43416         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43417         *ret_copy = UnsignedGossipMessage_node_announcement(a_conv);
43418         int64_t ret_ref = tag_ptr(ret_copy, true);
43419         return ret_ref;
43420 }
43421
43422 int8_tArray  CS_LDK_UnsignedGossipMessage_write(int64_t obj) {
43423         LDKUnsignedGossipMessage* obj_conv = (LDKUnsignedGossipMessage*)untag_ptr(obj);
43424         LDKCVec_u8Z ret_var = UnsignedGossipMessage_write(obj_conv);
43425         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43426         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43427         CVec_u8Z_free(ret_var);
43428         return ret_arr;
43429 }
43430
43431 void  CS_LDK_UnsignedNodeAnnouncement_free(int64_t this_obj) {
43432         LDKUnsignedNodeAnnouncement this_obj_conv;
43433         this_obj_conv.inner = untag_ptr(this_obj);
43434         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43436         UnsignedNodeAnnouncement_free(this_obj_conv);
43437 }
43438
43439 int64_t  CS_LDK_UnsignedNodeAnnouncement_get_features(int64_t this_ptr) {
43440         LDKUnsignedNodeAnnouncement this_ptr_conv;
43441         this_ptr_conv.inner = untag_ptr(this_ptr);
43442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43444         this_ptr_conv.is_owned = false;
43445         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
43446         int64_t ret_ref = 0;
43447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43449         return ret_ref;
43450 }
43451
43452 void  CS_LDK_UnsignedNodeAnnouncement_set_features(int64_t this_ptr, int64_t val) {
43453         LDKUnsignedNodeAnnouncement this_ptr_conv;
43454         this_ptr_conv.inner = untag_ptr(this_ptr);
43455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43457         this_ptr_conv.is_owned = false;
43458         LDKNodeFeatures val_conv;
43459         val_conv.inner = untag_ptr(val);
43460         val_conv.is_owned = ptr_is_owned(val);
43461         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43462         val_conv = NodeFeatures_clone(&val_conv);
43463         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
43464 }
43465
43466 int32_t  CS_LDK_UnsignedNodeAnnouncement_get_timestamp(int64_t this_ptr) {
43467         LDKUnsignedNodeAnnouncement this_ptr_conv;
43468         this_ptr_conv.inner = untag_ptr(this_ptr);
43469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43471         this_ptr_conv.is_owned = false;
43472         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
43473         return ret_conv;
43474 }
43475
43476 void  CS_LDK_UnsignedNodeAnnouncement_set_timestamp(int64_t this_ptr, int32_t val) {
43477         LDKUnsignedNodeAnnouncement this_ptr_conv;
43478         this_ptr_conv.inner = untag_ptr(this_ptr);
43479         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43481         this_ptr_conv.is_owned = false;
43482         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
43483 }
43484
43485 int64_t  CS_LDK_UnsignedNodeAnnouncement_get_node_id(int64_t this_ptr) {
43486         LDKUnsignedNodeAnnouncement this_ptr_conv;
43487         this_ptr_conv.inner = untag_ptr(this_ptr);
43488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43490         this_ptr_conv.is_owned = false;
43491         LDKNodeId ret_var = UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv);
43492         int64_t ret_ref = 0;
43493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43494         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43495         return ret_ref;
43496 }
43497
43498 void  CS_LDK_UnsignedNodeAnnouncement_set_node_id(int64_t this_ptr, int64_t val) {
43499         LDKUnsignedNodeAnnouncement this_ptr_conv;
43500         this_ptr_conv.inner = untag_ptr(this_ptr);
43501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43503         this_ptr_conv.is_owned = false;
43504         LDKNodeId val_conv;
43505         val_conv.inner = untag_ptr(val);
43506         val_conv.is_owned = ptr_is_owned(val);
43507         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43508         val_conv = NodeId_clone(&val_conv);
43509         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_conv);
43510 }
43511
43512 int8_tArray  CS_LDK_UnsignedNodeAnnouncement_get_rgb(int64_t this_ptr) {
43513         LDKUnsignedNodeAnnouncement this_ptr_conv;
43514         this_ptr_conv.inner = untag_ptr(this_ptr);
43515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43517         this_ptr_conv.is_owned = false;
43518         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
43519         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
43520         return ret_arr;
43521 }
43522
43523 void  CS_LDK_UnsignedNodeAnnouncement_set_rgb(int64_t this_ptr, int8_tArray val) {
43524         LDKUnsignedNodeAnnouncement this_ptr_conv;
43525         this_ptr_conv.inner = untag_ptr(this_ptr);
43526         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43528         this_ptr_conv.is_owned = false;
43529         LDKThreeBytes val_ref;
43530         CHECK(val->arr_len == 3);
43531         memcpy(val_ref.data, val->elems, 3); FREE(val);
43532         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
43533 }
43534
43535 int64_t  CS_LDK_UnsignedNodeAnnouncement_get_alias(int64_t this_ptr) {
43536         LDKUnsignedNodeAnnouncement this_ptr_conv;
43537         this_ptr_conv.inner = untag_ptr(this_ptr);
43538         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43540         this_ptr_conv.is_owned = false;
43541         LDKNodeAlias ret_var = UnsignedNodeAnnouncement_get_alias(&this_ptr_conv);
43542         int64_t ret_ref = 0;
43543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43544         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43545         return ret_ref;
43546 }
43547
43548 void  CS_LDK_UnsignedNodeAnnouncement_set_alias(int64_t this_ptr, int64_t val) {
43549         LDKUnsignedNodeAnnouncement this_ptr_conv;
43550         this_ptr_conv.inner = untag_ptr(this_ptr);
43551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43553         this_ptr_conv.is_owned = false;
43554         LDKNodeAlias val_conv;
43555         val_conv.inner = untag_ptr(val);
43556         val_conv.is_owned = ptr_is_owned(val);
43557         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43558         val_conv = NodeAlias_clone(&val_conv);
43559         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_conv);
43560 }
43561
43562 int64_tArray  CS_LDK_UnsignedNodeAnnouncement_get_addresses(int64_t this_ptr) {
43563         LDKUnsignedNodeAnnouncement this_ptr_conv;
43564         this_ptr_conv.inner = untag_ptr(this_ptr);
43565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43567         this_ptr_conv.is_owned = false;
43568         LDKCVec_SocketAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
43569         int64_tArray ret_arr = NULL;
43570         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
43571         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
43572         for (size_t p = 0; p < ret_var.datalen; p++) {
43573                 LDKSocketAddress *ret_conv_15_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43574                 *ret_conv_15_copy = ret_var.data[p];
43575                 int64_t ret_conv_15_ref = tag_ptr(ret_conv_15_copy, true);
43576                 ret_arr_ptr[p] = ret_conv_15_ref;
43577         }
43578         
43579         FREE(ret_var.data);
43580         return ret_arr;
43581 }
43582
43583 void  CS_LDK_UnsignedNodeAnnouncement_set_addresses(int64_t this_ptr, int64_tArray val) {
43584         LDKUnsignedNodeAnnouncement this_ptr_conv;
43585         this_ptr_conv.inner = untag_ptr(this_ptr);
43586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43588         this_ptr_conv.is_owned = false;
43589         LDKCVec_SocketAddressZ val_constr;
43590         val_constr.datalen = val->arr_len;
43591         if (val_constr.datalen > 0)
43592                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSocketAddress), "LDKCVec_SocketAddressZ Elements");
43593         else
43594                 val_constr.data = NULL;
43595         int64_t* val_vals = val->elems;
43596         for (size_t p = 0; p < val_constr.datalen; p++) {
43597                 int64_t val_conv_15 = val_vals[p];
43598                 void* val_conv_15_ptr = untag_ptr(val_conv_15);
43599                 CHECK_ACCESS(val_conv_15_ptr);
43600                 LDKSocketAddress val_conv_15_conv = *(LDKSocketAddress*)(val_conv_15_ptr);
43601                 val_conv_15_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(val_conv_15));
43602                 val_constr.data[p] = val_conv_15_conv;
43603         }
43604         FREE(val);
43605         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
43606 }
43607
43608 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
43609         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
43610         int64_t ret_ref = 0;
43611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43612         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43613         return ret_ref;
43614 }
43615 int64_t  CS_LDK_UnsignedNodeAnnouncement_clone_ptr(int64_t arg) {
43616         LDKUnsignedNodeAnnouncement arg_conv;
43617         arg_conv.inner = untag_ptr(arg);
43618         arg_conv.is_owned = ptr_is_owned(arg);
43619         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43620         arg_conv.is_owned = false;
43621         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
43622         return ret_conv;
43623 }
43624
43625 int64_t  CS_LDK_UnsignedNodeAnnouncement_clone(int64_t orig) {
43626         LDKUnsignedNodeAnnouncement orig_conv;
43627         orig_conv.inner = untag_ptr(orig);
43628         orig_conv.is_owned = ptr_is_owned(orig);
43629         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43630         orig_conv.is_owned = false;
43631         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
43632         int64_t ret_ref = 0;
43633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43634         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43635         return ret_ref;
43636 }
43637
43638 jboolean  CS_LDK_UnsignedNodeAnnouncement_eq(int64_t a, int64_t b) {
43639         LDKUnsignedNodeAnnouncement a_conv;
43640         a_conv.inner = untag_ptr(a);
43641         a_conv.is_owned = ptr_is_owned(a);
43642         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43643         a_conv.is_owned = false;
43644         LDKUnsignedNodeAnnouncement b_conv;
43645         b_conv.inner = untag_ptr(b);
43646         b_conv.is_owned = ptr_is_owned(b);
43647         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43648         b_conv.is_owned = false;
43649         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
43650         return ret_conv;
43651 }
43652
43653 void  CS_LDK_NodeAnnouncement_free(int64_t this_obj) {
43654         LDKNodeAnnouncement this_obj_conv;
43655         this_obj_conv.inner = untag_ptr(this_obj);
43656         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43658         NodeAnnouncement_free(this_obj_conv);
43659 }
43660
43661 int8_tArray  CS_LDK_NodeAnnouncement_get_signature(int64_t this_ptr) {
43662         LDKNodeAnnouncement this_ptr_conv;
43663         this_ptr_conv.inner = untag_ptr(this_ptr);
43664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43666         this_ptr_conv.is_owned = false;
43667         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
43668         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
43669         return ret_arr;
43670 }
43671
43672 void  CS_LDK_NodeAnnouncement_set_signature(int64_t this_ptr, int8_tArray val) {
43673         LDKNodeAnnouncement this_ptr_conv;
43674         this_ptr_conv.inner = untag_ptr(this_ptr);
43675         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43677         this_ptr_conv.is_owned = false;
43678         LDKECDSASignature val_ref;
43679         CHECK(val->arr_len == 64);
43680         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
43681         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
43682 }
43683
43684 int64_t  CS_LDK_NodeAnnouncement_get_contents(int64_t this_ptr) {
43685         LDKNodeAnnouncement this_ptr_conv;
43686         this_ptr_conv.inner = untag_ptr(this_ptr);
43687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43689         this_ptr_conv.is_owned = false;
43690         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
43691         int64_t ret_ref = 0;
43692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43694         return ret_ref;
43695 }
43696
43697 void  CS_LDK_NodeAnnouncement_set_contents(int64_t this_ptr, int64_t val) {
43698         LDKNodeAnnouncement this_ptr_conv;
43699         this_ptr_conv.inner = untag_ptr(this_ptr);
43700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43702         this_ptr_conv.is_owned = false;
43703         LDKUnsignedNodeAnnouncement val_conv;
43704         val_conv.inner = untag_ptr(val);
43705         val_conv.is_owned = ptr_is_owned(val);
43706         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43707         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
43708         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
43709 }
43710
43711 int64_t  CS_LDK_NodeAnnouncement_new(int8_tArray signature_arg, int64_t contents_arg) {
43712         LDKECDSASignature signature_arg_ref;
43713         CHECK(signature_arg->arr_len == 64);
43714         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
43715         LDKUnsignedNodeAnnouncement contents_arg_conv;
43716         contents_arg_conv.inner = untag_ptr(contents_arg);
43717         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
43718         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
43719         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
43720         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
43721         int64_t ret_ref = 0;
43722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43723         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43724         return ret_ref;
43725 }
43726
43727 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
43728         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
43729         int64_t ret_ref = 0;
43730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43731         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43732         return ret_ref;
43733 }
43734 int64_t  CS_LDK_NodeAnnouncement_clone_ptr(int64_t arg) {
43735         LDKNodeAnnouncement arg_conv;
43736         arg_conv.inner = untag_ptr(arg);
43737         arg_conv.is_owned = ptr_is_owned(arg);
43738         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43739         arg_conv.is_owned = false;
43740         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
43741         return ret_conv;
43742 }
43743
43744 int64_t  CS_LDK_NodeAnnouncement_clone(int64_t orig) {
43745         LDKNodeAnnouncement orig_conv;
43746         orig_conv.inner = untag_ptr(orig);
43747         orig_conv.is_owned = ptr_is_owned(orig);
43748         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43749         orig_conv.is_owned = false;
43750         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
43751         int64_t ret_ref = 0;
43752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43754         return ret_ref;
43755 }
43756
43757 jboolean  CS_LDK_NodeAnnouncement_eq(int64_t a, int64_t b) {
43758         LDKNodeAnnouncement a_conv;
43759         a_conv.inner = untag_ptr(a);
43760         a_conv.is_owned = ptr_is_owned(a);
43761         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43762         a_conv.is_owned = false;
43763         LDKNodeAnnouncement b_conv;
43764         b_conv.inner = untag_ptr(b);
43765         b_conv.is_owned = ptr_is_owned(b);
43766         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43767         b_conv.is_owned = false;
43768         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
43769         return ret_conv;
43770 }
43771
43772 void  CS_LDK_UnsignedChannelAnnouncement_free(int64_t this_obj) {
43773         LDKUnsignedChannelAnnouncement this_obj_conv;
43774         this_obj_conv.inner = untag_ptr(this_obj);
43775         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43777         UnsignedChannelAnnouncement_free(this_obj_conv);
43778 }
43779
43780 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_features(int64_t this_ptr) {
43781         LDKUnsignedChannelAnnouncement this_ptr_conv;
43782         this_ptr_conv.inner = untag_ptr(this_ptr);
43783         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43785         this_ptr_conv.is_owned = false;
43786         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
43787         int64_t ret_ref = 0;
43788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43789         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43790         return ret_ref;
43791 }
43792
43793 void  CS_LDK_UnsignedChannelAnnouncement_set_features(int64_t this_ptr, int64_t val) {
43794         LDKUnsignedChannelAnnouncement this_ptr_conv;
43795         this_ptr_conv.inner = untag_ptr(this_ptr);
43796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43798         this_ptr_conv.is_owned = false;
43799         LDKChannelFeatures val_conv;
43800         val_conv.inner = untag_ptr(val);
43801         val_conv.is_owned = ptr_is_owned(val);
43802         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43803         val_conv = ChannelFeatures_clone(&val_conv);
43804         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
43805 }
43806
43807 int8_tArray  CS_LDK_UnsignedChannelAnnouncement_get_chain_hash(int64_t this_ptr) {
43808         LDKUnsignedChannelAnnouncement this_ptr_conv;
43809         this_ptr_conv.inner = untag_ptr(this_ptr);
43810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43812         this_ptr_conv.is_owned = false;
43813         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43814         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
43815         return ret_arr;
43816 }
43817
43818 void  CS_LDK_UnsignedChannelAnnouncement_set_chain_hash(int64_t this_ptr, int8_tArray val) {
43819         LDKUnsignedChannelAnnouncement this_ptr_conv;
43820         this_ptr_conv.inner = untag_ptr(this_ptr);
43821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43823         this_ptr_conv.is_owned = false;
43824         LDKThirtyTwoBytes val_ref;
43825         CHECK(val->arr_len == 32);
43826         memcpy(val_ref.data, val->elems, 32); FREE(val);
43827         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
43828 }
43829
43830 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_short_channel_id(int64_t this_ptr) {
43831         LDKUnsignedChannelAnnouncement this_ptr_conv;
43832         this_ptr_conv.inner = untag_ptr(this_ptr);
43833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43835         this_ptr_conv.is_owned = false;
43836         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
43837         return ret_conv;
43838 }
43839
43840 void  CS_LDK_UnsignedChannelAnnouncement_set_short_channel_id(int64_t this_ptr, int64_t val) {
43841         LDKUnsignedChannelAnnouncement this_ptr_conv;
43842         this_ptr_conv.inner = untag_ptr(this_ptr);
43843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43845         this_ptr_conv.is_owned = false;
43846         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
43847 }
43848
43849 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_node_id_1(int64_t this_ptr) {
43850         LDKUnsignedChannelAnnouncement this_ptr_conv;
43851         this_ptr_conv.inner = untag_ptr(this_ptr);
43852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43854         this_ptr_conv.is_owned = false;
43855         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv);
43856         int64_t ret_ref = 0;
43857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43859         return ret_ref;
43860 }
43861
43862 void  CS_LDK_UnsignedChannelAnnouncement_set_node_id_1(int64_t this_ptr, int64_t val) {
43863         LDKUnsignedChannelAnnouncement this_ptr_conv;
43864         this_ptr_conv.inner = untag_ptr(this_ptr);
43865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43867         this_ptr_conv.is_owned = false;
43868         LDKNodeId val_conv;
43869         val_conv.inner = untag_ptr(val);
43870         val_conv.is_owned = ptr_is_owned(val);
43871         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43872         val_conv = NodeId_clone(&val_conv);
43873         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_conv);
43874 }
43875
43876 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_node_id_2(int64_t this_ptr) {
43877         LDKUnsignedChannelAnnouncement this_ptr_conv;
43878         this_ptr_conv.inner = untag_ptr(this_ptr);
43879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43881         this_ptr_conv.is_owned = false;
43882         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv);
43883         int64_t ret_ref = 0;
43884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43886         return ret_ref;
43887 }
43888
43889 void  CS_LDK_UnsignedChannelAnnouncement_set_node_id_2(int64_t this_ptr, int64_t val) {
43890         LDKUnsignedChannelAnnouncement this_ptr_conv;
43891         this_ptr_conv.inner = untag_ptr(this_ptr);
43892         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43894         this_ptr_conv.is_owned = false;
43895         LDKNodeId val_conv;
43896         val_conv.inner = untag_ptr(val);
43897         val_conv.is_owned = ptr_is_owned(val);
43898         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43899         val_conv = NodeId_clone(&val_conv);
43900         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_conv);
43901 }
43902
43903 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_bitcoin_key_1(int64_t this_ptr) {
43904         LDKUnsignedChannelAnnouncement this_ptr_conv;
43905         this_ptr_conv.inner = untag_ptr(this_ptr);
43906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43908         this_ptr_conv.is_owned = false;
43909         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv);
43910         int64_t ret_ref = 0;
43911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43913         return ret_ref;
43914 }
43915
43916 void  CS_LDK_UnsignedChannelAnnouncement_set_bitcoin_key_1(int64_t this_ptr, int64_t val) {
43917         LDKUnsignedChannelAnnouncement this_ptr_conv;
43918         this_ptr_conv.inner = untag_ptr(this_ptr);
43919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43921         this_ptr_conv.is_owned = false;
43922         LDKNodeId val_conv;
43923         val_conv.inner = untag_ptr(val);
43924         val_conv.is_owned = ptr_is_owned(val);
43925         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43926         val_conv = NodeId_clone(&val_conv);
43927         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_conv);
43928 }
43929
43930 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_bitcoin_key_2(int64_t this_ptr) {
43931         LDKUnsignedChannelAnnouncement this_ptr_conv;
43932         this_ptr_conv.inner = untag_ptr(this_ptr);
43933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43935         this_ptr_conv.is_owned = false;
43936         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv);
43937         int64_t ret_ref = 0;
43938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43940         return ret_ref;
43941 }
43942
43943 void  CS_LDK_UnsignedChannelAnnouncement_set_bitcoin_key_2(int64_t this_ptr, int64_t val) {
43944         LDKUnsignedChannelAnnouncement this_ptr_conv;
43945         this_ptr_conv.inner = untag_ptr(this_ptr);
43946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43948         this_ptr_conv.is_owned = false;
43949         LDKNodeId val_conv;
43950         val_conv.inner = untag_ptr(val);
43951         val_conv.is_owned = ptr_is_owned(val);
43952         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43953         val_conv = NodeId_clone(&val_conv);
43954         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_conv);
43955 }
43956
43957 int8_tArray  CS_LDK_UnsignedChannelAnnouncement_get_excess_data(int64_t this_ptr) {
43958         LDKUnsignedChannelAnnouncement this_ptr_conv;
43959         this_ptr_conv.inner = untag_ptr(this_ptr);
43960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43962         this_ptr_conv.is_owned = false;
43963         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_get_excess_data(&this_ptr_conv);
43964         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43965         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43966         CVec_u8Z_free(ret_var);
43967         return ret_arr;
43968 }
43969
43970 void  CS_LDK_UnsignedChannelAnnouncement_set_excess_data(int64_t this_ptr, int8_tArray val) {
43971         LDKUnsignedChannelAnnouncement this_ptr_conv;
43972         this_ptr_conv.inner = untag_ptr(this_ptr);
43973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43975         this_ptr_conv.is_owned = false;
43976         LDKCVec_u8Z val_ref;
43977         val_ref.datalen = val->arr_len;
43978         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
43979         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
43980         UnsignedChannelAnnouncement_set_excess_data(&this_ptr_conv, val_ref);
43981 }
43982
43983 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) {
43984         LDKChannelFeatures features_arg_conv;
43985         features_arg_conv.inner = untag_ptr(features_arg);
43986         features_arg_conv.is_owned = ptr_is_owned(features_arg);
43987         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
43988         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
43989         LDKThirtyTwoBytes chain_hash_arg_ref;
43990         CHECK(chain_hash_arg->arr_len == 32);
43991         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
43992         LDKNodeId node_id_1_arg_conv;
43993         node_id_1_arg_conv.inner = untag_ptr(node_id_1_arg);
43994         node_id_1_arg_conv.is_owned = ptr_is_owned(node_id_1_arg);
43995         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_1_arg_conv);
43996         node_id_1_arg_conv = NodeId_clone(&node_id_1_arg_conv);
43997         LDKNodeId node_id_2_arg_conv;
43998         node_id_2_arg_conv.inner = untag_ptr(node_id_2_arg);
43999         node_id_2_arg_conv.is_owned = ptr_is_owned(node_id_2_arg);
44000         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_2_arg_conv);
44001         node_id_2_arg_conv = NodeId_clone(&node_id_2_arg_conv);
44002         LDKNodeId bitcoin_key_1_arg_conv;
44003         bitcoin_key_1_arg_conv.inner = untag_ptr(bitcoin_key_1_arg);
44004         bitcoin_key_1_arg_conv.is_owned = ptr_is_owned(bitcoin_key_1_arg);
44005         CHECK_INNER_FIELD_ACCESS_OR_NULL(bitcoin_key_1_arg_conv);
44006         bitcoin_key_1_arg_conv = NodeId_clone(&bitcoin_key_1_arg_conv);
44007         LDKNodeId bitcoin_key_2_arg_conv;
44008         bitcoin_key_2_arg_conv.inner = untag_ptr(bitcoin_key_2_arg);
44009         bitcoin_key_2_arg_conv.is_owned = ptr_is_owned(bitcoin_key_2_arg);
44010         CHECK_INNER_FIELD_ACCESS_OR_NULL(bitcoin_key_2_arg_conv);
44011         bitcoin_key_2_arg_conv = NodeId_clone(&bitcoin_key_2_arg_conv);
44012         LDKCVec_u8Z excess_data_arg_ref;
44013         excess_data_arg_ref.datalen = excess_data_arg->arr_len;
44014         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
44015         memcpy(excess_data_arg_ref.data, excess_data_arg->elems, excess_data_arg_ref.datalen); FREE(excess_data_arg);
44016         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);
44017         int64_t ret_ref = 0;
44018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44020         return ret_ref;
44021 }
44022
44023 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
44024         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
44025         int64_t ret_ref = 0;
44026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44027         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44028         return ret_ref;
44029 }
44030 int64_t  CS_LDK_UnsignedChannelAnnouncement_clone_ptr(int64_t arg) {
44031         LDKUnsignedChannelAnnouncement arg_conv;
44032         arg_conv.inner = untag_ptr(arg);
44033         arg_conv.is_owned = ptr_is_owned(arg);
44034         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44035         arg_conv.is_owned = false;
44036         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
44037         return ret_conv;
44038 }
44039
44040 int64_t  CS_LDK_UnsignedChannelAnnouncement_clone(int64_t orig) {
44041         LDKUnsignedChannelAnnouncement orig_conv;
44042         orig_conv.inner = untag_ptr(orig);
44043         orig_conv.is_owned = ptr_is_owned(orig);
44044         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44045         orig_conv.is_owned = false;
44046         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
44047         int64_t ret_ref = 0;
44048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44050         return ret_ref;
44051 }
44052
44053 jboolean  CS_LDK_UnsignedChannelAnnouncement_eq(int64_t a, int64_t b) {
44054         LDKUnsignedChannelAnnouncement a_conv;
44055         a_conv.inner = untag_ptr(a);
44056         a_conv.is_owned = ptr_is_owned(a);
44057         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44058         a_conv.is_owned = false;
44059         LDKUnsignedChannelAnnouncement b_conv;
44060         b_conv.inner = untag_ptr(b);
44061         b_conv.is_owned = ptr_is_owned(b);
44062         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44063         b_conv.is_owned = false;
44064         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
44065         return ret_conv;
44066 }
44067
44068 void  CS_LDK_ChannelAnnouncement_free(int64_t this_obj) {
44069         LDKChannelAnnouncement this_obj_conv;
44070         this_obj_conv.inner = untag_ptr(this_obj);
44071         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44073         ChannelAnnouncement_free(this_obj_conv);
44074 }
44075
44076 int8_tArray  CS_LDK_ChannelAnnouncement_get_node_signature_1(int64_t this_ptr) {
44077         LDKChannelAnnouncement this_ptr_conv;
44078         this_ptr_conv.inner = untag_ptr(this_ptr);
44079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44081         this_ptr_conv.is_owned = false;
44082         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44083         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
44084         return ret_arr;
44085 }
44086
44087 void  CS_LDK_ChannelAnnouncement_set_node_signature_1(int64_t this_ptr, int8_tArray val) {
44088         LDKChannelAnnouncement this_ptr_conv;
44089         this_ptr_conv.inner = untag_ptr(this_ptr);
44090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44092         this_ptr_conv.is_owned = false;
44093         LDKECDSASignature val_ref;
44094         CHECK(val->arr_len == 64);
44095         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44096         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
44097 }
44098
44099 int8_tArray  CS_LDK_ChannelAnnouncement_get_node_signature_2(int64_t this_ptr) {
44100         LDKChannelAnnouncement this_ptr_conv;
44101         this_ptr_conv.inner = untag_ptr(this_ptr);
44102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44104         this_ptr_conv.is_owned = false;
44105         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44106         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
44107         return ret_arr;
44108 }
44109
44110 void  CS_LDK_ChannelAnnouncement_set_node_signature_2(int64_t this_ptr, int8_tArray val) {
44111         LDKChannelAnnouncement this_ptr_conv;
44112         this_ptr_conv.inner = untag_ptr(this_ptr);
44113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44115         this_ptr_conv.is_owned = false;
44116         LDKECDSASignature val_ref;
44117         CHECK(val->arr_len == 64);
44118         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44119         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
44120 }
44121
44122 int8_tArray  CS_LDK_ChannelAnnouncement_get_bitcoin_signature_1(int64_t this_ptr) {
44123         LDKChannelAnnouncement this_ptr_conv;
44124         this_ptr_conv.inner = untag_ptr(this_ptr);
44125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44127         this_ptr_conv.is_owned = false;
44128         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44129         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
44130         return ret_arr;
44131 }
44132
44133 void  CS_LDK_ChannelAnnouncement_set_bitcoin_signature_1(int64_t this_ptr, int8_tArray val) {
44134         LDKChannelAnnouncement this_ptr_conv;
44135         this_ptr_conv.inner = untag_ptr(this_ptr);
44136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44138         this_ptr_conv.is_owned = false;
44139         LDKECDSASignature val_ref;
44140         CHECK(val->arr_len == 64);
44141         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44142         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
44143 }
44144
44145 int8_tArray  CS_LDK_ChannelAnnouncement_get_bitcoin_signature_2(int64_t this_ptr) {
44146         LDKChannelAnnouncement this_ptr_conv;
44147         this_ptr_conv.inner = untag_ptr(this_ptr);
44148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44150         this_ptr_conv.is_owned = false;
44151         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44152         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
44153         return ret_arr;
44154 }
44155
44156 void  CS_LDK_ChannelAnnouncement_set_bitcoin_signature_2(int64_t this_ptr, int8_tArray val) {
44157         LDKChannelAnnouncement this_ptr_conv;
44158         this_ptr_conv.inner = untag_ptr(this_ptr);
44159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44161         this_ptr_conv.is_owned = false;
44162         LDKECDSASignature val_ref;
44163         CHECK(val->arr_len == 64);
44164         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44165         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
44166 }
44167
44168 int64_t  CS_LDK_ChannelAnnouncement_get_contents(int64_t this_ptr) {
44169         LDKChannelAnnouncement this_ptr_conv;
44170         this_ptr_conv.inner = untag_ptr(this_ptr);
44171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44173         this_ptr_conv.is_owned = false;
44174         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
44175         int64_t ret_ref = 0;
44176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44178         return ret_ref;
44179 }
44180
44181 void  CS_LDK_ChannelAnnouncement_set_contents(int64_t this_ptr, int64_t val) {
44182         LDKChannelAnnouncement this_ptr_conv;
44183         this_ptr_conv.inner = untag_ptr(this_ptr);
44184         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44186         this_ptr_conv.is_owned = false;
44187         LDKUnsignedChannelAnnouncement val_conv;
44188         val_conv.inner = untag_ptr(val);
44189         val_conv.is_owned = ptr_is_owned(val);
44190         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44191         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
44192         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
44193 }
44194
44195 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) {
44196         LDKECDSASignature node_signature_1_arg_ref;
44197         CHECK(node_signature_1_arg->arr_len == 64);
44198         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
44199         LDKECDSASignature node_signature_2_arg_ref;
44200         CHECK(node_signature_2_arg->arr_len == 64);
44201         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
44202         LDKECDSASignature bitcoin_signature_1_arg_ref;
44203         CHECK(bitcoin_signature_1_arg->arr_len == 64);
44204         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
44205         LDKECDSASignature bitcoin_signature_2_arg_ref;
44206         CHECK(bitcoin_signature_2_arg->arr_len == 64);
44207         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
44208         LDKUnsignedChannelAnnouncement contents_arg_conv;
44209         contents_arg_conv.inner = untag_ptr(contents_arg);
44210         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
44211         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
44212         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
44213         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);
44214         int64_t ret_ref = 0;
44215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44217         return ret_ref;
44218 }
44219
44220 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
44221         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
44222         int64_t ret_ref = 0;
44223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44225         return ret_ref;
44226 }
44227 int64_t  CS_LDK_ChannelAnnouncement_clone_ptr(int64_t arg) {
44228         LDKChannelAnnouncement arg_conv;
44229         arg_conv.inner = untag_ptr(arg);
44230         arg_conv.is_owned = ptr_is_owned(arg);
44231         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44232         arg_conv.is_owned = false;
44233         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
44234         return ret_conv;
44235 }
44236
44237 int64_t  CS_LDK_ChannelAnnouncement_clone(int64_t orig) {
44238         LDKChannelAnnouncement orig_conv;
44239         orig_conv.inner = untag_ptr(orig);
44240         orig_conv.is_owned = ptr_is_owned(orig);
44241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44242         orig_conv.is_owned = false;
44243         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
44244         int64_t ret_ref = 0;
44245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44247         return ret_ref;
44248 }
44249
44250 jboolean  CS_LDK_ChannelAnnouncement_eq(int64_t a, int64_t b) {
44251         LDKChannelAnnouncement a_conv;
44252         a_conv.inner = untag_ptr(a);
44253         a_conv.is_owned = ptr_is_owned(a);
44254         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44255         a_conv.is_owned = false;
44256         LDKChannelAnnouncement b_conv;
44257         b_conv.inner = untag_ptr(b);
44258         b_conv.is_owned = ptr_is_owned(b);
44259         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44260         b_conv.is_owned = false;
44261         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
44262         return ret_conv;
44263 }
44264
44265 void  CS_LDK_UnsignedChannelUpdate_free(int64_t this_obj) {
44266         LDKUnsignedChannelUpdate this_obj_conv;
44267         this_obj_conv.inner = untag_ptr(this_obj);
44268         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44270         UnsignedChannelUpdate_free(this_obj_conv);
44271 }
44272
44273 int8_tArray  CS_LDK_UnsignedChannelUpdate_get_chain_hash(int64_t this_ptr) {
44274         LDKUnsignedChannelUpdate this_ptr_conv;
44275         this_ptr_conv.inner = untag_ptr(this_ptr);
44276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44278         this_ptr_conv.is_owned = false;
44279         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44280         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
44281         return ret_arr;
44282 }
44283
44284 void  CS_LDK_UnsignedChannelUpdate_set_chain_hash(int64_t this_ptr, int8_tArray val) {
44285         LDKUnsignedChannelUpdate this_ptr_conv;
44286         this_ptr_conv.inner = untag_ptr(this_ptr);
44287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44289         this_ptr_conv.is_owned = false;
44290         LDKThirtyTwoBytes val_ref;
44291         CHECK(val->arr_len == 32);
44292         memcpy(val_ref.data, val->elems, 32); FREE(val);
44293         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
44294 }
44295
44296 int64_t  CS_LDK_UnsignedChannelUpdate_get_short_channel_id(int64_t this_ptr) {
44297         LDKUnsignedChannelUpdate this_ptr_conv;
44298         this_ptr_conv.inner = untag_ptr(this_ptr);
44299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44301         this_ptr_conv.is_owned = false;
44302         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
44303         return ret_conv;
44304 }
44305
44306 void  CS_LDK_UnsignedChannelUpdate_set_short_channel_id(int64_t this_ptr, int64_t val) {
44307         LDKUnsignedChannelUpdate this_ptr_conv;
44308         this_ptr_conv.inner = untag_ptr(this_ptr);
44309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44311         this_ptr_conv.is_owned = false;
44312         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
44313 }
44314
44315 int32_t  CS_LDK_UnsignedChannelUpdate_get_timestamp(int64_t this_ptr) {
44316         LDKUnsignedChannelUpdate this_ptr_conv;
44317         this_ptr_conv.inner = untag_ptr(this_ptr);
44318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44320         this_ptr_conv.is_owned = false;
44321         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
44322         return ret_conv;
44323 }
44324
44325 void  CS_LDK_UnsignedChannelUpdate_set_timestamp(int64_t this_ptr, int32_t val) {
44326         LDKUnsignedChannelUpdate this_ptr_conv;
44327         this_ptr_conv.inner = untag_ptr(this_ptr);
44328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44330         this_ptr_conv.is_owned = false;
44331         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
44332 }
44333
44334 int8_t  CS_LDK_UnsignedChannelUpdate_get_flags(int64_t this_ptr) {
44335         LDKUnsignedChannelUpdate this_ptr_conv;
44336         this_ptr_conv.inner = untag_ptr(this_ptr);
44337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44339         this_ptr_conv.is_owned = false;
44340         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
44341         return ret_conv;
44342 }
44343
44344 void  CS_LDK_UnsignedChannelUpdate_set_flags(int64_t this_ptr, int8_t val) {
44345         LDKUnsignedChannelUpdate this_ptr_conv;
44346         this_ptr_conv.inner = untag_ptr(this_ptr);
44347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44349         this_ptr_conv.is_owned = false;
44350         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
44351 }
44352
44353 int16_t  CS_LDK_UnsignedChannelUpdate_get_cltv_expiry_delta(int64_t this_ptr) {
44354         LDKUnsignedChannelUpdate this_ptr_conv;
44355         this_ptr_conv.inner = untag_ptr(this_ptr);
44356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44358         this_ptr_conv.is_owned = false;
44359         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
44360         return ret_conv;
44361 }
44362
44363 void  CS_LDK_UnsignedChannelUpdate_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
44364         LDKUnsignedChannelUpdate this_ptr_conv;
44365         this_ptr_conv.inner = untag_ptr(this_ptr);
44366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44368         this_ptr_conv.is_owned = false;
44369         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
44370 }
44371
44372 int64_t  CS_LDK_UnsignedChannelUpdate_get_htlc_minimum_msat(int64_t this_ptr) {
44373         LDKUnsignedChannelUpdate this_ptr_conv;
44374         this_ptr_conv.inner = untag_ptr(this_ptr);
44375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44377         this_ptr_conv.is_owned = false;
44378         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
44379         return ret_conv;
44380 }
44381
44382 void  CS_LDK_UnsignedChannelUpdate_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
44383         LDKUnsignedChannelUpdate this_ptr_conv;
44384         this_ptr_conv.inner = untag_ptr(this_ptr);
44385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44387         this_ptr_conv.is_owned = false;
44388         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
44389 }
44390
44391 int64_t  CS_LDK_UnsignedChannelUpdate_get_htlc_maximum_msat(int64_t this_ptr) {
44392         LDKUnsignedChannelUpdate this_ptr_conv;
44393         this_ptr_conv.inner = untag_ptr(this_ptr);
44394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44396         this_ptr_conv.is_owned = false;
44397         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
44398         return ret_conv;
44399 }
44400
44401 void  CS_LDK_UnsignedChannelUpdate_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
44402         LDKUnsignedChannelUpdate this_ptr_conv;
44403         this_ptr_conv.inner = untag_ptr(this_ptr);
44404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44406         this_ptr_conv.is_owned = false;
44407         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
44408 }
44409
44410 int32_t  CS_LDK_UnsignedChannelUpdate_get_fee_base_msat(int64_t this_ptr) {
44411         LDKUnsignedChannelUpdate this_ptr_conv;
44412         this_ptr_conv.inner = untag_ptr(this_ptr);
44413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44415         this_ptr_conv.is_owned = false;
44416         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
44417         return ret_conv;
44418 }
44419
44420 void  CS_LDK_UnsignedChannelUpdate_set_fee_base_msat(int64_t this_ptr, int32_t val) {
44421         LDKUnsignedChannelUpdate this_ptr_conv;
44422         this_ptr_conv.inner = untag_ptr(this_ptr);
44423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44425         this_ptr_conv.is_owned = false;
44426         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
44427 }
44428
44429 int32_t  CS_LDK_UnsignedChannelUpdate_get_fee_proportional_millionths(int64_t this_ptr) {
44430         LDKUnsignedChannelUpdate this_ptr_conv;
44431         this_ptr_conv.inner = untag_ptr(this_ptr);
44432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44434         this_ptr_conv.is_owned = false;
44435         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
44436         return ret_conv;
44437 }
44438
44439 void  CS_LDK_UnsignedChannelUpdate_set_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
44440         LDKUnsignedChannelUpdate this_ptr_conv;
44441         this_ptr_conv.inner = untag_ptr(this_ptr);
44442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44444         this_ptr_conv.is_owned = false;
44445         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
44446 }
44447
44448 int8_tArray  CS_LDK_UnsignedChannelUpdate_get_excess_data(int64_t this_ptr) {
44449         LDKUnsignedChannelUpdate this_ptr_conv;
44450         this_ptr_conv.inner = untag_ptr(this_ptr);
44451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44453         this_ptr_conv.is_owned = false;
44454         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
44455         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
44456         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
44457         CVec_u8Z_free(ret_var);
44458         return ret_arr;
44459 }
44460
44461 void  CS_LDK_UnsignedChannelUpdate_set_excess_data(int64_t this_ptr, int8_tArray val) {
44462         LDKUnsignedChannelUpdate this_ptr_conv;
44463         this_ptr_conv.inner = untag_ptr(this_ptr);
44464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44466         this_ptr_conv.is_owned = false;
44467         LDKCVec_u8Z val_ref;
44468         val_ref.datalen = val->arr_len;
44469         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
44470         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
44471         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
44472 }
44473
44474 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) {
44475         LDKThirtyTwoBytes chain_hash_arg_ref;
44476         CHECK(chain_hash_arg->arr_len == 32);
44477         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
44478         LDKCVec_u8Z excess_data_arg_ref;
44479         excess_data_arg_ref.datalen = excess_data_arg->arr_len;
44480         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
44481         memcpy(excess_data_arg_ref.data, excess_data_arg->elems, excess_data_arg_ref.datalen); FREE(excess_data_arg);
44482         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);
44483         int64_t ret_ref = 0;
44484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44486         return ret_ref;
44487 }
44488
44489 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
44490         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
44491         int64_t ret_ref = 0;
44492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44493         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44494         return ret_ref;
44495 }
44496 int64_t  CS_LDK_UnsignedChannelUpdate_clone_ptr(int64_t arg) {
44497         LDKUnsignedChannelUpdate arg_conv;
44498         arg_conv.inner = untag_ptr(arg);
44499         arg_conv.is_owned = ptr_is_owned(arg);
44500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44501         arg_conv.is_owned = false;
44502         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
44503         return ret_conv;
44504 }
44505
44506 int64_t  CS_LDK_UnsignedChannelUpdate_clone(int64_t orig) {
44507         LDKUnsignedChannelUpdate orig_conv;
44508         orig_conv.inner = untag_ptr(orig);
44509         orig_conv.is_owned = ptr_is_owned(orig);
44510         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44511         orig_conv.is_owned = false;
44512         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
44513         int64_t ret_ref = 0;
44514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44515         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44516         return ret_ref;
44517 }
44518
44519 jboolean  CS_LDK_UnsignedChannelUpdate_eq(int64_t a, int64_t b) {
44520         LDKUnsignedChannelUpdate a_conv;
44521         a_conv.inner = untag_ptr(a);
44522         a_conv.is_owned = ptr_is_owned(a);
44523         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44524         a_conv.is_owned = false;
44525         LDKUnsignedChannelUpdate b_conv;
44526         b_conv.inner = untag_ptr(b);
44527         b_conv.is_owned = ptr_is_owned(b);
44528         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44529         b_conv.is_owned = false;
44530         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
44531         return ret_conv;
44532 }
44533
44534 void  CS_LDK_ChannelUpdate_free(int64_t this_obj) {
44535         LDKChannelUpdate this_obj_conv;
44536         this_obj_conv.inner = untag_ptr(this_obj);
44537         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44539         ChannelUpdate_free(this_obj_conv);
44540 }
44541
44542 int8_tArray  CS_LDK_ChannelUpdate_get_signature(int64_t this_ptr) {
44543         LDKChannelUpdate this_ptr_conv;
44544         this_ptr_conv.inner = untag_ptr(this_ptr);
44545         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44547         this_ptr_conv.is_owned = false;
44548         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44549         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
44550         return ret_arr;
44551 }
44552
44553 void  CS_LDK_ChannelUpdate_set_signature(int64_t this_ptr, int8_tArray val) {
44554         LDKChannelUpdate this_ptr_conv;
44555         this_ptr_conv.inner = untag_ptr(this_ptr);
44556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44558         this_ptr_conv.is_owned = false;
44559         LDKECDSASignature val_ref;
44560         CHECK(val->arr_len == 64);
44561         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44562         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
44563 }
44564
44565 int64_t  CS_LDK_ChannelUpdate_get_contents(int64_t this_ptr) {
44566         LDKChannelUpdate this_ptr_conv;
44567         this_ptr_conv.inner = untag_ptr(this_ptr);
44568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44570         this_ptr_conv.is_owned = false;
44571         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
44572         int64_t ret_ref = 0;
44573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44574         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44575         return ret_ref;
44576 }
44577
44578 void  CS_LDK_ChannelUpdate_set_contents(int64_t this_ptr, int64_t val) {
44579         LDKChannelUpdate this_ptr_conv;
44580         this_ptr_conv.inner = untag_ptr(this_ptr);
44581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44583         this_ptr_conv.is_owned = false;
44584         LDKUnsignedChannelUpdate val_conv;
44585         val_conv.inner = untag_ptr(val);
44586         val_conv.is_owned = ptr_is_owned(val);
44587         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44588         val_conv = UnsignedChannelUpdate_clone(&val_conv);
44589         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
44590 }
44591
44592 int64_t  CS_LDK_ChannelUpdate_new(int8_tArray signature_arg, int64_t contents_arg) {
44593         LDKECDSASignature signature_arg_ref;
44594         CHECK(signature_arg->arr_len == 64);
44595         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
44596         LDKUnsignedChannelUpdate contents_arg_conv;
44597         contents_arg_conv.inner = untag_ptr(contents_arg);
44598         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
44599         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
44600         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
44601         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
44602         int64_t ret_ref = 0;
44603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44604         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44605         return ret_ref;
44606 }
44607
44608 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
44609         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
44610         int64_t ret_ref = 0;
44611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44612         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44613         return ret_ref;
44614 }
44615 int64_t  CS_LDK_ChannelUpdate_clone_ptr(int64_t arg) {
44616         LDKChannelUpdate arg_conv;
44617         arg_conv.inner = untag_ptr(arg);
44618         arg_conv.is_owned = ptr_is_owned(arg);
44619         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44620         arg_conv.is_owned = false;
44621         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
44622         return ret_conv;
44623 }
44624
44625 int64_t  CS_LDK_ChannelUpdate_clone(int64_t orig) {
44626         LDKChannelUpdate orig_conv;
44627         orig_conv.inner = untag_ptr(orig);
44628         orig_conv.is_owned = ptr_is_owned(orig);
44629         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44630         orig_conv.is_owned = false;
44631         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
44632         int64_t ret_ref = 0;
44633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44634         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44635         return ret_ref;
44636 }
44637
44638 jboolean  CS_LDK_ChannelUpdate_eq(int64_t a, int64_t b) {
44639         LDKChannelUpdate a_conv;
44640         a_conv.inner = untag_ptr(a);
44641         a_conv.is_owned = ptr_is_owned(a);
44642         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44643         a_conv.is_owned = false;
44644         LDKChannelUpdate b_conv;
44645         b_conv.inner = untag_ptr(b);
44646         b_conv.is_owned = ptr_is_owned(b);
44647         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44648         b_conv.is_owned = false;
44649         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
44650         return ret_conv;
44651 }
44652
44653 void  CS_LDK_QueryChannelRange_free(int64_t this_obj) {
44654         LDKQueryChannelRange this_obj_conv;
44655         this_obj_conv.inner = untag_ptr(this_obj);
44656         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44658         QueryChannelRange_free(this_obj_conv);
44659 }
44660
44661 int8_tArray  CS_LDK_QueryChannelRange_get_chain_hash(int64_t this_ptr) {
44662         LDKQueryChannelRange this_ptr_conv;
44663         this_ptr_conv.inner = untag_ptr(this_ptr);
44664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44666         this_ptr_conv.is_owned = false;
44667         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44668         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
44669         return ret_arr;
44670 }
44671
44672 void  CS_LDK_QueryChannelRange_set_chain_hash(int64_t this_ptr, int8_tArray val) {
44673         LDKQueryChannelRange this_ptr_conv;
44674         this_ptr_conv.inner = untag_ptr(this_ptr);
44675         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44677         this_ptr_conv.is_owned = false;
44678         LDKThirtyTwoBytes val_ref;
44679         CHECK(val->arr_len == 32);
44680         memcpy(val_ref.data, val->elems, 32); FREE(val);
44681         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
44682 }
44683
44684 int32_t  CS_LDK_QueryChannelRange_get_first_blocknum(int64_t this_ptr) {
44685         LDKQueryChannelRange this_ptr_conv;
44686         this_ptr_conv.inner = untag_ptr(this_ptr);
44687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44689         this_ptr_conv.is_owned = false;
44690         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
44691         return ret_conv;
44692 }
44693
44694 void  CS_LDK_QueryChannelRange_set_first_blocknum(int64_t this_ptr, int32_t val) {
44695         LDKQueryChannelRange this_ptr_conv;
44696         this_ptr_conv.inner = untag_ptr(this_ptr);
44697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44699         this_ptr_conv.is_owned = false;
44700         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
44701 }
44702
44703 int32_t  CS_LDK_QueryChannelRange_get_number_of_blocks(int64_t this_ptr) {
44704         LDKQueryChannelRange this_ptr_conv;
44705         this_ptr_conv.inner = untag_ptr(this_ptr);
44706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44708         this_ptr_conv.is_owned = false;
44709         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
44710         return ret_conv;
44711 }
44712
44713 void  CS_LDK_QueryChannelRange_set_number_of_blocks(int64_t this_ptr, int32_t val) {
44714         LDKQueryChannelRange this_ptr_conv;
44715         this_ptr_conv.inner = untag_ptr(this_ptr);
44716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44718         this_ptr_conv.is_owned = false;
44719         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
44720 }
44721
44722 int64_t  CS_LDK_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
44723         LDKThirtyTwoBytes chain_hash_arg_ref;
44724         CHECK(chain_hash_arg->arr_len == 32);
44725         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
44726         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
44727         int64_t ret_ref = 0;
44728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44730         return ret_ref;
44731 }
44732
44733 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
44734         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
44735         int64_t ret_ref = 0;
44736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44738         return ret_ref;
44739 }
44740 int64_t  CS_LDK_QueryChannelRange_clone_ptr(int64_t arg) {
44741         LDKQueryChannelRange arg_conv;
44742         arg_conv.inner = untag_ptr(arg);
44743         arg_conv.is_owned = ptr_is_owned(arg);
44744         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44745         arg_conv.is_owned = false;
44746         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
44747         return ret_conv;
44748 }
44749
44750 int64_t  CS_LDK_QueryChannelRange_clone(int64_t orig) {
44751         LDKQueryChannelRange orig_conv;
44752         orig_conv.inner = untag_ptr(orig);
44753         orig_conv.is_owned = ptr_is_owned(orig);
44754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44755         orig_conv.is_owned = false;
44756         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
44757         int64_t ret_ref = 0;
44758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44760         return ret_ref;
44761 }
44762
44763 jboolean  CS_LDK_QueryChannelRange_eq(int64_t a, int64_t b) {
44764         LDKQueryChannelRange a_conv;
44765         a_conv.inner = untag_ptr(a);
44766         a_conv.is_owned = ptr_is_owned(a);
44767         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44768         a_conv.is_owned = false;
44769         LDKQueryChannelRange b_conv;
44770         b_conv.inner = untag_ptr(b);
44771         b_conv.is_owned = ptr_is_owned(b);
44772         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44773         b_conv.is_owned = false;
44774         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
44775         return ret_conv;
44776 }
44777
44778 void  CS_LDK_ReplyChannelRange_free(int64_t this_obj) {
44779         LDKReplyChannelRange this_obj_conv;
44780         this_obj_conv.inner = untag_ptr(this_obj);
44781         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44783         ReplyChannelRange_free(this_obj_conv);
44784 }
44785
44786 int8_tArray  CS_LDK_ReplyChannelRange_get_chain_hash(int64_t this_ptr) {
44787         LDKReplyChannelRange this_ptr_conv;
44788         this_ptr_conv.inner = untag_ptr(this_ptr);
44789         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44791         this_ptr_conv.is_owned = false;
44792         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44793         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
44794         return ret_arr;
44795 }
44796
44797 void  CS_LDK_ReplyChannelRange_set_chain_hash(int64_t this_ptr, int8_tArray val) {
44798         LDKReplyChannelRange this_ptr_conv;
44799         this_ptr_conv.inner = untag_ptr(this_ptr);
44800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44802         this_ptr_conv.is_owned = false;
44803         LDKThirtyTwoBytes val_ref;
44804         CHECK(val->arr_len == 32);
44805         memcpy(val_ref.data, val->elems, 32); FREE(val);
44806         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
44807 }
44808
44809 int32_t  CS_LDK_ReplyChannelRange_get_first_blocknum(int64_t this_ptr) {
44810         LDKReplyChannelRange this_ptr_conv;
44811         this_ptr_conv.inner = untag_ptr(this_ptr);
44812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44814         this_ptr_conv.is_owned = false;
44815         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
44816         return ret_conv;
44817 }
44818
44819 void  CS_LDK_ReplyChannelRange_set_first_blocknum(int64_t this_ptr, int32_t val) {
44820         LDKReplyChannelRange this_ptr_conv;
44821         this_ptr_conv.inner = untag_ptr(this_ptr);
44822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44824         this_ptr_conv.is_owned = false;
44825         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
44826 }
44827
44828 int32_t  CS_LDK_ReplyChannelRange_get_number_of_blocks(int64_t this_ptr) {
44829         LDKReplyChannelRange this_ptr_conv;
44830         this_ptr_conv.inner = untag_ptr(this_ptr);
44831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44833         this_ptr_conv.is_owned = false;
44834         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
44835         return ret_conv;
44836 }
44837
44838 void  CS_LDK_ReplyChannelRange_set_number_of_blocks(int64_t this_ptr, int32_t val) {
44839         LDKReplyChannelRange this_ptr_conv;
44840         this_ptr_conv.inner = untag_ptr(this_ptr);
44841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44843         this_ptr_conv.is_owned = false;
44844         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
44845 }
44846
44847 jboolean  CS_LDK_ReplyChannelRange_get_sync_complete(int64_t this_ptr) {
44848         LDKReplyChannelRange this_ptr_conv;
44849         this_ptr_conv.inner = untag_ptr(this_ptr);
44850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44852         this_ptr_conv.is_owned = false;
44853         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
44854         return ret_conv;
44855 }
44856
44857 void  CS_LDK_ReplyChannelRange_set_sync_complete(int64_t this_ptr, jboolean val) {
44858         LDKReplyChannelRange this_ptr_conv;
44859         this_ptr_conv.inner = untag_ptr(this_ptr);
44860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44862         this_ptr_conv.is_owned = false;
44863         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
44864 }
44865
44866 int64_tArray  CS_LDK_ReplyChannelRange_get_short_channel_ids(int64_t this_ptr) {
44867         LDKReplyChannelRange this_ptr_conv;
44868         this_ptr_conv.inner = untag_ptr(this_ptr);
44869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44871         this_ptr_conv.is_owned = false;
44872         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
44873         int64_tArray ret_arr = NULL;
44874         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
44875         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
44876         for (size_t g = 0; g < ret_var.datalen; g++) {
44877                 int64_t ret_conv_6_conv = ret_var.data[g];
44878                 ret_arr_ptr[g] = ret_conv_6_conv;
44879         }
44880         
44881         FREE(ret_var.data);
44882         return ret_arr;
44883 }
44884
44885 void  CS_LDK_ReplyChannelRange_set_short_channel_ids(int64_t this_ptr, int64_tArray val) {
44886         LDKReplyChannelRange this_ptr_conv;
44887         this_ptr_conv.inner = untag_ptr(this_ptr);
44888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44890         this_ptr_conv.is_owned = false;
44891         LDKCVec_u64Z val_constr;
44892         val_constr.datalen = val->arr_len;
44893         if (val_constr.datalen > 0)
44894                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44895         else
44896                 val_constr.data = NULL;
44897         int64_t* val_vals = val->elems;
44898         for (size_t g = 0; g < val_constr.datalen; g++) {
44899                 int64_t val_conv_6 = val_vals[g];
44900                 val_constr.data[g] = val_conv_6;
44901         }
44902         FREE(val);
44903         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
44904 }
44905
44906 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) {
44907         LDKThirtyTwoBytes chain_hash_arg_ref;
44908         CHECK(chain_hash_arg->arr_len == 32);
44909         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
44910         LDKCVec_u64Z short_channel_ids_arg_constr;
44911         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
44912         if (short_channel_ids_arg_constr.datalen > 0)
44913                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44914         else
44915                 short_channel_ids_arg_constr.data = NULL;
44916         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
44917         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
44918                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
44919                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
44920         }
44921         FREE(short_channel_ids_arg);
44922         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
44923         int64_t ret_ref = 0;
44924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44926         return ret_ref;
44927 }
44928
44929 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
44930         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
44931         int64_t ret_ref = 0;
44932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44933         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44934         return ret_ref;
44935 }
44936 int64_t  CS_LDK_ReplyChannelRange_clone_ptr(int64_t arg) {
44937         LDKReplyChannelRange arg_conv;
44938         arg_conv.inner = untag_ptr(arg);
44939         arg_conv.is_owned = ptr_is_owned(arg);
44940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44941         arg_conv.is_owned = false;
44942         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
44943         return ret_conv;
44944 }
44945
44946 int64_t  CS_LDK_ReplyChannelRange_clone(int64_t orig) {
44947         LDKReplyChannelRange orig_conv;
44948         orig_conv.inner = untag_ptr(orig);
44949         orig_conv.is_owned = ptr_is_owned(orig);
44950         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44951         orig_conv.is_owned = false;
44952         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
44953         int64_t ret_ref = 0;
44954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44955         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44956         return ret_ref;
44957 }
44958
44959 jboolean  CS_LDK_ReplyChannelRange_eq(int64_t a, int64_t b) {
44960         LDKReplyChannelRange a_conv;
44961         a_conv.inner = untag_ptr(a);
44962         a_conv.is_owned = ptr_is_owned(a);
44963         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44964         a_conv.is_owned = false;
44965         LDKReplyChannelRange b_conv;
44966         b_conv.inner = untag_ptr(b);
44967         b_conv.is_owned = ptr_is_owned(b);
44968         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44969         b_conv.is_owned = false;
44970         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
44971         return ret_conv;
44972 }
44973
44974 void  CS_LDK_QueryShortChannelIds_free(int64_t this_obj) {
44975         LDKQueryShortChannelIds this_obj_conv;
44976         this_obj_conv.inner = untag_ptr(this_obj);
44977         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44979         QueryShortChannelIds_free(this_obj_conv);
44980 }
44981
44982 int8_tArray  CS_LDK_QueryShortChannelIds_get_chain_hash(int64_t this_ptr) {
44983         LDKQueryShortChannelIds this_ptr_conv;
44984         this_ptr_conv.inner = untag_ptr(this_ptr);
44985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44987         this_ptr_conv.is_owned = false;
44988         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44989         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
44990         return ret_arr;
44991 }
44992
44993 void  CS_LDK_QueryShortChannelIds_set_chain_hash(int64_t this_ptr, int8_tArray val) {
44994         LDKQueryShortChannelIds this_ptr_conv;
44995         this_ptr_conv.inner = untag_ptr(this_ptr);
44996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44998         this_ptr_conv.is_owned = false;
44999         LDKThirtyTwoBytes val_ref;
45000         CHECK(val->arr_len == 32);
45001         memcpy(val_ref.data, val->elems, 32); FREE(val);
45002         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
45003 }
45004
45005 int64_tArray  CS_LDK_QueryShortChannelIds_get_short_channel_ids(int64_t this_ptr) {
45006         LDKQueryShortChannelIds this_ptr_conv;
45007         this_ptr_conv.inner = untag_ptr(this_ptr);
45008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45010         this_ptr_conv.is_owned = false;
45011         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
45012         int64_tArray ret_arr = NULL;
45013         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45014         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45015         for (size_t g = 0; g < ret_var.datalen; g++) {
45016                 int64_t ret_conv_6_conv = ret_var.data[g];
45017                 ret_arr_ptr[g] = ret_conv_6_conv;
45018         }
45019         
45020         FREE(ret_var.data);
45021         return ret_arr;
45022 }
45023
45024 void  CS_LDK_QueryShortChannelIds_set_short_channel_ids(int64_t this_ptr, int64_tArray val) {
45025         LDKQueryShortChannelIds this_ptr_conv;
45026         this_ptr_conv.inner = untag_ptr(this_ptr);
45027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45029         this_ptr_conv.is_owned = false;
45030         LDKCVec_u64Z val_constr;
45031         val_constr.datalen = val->arr_len;
45032         if (val_constr.datalen > 0)
45033                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45034         else
45035                 val_constr.data = NULL;
45036         int64_t* val_vals = val->elems;
45037         for (size_t g = 0; g < val_constr.datalen; g++) {
45038                 int64_t val_conv_6 = val_vals[g];
45039                 val_constr.data[g] = val_conv_6;
45040         }
45041         FREE(val);
45042         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
45043 }
45044
45045 int64_t  CS_LDK_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
45046         LDKThirtyTwoBytes chain_hash_arg_ref;
45047         CHECK(chain_hash_arg->arr_len == 32);
45048         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
45049         LDKCVec_u64Z short_channel_ids_arg_constr;
45050         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
45051         if (short_channel_ids_arg_constr.datalen > 0)
45052                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45053         else
45054                 short_channel_ids_arg_constr.data = NULL;
45055         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
45056         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
45057                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
45058                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
45059         }
45060         FREE(short_channel_ids_arg);
45061         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
45062         int64_t ret_ref = 0;
45063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45064         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45065         return ret_ref;
45066 }
45067
45068 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
45069         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
45070         int64_t ret_ref = 0;
45071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45072         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45073         return ret_ref;
45074 }
45075 int64_t  CS_LDK_QueryShortChannelIds_clone_ptr(int64_t arg) {
45076         LDKQueryShortChannelIds arg_conv;
45077         arg_conv.inner = untag_ptr(arg);
45078         arg_conv.is_owned = ptr_is_owned(arg);
45079         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45080         arg_conv.is_owned = false;
45081         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
45082         return ret_conv;
45083 }
45084
45085 int64_t  CS_LDK_QueryShortChannelIds_clone(int64_t orig) {
45086         LDKQueryShortChannelIds orig_conv;
45087         orig_conv.inner = untag_ptr(orig);
45088         orig_conv.is_owned = ptr_is_owned(orig);
45089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45090         orig_conv.is_owned = false;
45091         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
45092         int64_t ret_ref = 0;
45093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45095         return ret_ref;
45096 }
45097
45098 jboolean  CS_LDK_QueryShortChannelIds_eq(int64_t a, int64_t b) {
45099         LDKQueryShortChannelIds a_conv;
45100         a_conv.inner = untag_ptr(a);
45101         a_conv.is_owned = ptr_is_owned(a);
45102         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45103         a_conv.is_owned = false;
45104         LDKQueryShortChannelIds b_conv;
45105         b_conv.inner = untag_ptr(b);
45106         b_conv.is_owned = ptr_is_owned(b);
45107         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45108         b_conv.is_owned = false;
45109         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
45110         return ret_conv;
45111 }
45112
45113 void  CS_LDK_ReplyShortChannelIdsEnd_free(int64_t this_obj) {
45114         LDKReplyShortChannelIdsEnd this_obj_conv;
45115         this_obj_conv.inner = untag_ptr(this_obj);
45116         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45118         ReplyShortChannelIdsEnd_free(this_obj_conv);
45119 }
45120
45121 int8_tArray  CS_LDK_ReplyShortChannelIdsEnd_get_chain_hash(int64_t this_ptr) {
45122         LDKReplyShortChannelIdsEnd this_ptr_conv;
45123         this_ptr_conv.inner = untag_ptr(this_ptr);
45124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45126         this_ptr_conv.is_owned = false;
45127         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45128         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
45129         return ret_arr;
45130 }
45131
45132 void  CS_LDK_ReplyShortChannelIdsEnd_set_chain_hash(int64_t this_ptr, int8_tArray val) {
45133         LDKReplyShortChannelIdsEnd this_ptr_conv;
45134         this_ptr_conv.inner = untag_ptr(this_ptr);
45135         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45137         this_ptr_conv.is_owned = false;
45138         LDKThirtyTwoBytes val_ref;
45139         CHECK(val->arr_len == 32);
45140         memcpy(val_ref.data, val->elems, 32); FREE(val);
45141         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
45142 }
45143
45144 jboolean  CS_LDK_ReplyShortChannelIdsEnd_get_full_information(int64_t this_ptr) {
45145         LDKReplyShortChannelIdsEnd this_ptr_conv;
45146         this_ptr_conv.inner = untag_ptr(this_ptr);
45147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45149         this_ptr_conv.is_owned = false;
45150         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
45151         return ret_conv;
45152 }
45153
45154 void  CS_LDK_ReplyShortChannelIdsEnd_set_full_information(int64_t this_ptr, jboolean val) {
45155         LDKReplyShortChannelIdsEnd this_ptr_conv;
45156         this_ptr_conv.inner = untag_ptr(this_ptr);
45157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45159         this_ptr_conv.is_owned = false;
45160         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
45161 }
45162
45163 int64_t  CS_LDK_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
45164         LDKThirtyTwoBytes chain_hash_arg_ref;
45165         CHECK(chain_hash_arg->arr_len == 32);
45166         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
45167         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
45168         int64_t ret_ref = 0;
45169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45170         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45171         return ret_ref;
45172 }
45173
45174 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
45175         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
45176         int64_t ret_ref = 0;
45177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45179         return ret_ref;
45180 }
45181 int64_t  CS_LDK_ReplyShortChannelIdsEnd_clone_ptr(int64_t arg) {
45182         LDKReplyShortChannelIdsEnd arg_conv;
45183         arg_conv.inner = untag_ptr(arg);
45184         arg_conv.is_owned = ptr_is_owned(arg);
45185         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45186         arg_conv.is_owned = false;
45187         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
45188         return ret_conv;
45189 }
45190
45191 int64_t  CS_LDK_ReplyShortChannelIdsEnd_clone(int64_t orig) {
45192         LDKReplyShortChannelIdsEnd orig_conv;
45193         orig_conv.inner = untag_ptr(orig);
45194         orig_conv.is_owned = ptr_is_owned(orig);
45195         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45196         orig_conv.is_owned = false;
45197         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
45198         int64_t ret_ref = 0;
45199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45201         return ret_ref;
45202 }
45203
45204 jboolean  CS_LDK_ReplyShortChannelIdsEnd_eq(int64_t a, int64_t b) {
45205         LDKReplyShortChannelIdsEnd a_conv;
45206         a_conv.inner = untag_ptr(a);
45207         a_conv.is_owned = ptr_is_owned(a);
45208         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45209         a_conv.is_owned = false;
45210         LDKReplyShortChannelIdsEnd b_conv;
45211         b_conv.inner = untag_ptr(b);
45212         b_conv.is_owned = ptr_is_owned(b);
45213         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45214         b_conv.is_owned = false;
45215         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
45216         return ret_conv;
45217 }
45218
45219 void  CS_LDK_GossipTimestampFilter_free(int64_t this_obj) {
45220         LDKGossipTimestampFilter this_obj_conv;
45221         this_obj_conv.inner = untag_ptr(this_obj);
45222         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45224         GossipTimestampFilter_free(this_obj_conv);
45225 }
45226
45227 int8_tArray  CS_LDK_GossipTimestampFilter_get_chain_hash(int64_t this_ptr) {
45228         LDKGossipTimestampFilter this_ptr_conv;
45229         this_ptr_conv.inner = untag_ptr(this_ptr);
45230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45232         this_ptr_conv.is_owned = false;
45233         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45234         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
45235         return ret_arr;
45236 }
45237
45238 void  CS_LDK_GossipTimestampFilter_set_chain_hash(int64_t this_ptr, int8_tArray val) {
45239         LDKGossipTimestampFilter this_ptr_conv;
45240         this_ptr_conv.inner = untag_ptr(this_ptr);
45241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45243         this_ptr_conv.is_owned = false;
45244         LDKThirtyTwoBytes val_ref;
45245         CHECK(val->arr_len == 32);
45246         memcpy(val_ref.data, val->elems, 32); FREE(val);
45247         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
45248 }
45249
45250 int32_t  CS_LDK_GossipTimestampFilter_get_first_timestamp(int64_t this_ptr) {
45251         LDKGossipTimestampFilter this_ptr_conv;
45252         this_ptr_conv.inner = untag_ptr(this_ptr);
45253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45255         this_ptr_conv.is_owned = false;
45256         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
45257         return ret_conv;
45258 }
45259
45260 void  CS_LDK_GossipTimestampFilter_set_first_timestamp(int64_t this_ptr, int32_t val) {
45261         LDKGossipTimestampFilter this_ptr_conv;
45262         this_ptr_conv.inner = untag_ptr(this_ptr);
45263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45265         this_ptr_conv.is_owned = false;
45266         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
45267 }
45268
45269 int32_t  CS_LDK_GossipTimestampFilter_get_timestamp_range(int64_t this_ptr) {
45270         LDKGossipTimestampFilter this_ptr_conv;
45271         this_ptr_conv.inner = untag_ptr(this_ptr);
45272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45274         this_ptr_conv.is_owned = false;
45275         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
45276         return ret_conv;
45277 }
45278
45279 void  CS_LDK_GossipTimestampFilter_set_timestamp_range(int64_t this_ptr, int32_t val) {
45280         LDKGossipTimestampFilter this_ptr_conv;
45281         this_ptr_conv.inner = untag_ptr(this_ptr);
45282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45284         this_ptr_conv.is_owned = false;
45285         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
45286 }
45287
45288 int64_t  CS_LDK_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
45289         LDKThirtyTwoBytes chain_hash_arg_ref;
45290         CHECK(chain_hash_arg->arr_len == 32);
45291         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
45292         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
45293         int64_t ret_ref = 0;
45294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45295         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45296         return ret_ref;
45297 }
45298
45299 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
45300         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
45301         int64_t ret_ref = 0;
45302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45303         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45304         return ret_ref;
45305 }
45306 int64_t  CS_LDK_GossipTimestampFilter_clone_ptr(int64_t arg) {
45307         LDKGossipTimestampFilter arg_conv;
45308         arg_conv.inner = untag_ptr(arg);
45309         arg_conv.is_owned = ptr_is_owned(arg);
45310         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45311         arg_conv.is_owned = false;
45312         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
45313         return ret_conv;
45314 }
45315
45316 int64_t  CS_LDK_GossipTimestampFilter_clone(int64_t orig) {
45317         LDKGossipTimestampFilter orig_conv;
45318         orig_conv.inner = untag_ptr(orig);
45319         orig_conv.is_owned = ptr_is_owned(orig);
45320         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45321         orig_conv.is_owned = false;
45322         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
45323         int64_t ret_ref = 0;
45324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45325         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45326         return ret_ref;
45327 }
45328
45329 jboolean  CS_LDK_GossipTimestampFilter_eq(int64_t a, int64_t b) {
45330         LDKGossipTimestampFilter a_conv;
45331         a_conv.inner = untag_ptr(a);
45332         a_conv.is_owned = ptr_is_owned(a);
45333         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45334         a_conv.is_owned = false;
45335         LDKGossipTimestampFilter b_conv;
45336         b_conv.inner = untag_ptr(b);
45337         b_conv.is_owned = ptr_is_owned(b);
45338         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45339         b_conv.is_owned = false;
45340         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
45341         return ret_conv;
45342 }
45343
45344 void  CS_LDK_ErrorAction_free(int64_t this_ptr) {
45345         if (!ptr_is_owned(this_ptr)) return;
45346         void* this_ptr_ptr = untag_ptr(this_ptr);
45347         CHECK_ACCESS(this_ptr_ptr);
45348         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
45349         FREE(untag_ptr(this_ptr));
45350         ErrorAction_free(this_ptr_conv);
45351 }
45352
45353 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
45354         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45355         *ret_copy = ErrorAction_clone(arg);
45356         int64_t ret_ref = tag_ptr(ret_copy, true);
45357         return ret_ref;
45358 }
45359 int64_t  CS_LDK_ErrorAction_clone_ptr(int64_t arg) {
45360         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
45361         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
45362         return ret_conv;
45363 }
45364
45365 int64_t  CS_LDK_ErrorAction_clone(int64_t orig) {
45366         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
45367         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45368         *ret_copy = ErrorAction_clone(orig_conv);
45369         int64_t ret_ref = tag_ptr(ret_copy, true);
45370         return ret_ref;
45371 }
45372
45373 int64_t  CS_LDK_ErrorAction_disconnect_peer(int64_t msg) {
45374         LDKErrorMessage msg_conv;
45375         msg_conv.inner = untag_ptr(msg);
45376         msg_conv.is_owned = ptr_is_owned(msg);
45377         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45378         msg_conv = ErrorMessage_clone(&msg_conv);
45379         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45380         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
45381         int64_t ret_ref = tag_ptr(ret_copy, true);
45382         return ret_ref;
45383 }
45384
45385 int64_t  CS_LDK_ErrorAction_disconnect_peer_with_warning(int64_t msg) {
45386         LDKWarningMessage msg_conv;
45387         msg_conv.inner = untag_ptr(msg);
45388         msg_conv.is_owned = ptr_is_owned(msg);
45389         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45390         msg_conv = WarningMessage_clone(&msg_conv);
45391         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45392         *ret_copy = ErrorAction_disconnect_peer_with_warning(msg_conv);
45393         int64_t ret_ref = tag_ptr(ret_copy, true);
45394         return ret_ref;
45395 }
45396
45397 int64_t  CS_LDK_ErrorAction_ignore_error() {
45398         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45399         *ret_copy = ErrorAction_ignore_error();
45400         int64_t ret_ref = tag_ptr(ret_copy, true);
45401         return ret_ref;
45402 }
45403
45404 int64_t  CS_LDK_ErrorAction_ignore_and_log(int32_t a) {
45405         LDKLevel a_conv = LDKLevel_from_cs(a);
45406         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45407         *ret_copy = ErrorAction_ignore_and_log(a_conv);
45408         int64_t ret_ref = tag_ptr(ret_copy, true);
45409         return ret_ref;
45410 }
45411
45412 int64_t  CS_LDK_ErrorAction_ignore_duplicate_gossip() {
45413         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45414         *ret_copy = ErrorAction_ignore_duplicate_gossip();
45415         int64_t ret_ref = tag_ptr(ret_copy, true);
45416         return ret_ref;
45417 }
45418
45419 int64_t  CS_LDK_ErrorAction_send_error_message(int64_t msg) {
45420         LDKErrorMessage msg_conv;
45421         msg_conv.inner = untag_ptr(msg);
45422         msg_conv.is_owned = ptr_is_owned(msg);
45423         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45424         msg_conv = ErrorMessage_clone(&msg_conv);
45425         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45426         *ret_copy = ErrorAction_send_error_message(msg_conv);
45427         int64_t ret_ref = tag_ptr(ret_copy, true);
45428         return ret_ref;
45429 }
45430
45431 int64_t  CS_LDK_ErrorAction_send_warning_message(int64_t msg, int32_t log_level) {
45432         LDKWarningMessage msg_conv;
45433         msg_conv.inner = untag_ptr(msg);
45434         msg_conv.is_owned = ptr_is_owned(msg);
45435         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45436         msg_conv = WarningMessage_clone(&msg_conv);
45437         LDKLevel log_level_conv = LDKLevel_from_cs(log_level);
45438         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45439         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
45440         int64_t ret_ref = tag_ptr(ret_copy, true);
45441         return ret_ref;
45442 }
45443
45444 void  CS_LDK_LightningError_free(int64_t this_obj) {
45445         LDKLightningError this_obj_conv;
45446         this_obj_conv.inner = untag_ptr(this_obj);
45447         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45449         LightningError_free(this_obj_conv);
45450 }
45451
45452 jstring  CS_LDK_LightningError_get_err(int64_t this_ptr) {
45453         LDKLightningError this_ptr_conv;
45454         this_ptr_conv.inner = untag_ptr(this_ptr);
45455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45457         this_ptr_conv.is_owned = false;
45458         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
45459         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
45460         Str_free(ret_str);
45461         return ret_conv;
45462 }
45463
45464 void  CS_LDK_LightningError_set_err(int64_t this_ptr, jstring val) {
45465         LDKLightningError this_ptr_conv;
45466         this_ptr_conv.inner = untag_ptr(this_ptr);
45467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45469         this_ptr_conv.is_owned = false;
45470         LDKStr val_conv = str_ref_to_owned_c(val);
45471         LightningError_set_err(&this_ptr_conv, val_conv);
45472 }
45473
45474 int64_t  CS_LDK_LightningError_get_action(int64_t this_ptr) {
45475         LDKLightningError this_ptr_conv;
45476         this_ptr_conv.inner = untag_ptr(this_ptr);
45477         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45479         this_ptr_conv.is_owned = false;
45480         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45481         *ret_copy = LightningError_get_action(&this_ptr_conv);
45482         int64_t ret_ref = tag_ptr(ret_copy, true);
45483         return ret_ref;
45484 }
45485
45486 void  CS_LDK_LightningError_set_action(int64_t this_ptr, int64_t val) {
45487         LDKLightningError this_ptr_conv;
45488         this_ptr_conv.inner = untag_ptr(this_ptr);
45489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45491         this_ptr_conv.is_owned = false;
45492         void* val_ptr = untag_ptr(val);
45493         CHECK_ACCESS(val_ptr);
45494         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
45495         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
45496         LightningError_set_action(&this_ptr_conv, val_conv);
45497 }
45498
45499 int64_t  CS_LDK_LightningError_new(jstring err_arg, int64_t action_arg) {
45500         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
45501         void* action_arg_ptr = untag_ptr(action_arg);
45502         CHECK_ACCESS(action_arg_ptr);
45503         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
45504         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
45505         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
45506         int64_t ret_ref = 0;
45507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45509         return ret_ref;
45510 }
45511
45512 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
45513         LDKLightningError ret_var = LightningError_clone(arg);
45514         int64_t ret_ref = 0;
45515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45517         return ret_ref;
45518 }
45519 int64_t  CS_LDK_LightningError_clone_ptr(int64_t arg) {
45520         LDKLightningError arg_conv;
45521         arg_conv.inner = untag_ptr(arg);
45522         arg_conv.is_owned = ptr_is_owned(arg);
45523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45524         arg_conv.is_owned = false;
45525         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
45526         return ret_conv;
45527 }
45528
45529 int64_t  CS_LDK_LightningError_clone(int64_t orig) {
45530         LDKLightningError orig_conv;
45531         orig_conv.inner = untag_ptr(orig);
45532         orig_conv.is_owned = ptr_is_owned(orig);
45533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45534         orig_conv.is_owned = false;
45535         LDKLightningError ret_var = LightningError_clone(&orig_conv);
45536         int64_t ret_ref = 0;
45537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45539         return ret_ref;
45540 }
45541
45542 void  CS_LDK_CommitmentUpdate_free(int64_t this_obj) {
45543         LDKCommitmentUpdate this_obj_conv;
45544         this_obj_conv.inner = untag_ptr(this_obj);
45545         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45547         CommitmentUpdate_free(this_obj_conv);
45548 }
45549
45550 int64_tArray  CS_LDK_CommitmentUpdate_get_update_add_htlcs(int64_t this_ptr) {
45551         LDKCommitmentUpdate this_ptr_conv;
45552         this_ptr_conv.inner = untag_ptr(this_ptr);
45553         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45555         this_ptr_conv.is_owned = false;
45556         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
45557         int64_tArray ret_arr = NULL;
45558         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45559         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45560         for (size_t p = 0; p < ret_var.datalen; p++) {
45561                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
45562                 int64_t ret_conv_15_ref = 0;
45563                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
45564                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
45565                 ret_arr_ptr[p] = ret_conv_15_ref;
45566         }
45567         
45568         FREE(ret_var.data);
45569         return ret_arr;
45570 }
45571
45572 void  CS_LDK_CommitmentUpdate_set_update_add_htlcs(int64_t this_ptr, int64_tArray val) {
45573         LDKCommitmentUpdate this_ptr_conv;
45574         this_ptr_conv.inner = untag_ptr(this_ptr);
45575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45577         this_ptr_conv.is_owned = false;
45578         LDKCVec_UpdateAddHTLCZ val_constr;
45579         val_constr.datalen = val->arr_len;
45580         if (val_constr.datalen > 0)
45581                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
45582         else
45583                 val_constr.data = NULL;
45584         int64_t* val_vals = val->elems;
45585         for (size_t p = 0; p < val_constr.datalen; p++) {
45586                 int64_t val_conv_15 = val_vals[p];
45587                 LDKUpdateAddHTLC val_conv_15_conv;
45588                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
45589                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
45590                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
45591                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
45592                 val_constr.data[p] = val_conv_15_conv;
45593         }
45594         FREE(val);
45595         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
45596 }
45597
45598 int64_tArray  CS_LDK_CommitmentUpdate_get_update_fulfill_htlcs(int64_t this_ptr) {
45599         LDKCommitmentUpdate this_ptr_conv;
45600         this_ptr_conv.inner = untag_ptr(this_ptr);
45601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45603         this_ptr_conv.is_owned = false;
45604         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
45605         int64_tArray ret_arr = NULL;
45606         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45607         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45608         for (size_t t = 0; t < ret_var.datalen; t++) {
45609                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
45610                 int64_t ret_conv_19_ref = 0;
45611                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
45612                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
45613                 ret_arr_ptr[t] = ret_conv_19_ref;
45614         }
45615         
45616         FREE(ret_var.data);
45617         return ret_arr;
45618 }
45619
45620 void  CS_LDK_CommitmentUpdate_set_update_fulfill_htlcs(int64_t this_ptr, int64_tArray val) {
45621         LDKCommitmentUpdate this_ptr_conv;
45622         this_ptr_conv.inner = untag_ptr(this_ptr);
45623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45625         this_ptr_conv.is_owned = false;
45626         LDKCVec_UpdateFulfillHTLCZ val_constr;
45627         val_constr.datalen = val->arr_len;
45628         if (val_constr.datalen > 0)
45629                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
45630         else
45631                 val_constr.data = NULL;
45632         int64_t* val_vals = val->elems;
45633         for (size_t t = 0; t < val_constr.datalen; t++) {
45634                 int64_t val_conv_19 = val_vals[t];
45635                 LDKUpdateFulfillHTLC val_conv_19_conv;
45636                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
45637                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
45638                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
45639                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
45640                 val_constr.data[t] = val_conv_19_conv;
45641         }
45642         FREE(val);
45643         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
45644 }
45645
45646 int64_tArray  CS_LDK_CommitmentUpdate_get_update_fail_htlcs(int64_t this_ptr) {
45647         LDKCommitmentUpdate this_ptr_conv;
45648         this_ptr_conv.inner = untag_ptr(this_ptr);
45649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45651         this_ptr_conv.is_owned = false;
45652         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
45653         int64_tArray ret_arr = NULL;
45654         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45655         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45656         for (size_t q = 0; q < ret_var.datalen; q++) {
45657                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
45658                 int64_t ret_conv_16_ref = 0;
45659                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
45660                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
45661                 ret_arr_ptr[q] = ret_conv_16_ref;
45662         }
45663         
45664         FREE(ret_var.data);
45665         return ret_arr;
45666 }
45667
45668 void  CS_LDK_CommitmentUpdate_set_update_fail_htlcs(int64_t this_ptr, int64_tArray val) {
45669         LDKCommitmentUpdate this_ptr_conv;
45670         this_ptr_conv.inner = untag_ptr(this_ptr);
45671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45673         this_ptr_conv.is_owned = false;
45674         LDKCVec_UpdateFailHTLCZ val_constr;
45675         val_constr.datalen = val->arr_len;
45676         if (val_constr.datalen > 0)
45677                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
45678         else
45679                 val_constr.data = NULL;
45680         int64_t* val_vals = val->elems;
45681         for (size_t q = 0; q < val_constr.datalen; q++) {
45682                 int64_t val_conv_16 = val_vals[q];
45683                 LDKUpdateFailHTLC val_conv_16_conv;
45684                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
45685                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
45686                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
45687                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
45688                 val_constr.data[q] = val_conv_16_conv;
45689         }
45690         FREE(val);
45691         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
45692 }
45693
45694 int64_tArray  CS_LDK_CommitmentUpdate_get_update_fail_malformed_htlcs(int64_t this_ptr) {
45695         LDKCommitmentUpdate this_ptr_conv;
45696         this_ptr_conv.inner = untag_ptr(this_ptr);
45697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45699         this_ptr_conv.is_owned = false;
45700         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
45701         int64_tArray ret_arr = NULL;
45702         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45703         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45704         for (size_t z = 0; z < ret_var.datalen; z++) {
45705                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
45706                 int64_t ret_conv_25_ref = 0;
45707                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
45708                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
45709                 ret_arr_ptr[z] = ret_conv_25_ref;
45710         }
45711         
45712         FREE(ret_var.data);
45713         return ret_arr;
45714 }
45715
45716 void  CS_LDK_CommitmentUpdate_set_update_fail_malformed_htlcs(int64_t this_ptr, int64_tArray val) {
45717         LDKCommitmentUpdate this_ptr_conv;
45718         this_ptr_conv.inner = untag_ptr(this_ptr);
45719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45721         this_ptr_conv.is_owned = false;
45722         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
45723         val_constr.datalen = val->arr_len;
45724         if (val_constr.datalen > 0)
45725                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
45726         else
45727                 val_constr.data = NULL;
45728         int64_t* val_vals = val->elems;
45729         for (size_t z = 0; z < val_constr.datalen; z++) {
45730                 int64_t val_conv_25 = val_vals[z];
45731                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
45732                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
45733                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
45734                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
45735                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
45736                 val_constr.data[z] = val_conv_25_conv;
45737         }
45738         FREE(val);
45739         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
45740 }
45741
45742 int64_t  CS_LDK_CommitmentUpdate_get_update_fee(int64_t this_ptr) {
45743         LDKCommitmentUpdate this_ptr_conv;
45744         this_ptr_conv.inner = untag_ptr(this_ptr);
45745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45747         this_ptr_conv.is_owned = false;
45748         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
45749         int64_t ret_ref = 0;
45750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45751         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45752         return ret_ref;
45753 }
45754
45755 void  CS_LDK_CommitmentUpdate_set_update_fee(int64_t this_ptr, int64_t val) {
45756         LDKCommitmentUpdate this_ptr_conv;
45757         this_ptr_conv.inner = untag_ptr(this_ptr);
45758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45760         this_ptr_conv.is_owned = false;
45761         LDKUpdateFee val_conv;
45762         val_conv.inner = untag_ptr(val);
45763         val_conv.is_owned = ptr_is_owned(val);
45764         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45765         val_conv = UpdateFee_clone(&val_conv);
45766         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
45767 }
45768
45769 int64_t  CS_LDK_CommitmentUpdate_get_commitment_signed(int64_t this_ptr) {
45770         LDKCommitmentUpdate this_ptr_conv;
45771         this_ptr_conv.inner = untag_ptr(this_ptr);
45772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45774         this_ptr_conv.is_owned = false;
45775         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
45776         int64_t ret_ref = 0;
45777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45779         return ret_ref;
45780 }
45781
45782 void  CS_LDK_CommitmentUpdate_set_commitment_signed(int64_t this_ptr, int64_t val) {
45783         LDKCommitmentUpdate this_ptr_conv;
45784         this_ptr_conv.inner = untag_ptr(this_ptr);
45785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45787         this_ptr_conv.is_owned = false;
45788         LDKCommitmentSigned val_conv;
45789         val_conv.inner = untag_ptr(val);
45790         val_conv.is_owned = ptr_is_owned(val);
45791         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45792         val_conv = CommitmentSigned_clone(&val_conv);
45793         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
45794 }
45795
45796 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) {
45797         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
45798         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
45799         if (update_add_htlcs_arg_constr.datalen > 0)
45800                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
45801         else
45802                 update_add_htlcs_arg_constr.data = NULL;
45803         int64_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
45804         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
45805                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
45806                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
45807                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
45808                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
45809                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
45810                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
45811                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
45812         }
45813         FREE(update_add_htlcs_arg);
45814         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
45815         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
45816         if (update_fulfill_htlcs_arg_constr.datalen > 0)
45817                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
45818         else
45819                 update_fulfill_htlcs_arg_constr.data = NULL;
45820         int64_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
45821         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
45822                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
45823                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
45824                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
45825                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
45826                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
45827                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
45828                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
45829         }
45830         FREE(update_fulfill_htlcs_arg);
45831         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
45832         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
45833         if (update_fail_htlcs_arg_constr.datalen > 0)
45834                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
45835         else
45836                 update_fail_htlcs_arg_constr.data = NULL;
45837         int64_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
45838         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
45839                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
45840                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
45841                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
45842                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
45843                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
45844                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
45845                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
45846         }
45847         FREE(update_fail_htlcs_arg);
45848         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
45849         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
45850         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
45851                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
45852         else
45853                 update_fail_malformed_htlcs_arg_constr.data = NULL;
45854         int64_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
45855         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
45856                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
45857                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
45858                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
45859                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
45860                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
45861                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
45862                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
45863         }
45864         FREE(update_fail_malformed_htlcs_arg);
45865         LDKUpdateFee update_fee_arg_conv;
45866         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
45867         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
45868         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
45869         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
45870         LDKCommitmentSigned commitment_signed_arg_conv;
45871         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
45872         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
45873         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
45874         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
45875         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);
45876         int64_t ret_ref = 0;
45877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45878         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45879         return ret_ref;
45880 }
45881
45882 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
45883         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
45884         int64_t ret_ref = 0;
45885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45887         return ret_ref;
45888 }
45889 int64_t  CS_LDK_CommitmentUpdate_clone_ptr(int64_t arg) {
45890         LDKCommitmentUpdate arg_conv;
45891         arg_conv.inner = untag_ptr(arg);
45892         arg_conv.is_owned = ptr_is_owned(arg);
45893         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45894         arg_conv.is_owned = false;
45895         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
45896         return ret_conv;
45897 }
45898
45899 int64_t  CS_LDK_CommitmentUpdate_clone(int64_t orig) {
45900         LDKCommitmentUpdate orig_conv;
45901         orig_conv.inner = untag_ptr(orig);
45902         orig_conv.is_owned = ptr_is_owned(orig);
45903         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45904         orig_conv.is_owned = false;
45905         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
45906         int64_t ret_ref = 0;
45907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45908         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45909         return ret_ref;
45910 }
45911
45912 jboolean  CS_LDK_CommitmentUpdate_eq(int64_t a, int64_t b) {
45913         LDKCommitmentUpdate a_conv;
45914         a_conv.inner = untag_ptr(a);
45915         a_conv.is_owned = ptr_is_owned(a);
45916         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45917         a_conv.is_owned = false;
45918         LDKCommitmentUpdate b_conv;
45919         b_conv.inner = untag_ptr(b);
45920         b_conv.is_owned = ptr_is_owned(b);
45921         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45922         b_conv.is_owned = false;
45923         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
45924         return ret_conv;
45925 }
45926
45927 void  CS_LDK_ChannelMessageHandler_free(int64_t this_ptr) {
45928         if (!ptr_is_owned(this_ptr)) return;
45929         void* this_ptr_ptr = untag_ptr(this_ptr);
45930         CHECK_ACCESS(this_ptr_ptr);
45931         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
45932         FREE(untag_ptr(this_ptr));
45933         ChannelMessageHandler_free(this_ptr_conv);
45934 }
45935
45936 void  CS_LDK_RoutingMessageHandler_free(int64_t this_ptr) {
45937         if (!ptr_is_owned(this_ptr)) return;
45938         void* this_ptr_ptr = untag_ptr(this_ptr);
45939         CHECK_ACCESS(this_ptr_ptr);
45940         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
45941         FREE(untag_ptr(this_ptr));
45942         RoutingMessageHandler_free(this_ptr_conv);
45943 }
45944
45945 void  CS_LDK_OnionMessageHandler_free(int64_t this_ptr) {
45946         if (!ptr_is_owned(this_ptr)) return;
45947         void* this_ptr_ptr = untag_ptr(this_ptr);
45948         CHECK_ACCESS(this_ptr_ptr);
45949         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
45950         FREE(untag_ptr(this_ptr));
45951         OnionMessageHandler_free(this_ptr_conv);
45952 }
45953
45954 int8_tArray  CS_LDK_AcceptChannel_write(int64_t obj) {
45955         LDKAcceptChannel obj_conv;
45956         obj_conv.inner = untag_ptr(obj);
45957         obj_conv.is_owned = ptr_is_owned(obj);
45958         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45959         obj_conv.is_owned = false;
45960         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
45961         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
45962         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
45963         CVec_u8Z_free(ret_var);
45964         return ret_arr;
45965 }
45966
45967 int64_t  CS_LDK_AcceptChannel_read(int8_tArray ser) {
45968         LDKu8slice ser_ref;
45969         ser_ref.datalen = ser->arr_len;
45970         ser_ref.data = ser->elems;
45971         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
45972         *ret_conv = AcceptChannel_read(ser_ref);
45973         FREE(ser);
45974         return tag_ptr(ret_conv, true);
45975 }
45976
45977 int8_tArray  CS_LDK_AcceptChannelV2_write(int64_t obj) {
45978         LDKAcceptChannelV2 obj_conv;
45979         obj_conv.inner = untag_ptr(obj);
45980         obj_conv.is_owned = ptr_is_owned(obj);
45981         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45982         obj_conv.is_owned = false;
45983         LDKCVec_u8Z ret_var = AcceptChannelV2_write(&obj_conv);
45984         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
45985         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
45986         CVec_u8Z_free(ret_var);
45987         return ret_arr;
45988 }
45989
45990 int64_t  CS_LDK_AcceptChannelV2_read(int8_tArray ser) {
45991         LDKu8slice ser_ref;
45992         ser_ref.datalen = ser->arr_len;
45993         ser_ref.data = ser->elems;
45994         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
45995         *ret_conv = AcceptChannelV2_read(ser_ref);
45996         FREE(ser);
45997         return tag_ptr(ret_conv, true);
45998 }
45999
46000 int8_tArray  CS_LDK_TxAddInput_write(int64_t obj) {
46001         LDKTxAddInput obj_conv;
46002         obj_conv.inner = untag_ptr(obj);
46003         obj_conv.is_owned = ptr_is_owned(obj);
46004         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46005         obj_conv.is_owned = false;
46006         LDKCVec_u8Z ret_var = TxAddInput_write(&obj_conv);
46007         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46008         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46009         CVec_u8Z_free(ret_var);
46010         return ret_arr;
46011 }
46012
46013 int64_t  CS_LDK_TxAddInput_read(int8_tArray ser) {
46014         LDKu8slice ser_ref;
46015         ser_ref.datalen = ser->arr_len;
46016         ser_ref.data = ser->elems;
46017         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
46018         *ret_conv = TxAddInput_read(ser_ref);
46019         FREE(ser);
46020         return tag_ptr(ret_conv, true);
46021 }
46022
46023 int8_tArray  CS_LDK_TxAddOutput_write(int64_t obj) {
46024         LDKTxAddOutput obj_conv;
46025         obj_conv.inner = untag_ptr(obj);
46026         obj_conv.is_owned = ptr_is_owned(obj);
46027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46028         obj_conv.is_owned = false;
46029         LDKCVec_u8Z ret_var = TxAddOutput_write(&obj_conv);
46030         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46031         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46032         CVec_u8Z_free(ret_var);
46033         return ret_arr;
46034 }
46035
46036 int64_t  CS_LDK_TxAddOutput_read(int8_tArray ser) {
46037         LDKu8slice ser_ref;
46038         ser_ref.datalen = ser->arr_len;
46039         ser_ref.data = ser->elems;
46040         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
46041         *ret_conv = TxAddOutput_read(ser_ref);
46042         FREE(ser);
46043         return tag_ptr(ret_conv, true);
46044 }
46045
46046 int8_tArray  CS_LDK_TxRemoveInput_write(int64_t obj) {
46047         LDKTxRemoveInput obj_conv;
46048         obj_conv.inner = untag_ptr(obj);
46049         obj_conv.is_owned = ptr_is_owned(obj);
46050         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46051         obj_conv.is_owned = false;
46052         LDKCVec_u8Z ret_var = TxRemoveInput_write(&obj_conv);
46053         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46054         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46055         CVec_u8Z_free(ret_var);
46056         return ret_arr;
46057 }
46058
46059 int64_t  CS_LDK_TxRemoveInput_read(int8_tArray ser) {
46060         LDKu8slice ser_ref;
46061         ser_ref.datalen = ser->arr_len;
46062         ser_ref.data = ser->elems;
46063         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
46064         *ret_conv = TxRemoveInput_read(ser_ref);
46065         FREE(ser);
46066         return tag_ptr(ret_conv, true);
46067 }
46068
46069 int8_tArray  CS_LDK_TxRemoveOutput_write(int64_t obj) {
46070         LDKTxRemoveOutput obj_conv;
46071         obj_conv.inner = untag_ptr(obj);
46072         obj_conv.is_owned = ptr_is_owned(obj);
46073         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46074         obj_conv.is_owned = false;
46075         LDKCVec_u8Z ret_var = TxRemoveOutput_write(&obj_conv);
46076         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46077         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46078         CVec_u8Z_free(ret_var);
46079         return ret_arr;
46080 }
46081
46082 int64_t  CS_LDK_TxRemoveOutput_read(int8_tArray ser) {
46083         LDKu8slice ser_ref;
46084         ser_ref.datalen = ser->arr_len;
46085         ser_ref.data = ser->elems;
46086         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
46087         *ret_conv = TxRemoveOutput_read(ser_ref);
46088         FREE(ser);
46089         return tag_ptr(ret_conv, true);
46090 }
46091
46092 int8_tArray  CS_LDK_TxComplete_write(int64_t obj) {
46093         LDKTxComplete obj_conv;
46094         obj_conv.inner = untag_ptr(obj);
46095         obj_conv.is_owned = ptr_is_owned(obj);
46096         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46097         obj_conv.is_owned = false;
46098         LDKCVec_u8Z ret_var = TxComplete_write(&obj_conv);
46099         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46100         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46101         CVec_u8Z_free(ret_var);
46102         return ret_arr;
46103 }
46104
46105 int64_t  CS_LDK_TxComplete_read(int8_tArray ser) {
46106         LDKu8slice ser_ref;
46107         ser_ref.datalen = ser->arr_len;
46108         ser_ref.data = ser->elems;
46109         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
46110         *ret_conv = TxComplete_read(ser_ref);
46111         FREE(ser);
46112         return tag_ptr(ret_conv, true);
46113 }
46114
46115 int8_tArray  CS_LDK_TxSignatures_write(int64_t obj) {
46116         LDKTxSignatures obj_conv;
46117         obj_conv.inner = untag_ptr(obj);
46118         obj_conv.is_owned = ptr_is_owned(obj);
46119         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46120         obj_conv.is_owned = false;
46121         LDKCVec_u8Z ret_var = TxSignatures_write(&obj_conv);
46122         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46123         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46124         CVec_u8Z_free(ret_var);
46125         return ret_arr;
46126 }
46127
46128 int64_t  CS_LDK_TxSignatures_read(int8_tArray ser) {
46129         LDKu8slice ser_ref;
46130         ser_ref.datalen = ser->arr_len;
46131         ser_ref.data = ser->elems;
46132         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
46133         *ret_conv = TxSignatures_read(ser_ref);
46134         FREE(ser);
46135         return tag_ptr(ret_conv, true);
46136 }
46137
46138 int8_tArray  CS_LDK_TxInitRbf_write(int64_t obj) {
46139         LDKTxInitRbf obj_conv;
46140         obj_conv.inner = untag_ptr(obj);
46141         obj_conv.is_owned = ptr_is_owned(obj);
46142         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46143         obj_conv.is_owned = false;
46144         LDKCVec_u8Z ret_var = TxInitRbf_write(&obj_conv);
46145         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46146         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46147         CVec_u8Z_free(ret_var);
46148         return ret_arr;
46149 }
46150
46151 int64_t  CS_LDK_TxInitRbf_read(int8_tArray ser) {
46152         LDKu8slice ser_ref;
46153         ser_ref.datalen = ser->arr_len;
46154         ser_ref.data = ser->elems;
46155         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
46156         *ret_conv = TxInitRbf_read(ser_ref);
46157         FREE(ser);
46158         return tag_ptr(ret_conv, true);
46159 }
46160
46161 int8_tArray  CS_LDK_TxAckRbf_write(int64_t obj) {
46162         LDKTxAckRbf obj_conv;
46163         obj_conv.inner = untag_ptr(obj);
46164         obj_conv.is_owned = ptr_is_owned(obj);
46165         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46166         obj_conv.is_owned = false;
46167         LDKCVec_u8Z ret_var = TxAckRbf_write(&obj_conv);
46168         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46169         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46170         CVec_u8Z_free(ret_var);
46171         return ret_arr;
46172 }
46173
46174 int64_t  CS_LDK_TxAckRbf_read(int8_tArray ser) {
46175         LDKu8slice ser_ref;
46176         ser_ref.datalen = ser->arr_len;
46177         ser_ref.data = ser->elems;
46178         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
46179         *ret_conv = TxAckRbf_read(ser_ref);
46180         FREE(ser);
46181         return tag_ptr(ret_conv, true);
46182 }
46183
46184 int8_tArray  CS_LDK_TxAbort_write(int64_t obj) {
46185         LDKTxAbort obj_conv;
46186         obj_conv.inner = untag_ptr(obj);
46187         obj_conv.is_owned = ptr_is_owned(obj);
46188         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46189         obj_conv.is_owned = false;
46190         LDKCVec_u8Z ret_var = TxAbort_write(&obj_conv);
46191         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46192         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46193         CVec_u8Z_free(ret_var);
46194         return ret_arr;
46195 }
46196
46197 int64_t  CS_LDK_TxAbort_read(int8_tArray ser) {
46198         LDKu8slice ser_ref;
46199         ser_ref.datalen = ser->arr_len;
46200         ser_ref.data = ser->elems;
46201         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
46202         *ret_conv = TxAbort_read(ser_ref);
46203         FREE(ser);
46204         return tag_ptr(ret_conv, true);
46205 }
46206
46207 int8_tArray  CS_LDK_AnnouncementSignatures_write(int64_t obj) {
46208         LDKAnnouncementSignatures obj_conv;
46209         obj_conv.inner = untag_ptr(obj);
46210         obj_conv.is_owned = ptr_is_owned(obj);
46211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46212         obj_conv.is_owned = false;
46213         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
46214         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46215         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46216         CVec_u8Z_free(ret_var);
46217         return ret_arr;
46218 }
46219
46220 int64_t  CS_LDK_AnnouncementSignatures_read(int8_tArray ser) {
46221         LDKu8slice ser_ref;
46222         ser_ref.datalen = ser->arr_len;
46223         ser_ref.data = ser->elems;
46224         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
46225         *ret_conv = AnnouncementSignatures_read(ser_ref);
46226         FREE(ser);
46227         return tag_ptr(ret_conv, true);
46228 }
46229
46230 int8_tArray  CS_LDK_ChannelReestablish_write(int64_t obj) {
46231         LDKChannelReestablish obj_conv;
46232         obj_conv.inner = untag_ptr(obj);
46233         obj_conv.is_owned = ptr_is_owned(obj);
46234         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46235         obj_conv.is_owned = false;
46236         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
46237         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46238         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46239         CVec_u8Z_free(ret_var);
46240         return ret_arr;
46241 }
46242
46243 int64_t  CS_LDK_ChannelReestablish_read(int8_tArray ser) {
46244         LDKu8slice ser_ref;
46245         ser_ref.datalen = ser->arr_len;
46246         ser_ref.data = ser->elems;
46247         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
46248         *ret_conv = ChannelReestablish_read(ser_ref);
46249         FREE(ser);
46250         return tag_ptr(ret_conv, true);
46251 }
46252
46253 int8_tArray  CS_LDK_ClosingSigned_write(int64_t obj) {
46254         LDKClosingSigned obj_conv;
46255         obj_conv.inner = untag_ptr(obj);
46256         obj_conv.is_owned = ptr_is_owned(obj);
46257         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46258         obj_conv.is_owned = false;
46259         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
46260         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46261         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46262         CVec_u8Z_free(ret_var);
46263         return ret_arr;
46264 }
46265
46266 int64_t  CS_LDK_ClosingSigned_read(int8_tArray ser) {
46267         LDKu8slice ser_ref;
46268         ser_ref.datalen = ser->arr_len;
46269         ser_ref.data = ser->elems;
46270         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
46271         *ret_conv = ClosingSigned_read(ser_ref);
46272         FREE(ser);
46273         return tag_ptr(ret_conv, true);
46274 }
46275
46276 int8_tArray  CS_LDK_ClosingSignedFeeRange_write(int64_t obj) {
46277         LDKClosingSignedFeeRange obj_conv;
46278         obj_conv.inner = untag_ptr(obj);
46279         obj_conv.is_owned = ptr_is_owned(obj);
46280         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46281         obj_conv.is_owned = false;
46282         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
46283         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46284         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46285         CVec_u8Z_free(ret_var);
46286         return ret_arr;
46287 }
46288
46289 int64_t  CS_LDK_ClosingSignedFeeRange_read(int8_tArray ser) {
46290         LDKu8slice ser_ref;
46291         ser_ref.datalen = ser->arr_len;
46292         ser_ref.data = ser->elems;
46293         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
46294         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
46295         FREE(ser);
46296         return tag_ptr(ret_conv, true);
46297 }
46298
46299 int8_tArray  CS_LDK_CommitmentSigned_write(int64_t obj) {
46300         LDKCommitmentSigned obj_conv;
46301         obj_conv.inner = untag_ptr(obj);
46302         obj_conv.is_owned = ptr_is_owned(obj);
46303         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46304         obj_conv.is_owned = false;
46305         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
46306         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46307         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46308         CVec_u8Z_free(ret_var);
46309         return ret_arr;
46310 }
46311
46312 int64_t  CS_LDK_CommitmentSigned_read(int8_tArray ser) {
46313         LDKu8slice ser_ref;
46314         ser_ref.datalen = ser->arr_len;
46315         ser_ref.data = ser->elems;
46316         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
46317         *ret_conv = CommitmentSigned_read(ser_ref);
46318         FREE(ser);
46319         return tag_ptr(ret_conv, true);
46320 }
46321
46322 int8_tArray  CS_LDK_FundingCreated_write(int64_t obj) {
46323         LDKFundingCreated obj_conv;
46324         obj_conv.inner = untag_ptr(obj);
46325         obj_conv.is_owned = ptr_is_owned(obj);
46326         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46327         obj_conv.is_owned = false;
46328         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
46329         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46330         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46331         CVec_u8Z_free(ret_var);
46332         return ret_arr;
46333 }
46334
46335 int64_t  CS_LDK_FundingCreated_read(int8_tArray ser) {
46336         LDKu8slice ser_ref;
46337         ser_ref.datalen = ser->arr_len;
46338         ser_ref.data = ser->elems;
46339         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
46340         *ret_conv = FundingCreated_read(ser_ref);
46341         FREE(ser);
46342         return tag_ptr(ret_conv, true);
46343 }
46344
46345 int8_tArray  CS_LDK_FundingSigned_write(int64_t obj) {
46346         LDKFundingSigned obj_conv;
46347         obj_conv.inner = untag_ptr(obj);
46348         obj_conv.is_owned = ptr_is_owned(obj);
46349         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46350         obj_conv.is_owned = false;
46351         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
46352         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46353         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46354         CVec_u8Z_free(ret_var);
46355         return ret_arr;
46356 }
46357
46358 int64_t  CS_LDK_FundingSigned_read(int8_tArray ser) {
46359         LDKu8slice ser_ref;
46360         ser_ref.datalen = ser->arr_len;
46361         ser_ref.data = ser->elems;
46362         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
46363         *ret_conv = FundingSigned_read(ser_ref);
46364         FREE(ser);
46365         return tag_ptr(ret_conv, true);
46366 }
46367
46368 int8_tArray  CS_LDK_ChannelReady_write(int64_t obj) {
46369         LDKChannelReady obj_conv;
46370         obj_conv.inner = untag_ptr(obj);
46371         obj_conv.is_owned = ptr_is_owned(obj);
46372         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46373         obj_conv.is_owned = false;
46374         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
46375         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46376         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46377         CVec_u8Z_free(ret_var);
46378         return ret_arr;
46379 }
46380
46381 int64_t  CS_LDK_ChannelReady_read(int8_tArray ser) {
46382         LDKu8slice ser_ref;
46383         ser_ref.datalen = ser->arr_len;
46384         ser_ref.data = ser->elems;
46385         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
46386         *ret_conv = ChannelReady_read(ser_ref);
46387         FREE(ser);
46388         return tag_ptr(ret_conv, true);
46389 }
46390
46391 int8_tArray  CS_LDK_Init_write(int64_t obj) {
46392         LDKInit obj_conv;
46393         obj_conv.inner = untag_ptr(obj);
46394         obj_conv.is_owned = ptr_is_owned(obj);
46395         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46396         obj_conv.is_owned = false;
46397         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
46398         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46399         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46400         CVec_u8Z_free(ret_var);
46401         return ret_arr;
46402 }
46403
46404 int64_t  CS_LDK_Init_read(int8_tArray ser) {
46405         LDKu8slice ser_ref;
46406         ser_ref.datalen = ser->arr_len;
46407         ser_ref.data = ser->elems;
46408         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
46409         *ret_conv = Init_read(ser_ref);
46410         FREE(ser);
46411         return tag_ptr(ret_conv, true);
46412 }
46413
46414 int8_tArray  CS_LDK_OpenChannel_write(int64_t obj) {
46415         LDKOpenChannel obj_conv;
46416         obj_conv.inner = untag_ptr(obj);
46417         obj_conv.is_owned = ptr_is_owned(obj);
46418         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46419         obj_conv.is_owned = false;
46420         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
46421         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46422         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46423         CVec_u8Z_free(ret_var);
46424         return ret_arr;
46425 }
46426
46427 int64_t  CS_LDK_OpenChannel_read(int8_tArray ser) {
46428         LDKu8slice ser_ref;
46429         ser_ref.datalen = ser->arr_len;
46430         ser_ref.data = ser->elems;
46431         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
46432         *ret_conv = OpenChannel_read(ser_ref);
46433         FREE(ser);
46434         return tag_ptr(ret_conv, true);
46435 }
46436
46437 int8_tArray  CS_LDK_OpenChannelV2_write(int64_t obj) {
46438         LDKOpenChannelV2 obj_conv;
46439         obj_conv.inner = untag_ptr(obj);
46440         obj_conv.is_owned = ptr_is_owned(obj);
46441         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46442         obj_conv.is_owned = false;
46443         LDKCVec_u8Z ret_var = OpenChannelV2_write(&obj_conv);
46444         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46445         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46446         CVec_u8Z_free(ret_var);
46447         return ret_arr;
46448 }
46449
46450 int64_t  CS_LDK_OpenChannelV2_read(int8_tArray ser) {
46451         LDKu8slice ser_ref;
46452         ser_ref.datalen = ser->arr_len;
46453         ser_ref.data = ser->elems;
46454         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
46455         *ret_conv = OpenChannelV2_read(ser_ref);
46456         FREE(ser);
46457         return tag_ptr(ret_conv, true);
46458 }
46459
46460 int8_tArray  CS_LDK_RevokeAndACK_write(int64_t obj) {
46461         LDKRevokeAndACK obj_conv;
46462         obj_conv.inner = untag_ptr(obj);
46463         obj_conv.is_owned = ptr_is_owned(obj);
46464         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46465         obj_conv.is_owned = false;
46466         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
46467         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46468         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46469         CVec_u8Z_free(ret_var);
46470         return ret_arr;
46471 }
46472
46473 int64_t  CS_LDK_RevokeAndACK_read(int8_tArray ser) {
46474         LDKu8slice ser_ref;
46475         ser_ref.datalen = ser->arr_len;
46476         ser_ref.data = ser->elems;
46477         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
46478         *ret_conv = RevokeAndACK_read(ser_ref);
46479         FREE(ser);
46480         return tag_ptr(ret_conv, true);
46481 }
46482
46483 int8_tArray  CS_LDK_Shutdown_write(int64_t obj) {
46484         LDKShutdown obj_conv;
46485         obj_conv.inner = untag_ptr(obj);
46486         obj_conv.is_owned = ptr_is_owned(obj);
46487         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46488         obj_conv.is_owned = false;
46489         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
46490         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46491         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46492         CVec_u8Z_free(ret_var);
46493         return ret_arr;
46494 }
46495
46496 int64_t  CS_LDK_Shutdown_read(int8_tArray ser) {
46497         LDKu8slice ser_ref;
46498         ser_ref.datalen = ser->arr_len;
46499         ser_ref.data = ser->elems;
46500         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
46501         *ret_conv = Shutdown_read(ser_ref);
46502         FREE(ser);
46503         return tag_ptr(ret_conv, true);
46504 }
46505
46506 int8_tArray  CS_LDK_UpdateFailHTLC_write(int64_t obj) {
46507         LDKUpdateFailHTLC obj_conv;
46508         obj_conv.inner = untag_ptr(obj);
46509         obj_conv.is_owned = ptr_is_owned(obj);
46510         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46511         obj_conv.is_owned = false;
46512         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
46513         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46514         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46515         CVec_u8Z_free(ret_var);
46516         return ret_arr;
46517 }
46518
46519 int64_t  CS_LDK_UpdateFailHTLC_read(int8_tArray ser) {
46520         LDKu8slice ser_ref;
46521         ser_ref.datalen = ser->arr_len;
46522         ser_ref.data = ser->elems;
46523         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
46524         *ret_conv = UpdateFailHTLC_read(ser_ref);
46525         FREE(ser);
46526         return tag_ptr(ret_conv, true);
46527 }
46528
46529 int8_tArray  CS_LDK_UpdateFailMalformedHTLC_write(int64_t obj) {
46530         LDKUpdateFailMalformedHTLC obj_conv;
46531         obj_conv.inner = untag_ptr(obj);
46532         obj_conv.is_owned = ptr_is_owned(obj);
46533         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46534         obj_conv.is_owned = false;
46535         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
46536         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46537         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46538         CVec_u8Z_free(ret_var);
46539         return ret_arr;
46540 }
46541
46542 int64_t  CS_LDK_UpdateFailMalformedHTLC_read(int8_tArray ser) {
46543         LDKu8slice ser_ref;
46544         ser_ref.datalen = ser->arr_len;
46545         ser_ref.data = ser->elems;
46546         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
46547         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
46548         FREE(ser);
46549         return tag_ptr(ret_conv, true);
46550 }
46551
46552 int8_tArray  CS_LDK_UpdateFee_write(int64_t obj) {
46553         LDKUpdateFee obj_conv;
46554         obj_conv.inner = untag_ptr(obj);
46555         obj_conv.is_owned = ptr_is_owned(obj);
46556         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46557         obj_conv.is_owned = false;
46558         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
46559         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46560         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46561         CVec_u8Z_free(ret_var);
46562         return ret_arr;
46563 }
46564
46565 int64_t  CS_LDK_UpdateFee_read(int8_tArray ser) {
46566         LDKu8slice ser_ref;
46567         ser_ref.datalen = ser->arr_len;
46568         ser_ref.data = ser->elems;
46569         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
46570         *ret_conv = UpdateFee_read(ser_ref);
46571         FREE(ser);
46572         return tag_ptr(ret_conv, true);
46573 }
46574
46575 int8_tArray  CS_LDK_UpdateFulfillHTLC_write(int64_t obj) {
46576         LDKUpdateFulfillHTLC obj_conv;
46577         obj_conv.inner = untag_ptr(obj);
46578         obj_conv.is_owned = ptr_is_owned(obj);
46579         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46580         obj_conv.is_owned = false;
46581         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
46582         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46583         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46584         CVec_u8Z_free(ret_var);
46585         return ret_arr;
46586 }
46587
46588 int64_t  CS_LDK_UpdateFulfillHTLC_read(int8_tArray ser) {
46589         LDKu8slice ser_ref;
46590         ser_ref.datalen = ser->arr_len;
46591         ser_ref.data = ser->elems;
46592         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
46593         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
46594         FREE(ser);
46595         return tag_ptr(ret_conv, true);
46596 }
46597
46598 int8_tArray  CS_LDK_UpdateAddHTLC_write(int64_t obj) {
46599         LDKUpdateAddHTLC obj_conv;
46600         obj_conv.inner = untag_ptr(obj);
46601         obj_conv.is_owned = ptr_is_owned(obj);
46602         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46603         obj_conv.is_owned = false;
46604         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
46605         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46606         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46607         CVec_u8Z_free(ret_var);
46608         return ret_arr;
46609 }
46610
46611 int64_t  CS_LDK_UpdateAddHTLC_read(int8_tArray ser) {
46612         LDKu8slice ser_ref;
46613         ser_ref.datalen = ser->arr_len;
46614         ser_ref.data = ser->elems;
46615         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
46616         *ret_conv = UpdateAddHTLC_read(ser_ref);
46617         FREE(ser);
46618         return tag_ptr(ret_conv, true);
46619 }
46620
46621 int64_t  CS_LDK_OnionMessage_read(int8_tArray ser) {
46622         LDKu8slice ser_ref;
46623         ser_ref.datalen = ser->arr_len;
46624         ser_ref.data = ser->elems;
46625         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
46626         *ret_conv = OnionMessage_read(ser_ref);
46627         FREE(ser);
46628         return tag_ptr(ret_conv, true);
46629 }
46630
46631 int8_tArray  CS_LDK_OnionMessage_write(int64_t obj) {
46632         LDKOnionMessage obj_conv;
46633         obj_conv.inner = untag_ptr(obj);
46634         obj_conv.is_owned = ptr_is_owned(obj);
46635         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46636         obj_conv.is_owned = false;
46637         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
46638         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46639         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46640         CVec_u8Z_free(ret_var);
46641         return ret_arr;
46642 }
46643
46644 int8_tArray  CS_LDK_Ping_write(int64_t obj) {
46645         LDKPing obj_conv;
46646         obj_conv.inner = untag_ptr(obj);
46647         obj_conv.is_owned = ptr_is_owned(obj);
46648         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46649         obj_conv.is_owned = false;
46650         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
46651         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46652         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46653         CVec_u8Z_free(ret_var);
46654         return ret_arr;
46655 }
46656
46657 int64_t  CS_LDK_Ping_read(int8_tArray ser) {
46658         LDKu8slice ser_ref;
46659         ser_ref.datalen = ser->arr_len;
46660         ser_ref.data = ser->elems;
46661         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
46662         *ret_conv = Ping_read(ser_ref);
46663         FREE(ser);
46664         return tag_ptr(ret_conv, true);
46665 }
46666
46667 int8_tArray  CS_LDK_Pong_write(int64_t obj) {
46668         LDKPong obj_conv;
46669         obj_conv.inner = untag_ptr(obj);
46670         obj_conv.is_owned = ptr_is_owned(obj);
46671         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46672         obj_conv.is_owned = false;
46673         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
46674         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46675         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46676         CVec_u8Z_free(ret_var);
46677         return ret_arr;
46678 }
46679
46680 int64_t  CS_LDK_Pong_read(int8_tArray ser) {
46681         LDKu8slice ser_ref;
46682         ser_ref.datalen = ser->arr_len;
46683         ser_ref.data = ser->elems;
46684         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
46685         *ret_conv = Pong_read(ser_ref);
46686         FREE(ser);
46687         return tag_ptr(ret_conv, true);
46688 }
46689
46690 int8_tArray  CS_LDK_UnsignedChannelAnnouncement_write(int64_t obj) {
46691         LDKUnsignedChannelAnnouncement obj_conv;
46692         obj_conv.inner = untag_ptr(obj);
46693         obj_conv.is_owned = ptr_is_owned(obj);
46694         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46695         obj_conv.is_owned = false;
46696         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
46697         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46698         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46699         CVec_u8Z_free(ret_var);
46700         return ret_arr;
46701 }
46702
46703 int64_t  CS_LDK_UnsignedChannelAnnouncement_read(int8_tArray ser) {
46704         LDKu8slice ser_ref;
46705         ser_ref.datalen = ser->arr_len;
46706         ser_ref.data = ser->elems;
46707         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
46708         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
46709         FREE(ser);
46710         return tag_ptr(ret_conv, true);
46711 }
46712
46713 int8_tArray  CS_LDK_ChannelAnnouncement_write(int64_t obj) {
46714         LDKChannelAnnouncement obj_conv;
46715         obj_conv.inner = untag_ptr(obj);
46716         obj_conv.is_owned = ptr_is_owned(obj);
46717         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46718         obj_conv.is_owned = false;
46719         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
46720         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46721         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46722         CVec_u8Z_free(ret_var);
46723         return ret_arr;
46724 }
46725
46726 int64_t  CS_LDK_ChannelAnnouncement_read(int8_tArray ser) {
46727         LDKu8slice ser_ref;
46728         ser_ref.datalen = ser->arr_len;
46729         ser_ref.data = ser->elems;
46730         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
46731         *ret_conv = ChannelAnnouncement_read(ser_ref);
46732         FREE(ser);
46733         return tag_ptr(ret_conv, true);
46734 }
46735
46736 int8_tArray  CS_LDK_UnsignedChannelUpdate_write(int64_t obj) {
46737         LDKUnsignedChannelUpdate obj_conv;
46738         obj_conv.inner = untag_ptr(obj);
46739         obj_conv.is_owned = ptr_is_owned(obj);
46740         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46741         obj_conv.is_owned = false;
46742         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
46743         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46744         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46745         CVec_u8Z_free(ret_var);
46746         return ret_arr;
46747 }
46748
46749 int64_t  CS_LDK_UnsignedChannelUpdate_read(int8_tArray ser) {
46750         LDKu8slice ser_ref;
46751         ser_ref.datalen = ser->arr_len;
46752         ser_ref.data = ser->elems;
46753         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
46754         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
46755         FREE(ser);
46756         return tag_ptr(ret_conv, true);
46757 }
46758
46759 int8_tArray  CS_LDK_ChannelUpdate_write(int64_t obj) {
46760         LDKChannelUpdate obj_conv;
46761         obj_conv.inner = untag_ptr(obj);
46762         obj_conv.is_owned = ptr_is_owned(obj);
46763         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46764         obj_conv.is_owned = false;
46765         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
46766         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46767         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46768         CVec_u8Z_free(ret_var);
46769         return ret_arr;
46770 }
46771
46772 int64_t  CS_LDK_ChannelUpdate_read(int8_tArray ser) {
46773         LDKu8slice ser_ref;
46774         ser_ref.datalen = ser->arr_len;
46775         ser_ref.data = ser->elems;
46776         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
46777         *ret_conv = ChannelUpdate_read(ser_ref);
46778         FREE(ser);
46779         return tag_ptr(ret_conv, true);
46780 }
46781
46782 int8_tArray  CS_LDK_ErrorMessage_write(int64_t obj) {
46783         LDKErrorMessage obj_conv;
46784         obj_conv.inner = untag_ptr(obj);
46785         obj_conv.is_owned = ptr_is_owned(obj);
46786         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46787         obj_conv.is_owned = false;
46788         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
46789         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46790         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46791         CVec_u8Z_free(ret_var);
46792         return ret_arr;
46793 }
46794
46795 int64_t  CS_LDK_ErrorMessage_read(int8_tArray ser) {
46796         LDKu8slice ser_ref;
46797         ser_ref.datalen = ser->arr_len;
46798         ser_ref.data = ser->elems;
46799         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
46800         *ret_conv = ErrorMessage_read(ser_ref);
46801         FREE(ser);
46802         return tag_ptr(ret_conv, true);
46803 }
46804
46805 int8_tArray  CS_LDK_WarningMessage_write(int64_t obj) {
46806         LDKWarningMessage obj_conv;
46807         obj_conv.inner = untag_ptr(obj);
46808         obj_conv.is_owned = ptr_is_owned(obj);
46809         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46810         obj_conv.is_owned = false;
46811         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
46812         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46813         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46814         CVec_u8Z_free(ret_var);
46815         return ret_arr;
46816 }
46817
46818 int64_t  CS_LDK_WarningMessage_read(int8_tArray ser) {
46819         LDKu8slice ser_ref;
46820         ser_ref.datalen = ser->arr_len;
46821         ser_ref.data = ser->elems;
46822         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
46823         *ret_conv = WarningMessage_read(ser_ref);
46824         FREE(ser);
46825         return tag_ptr(ret_conv, true);
46826 }
46827
46828 int8_tArray  CS_LDK_UnsignedNodeAnnouncement_write(int64_t obj) {
46829         LDKUnsignedNodeAnnouncement obj_conv;
46830         obj_conv.inner = untag_ptr(obj);
46831         obj_conv.is_owned = ptr_is_owned(obj);
46832         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46833         obj_conv.is_owned = false;
46834         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
46835         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46836         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46837         CVec_u8Z_free(ret_var);
46838         return ret_arr;
46839 }
46840
46841 int64_t  CS_LDK_UnsignedNodeAnnouncement_read(int8_tArray ser) {
46842         LDKu8slice ser_ref;
46843         ser_ref.datalen = ser->arr_len;
46844         ser_ref.data = ser->elems;
46845         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
46846         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
46847         FREE(ser);
46848         return tag_ptr(ret_conv, true);
46849 }
46850
46851 int8_tArray  CS_LDK_NodeAnnouncement_write(int64_t obj) {
46852         LDKNodeAnnouncement obj_conv;
46853         obj_conv.inner = untag_ptr(obj);
46854         obj_conv.is_owned = ptr_is_owned(obj);
46855         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46856         obj_conv.is_owned = false;
46857         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
46858         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46859         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46860         CVec_u8Z_free(ret_var);
46861         return ret_arr;
46862 }
46863
46864 int64_t  CS_LDK_NodeAnnouncement_read(int8_tArray ser) {
46865         LDKu8slice ser_ref;
46866         ser_ref.datalen = ser->arr_len;
46867         ser_ref.data = ser->elems;
46868         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
46869         *ret_conv = NodeAnnouncement_read(ser_ref);
46870         FREE(ser);
46871         return tag_ptr(ret_conv, true);
46872 }
46873
46874 int64_t  CS_LDK_QueryShortChannelIds_read(int8_tArray ser) {
46875         LDKu8slice ser_ref;
46876         ser_ref.datalen = ser->arr_len;
46877         ser_ref.data = ser->elems;
46878         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
46879         *ret_conv = QueryShortChannelIds_read(ser_ref);
46880         FREE(ser);
46881         return tag_ptr(ret_conv, true);
46882 }
46883
46884 int8_tArray  CS_LDK_QueryShortChannelIds_write(int64_t obj) {
46885         LDKQueryShortChannelIds obj_conv;
46886         obj_conv.inner = untag_ptr(obj);
46887         obj_conv.is_owned = ptr_is_owned(obj);
46888         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46889         obj_conv.is_owned = false;
46890         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
46891         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46892         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46893         CVec_u8Z_free(ret_var);
46894         return ret_arr;
46895 }
46896
46897 int8_tArray  CS_LDK_ReplyShortChannelIdsEnd_write(int64_t obj) {
46898         LDKReplyShortChannelIdsEnd obj_conv;
46899         obj_conv.inner = untag_ptr(obj);
46900         obj_conv.is_owned = ptr_is_owned(obj);
46901         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46902         obj_conv.is_owned = false;
46903         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
46904         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46905         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46906         CVec_u8Z_free(ret_var);
46907         return ret_arr;
46908 }
46909
46910 int64_t  CS_LDK_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
46911         LDKu8slice ser_ref;
46912         ser_ref.datalen = ser->arr_len;
46913         ser_ref.data = ser->elems;
46914         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
46915         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
46916         FREE(ser);
46917         return tag_ptr(ret_conv, true);
46918 }
46919
46920 int32_t  CS_LDK_QueryChannelRange_end_blocknum(int64_t this_arg) {
46921         LDKQueryChannelRange this_arg_conv;
46922         this_arg_conv.inner = untag_ptr(this_arg);
46923         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46925         this_arg_conv.is_owned = false;
46926         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
46927         return ret_conv;
46928 }
46929
46930 int8_tArray  CS_LDK_QueryChannelRange_write(int64_t obj) {
46931         LDKQueryChannelRange obj_conv;
46932         obj_conv.inner = untag_ptr(obj);
46933         obj_conv.is_owned = ptr_is_owned(obj);
46934         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46935         obj_conv.is_owned = false;
46936         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
46937         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46938         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46939         CVec_u8Z_free(ret_var);
46940         return ret_arr;
46941 }
46942
46943 int64_t  CS_LDK_QueryChannelRange_read(int8_tArray ser) {
46944         LDKu8slice ser_ref;
46945         ser_ref.datalen = ser->arr_len;
46946         ser_ref.data = ser->elems;
46947         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
46948         *ret_conv = QueryChannelRange_read(ser_ref);
46949         FREE(ser);
46950         return tag_ptr(ret_conv, true);
46951 }
46952
46953 int64_t  CS_LDK_ReplyChannelRange_read(int8_tArray ser) {
46954         LDKu8slice ser_ref;
46955         ser_ref.datalen = ser->arr_len;
46956         ser_ref.data = ser->elems;
46957         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
46958         *ret_conv = ReplyChannelRange_read(ser_ref);
46959         FREE(ser);
46960         return tag_ptr(ret_conv, true);
46961 }
46962
46963 int8_tArray  CS_LDK_ReplyChannelRange_write(int64_t obj) {
46964         LDKReplyChannelRange obj_conv;
46965         obj_conv.inner = untag_ptr(obj);
46966         obj_conv.is_owned = ptr_is_owned(obj);
46967         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46968         obj_conv.is_owned = false;
46969         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
46970         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46971         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46972         CVec_u8Z_free(ret_var);
46973         return ret_arr;
46974 }
46975
46976 int8_tArray  CS_LDK_GossipTimestampFilter_write(int64_t obj) {
46977         LDKGossipTimestampFilter obj_conv;
46978         obj_conv.inner = untag_ptr(obj);
46979         obj_conv.is_owned = ptr_is_owned(obj);
46980         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46981         obj_conv.is_owned = false;
46982         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
46983         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46984         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46985         CVec_u8Z_free(ret_var);
46986         return ret_arr;
46987 }
46988
46989 int64_t  CS_LDK_GossipTimestampFilter_read(int8_tArray ser) {
46990         LDKu8slice ser_ref;
46991         ser_ref.datalen = ser->arr_len;
46992         ser_ref.data = ser->elems;
46993         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
46994         *ret_conv = GossipTimestampFilter_read(ser_ref);
46995         FREE(ser);
46996         return tag_ptr(ret_conv, true);
46997 }
46998
46999 void  CS_LDK_CustomMessageHandler_free(int64_t this_ptr) {
47000         if (!ptr_is_owned(this_ptr)) return;
47001         void* this_ptr_ptr = untag_ptr(this_ptr);
47002         CHECK_ACCESS(this_ptr_ptr);
47003         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
47004         FREE(untag_ptr(this_ptr));
47005         CustomMessageHandler_free(this_ptr_conv);
47006 }
47007
47008 void  CS_LDK_IgnoringMessageHandler_free(int64_t this_obj) {
47009         LDKIgnoringMessageHandler this_obj_conv;
47010         this_obj_conv.inner = untag_ptr(this_obj);
47011         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47013         IgnoringMessageHandler_free(this_obj_conv);
47014 }
47015
47016 int64_t  CS_LDK_IgnoringMessageHandler_new() {
47017         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
47018         int64_t ret_ref = 0;
47019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47021         return ret_ref;
47022 }
47023
47024 int64_t  CS_LDK_IgnoringMessageHandler_as_MessageSendEventsProvider(int64_t this_arg) {
47025         LDKIgnoringMessageHandler this_arg_conv;
47026         this_arg_conv.inner = untag_ptr(this_arg);
47027         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47029         this_arg_conv.is_owned = false;
47030         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
47031         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
47032         return tag_ptr(ret_ret, true);
47033 }
47034
47035 int64_t  CS_LDK_IgnoringMessageHandler_as_RoutingMessageHandler(int64_t this_arg) {
47036         LDKIgnoringMessageHandler this_arg_conv;
47037         this_arg_conv.inner = untag_ptr(this_arg);
47038         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47040         this_arg_conv.is_owned = false;
47041         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
47042         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
47043         return tag_ptr(ret_ret, true);
47044 }
47045
47046 int64_t  CS_LDK_IgnoringMessageHandler_as_OnionMessageHandler(int64_t this_arg) {
47047         LDKIgnoringMessageHandler this_arg_conv;
47048         this_arg_conv.inner = untag_ptr(this_arg);
47049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47051         this_arg_conv.is_owned = false;
47052         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
47053         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
47054         return tag_ptr(ret_ret, true);
47055 }
47056
47057 int64_t  CS_LDK_IgnoringMessageHandler_as_OffersMessageHandler(int64_t this_arg) {
47058         LDKIgnoringMessageHandler this_arg_conv;
47059         this_arg_conv.inner = untag_ptr(this_arg);
47060         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47062         this_arg_conv.is_owned = false;
47063         LDKOffersMessageHandler* ret_ret = MALLOC(sizeof(LDKOffersMessageHandler), "LDKOffersMessageHandler");
47064         *ret_ret = IgnoringMessageHandler_as_OffersMessageHandler(&this_arg_conv);
47065         return tag_ptr(ret_ret, true);
47066 }
47067
47068 int64_t  CS_LDK_IgnoringMessageHandler_as_CustomOnionMessageHandler(int64_t this_arg) {
47069         LDKIgnoringMessageHandler this_arg_conv;
47070         this_arg_conv.inner = untag_ptr(this_arg);
47071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47073         this_arg_conv.is_owned = false;
47074         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
47075         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
47076         return tag_ptr(ret_ret, true);
47077 }
47078
47079 int64_t  CS_LDK_IgnoringMessageHandler_as_CustomMessageReader(int64_t this_arg) {
47080         LDKIgnoringMessageHandler this_arg_conv;
47081         this_arg_conv.inner = untag_ptr(this_arg);
47082         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47084         this_arg_conv.is_owned = false;
47085         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
47086         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
47087         return tag_ptr(ret_ret, true);
47088 }
47089
47090 int64_t  CS_LDK_IgnoringMessageHandler_as_CustomMessageHandler(int64_t this_arg) {
47091         LDKIgnoringMessageHandler this_arg_conv;
47092         this_arg_conv.inner = untag_ptr(this_arg);
47093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47095         this_arg_conv.is_owned = false;
47096         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
47097         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
47098         return tag_ptr(ret_ret, true);
47099 }
47100
47101 void  CS_LDK_ErroringMessageHandler_free(int64_t this_obj) {
47102         LDKErroringMessageHandler this_obj_conv;
47103         this_obj_conv.inner = untag_ptr(this_obj);
47104         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47106         ErroringMessageHandler_free(this_obj_conv);
47107 }
47108
47109 int64_t  CS_LDK_ErroringMessageHandler_new() {
47110         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
47111         int64_t ret_ref = 0;
47112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47114         return ret_ref;
47115 }
47116
47117 int64_t  CS_LDK_ErroringMessageHandler_as_MessageSendEventsProvider(int64_t this_arg) {
47118         LDKErroringMessageHandler this_arg_conv;
47119         this_arg_conv.inner = untag_ptr(this_arg);
47120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47122         this_arg_conv.is_owned = false;
47123         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
47124         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
47125         return tag_ptr(ret_ret, true);
47126 }
47127
47128 int64_t  CS_LDK_ErroringMessageHandler_as_ChannelMessageHandler(int64_t this_arg) {
47129         LDKErroringMessageHandler this_arg_conv;
47130         this_arg_conv.inner = untag_ptr(this_arg);
47131         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47133         this_arg_conv.is_owned = false;
47134         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
47135         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
47136         return tag_ptr(ret_ret, true);
47137 }
47138
47139 void  CS_LDK_MessageHandler_free(int64_t this_obj) {
47140         LDKMessageHandler this_obj_conv;
47141         this_obj_conv.inner = untag_ptr(this_obj);
47142         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47144         MessageHandler_free(this_obj_conv);
47145 }
47146
47147 int64_t  CS_LDK_MessageHandler_get_chan_handler(int64_t this_ptr) {
47148         LDKMessageHandler this_ptr_conv;
47149         this_ptr_conv.inner = untag_ptr(this_ptr);
47150         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47152         this_ptr_conv.is_owned = false;
47153         // WARNING: This object doesn't live past this scope, needs clone!
47154         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
47155         return ret_ret;
47156 }
47157
47158 void  CS_LDK_MessageHandler_set_chan_handler(int64_t this_ptr, int64_t val) {
47159         LDKMessageHandler this_ptr_conv;
47160         this_ptr_conv.inner = untag_ptr(this_ptr);
47161         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47163         this_ptr_conv.is_owned = false;
47164         void* val_ptr = untag_ptr(val);
47165         CHECK_ACCESS(val_ptr);
47166         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
47167         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
47168                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47169                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
47170         }
47171         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
47172 }
47173
47174 int64_t  CS_LDK_MessageHandler_get_route_handler(int64_t this_ptr) {
47175         LDKMessageHandler this_ptr_conv;
47176         this_ptr_conv.inner = untag_ptr(this_ptr);
47177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47179         this_ptr_conv.is_owned = false;
47180         // WARNING: This object doesn't live past this scope, needs clone!
47181         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
47182         return ret_ret;
47183 }
47184
47185 void  CS_LDK_MessageHandler_set_route_handler(int64_t this_ptr, int64_t val) {
47186         LDKMessageHandler this_ptr_conv;
47187         this_ptr_conv.inner = untag_ptr(this_ptr);
47188         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47190         this_ptr_conv.is_owned = false;
47191         void* val_ptr = untag_ptr(val);
47192         CHECK_ACCESS(val_ptr);
47193         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
47194         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
47195                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47196                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
47197         }
47198         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
47199 }
47200
47201 int64_t  CS_LDK_MessageHandler_get_onion_message_handler(int64_t this_ptr) {
47202         LDKMessageHandler this_ptr_conv;
47203         this_ptr_conv.inner = untag_ptr(this_ptr);
47204         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47206         this_ptr_conv.is_owned = false;
47207         // WARNING: This object doesn't live past this scope, needs clone!
47208         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
47209         return ret_ret;
47210 }
47211
47212 void  CS_LDK_MessageHandler_set_onion_message_handler(int64_t this_ptr, int64_t val) {
47213         LDKMessageHandler this_ptr_conv;
47214         this_ptr_conv.inner = untag_ptr(this_ptr);
47215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47217         this_ptr_conv.is_owned = false;
47218         void* val_ptr = untag_ptr(val);
47219         CHECK_ACCESS(val_ptr);
47220         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
47221         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
47222                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47223                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
47224         }
47225         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
47226 }
47227
47228 int64_t  CS_LDK_MessageHandler_get_custom_message_handler(int64_t this_ptr) {
47229         LDKMessageHandler this_ptr_conv;
47230         this_ptr_conv.inner = untag_ptr(this_ptr);
47231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47233         this_ptr_conv.is_owned = false;
47234         // WARNING: This object doesn't live past this scope, needs clone!
47235         int64_t ret_ret = tag_ptr(MessageHandler_get_custom_message_handler(&this_ptr_conv), false);
47236         return ret_ret;
47237 }
47238
47239 void  CS_LDK_MessageHandler_set_custom_message_handler(int64_t this_ptr, int64_t val) {
47240         LDKMessageHandler this_ptr_conv;
47241         this_ptr_conv.inner = untag_ptr(this_ptr);
47242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47244         this_ptr_conv.is_owned = false;
47245         void* val_ptr = untag_ptr(val);
47246         CHECK_ACCESS(val_ptr);
47247         LDKCustomMessageHandler val_conv = *(LDKCustomMessageHandler*)(val_ptr);
47248         if (val_conv.free == LDKCustomMessageHandler_JCalls_free) {
47249                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47250                 LDKCustomMessageHandler_JCalls_cloned(&val_conv);
47251         }
47252         MessageHandler_set_custom_message_handler(&this_ptr_conv, val_conv);
47253 }
47254
47255 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) {
47256         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
47257         CHECK_ACCESS(chan_handler_arg_ptr);
47258         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
47259         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
47260                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47261                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
47262         }
47263         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
47264         CHECK_ACCESS(route_handler_arg_ptr);
47265         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
47266         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
47267                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47268                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
47269         }
47270         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
47271         CHECK_ACCESS(onion_message_handler_arg_ptr);
47272         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
47273         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
47274                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47275                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
47276         }
47277         void* custom_message_handler_arg_ptr = untag_ptr(custom_message_handler_arg);
47278         CHECK_ACCESS(custom_message_handler_arg_ptr);
47279         LDKCustomMessageHandler custom_message_handler_arg_conv = *(LDKCustomMessageHandler*)(custom_message_handler_arg_ptr);
47280         if (custom_message_handler_arg_conv.free == LDKCustomMessageHandler_JCalls_free) {
47281                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47282                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_arg_conv);
47283         }
47284         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv, custom_message_handler_arg_conv);
47285         int64_t ret_ref = 0;
47286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47288         return ret_ref;
47289 }
47290
47291 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
47292         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
47293         *ret_ret = SocketDescriptor_clone(arg);
47294         return tag_ptr(ret_ret, true);
47295 }
47296 int64_t  CS_LDK_SocketDescriptor_clone_ptr(int64_t arg) {
47297         void* arg_ptr = untag_ptr(arg);
47298         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
47299         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
47300         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
47301         return ret_conv;
47302 }
47303
47304 int64_t  CS_LDK_SocketDescriptor_clone(int64_t orig) {
47305         void* orig_ptr = untag_ptr(orig);
47306         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
47307         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
47308         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
47309         *ret_ret = SocketDescriptor_clone(orig_conv);
47310         return tag_ptr(ret_ret, true);
47311 }
47312
47313 void  CS_LDK_SocketDescriptor_free(int64_t this_ptr) {
47314         if (!ptr_is_owned(this_ptr)) return;
47315         void* this_ptr_ptr = untag_ptr(this_ptr);
47316         CHECK_ACCESS(this_ptr_ptr);
47317         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
47318         FREE(untag_ptr(this_ptr));
47319         SocketDescriptor_free(this_ptr_conv);
47320 }
47321
47322 void  CS_LDK_PeerHandleError_free(int64_t this_obj) {
47323         LDKPeerHandleError this_obj_conv;
47324         this_obj_conv.inner = untag_ptr(this_obj);
47325         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47327         PeerHandleError_free(this_obj_conv);
47328 }
47329
47330 int64_t  CS_LDK_PeerHandleError_new() {
47331         LDKPeerHandleError ret_var = PeerHandleError_new();
47332         int64_t ret_ref = 0;
47333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47334         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47335         return ret_ref;
47336 }
47337
47338 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
47339         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
47340         int64_t ret_ref = 0;
47341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47342         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47343         return ret_ref;
47344 }
47345 int64_t  CS_LDK_PeerHandleError_clone_ptr(int64_t arg) {
47346         LDKPeerHandleError arg_conv;
47347         arg_conv.inner = untag_ptr(arg);
47348         arg_conv.is_owned = ptr_is_owned(arg);
47349         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47350         arg_conv.is_owned = false;
47351         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
47352         return ret_conv;
47353 }
47354
47355 int64_t  CS_LDK_PeerHandleError_clone(int64_t orig) {
47356         LDKPeerHandleError orig_conv;
47357         orig_conv.inner = untag_ptr(orig);
47358         orig_conv.is_owned = ptr_is_owned(orig);
47359         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47360         orig_conv.is_owned = false;
47361         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
47362         int64_t ret_ref = 0;
47363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47364         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47365         return ret_ref;
47366 }
47367
47368 void  CS_LDK_PeerManager_free(int64_t this_obj) {
47369         LDKPeerManager this_obj_conv;
47370         this_obj_conv.inner = untag_ptr(this_obj);
47371         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47373         PeerManager_free(this_obj_conv);
47374 }
47375
47376 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) {
47377         LDKMessageHandler message_handler_conv;
47378         message_handler_conv.inner = untag_ptr(message_handler);
47379         message_handler_conv.is_owned = ptr_is_owned(message_handler);
47380         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
47381         // WARNING: we need a move here but no clone is available for LDKMessageHandler
47382         
47383         uint8_t ephemeral_random_data_arr[32];
47384         CHECK(ephemeral_random_data->arr_len == 32);
47385         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
47386         uint8_t (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
47387         void* logger_ptr = untag_ptr(logger);
47388         CHECK_ACCESS(logger_ptr);
47389         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47390         if (logger_conv.free == LDKLogger_JCalls_free) {
47391                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47392                 LDKLogger_JCalls_cloned(&logger_conv);
47393         }
47394         void* node_signer_ptr = untag_ptr(node_signer);
47395         CHECK_ACCESS(node_signer_ptr);
47396         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
47397         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
47398                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47399                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
47400         }
47401         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, current_time, ephemeral_random_data_ref, logger_conv, node_signer_conv);
47402         int64_t ret_ref = 0;
47403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47404         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47405         return ret_ref;
47406 }
47407
47408 int64_tArray  CS_LDK_PeerManager_get_peer_node_ids(int64_t this_arg) {
47409         LDKPeerManager this_arg_conv;
47410         this_arg_conv.inner = untag_ptr(this_arg);
47411         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47413         this_arg_conv.is_owned = false;
47414         LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
47415         int64_tArray ret_arr = NULL;
47416         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
47417         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
47418         for (size_t r = 0; r < ret_var.datalen; r++) {
47419                 LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* ret_conv_43_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKC2Tuple_PublicKeyCOption_SocketAddressZZ");
47420                 *ret_conv_43_conv = ret_var.data[r];
47421                 ret_arr_ptr[r] = tag_ptr(ret_conv_43_conv, true);
47422         }
47423         
47424         FREE(ret_var.data);
47425         return ret_arr;
47426 }
47427
47428 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) {
47429         LDKPeerManager this_arg_conv;
47430         this_arg_conv.inner = untag_ptr(this_arg);
47431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47433         this_arg_conv.is_owned = false;
47434         LDKPublicKey their_node_id_ref;
47435         CHECK(their_node_id->arr_len == 33);
47436         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
47437         void* descriptor_ptr = untag_ptr(descriptor);
47438         CHECK_ACCESS(descriptor_ptr);
47439         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
47440         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
47441                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47442                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
47443         }
47444         void* remote_network_address_ptr = untag_ptr(remote_network_address);
47445         CHECK_ACCESS(remote_network_address_ptr);
47446         LDKCOption_SocketAddressZ remote_network_address_conv = *(LDKCOption_SocketAddressZ*)(remote_network_address_ptr);
47447         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
47448         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
47449         return tag_ptr(ret_conv, true);
47450 }
47451
47452 int64_t  CS_LDK_PeerManager_new_inbound_connection(int64_t this_arg, int64_t descriptor, int64_t remote_network_address) {
47453         LDKPeerManager this_arg_conv;
47454         this_arg_conv.inner = untag_ptr(this_arg);
47455         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47457         this_arg_conv.is_owned = false;
47458         void* descriptor_ptr = untag_ptr(descriptor);
47459         CHECK_ACCESS(descriptor_ptr);
47460         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
47461         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
47462                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47463                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
47464         }
47465         void* remote_network_address_ptr = untag_ptr(remote_network_address);
47466         CHECK_ACCESS(remote_network_address_ptr);
47467         LDKCOption_SocketAddressZ remote_network_address_conv = *(LDKCOption_SocketAddressZ*)(remote_network_address_ptr);
47468         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
47469         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
47470         return tag_ptr(ret_conv, true);
47471 }
47472
47473 int64_t  CS_LDK_PeerManager_write_buffer_space_avail(int64_t this_arg, int64_t descriptor) {
47474         LDKPeerManager this_arg_conv;
47475         this_arg_conv.inner = untag_ptr(this_arg);
47476         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47478         this_arg_conv.is_owned = false;
47479         void* descriptor_ptr = untag_ptr(descriptor);
47480         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
47481         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
47482         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
47483         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
47484         return tag_ptr(ret_conv, true);
47485 }
47486
47487 int64_t  CS_LDK_PeerManager_read_event(int64_t this_arg, int64_t peer_descriptor, int8_tArray data) {
47488         LDKPeerManager this_arg_conv;
47489         this_arg_conv.inner = untag_ptr(this_arg);
47490         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47492         this_arg_conv.is_owned = false;
47493         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
47494         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
47495         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
47496         LDKu8slice data_ref;
47497         data_ref.datalen = data->arr_len;
47498         data_ref.data = data->elems;
47499         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
47500         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
47501         FREE(data);
47502         return tag_ptr(ret_conv, true);
47503 }
47504
47505 void  CS_LDK_PeerManager_process_events(int64_t this_arg) {
47506         LDKPeerManager this_arg_conv;
47507         this_arg_conv.inner = untag_ptr(this_arg);
47508         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47510         this_arg_conv.is_owned = false;
47511         PeerManager_process_events(&this_arg_conv);
47512 }
47513
47514 void  CS_LDK_PeerManager_socket_disconnected(int64_t this_arg, int64_t descriptor) {
47515         LDKPeerManager this_arg_conv;
47516         this_arg_conv.inner = untag_ptr(this_arg);
47517         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47519         this_arg_conv.is_owned = false;
47520         void* descriptor_ptr = untag_ptr(descriptor);
47521         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
47522         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
47523         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
47524 }
47525
47526 void  CS_LDK_PeerManager_disconnect_by_node_id(int64_t this_arg, int8_tArray node_id) {
47527         LDKPeerManager this_arg_conv;
47528         this_arg_conv.inner = untag_ptr(this_arg);
47529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47531         this_arg_conv.is_owned = false;
47532         LDKPublicKey node_id_ref;
47533         CHECK(node_id->arr_len == 33);
47534         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
47535         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref);
47536 }
47537
47538 void  CS_LDK_PeerManager_disconnect_all_peers(int64_t this_arg) {
47539         LDKPeerManager this_arg_conv;
47540         this_arg_conv.inner = untag_ptr(this_arg);
47541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47543         this_arg_conv.is_owned = false;
47544         PeerManager_disconnect_all_peers(&this_arg_conv);
47545 }
47546
47547 void  CS_LDK_PeerManager_timer_tick_occurred(int64_t this_arg) {
47548         LDKPeerManager this_arg_conv;
47549         this_arg_conv.inner = untag_ptr(this_arg);
47550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47552         this_arg_conv.is_owned = false;
47553         PeerManager_timer_tick_occurred(&this_arg_conv);
47554 }
47555
47556 void  CS_LDK_PeerManager_broadcast_node_announcement(int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
47557         LDKPeerManager this_arg_conv;
47558         this_arg_conv.inner = untag_ptr(this_arg);
47559         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47561         this_arg_conv.is_owned = false;
47562         LDKThreeBytes rgb_ref;
47563         CHECK(rgb->arr_len == 3);
47564         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
47565         LDKThirtyTwoBytes alias_ref;
47566         CHECK(alias->arr_len == 32);
47567         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
47568         LDKCVec_SocketAddressZ addresses_constr;
47569         addresses_constr.datalen = addresses->arr_len;
47570         if (addresses_constr.datalen > 0)
47571                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKSocketAddress), "LDKCVec_SocketAddressZ Elements");
47572         else
47573                 addresses_constr.data = NULL;
47574         int64_t* addresses_vals = addresses->elems;
47575         for (size_t p = 0; p < addresses_constr.datalen; p++) {
47576                 int64_t addresses_conv_15 = addresses_vals[p];
47577                 void* addresses_conv_15_ptr = untag_ptr(addresses_conv_15);
47578                 CHECK_ACCESS(addresses_conv_15_ptr);
47579                 LDKSocketAddress addresses_conv_15_conv = *(LDKSocketAddress*)(addresses_conv_15_ptr);
47580                 addresses_constr.data[p] = addresses_conv_15_conv;
47581         }
47582         FREE(addresses);
47583         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
47584 }
47585
47586 int64_t  CS_LDK_htlc_success_tx_weight(int64_t channel_type_features) {
47587         LDKChannelTypeFeatures channel_type_features_conv;
47588         channel_type_features_conv.inner = untag_ptr(channel_type_features);
47589         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
47590         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
47591         channel_type_features_conv.is_owned = false;
47592         int64_t ret_conv = htlc_success_tx_weight(&channel_type_features_conv);
47593         return ret_conv;
47594 }
47595
47596 int64_t  CS_LDK_htlc_timeout_tx_weight(int64_t channel_type_features) {
47597         LDKChannelTypeFeatures channel_type_features_conv;
47598         channel_type_features_conv.inner = untag_ptr(channel_type_features);
47599         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
47600         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
47601         channel_type_features_conv.is_owned = false;
47602         int64_t ret_conv = htlc_timeout_tx_weight(&channel_type_features_conv);
47603         return ret_conv;
47604 }
47605
47606 int32_t  CS_LDK_HTLCClaim_clone(int64_t orig) {
47607         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
47608         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_clone(orig_conv));
47609         return ret_conv;
47610 }
47611
47612 int32_t  CS_LDK_HTLCClaim_offered_timeout() {
47613         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_offered_timeout());
47614         return ret_conv;
47615 }
47616
47617 int32_t  CS_LDK_HTLCClaim_offered_preimage() {
47618         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_offered_preimage());
47619         return ret_conv;
47620 }
47621
47622 int32_t  CS_LDK_HTLCClaim_accepted_timeout() {
47623         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_accepted_timeout());
47624         return ret_conv;
47625 }
47626
47627 int32_t  CS_LDK_HTLCClaim_accepted_preimage() {
47628         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_accepted_preimage());
47629         return ret_conv;
47630 }
47631
47632 int32_t  CS_LDK_HTLCClaim_revocation() {
47633         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_revocation());
47634         return ret_conv;
47635 }
47636
47637 jboolean  CS_LDK_HTLCClaim_eq(int64_t a, int64_t b) {
47638         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
47639         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
47640         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
47641         return ret_conv;
47642 }
47643
47644 int64_t  CS_LDK_HTLCClaim_from_witness(int8_tArray witness) {
47645         LDKWitness witness_ref;
47646         witness_ref.datalen = witness->arr_len;
47647         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
47648         memcpy(witness_ref.data, witness->elems, witness_ref.datalen); FREE(witness);
47649         witness_ref.data_is_owned = true;
47650         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
47651         *ret_copy = HTLCClaim_from_witness(witness_ref);
47652         int64_t ret_ref = tag_ptr(ret_copy, true);
47653         return ret_ref;
47654 }
47655
47656 int8_tArray  CS_LDK_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
47657         uint8_t commitment_seed_arr[32];
47658         CHECK(commitment_seed->arr_len == 32);
47659         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
47660         uint8_t (*commitment_seed_ref)[32] = &commitment_seed_arr;
47661         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
47662         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
47663         return ret_arr;
47664 }
47665
47666 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) {
47667         LDKCVec_u8Z to_holder_script_ref;
47668         to_holder_script_ref.datalen = to_holder_script->arr_len;
47669         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
47670         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
47671         LDKCVec_u8Z to_counterparty_script_ref;
47672         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
47673         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
47674         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
47675         LDKOutPoint funding_outpoint_conv;
47676         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
47677         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
47678         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
47679         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
47680         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);
47681         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
47682         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
47683         Transaction_free(ret_var);
47684         return ret_arr;
47685 }
47686
47687 void  CS_LDK_CounterpartyCommitmentSecrets_free(int64_t this_obj) {
47688         LDKCounterpartyCommitmentSecrets this_obj_conv;
47689         this_obj_conv.inner = untag_ptr(this_obj);
47690         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47692         CounterpartyCommitmentSecrets_free(this_obj_conv);
47693 }
47694
47695 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
47696         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
47697         int64_t ret_ref = 0;
47698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47700         return ret_ref;
47701 }
47702 int64_t  CS_LDK_CounterpartyCommitmentSecrets_clone_ptr(int64_t arg) {
47703         LDKCounterpartyCommitmentSecrets arg_conv;
47704         arg_conv.inner = untag_ptr(arg);
47705         arg_conv.is_owned = ptr_is_owned(arg);
47706         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47707         arg_conv.is_owned = false;
47708         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
47709         return ret_conv;
47710 }
47711
47712 int64_t  CS_LDK_CounterpartyCommitmentSecrets_clone(int64_t orig) {
47713         LDKCounterpartyCommitmentSecrets orig_conv;
47714         orig_conv.inner = untag_ptr(orig);
47715         orig_conv.is_owned = ptr_is_owned(orig);
47716         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47717         orig_conv.is_owned = false;
47718         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
47719         int64_t ret_ref = 0;
47720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47722         return ret_ref;
47723 }
47724
47725 int64_t  CS_LDK_CounterpartyCommitmentSecrets_new() {
47726         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
47727         int64_t ret_ref = 0;
47728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47730         return ret_ref;
47731 }
47732
47733 int64_t  CS_LDK_CounterpartyCommitmentSecrets_get_min_seen_secret(int64_t this_arg) {
47734         LDKCounterpartyCommitmentSecrets this_arg_conv;
47735         this_arg_conv.inner = untag_ptr(this_arg);
47736         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47738         this_arg_conv.is_owned = false;
47739         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
47740         return ret_conv;
47741 }
47742
47743 int64_t  CS_LDK_CounterpartyCommitmentSecrets_provide_secret(int64_t this_arg, int64_t idx, int8_tArray secret) {
47744         LDKCounterpartyCommitmentSecrets this_arg_conv;
47745         this_arg_conv.inner = untag_ptr(this_arg);
47746         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47748         this_arg_conv.is_owned = false;
47749         LDKThirtyTwoBytes secret_ref;
47750         CHECK(secret->arr_len == 32);
47751         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
47752         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
47753         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
47754         return tag_ptr(ret_conv, true);
47755 }
47756
47757 int8_tArray  CS_LDK_CounterpartyCommitmentSecrets_get_secret(int64_t this_arg, int64_t idx) {
47758         LDKCounterpartyCommitmentSecrets this_arg_conv;
47759         this_arg_conv.inner = untag_ptr(this_arg);
47760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47762         this_arg_conv.is_owned = false;
47763         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
47764         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
47765         return ret_arr;
47766 }
47767
47768 int8_tArray  CS_LDK_CounterpartyCommitmentSecrets_write(int64_t obj) {
47769         LDKCounterpartyCommitmentSecrets obj_conv;
47770         obj_conv.inner = untag_ptr(obj);
47771         obj_conv.is_owned = ptr_is_owned(obj);
47772         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47773         obj_conv.is_owned = false;
47774         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
47775         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
47776         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
47777         CVec_u8Z_free(ret_var);
47778         return ret_arr;
47779 }
47780
47781 int64_t  CS_LDK_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
47782         LDKu8slice ser_ref;
47783         ser_ref.datalen = ser->arr_len;
47784         ser_ref.data = ser->elems;
47785         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
47786         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
47787         FREE(ser);
47788         return tag_ptr(ret_conv, true);
47789 }
47790
47791 int8_tArray  CS_LDK_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
47792         LDKPublicKey per_commitment_point_ref;
47793         CHECK(per_commitment_point->arr_len == 33);
47794         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
47795         uint8_t base_secret_arr[32];
47796         CHECK(base_secret->arr_len == 32);
47797         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
47798         uint8_t (*base_secret_ref)[32] = &base_secret_arr;
47799         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
47800         memcpy(ret_arr->elems, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes, 32);
47801         return ret_arr;
47802 }
47803
47804 int8_tArray  CS_LDK_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
47805         LDKPublicKey per_commitment_point_ref;
47806         CHECK(per_commitment_point->arr_len == 33);
47807         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
47808         LDKPublicKey base_point_ref;
47809         CHECK(base_point->arr_len == 33);
47810         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
47811         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47812         memcpy(ret_arr->elems, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form, 33);
47813         return ret_arr;
47814 }
47815
47816 int8_tArray  CS_LDK_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
47817         uint8_t per_commitment_secret_arr[32];
47818         CHECK(per_commitment_secret->arr_len == 32);
47819         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
47820         uint8_t (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
47821         uint8_t countersignatory_revocation_base_secret_arr[32];
47822         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
47823         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
47824         uint8_t (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
47825         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
47826         memcpy(ret_arr->elems, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes, 32);
47827         return ret_arr;
47828 }
47829
47830 int8_tArray  CS_LDK_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
47831         LDKPublicKey per_commitment_point_ref;
47832         CHECK(per_commitment_point->arr_len == 33);
47833         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
47834         LDKPublicKey countersignatory_revocation_base_point_ref;
47835         CHECK(countersignatory_revocation_base_point->arr_len == 33);
47836         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
47837         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47838         memcpy(ret_arr->elems, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form, 33);
47839         return ret_arr;
47840 }
47841
47842 void  CS_LDK_TxCreationKeys_free(int64_t this_obj) {
47843         LDKTxCreationKeys this_obj_conv;
47844         this_obj_conv.inner = untag_ptr(this_obj);
47845         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47847         TxCreationKeys_free(this_obj_conv);
47848 }
47849
47850 int8_tArray  CS_LDK_TxCreationKeys_get_per_commitment_point(int64_t this_ptr) {
47851         LDKTxCreationKeys this_ptr_conv;
47852         this_ptr_conv.inner = untag_ptr(this_ptr);
47853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47855         this_ptr_conv.is_owned = false;
47856         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47857         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
47858         return ret_arr;
47859 }
47860
47861 void  CS_LDK_TxCreationKeys_set_per_commitment_point(int64_t this_ptr, int8_tArray val) {
47862         LDKTxCreationKeys this_ptr_conv;
47863         this_ptr_conv.inner = untag_ptr(this_ptr);
47864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47866         this_ptr_conv.is_owned = false;
47867         LDKPublicKey val_ref;
47868         CHECK(val->arr_len == 33);
47869         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47870         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
47871 }
47872
47873 int8_tArray  CS_LDK_TxCreationKeys_get_revocation_key(int64_t this_ptr) {
47874         LDKTxCreationKeys this_ptr_conv;
47875         this_ptr_conv.inner = untag_ptr(this_ptr);
47876         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47878         this_ptr_conv.is_owned = false;
47879         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47880         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
47881         return ret_arr;
47882 }
47883
47884 void  CS_LDK_TxCreationKeys_set_revocation_key(int64_t this_ptr, int8_tArray val) {
47885         LDKTxCreationKeys this_ptr_conv;
47886         this_ptr_conv.inner = untag_ptr(this_ptr);
47887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47889         this_ptr_conv.is_owned = false;
47890         LDKPublicKey val_ref;
47891         CHECK(val->arr_len == 33);
47892         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47893         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
47894 }
47895
47896 int8_tArray  CS_LDK_TxCreationKeys_get_broadcaster_htlc_key(int64_t this_ptr) {
47897         LDKTxCreationKeys this_ptr_conv;
47898         this_ptr_conv.inner = untag_ptr(this_ptr);
47899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47901         this_ptr_conv.is_owned = false;
47902         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47903         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
47904         return ret_arr;
47905 }
47906
47907 void  CS_LDK_TxCreationKeys_set_broadcaster_htlc_key(int64_t this_ptr, int8_tArray val) {
47908         LDKTxCreationKeys this_ptr_conv;
47909         this_ptr_conv.inner = untag_ptr(this_ptr);
47910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47912         this_ptr_conv.is_owned = false;
47913         LDKPublicKey val_ref;
47914         CHECK(val->arr_len == 33);
47915         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47916         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
47917 }
47918
47919 int8_tArray  CS_LDK_TxCreationKeys_get_countersignatory_htlc_key(int64_t this_ptr) {
47920         LDKTxCreationKeys this_ptr_conv;
47921         this_ptr_conv.inner = untag_ptr(this_ptr);
47922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47924         this_ptr_conv.is_owned = false;
47925         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47926         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
47927         return ret_arr;
47928 }
47929
47930 void  CS_LDK_TxCreationKeys_set_countersignatory_htlc_key(int64_t this_ptr, int8_tArray val) {
47931         LDKTxCreationKeys this_ptr_conv;
47932         this_ptr_conv.inner = untag_ptr(this_ptr);
47933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47935         this_ptr_conv.is_owned = false;
47936         LDKPublicKey val_ref;
47937         CHECK(val->arr_len == 33);
47938         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47939         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
47940 }
47941
47942 int8_tArray  CS_LDK_TxCreationKeys_get_broadcaster_delayed_payment_key(int64_t this_ptr) {
47943         LDKTxCreationKeys this_ptr_conv;
47944         this_ptr_conv.inner = untag_ptr(this_ptr);
47945         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47947         this_ptr_conv.is_owned = false;
47948         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47949         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
47950         return ret_arr;
47951 }
47952
47953 void  CS_LDK_TxCreationKeys_set_broadcaster_delayed_payment_key(int64_t this_ptr, int8_tArray val) {
47954         LDKTxCreationKeys this_ptr_conv;
47955         this_ptr_conv.inner = untag_ptr(this_ptr);
47956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47958         this_ptr_conv.is_owned = false;
47959         LDKPublicKey val_ref;
47960         CHECK(val->arr_len == 33);
47961         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47962         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
47963 }
47964
47965 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) {
47966         LDKPublicKey per_commitment_point_arg_ref;
47967         CHECK(per_commitment_point_arg->arr_len == 33);
47968         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
47969         LDKPublicKey revocation_key_arg_ref;
47970         CHECK(revocation_key_arg->arr_len == 33);
47971         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
47972         LDKPublicKey broadcaster_htlc_key_arg_ref;
47973         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
47974         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
47975         LDKPublicKey countersignatory_htlc_key_arg_ref;
47976         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
47977         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
47978         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
47979         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
47980         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
47981         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);
47982         int64_t ret_ref = 0;
47983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47984         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47985         return ret_ref;
47986 }
47987
47988 jboolean  CS_LDK_TxCreationKeys_eq(int64_t a, int64_t b) {
47989         LDKTxCreationKeys a_conv;
47990         a_conv.inner = untag_ptr(a);
47991         a_conv.is_owned = ptr_is_owned(a);
47992         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47993         a_conv.is_owned = false;
47994         LDKTxCreationKeys b_conv;
47995         b_conv.inner = untag_ptr(b);
47996         b_conv.is_owned = ptr_is_owned(b);
47997         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47998         b_conv.is_owned = false;
47999         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
48000         return ret_conv;
48001 }
48002
48003 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
48004         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
48005         int64_t ret_ref = 0;
48006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48008         return ret_ref;
48009 }
48010 int64_t  CS_LDK_TxCreationKeys_clone_ptr(int64_t arg) {
48011         LDKTxCreationKeys arg_conv;
48012         arg_conv.inner = untag_ptr(arg);
48013         arg_conv.is_owned = ptr_is_owned(arg);
48014         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48015         arg_conv.is_owned = false;
48016         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
48017         return ret_conv;
48018 }
48019
48020 int64_t  CS_LDK_TxCreationKeys_clone(int64_t orig) {
48021         LDKTxCreationKeys orig_conv;
48022         orig_conv.inner = untag_ptr(orig);
48023         orig_conv.is_owned = ptr_is_owned(orig);
48024         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48025         orig_conv.is_owned = false;
48026         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
48027         int64_t ret_ref = 0;
48028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48030         return ret_ref;
48031 }
48032
48033 int8_tArray  CS_LDK_TxCreationKeys_write(int64_t obj) {
48034         LDKTxCreationKeys obj_conv;
48035         obj_conv.inner = untag_ptr(obj);
48036         obj_conv.is_owned = ptr_is_owned(obj);
48037         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48038         obj_conv.is_owned = false;
48039         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
48040         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48041         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48042         CVec_u8Z_free(ret_var);
48043         return ret_arr;
48044 }
48045
48046 int64_t  CS_LDK_TxCreationKeys_read(int8_tArray ser) {
48047         LDKu8slice ser_ref;
48048         ser_ref.datalen = ser->arr_len;
48049         ser_ref.data = ser->elems;
48050         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
48051         *ret_conv = TxCreationKeys_read(ser_ref);
48052         FREE(ser);
48053         return tag_ptr(ret_conv, true);
48054 }
48055
48056 void  CS_LDK_ChannelPublicKeys_free(int64_t this_obj) {
48057         LDKChannelPublicKeys this_obj_conv;
48058         this_obj_conv.inner = untag_ptr(this_obj);
48059         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48061         ChannelPublicKeys_free(this_obj_conv);
48062 }
48063
48064 int8_tArray  CS_LDK_ChannelPublicKeys_get_funding_pubkey(int64_t this_ptr) {
48065         LDKChannelPublicKeys this_ptr_conv;
48066         this_ptr_conv.inner = untag_ptr(this_ptr);
48067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48069         this_ptr_conv.is_owned = false;
48070         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48071         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
48072         return ret_arr;
48073 }
48074
48075 void  CS_LDK_ChannelPublicKeys_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
48076         LDKChannelPublicKeys this_ptr_conv;
48077         this_ptr_conv.inner = untag_ptr(this_ptr);
48078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48080         this_ptr_conv.is_owned = false;
48081         LDKPublicKey val_ref;
48082         CHECK(val->arr_len == 33);
48083         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48084         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
48085 }
48086
48087 int8_tArray  CS_LDK_ChannelPublicKeys_get_revocation_basepoint(int64_t this_ptr) {
48088         LDKChannelPublicKeys this_ptr_conv;
48089         this_ptr_conv.inner = untag_ptr(this_ptr);
48090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48092         this_ptr_conv.is_owned = false;
48093         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48094         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
48095         return ret_arr;
48096 }
48097
48098 void  CS_LDK_ChannelPublicKeys_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
48099         LDKChannelPublicKeys this_ptr_conv;
48100         this_ptr_conv.inner = untag_ptr(this_ptr);
48101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48103         this_ptr_conv.is_owned = false;
48104         LDKPublicKey val_ref;
48105         CHECK(val->arr_len == 33);
48106         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48107         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
48108 }
48109
48110 int8_tArray  CS_LDK_ChannelPublicKeys_get_payment_point(int64_t this_ptr) {
48111         LDKChannelPublicKeys this_ptr_conv;
48112         this_ptr_conv.inner = untag_ptr(this_ptr);
48113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48115         this_ptr_conv.is_owned = false;
48116         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48117         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
48118         return ret_arr;
48119 }
48120
48121 void  CS_LDK_ChannelPublicKeys_set_payment_point(int64_t this_ptr, int8_tArray val) {
48122         LDKChannelPublicKeys this_ptr_conv;
48123         this_ptr_conv.inner = untag_ptr(this_ptr);
48124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48126         this_ptr_conv.is_owned = false;
48127         LDKPublicKey val_ref;
48128         CHECK(val->arr_len == 33);
48129         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48130         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
48131 }
48132
48133 int8_tArray  CS_LDK_ChannelPublicKeys_get_delayed_payment_basepoint(int64_t this_ptr) {
48134         LDKChannelPublicKeys this_ptr_conv;
48135         this_ptr_conv.inner = untag_ptr(this_ptr);
48136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48138         this_ptr_conv.is_owned = false;
48139         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48140         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
48141         return ret_arr;
48142 }
48143
48144 void  CS_LDK_ChannelPublicKeys_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
48145         LDKChannelPublicKeys this_ptr_conv;
48146         this_ptr_conv.inner = untag_ptr(this_ptr);
48147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48149         this_ptr_conv.is_owned = false;
48150         LDKPublicKey val_ref;
48151         CHECK(val->arr_len == 33);
48152         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48153         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
48154 }
48155
48156 int8_tArray  CS_LDK_ChannelPublicKeys_get_htlc_basepoint(int64_t this_ptr) {
48157         LDKChannelPublicKeys this_ptr_conv;
48158         this_ptr_conv.inner = untag_ptr(this_ptr);
48159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48161         this_ptr_conv.is_owned = false;
48162         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48163         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
48164         return ret_arr;
48165 }
48166
48167 void  CS_LDK_ChannelPublicKeys_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
48168         LDKChannelPublicKeys this_ptr_conv;
48169         this_ptr_conv.inner = untag_ptr(this_ptr);
48170         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48172         this_ptr_conv.is_owned = false;
48173         LDKPublicKey val_ref;
48174         CHECK(val->arr_len == 33);
48175         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48176         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
48177 }
48178
48179 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) {
48180         LDKPublicKey funding_pubkey_arg_ref;
48181         CHECK(funding_pubkey_arg->arr_len == 33);
48182         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
48183         LDKPublicKey revocation_basepoint_arg_ref;
48184         CHECK(revocation_basepoint_arg->arr_len == 33);
48185         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
48186         LDKPublicKey payment_point_arg_ref;
48187         CHECK(payment_point_arg->arr_len == 33);
48188         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
48189         LDKPublicKey delayed_payment_basepoint_arg_ref;
48190         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
48191         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
48192         LDKPublicKey htlc_basepoint_arg_ref;
48193         CHECK(htlc_basepoint_arg->arr_len == 33);
48194         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
48195         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);
48196         int64_t ret_ref = 0;
48197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48199         return ret_ref;
48200 }
48201
48202 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
48203         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
48204         int64_t ret_ref = 0;
48205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48206         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48207         return ret_ref;
48208 }
48209 int64_t  CS_LDK_ChannelPublicKeys_clone_ptr(int64_t arg) {
48210         LDKChannelPublicKeys arg_conv;
48211         arg_conv.inner = untag_ptr(arg);
48212         arg_conv.is_owned = ptr_is_owned(arg);
48213         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48214         arg_conv.is_owned = false;
48215         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
48216         return ret_conv;
48217 }
48218
48219 int64_t  CS_LDK_ChannelPublicKeys_clone(int64_t orig) {
48220         LDKChannelPublicKeys orig_conv;
48221         orig_conv.inner = untag_ptr(orig);
48222         orig_conv.is_owned = ptr_is_owned(orig);
48223         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48224         orig_conv.is_owned = false;
48225         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
48226         int64_t ret_ref = 0;
48227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48229         return ret_ref;
48230 }
48231
48232 int64_t  CS_LDK_ChannelPublicKeys_hash(int64_t o) {
48233         LDKChannelPublicKeys o_conv;
48234         o_conv.inner = untag_ptr(o);
48235         o_conv.is_owned = ptr_is_owned(o);
48236         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48237         o_conv.is_owned = false;
48238         int64_t ret_conv = ChannelPublicKeys_hash(&o_conv);
48239         return ret_conv;
48240 }
48241
48242 jboolean  CS_LDK_ChannelPublicKeys_eq(int64_t a, int64_t b) {
48243         LDKChannelPublicKeys a_conv;
48244         a_conv.inner = untag_ptr(a);
48245         a_conv.is_owned = ptr_is_owned(a);
48246         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48247         a_conv.is_owned = false;
48248         LDKChannelPublicKeys b_conv;
48249         b_conv.inner = untag_ptr(b);
48250         b_conv.is_owned = ptr_is_owned(b);
48251         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48252         b_conv.is_owned = false;
48253         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
48254         return ret_conv;
48255 }
48256
48257 int8_tArray  CS_LDK_ChannelPublicKeys_write(int64_t obj) {
48258         LDKChannelPublicKeys obj_conv;
48259         obj_conv.inner = untag_ptr(obj);
48260         obj_conv.is_owned = ptr_is_owned(obj);
48261         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48262         obj_conv.is_owned = false;
48263         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
48264         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48265         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48266         CVec_u8Z_free(ret_var);
48267         return ret_arr;
48268 }
48269
48270 int64_t  CS_LDK_ChannelPublicKeys_read(int8_tArray ser) {
48271         LDKu8slice ser_ref;
48272         ser_ref.datalen = ser->arr_len;
48273         ser_ref.data = ser->elems;
48274         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
48275         *ret_conv = ChannelPublicKeys_read(ser_ref);
48276         FREE(ser);
48277         return tag_ptr(ret_conv, true);
48278 }
48279
48280 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) {
48281         LDKPublicKey per_commitment_point_ref;
48282         CHECK(per_commitment_point->arr_len == 33);
48283         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
48284         LDKPublicKey broadcaster_delayed_payment_base_ref;
48285         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
48286         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
48287         LDKPublicKey broadcaster_htlc_base_ref;
48288         CHECK(broadcaster_htlc_base->arr_len == 33);
48289         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
48290         LDKPublicKey countersignatory_revocation_base_ref;
48291         CHECK(countersignatory_revocation_base->arr_len == 33);
48292         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
48293         LDKPublicKey countersignatory_htlc_base_ref;
48294         CHECK(countersignatory_htlc_base->arr_len == 33);
48295         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
48296         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);
48297         int64_t ret_ref = 0;
48298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48299         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48300         return ret_ref;
48301 }
48302
48303 int64_t  CS_LDK_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, int64_t broadcaster_keys, int64_t countersignatory_keys) {
48304         LDKPublicKey per_commitment_point_ref;
48305         CHECK(per_commitment_point->arr_len == 33);
48306         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
48307         LDKChannelPublicKeys broadcaster_keys_conv;
48308         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
48309         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
48310         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
48311         broadcaster_keys_conv.is_owned = false;
48312         LDKChannelPublicKeys countersignatory_keys_conv;
48313         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
48314         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
48315         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
48316         countersignatory_keys_conv.is_owned = false;
48317         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
48318         int64_t ret_ref = 0;
48319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48320         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48321         return ret_ref;
48322 }
48323
48324 int8_tArray  CS_LDK_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
48325         LDKPublicKey revocation_key_ref;
48326         CHECK(revocation_key->arr_len == 33);
48327         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
48328         LDKPublicKey broadcaster_delayed_payment_key_ref;
48329         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
48330         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
48331         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
48332         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48333         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48334         CVec_u8Z_free(ret_var);
48335         return ret_arr;
48336 }
48337
48338 int8_tArray  CS_LDK_get_counterparty_payment_script(int64_t channel_type_features, int8_tArray payment_key) {
48339         LDKChannelTypeFeatures channel_type_features_conv;
48340         channel_type_features_conv.inner = untag_ptr(channel_type_features);
48341         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
48342         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
48343         channel_type_features_conv.is_owned = false;
48344         LDKPublicKey payment_key_ref;
48345         CHECK(payment_key->arr_len == 33);
48346         memcpy(payment_key_ref.compressed_form, payment_key->elems, 33); FREE(payment_key);
48347         LDKCVec_u8Z ret_var = get_counterparty_payment_script(&channel_type_features_conv, payment_key_ref);
48348         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48349         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48350         CVec_u8Z_free(ret_var);
48351         return ret_arr;
48352 }
48353
48354 void  CS_LDK_HTLCOutputInCommitment_free(int64_t this_obj) {
48355         LDKHTLCOutputInCommitment this_obj_conv;
48356         this_obj_conv.inner = untag_ptr(this_obj);
48357         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48359         HTLCOutputInCommitment_free(this_obj_conv);
48360 }
48361
48362 jboolean  CS_LDK_HTLCOutputInCommitment_get_offered(int64_t this_ptr) {
48363         LDKHTLCOutputInCommitment this_ptr_conv;
48364         this_ptr_conv.inner = untag_ptr(this_ptr);
48365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48367         this_ptr_conv.is_owned = false;
48368         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
48369         return ret_conv;
48370 }
48371
48372 void  CS_LDK_HTLCOutputInCommitment_set_offered(int64_t this_ptr, jboolean val) {
48373         LDKHTLCOutputInCommitment this_ptr_conv;
48374         this_ptr_conv.inner = untag_ptr(this_ptr);
48375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48377         this_ptr_conv.is_owned = false;
48378         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
48379 }
48380
48381 int64_t  CS_LDK_HTLCOutputInCommitment_get_amount_msat(int64_t this_ptr) {
48382         LDKHTLCOutputInCommitment this_ptr_conv;
48383         this_ptr_conv.inner = untag_ptr(this_ptr);
48384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48386         this_ptr_conv.is_owned = false;
48387         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
48388         return ret_conv;
48389 }
48390
48391 void  CS_LDK_HTLCOutputInCommitment_set_amount_msat(int64_t this_ptr, int64_t val) {
48392         LDKHTLCOutputInCommitment this_ptr_conv;
48393         this_ptr_conv.inner = untag_ptr(this_ptr);
48394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48396         this_ptr_conv.is_owned = false;
48397         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
48398 }
48399
48400 int32_t  CS_LDK_HTLCOutputInCommitment_get_cltv_expiry(int64_t this_ptr) {
48401         LDKHTLCOutputInCommitment this_ptr_conv;
48402         this_ptr_conv.inner = untag_ptr(this_ptr);
48403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48405         this_ptr_conv.is_owned = false;
48406         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
48407         return ret_conv;
48408 }
48409
48410 void  CS_LDK_HTLCOutputInCommitment_set_cltv_expiry(int64_t this_ptr, int32_t val) {
48411         LDKHTLCOutputInCommitment this_ptr_conv;
48412         this_ptr_conv.inner = untag_ptr(this_ptr);
48413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48415         this_ptr_conv.is_owned = false;
48416         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
48417 }
48418
48419 int8_tArray  CS_LDK_HTLCOutputInCommitment_get_payment_hash(int64_t this_ptr) {
48420         LDKHTLCOutputInCommitment this_ptr_conv;
48421         this_ptr_conv.inner = untag_ptr(this_ptr);
48422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48424         this_ptr_conv.is_owned = false;
48425         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
48426         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
48427         return ret_arr;
48428 }
48429
48430 void  CS_LDK_HTLCOutputInCommitment_set_payment_hash(int64_t this_ptr, int8_tArray val) {
48431         LDKHTLCOutputInCommitment this_ptr_conv;
48432         this_ptr_conv.inner = untag_ptr(this_ptr);
48433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48435         this_ptr_conv.is_owned = false;
48436         LDKThirtyTwoBytes val_ref;
48437         CHECK(val->arr_len == 32);
48438         memcpy(val_ref.data, val->elems, 32); FREE(val);
48439         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
48440 }
48441
48442 int64_t  CS_LDK_HTLCOutputInCommitment_get_transaction_output_index(int64_t this_ptr) {
48443         LDKHTLCOutputInCommitment this_ptr_conv;
48444         this_ptr_conv.inner = untag_ptr(this_ptr);
48445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48447         this_ptr_conv.is_owned = false;
48448         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
48449         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
48450         int64_t ret_ref = tag_ptr(ret_copy, true);
48451         return ret_ref;
48452 }
48453
48454 void  CS_LDK_HTLCOutputInCommitment_set_transaction_output_index(int64_t this_ptr, int64_t val) {
48455         LDKHTLCOutputInCommitment this_ptr_conv;
48456         this_ptr_conv.inner = untag_ptr(this_ptr);
48457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48459         this_ptr_conv.is_owned = false;
48460         void* val_ptr = untag_ptr(val);
48461         CHECK_ACCESS(val_ptr);
48462         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
48463         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
48464         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
48465 }
48466
48467 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) {
48468         LDKThirtyTwoBytes payment_hash_arg_ref;
48469         CHECK(payment_hash_arg->arr_len == 32);
48470         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
48471         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
48472         CHECK_ACCESS(transaction_output_index_arg_ptr);
48473         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
48474         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
48475         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
48476         int64_t ret_ref = 0;
48477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48479         return ret_ref;
48480 }
48481
48482 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
48483         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
48484         int64_t ret_ref = 0;
48485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48487         return ret_ref;
48488 }
48489 int64_t  CS_LDK_HTLCOutputInCommitment_clone_ptr(int64_t arg) {
48490         LDKHTLCOutputInCommitment arg_conv;
48491         arg_conv.inner = untag_ptr(arg);
48492         arg_conv.is_owned = ptr_is_owned(arg);
48493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48494         arg_conv.is_owned = false;
48495         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
48496         return ret_conv;
48497 }
48498
48499 int64_t  CS_LDK_HTLCOutputInCommitment_clone(int64_t orig) {
48500         LDKHTLCOutputInCommitment orig_conv;
48501         orig_conv.inner = untag_ptr(orig);
48502         orig_conv.is_owned = ptr_is_owned(orig);
48503         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48504         orig_conv.is_owned = false;
48505         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
48506         int64_t ret_ref = 0;
48507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48509         return ret_ref;
48510 }
48511
48512 jboolean  CS_LDK_HTLCOutputInCommitment_eq(int64_t a, int64_t b) {
48513         LDKHTLCOutputInCommitment a_conv;
48514         a_conv.inner = untag_ptr(a);
48515         a_conv.is_owned = ptr_is_owned(a);
48516         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48517         a_conv.is_owned = false;
48518         LDKHTLCOutputInCommitment b_conv;
48519         b_conv.inner = untag_ptr(b);
48520         b_conv.is_owned = ptr_is_owned(b);
48521         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48522         b_conv.is_owned = false;
48523         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
48524         return ret_conv;
48525 }
48526
48527 int8_tArray  CS_LDK_HTLCOutputInCommitment_write(int64_t obj) {
48528         LDKHTLCOutputInCommitment obj_conv;
48529         obj_conv.inner = untag_ptr(obj);
48530         obj_conv.is_owned = ptr_is_owned(obj);
48531         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48532         obj_conv.is_owned = false;
48533         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
48534         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48535         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48536         CVec_u8Z_free(ret_var);
48537         return ret_arr;
48538 }
48539
48540 int64_t  CS_LDK_HTLCOutputInCommitment_read(int8_tArray ser) {
48541         LDKu8slice ser_ref;
48542         ser_ref.datalen = ser->arr_len;
48543         ser_ref.data = ser->elems;
48544         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
48545         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
48546         FREE(ser);
48547         return tag_ptr(ret_conv, true);
48548 }
48549
48550 int8_tArray  CS_LDK_get_htlc_redeemscript(int64_t htlc, int64_t channel_type_features, int64_t keys) {
48551         LDKHTLCOutputInCommitment htlc_conv;
48552         htlc_conv.inner = untag_ptr(htlc);
48553         htlc_conv.is_owned = ptr_is_owned(htlc);
48554         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
48555         htlc_conv.is_owned = false;
48556         LDKChannelTypeFeatures channel_type_features_conv;
48557         channel_type_features_conv.inner = untag_ptr(channel_type_features);
48558         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
48559         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
48560         channel_type_features_conv.is_owned = false;
48561         LDKTxCreationKeys keys_conv;
48562         keys_conv.inner = untag_ptr(keys);
48563         keys_conv.is_owned = ptr_is_owned(keys);
48564         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
48565         keys_conv.is_owned = false;
48566         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &channel_type_features_conv, &keys_conv);
48567         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48568         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48569         CVec_u8Z_free(ret_var);
48570         return ret_arr;
48571 }
48572
48573 int8_tArray  CS_LDK_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
48574         LDKPublicKey broadcaster_ref;
48575         CHECK(broadcaster->arr_len == 33);
48576         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
48577         LDKPublicKey countersignatory_ref;
48578         CHECK(countersignatory->arr_len == 33);
48579         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
48580         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
48581         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48582         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48583         CVec_u8Z_free(ret_var);
48584         return ret_arr;
48585 }
48586
48587 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) {
48588         uint8_t commitment_txid_arr[32];
48589         CHECK(commitment_txid->arr_len == 32);
48590         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
48591         uint8_t (*commitment_txid_ref)[32] = &commitment_txid_arr;
48592         LDKHTLCOutputInCommitment htlc_conv;
48593         htlc_conv.inner = untag_ptr(htlc);
48594         htlc_conv.is_owned = ptr_is_owned(htlc);
48595         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
48596         htlc_conv.is_owned = false;
48597         LDKChannelTypeFeatures channel_type_features_conv;
48598         channel_type_features_conv.inner = untag_ptr(channel_type_features);
48599         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
48600         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
48601         channel_type_features_conv.is_owned = false;
48602         LDKPublicKey broadcaster_delayed_payment_key_ref;
48603         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
48604         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
48605         LDKPublicKey revocation_key_ref;
48606         CHECK(revocation_key->arr_len == 33);
48607         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
48608         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);
48609         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48610         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48611         Transaction_free(ret_var);
48612         return ret_arr;
48613 }
48614
48615 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) {
48616         LDKECDSASignature local_sig_ref;
48617         CHECK(local_sig->arr_len == 64);
48618         memcpy(local_sig_ref.compact_form, local_sig->elems, 64); FREE(local_sig);
48619         LDKECDSASignature remote_sig_ref;
48620         CHECK(remote_sig->arr_len == 64);
48621         memcpy(remote_sig_ref.compact_form, remote_sig->elems, 64); FREE(remote_sig);
48622         void* preimage_ptr = untag_ptr(preimage);
48623         CHECK_ACCESS(preimage_ptr);
48624         LDKCOption_ThirtyTwoBytesZ preimage_conv = *(LDKCOption_ThirtyTwoBytesZ*)(preimage_ptr);
48625         preimage_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(preimage));
48626         LDKu8slice redeem_script_ref;
48627         redeem_script_ref.datalen = redeem_script->arr_len;
48628         redeem_script_ref.data = redeem_script->elems;
48629         LDKChannelTypeFeatures channel_type_features_conv;
48630         channel_type_features_conv.inner = untag_ptr(channel_type_features);
48631         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
48632         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
48633         channel_type_features_conv.is_owned = false;
48634         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_conv, redeem_script_ref, &channel_type_features_conv);
48635         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48636         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48637         Witness_free(ret_var);
48638         FREE(redeem_script);
48639         return ret_arr;
48640 }
48641
48642 int8_tArray  CS_LDK_get_to_countersignatory_with_anchors_redeemscript(int8_tArray payment_point) {
48643         LDKPublicKey payment_point_ref;
48644         CHECK(payment_point->arr_len == 33);
48645         memcpy(payment_point_ref.compressed_form, payment_point->elems, 33); FREE(payment_point);
48646         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
48647         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48648         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48649         CVec_u8Z_free(ret_var);
48650         return ret_arr;
48651 }
48652
48653 int8_tArray  CS_LDK_get_anchor_redeemscript(int8_tArray funding_pubkey) {
48654         LDKPublicKey funding_pubkey_ref;
48655         CHECK(funding_pubkey->arr_len == 33);
48656         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
48657         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
48658         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48659         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48660         CVec_u8Z_free(ret_var);
48661         return ret_arr;
48662 }
48663
48664 int8_tArray  CS_LDK_build_anchor_input_witness(int8_tArray funding_key, int8_tArray funding_sig) {
48665         LDKPublicKey funding_key_ref;
48666         CHECK(funding_key->arr_len == 33);
48667         memcpy(funding_key_ref.compressed_form, funding_key->elems, 33); FREE(funding_key);
48668         LDKECDSASignature funding_sig_ref;
48669         CHECK(funding_sig->arr_len == 64);
48670         memcpy(funding_sig_ref.compact_form, funding_sig->elems, 64); FREE(funding_sig);
48671         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
48672         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48673         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48674         Witness_free(ret_var);
48675         return ret_arr;
48676 }
48677
48678 void  CS_LDK_ChannelTransactionParameters_free(int64_t this_obj) {
48679         LDKChannelTransactionParameters this_obj_conv;
48680         this_obj_conv.inner = untag_ptr(this_obj);
48681         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48683         ChannelTransactionParameters_free(this_obj_conv);
48684 }
48685
48686 int64_t  CS_LDK_ChannelTransactionParameters_get_holder_pubkeys(int64_t this_ptr) {
48687         LDKChannelTransactionParameters this_ptr_conv;
48688         this_ptr_conv.inner = untag_ptr(this_ptr);
48689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48691         this_ptr_conv.is_owned = false;
48692         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
48693         int64_t ret_ref = 0;
48694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48696         return ret_ref;
48697 }
48698
48699 void  CS_LDK_ChannelTransactionParameters_set_holder_pubkeys(int64_t this_ptr, int64_t val) {
48700         LDKChannelTransactionParameters this_ptr_conv;
48701         this_ptr_conv.inner = untag_ptr(this_ptr);
48702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48704         this_ptr_conv.is_owned = false;
48705         LDKChannelPublicKeys val_conv;
48706         val_conv.inner = untag_ptr(val);
48707         val_conv.is_owned = ptr_is_owned(val);
48708         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48709         val_conv = ChannelPublicKeys_clone(&val_conv);
48710         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
48711 }
48712
48713 int16_t  CS_LDK_ChannelTransactionParameters_get_holder_selected_contest_delay(int64_t this_ptr) {
48714         LDKChannelTransactionParameters this_ptr_conv;
48715         this_ptr_conv.inner = untag_ptr(this_ptr);
48716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48718         this_ptr_conv.is_owned = false;
48719         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
48720         return ret_conv;
48721 }
48722
48723 void  CS_LDK_ChannelTransactionParameters_set_holder_selected_contest_delay(int64_t this_ptr, int16_t val) {
48724         LDKChannelTransactionParameters this_ptr_conv;
48725         this_ptr_conv.inner = untag_ptr(this_ptr);
48726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48728         this_ptr_conv.is_owned = false;
48729         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
48730 }
48731
48732 jboolean  CS_LDK_ChannelTransactionParameters_get_is_outbound_from_holder(int64_t this_ptr) {
48733         LDKChannelTransactionParameters this_ptr_conv;
48734         this_ptr_conv.inner = untag_ptr(this_ptr);
48735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48737         this_ptr_conv.is_owned = false;
48738         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
48739         return ret_conv;
48740 }
48741
48742 void  CS_LDK_ChannelTransactionParameters_set_is_outbound_from_holder(int64_t this_ptr, jboolean val) {
48743         LDKChannelTransactionParameters this_ptr_conv;
48744         this_ptr_conv.inner = untag_ptr(this_ptr);
48745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48747         this_ptr_conv.is_owned = false;
48748         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
48749 }
48750
48751 int64_t  CS_LDK_ChannelTransactionParameters_get_counterparty_parameters(int64_t this_ptr) {
48752         LDKChannelTransactionParameters this_ptr_conv;
48753         this_ptr_conv.inner = untag_ptr(this_ptr);
48754         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48756         this_ptr_conv.is_owned = false;
48757         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
48758         int64_t ret_ref = 0;
48759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48760         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48761         return ret_ref;
48762 }
48763
48764 void  CS_LDK_ChannelTransactionParameters_set_counterparty_parameters(int64_t this_ptr, int64_t val) {
48765         LDKChannelTransactionParameters this_ptr_conv;
48766         this_ptr_conv.inner = untag_ptr(this_ptr);
48767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48769         this_ptr_conv.is_owned = false;
48770         LDKCounterpartyChannelTransactionParameters val_conv;
48771         val_conv.inner = untag_ptr(val);
48772         val_conv.is_owned = ptr_is_owned(val);
48773         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48774         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
48775         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
48776 }
48777
48778 int64_t  CS_LDK_ChannelTransactionParameters_get_funding_outpoint(int64_t this_ptr) {
48779         LDKChannelTransactionParameters this_ptr_conv;
48780         this_ptr_conv.inner = untag_ptr(this_ptr);
48781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48783         this_ptr_conv.is_owned = false;
48784         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
48785         int64_t ret_ref = 0;
48786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48788         return ret_ref;
48789 }
48790
48791 void  CS_LDK_ChannelTransactionParameters_set_funding_outpoint(int64_t this_ptr, int64_t val) {
48792         LDKChannelTransactionParameters this_ptr_conv;
48793         this_ptr_conv.inner = untag_ptr(this_ptr);
48794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48796         this_ptr_conv.is_owned = false;
48797         LDKOutPoint val_conv;
48798         val_conv.inner = untag_ptr(val);
48799         val_conv.is_owned = ptr_is_owned(val);
48800         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48801         val_conv = OutPoint_clone(&val_conv);
48802         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
48803 }
48804
48805 int64_t  CS_LDK_ChannelTransactionParameters_get_channel_type_features(int64_t this_ptr) {
48806         LDKChannelTransactionParameters this_ptr_conv;
48807         this_ptr_conv.inner = untag_ptr(this_ptr);
48808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48810         this_ptr_conv.is_owned = false;
48811         LDKChannelTypeFeatures ret_var = ChannelTransactionParameters_get_channel_type_features(&this_ptr_conv);
48812         int64_t ret_ref = 0;
48813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48815         return ret_ref;
48816 }
48817
48818 void  CS_LDK_ChannelTransactionParameters_set_channel_type_features(int64_t this_ptr, int64_t val) {
48819         LDKChannelTransactionParameters this_ptr_conv;
48820         this_ptr_conv.inner = untag_ptr(this_ptr);
48821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48823         this_ptr_conv.is_owned = false;
48824         LDKChannelTypeFeatures val_conv;
48825         val_conv.inner = untag_ptr(val);
48826         val_conv.is_owned = ptr_is_owned(val);
48827         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48828         val_conv = ChannelTypeFeatures_clone(&val_conv);
48829         ChannelTransactionParameters_set_channel_type_features(&this_ptr_conv, val_conv);
48830 }
48831
48832 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) {
48833         LDKChannelPublicKeys holder_pubkeys_arg_conv;
48834         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
48835         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
48836         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
48837         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
48838         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
48839         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
48840         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
48841         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
48842         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
48843         LDKOutPoint funding_outpoint_arg_conv;
48844         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
48845         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
48846         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
48847         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
48848         LDKChannelTypeFeatures channel_type_features_arg_conv;
48849         channel_type_features_arg_conv.inner = untag_ptr(channel_type_features_arg);
48850         channel_type_features_arg_conv.is_owned = ptr_is_owned(channel_type_features_arg);
48851         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_arg_conv);
48852         channel_type_features_arg_conv = ChannelTypeFeatures_clone(&channel_type_features_arg_conv);
48853         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);
48854         int64_t ret_ref = 0;
48855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48857         return ret_ref;
48858 }
48859
48860 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
48861         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
48862         int64_t ret_ref = 0;
48863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48864         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48865         return ret_ref;
48866 }
48867 int64_t  CS_LDK_ChannelTransactionParameters_clone_ptr(int64_t arg) {
48868         LDKChannelTransactionParameters arg_conv;
48869         arg_conv.inner = untag_ptr(arg);
48870         arg_conv.is_owned = ptr_is_owned(arg);
48871         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48872         arg_conv.is_owned = false;
48873         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
48874         return ret_conv;
48875 }
48876
48877 int64_t  CS_LDK_ChannelTransactionParameters_clone(int64_t orig) {
48878         LDKChannelTransactionParameters orig_conv;
48879         orig_conv.inner = untag_ptr(orig);
48880         orig_conv.is_owned = ptr_is_owned(orig);
48881         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48882         orig_conv.is_owned = false;
48883         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
48884         int64_t ret_ref = 0;
48885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48887         return ret_ref;
48888 }
48889
48890 int64_t  CS_LDK_ChannelTransactionParameters_hash(int64_t o) {
48891         LDKChannelTransactionParameters o_conv;
48892         o_conv.inner = untag_ptr(o);
48893         o_conv.is_owned = ptr_is_owned(o);
48894         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48895         o_conv.is_owned = false;
48896         int64_t ret_conv = ChannelTransactionParameters_hash(&o_conv);
48897         return ret_conv;
48898 }
48899
48900 jboolean  CS_LDK_ChannelTransactionParameters_eq(int64_t a, int64_t b) {
48901         LDKChannelTransactionParameters a_conv;
48902         a_conv.inner = untag_ptr(a);
48903         a_conv.is_owned = ptr_is_owned(a);
48904         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48905         a_conv.is_owned = false;
48906         LDKChannelTransactionParameters b_conv;
48907         b_conv.inner = untag_ptr(b);
48908         b_conv.is_owned = ptr_is_owned(b);
48909         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48910         b_conv.is_owned = false;
48911         jboolean ret_conv = ChannelTransactionParameters_eq(&a_conv, &b_conv);
48912         return ret_conv;
48913 }
48914
48915 void  CS_LDK_CounterpartyChannelTransactionParameters_free(int64_t this_obj) {
48916         LDKCounterpartyChannelTransactionParameters this_obj_conv;
48917         this_obj_conv.inner = untag_ptr(this_obj);
48918         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48920         CounterpartyChannelTransactionParameters_free(this_obj_conv);
48921 }
48922
48923 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_get_pubkeys(int64_t this_ptr) {
48924         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
48925         this_ptr_conv.inner = untag_ptr(this_ptr);
48926         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48928         this_ptr_conv.is_owned = false;
48929         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
48930         int64_t ret_ref = 0;
48931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48933         return ret_ref;
48934 }
48935
48936 void  CS_LDK_CounterpartyChannelTransactionParameters_set_pubkeys(int64_t this_ptr, int64_t val) {
48937         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
48938         this_ptr_conv.inner = untag_ptr(this_ptr);
48939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48941         this_ptr_conv.is_owned = false;
48942         LDKChannelPublicKeys val_conv;
48943         val_conv.inner = untag_ptr(val);
48944         val_conv.is_owned = ptr_is_owned(val);
48945         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48946         val_conv = ChannelPublicKeys_clone(&val_conv);
48947         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
48948 }
48949
48950 int16_t  CS_LDK_CounterpartyChannelTransactionParameters_get_selected_contest_delay(int64_t this_ptr) {
48951         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
48952         this_ptr_conv.inner = untag_ptr(this_ptr);
48953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48955         this_ptr_conv.is_owned = false;
48956         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
48957         return ret_conv;
48958 }
48959
48960 void  CS_LDK_CounterpartyChannelTransactionParameters_set_selected_contest_delay(int64_t this_ptr, int16_t val) {
48961         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
48962         this_ptr_conv.inner = untag_ptr(this_ptr);
48963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48965         this_ptr_conv.is_owned = false;
48966         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
48967 }
48968
48969 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_new(int64_t pubkeys_arg, int16_t selected_contest_delay_arg) {
48970         LDKChannelPublicKeys pubkeys_arg_conv;
48971         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
48972         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
48973         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
48974         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
48975         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
48976         int64_t ret_ref = 0;
48977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48979         return ret_ref;
48980 }
48981
48982 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
48983         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
48984         int64_t ret_ref = 0;
48985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48987         return ret_ref;
48988 }
48989 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_clone_ptr(int64_t arg) {
48990         LDKCounterpartyChannelTransactionParameters arg_conv;
48991         arg_conv.inner = untag_ptr(arg);
48992         arg_conv.is_owned = ptr_is_owned(arg);
48993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48994         arg_conv.is_owned = false;
48995         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
48996         return ret_conv;
48997 }
48998
48999 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_clone(int64_t orig) {
49000         LDKCounterpartyChannelTransactionParameters orig_conv;
49001         orig_conv.inner = untag_ptr(orig);
49002         orig_conv.is_owned = ptr_is_owned(orig);
49003         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49004         orig_conv.is_owned = false;
49005         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
49006         int64_t ret_ref = 0;
49007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49008         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49009         return ret_ref;
49010 }
49011
49012 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_hash(int64_t o) {
49013         LDKCounterpartyChannelTransactionParameters o_conv;
49014         o_conv.inner = untag_ptr(o);
49015         o_conv.is_owned = ptr_is_owned(o);
49016         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49017         o_conv.is_owned = false;
49018         int64_t ret_conv = CounterpartyChannelTransactionParameters_hash(&o_conv);
49019         return ret_conv;
49020 }
49021
49022 jboolean  CS_LDK_CounterpartyChannelTransactionParameters_eq(int64_t a, int64_t b) {
49023         LDKCounterpartyChannelTransactionParameters a_conv;
49024         a_conv.inner = untag_ptr(a);
49025         a_conv.is_owned = ptr_is_owned(a);
49026         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49027         a_conv.is_owned = false;
49028         LDKCounterpartyChannelTransactionParameters b_conv;
49029         b_conv.inner = untag_ptr(b);
49030         b_conv.is_owned = ptr_is_owned(b);
49031         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49032         b_conv.is_owned = false;
49033         jboolean ret_conv = CounterpartyChannelTransactionParameters_eq(&a_conv, &b_conv);
49034         return ret_conv;
49035 }
49036
49037 jboolean  CS_LDK_ChannelTransactionParameters_is_populated(int64_t this_arg) {
49038         LDKChannelTransactionParameters this_arg_conv;
49039         this_arg_conv.inner = untag_ptr(this_arg);
49040         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49042         this_arg_conv.is_owned = false;
49043         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
49044         return ret_conv;
49045 }
49046
49047 int64_t  CS_LDK_ChannelTransactionParameters_as_holder_broadcastable(int64_t this_arg) {
49048         LDKChannelTransactionParameters this_arg_conv;
49049         this_arg_conv.inner = untag_ptr(this_arg);
49050         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49052         this_arg_conv.is_owned = false;
49053         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
49054         int64_t ret_ref = 0;
49055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49057         return ret_ref;
49058 }
49059
49060 int64_t  CS_LDK_ChannelTransactionParameters_as_counterparty_broadcastable(int64_t this_arg) {
49061         LDKChannelTransactionParameters this_arg_conv;
49062         this_arg_conv.inner = untag_ptr(this_arg);
49063         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49065         this_arg_conv.is_owned = false;
49066         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
49067         int64_t ret_ref = 0;
49068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49070         return ret_ref;
49071 }
49072
49073 int8_tArray  CS_LDK_CounterpartyChannelTransactionParameters_write(int64_t obj) {
49074         LDKCounterpartyChannelTransactionParameters obj_conv;
49075         obj_conv.inner = untag_ptr(obj);
49076         obj_conv.is_owned = ptr_is_owned(obj);
49077         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49078         obj_conv.is_owned = false;
49079         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
49080         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49081         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49082         CVec_u8Z_free(ret_var);
49083         return ret_arr;
49084 }
49085
49086 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
49087         LDKu8slice ser_ref;
49088         ser_ref.datalen = ser->arr_len;
49089         ser_ref.data = ser->elems;
49090         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
49091         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
49092         FREE(ser);
49093         return tag_ptr(ret_conv, true);
49094 }
49095
49096 int8_tArray  CS_LDK_ChannelTransactionParameters_write(int64_t obj) {
49097         LDKChannelTransactionParameters obj_conv;
49098         obj_conv.inner = untag_ptr(obj);
49099         obj_conv.is_owned = ptr_is_owned(obj);
49100         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49101         obj_conv.is_owned = false;
49102         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
49103         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49104         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49105         CVec_u8Z_free(ret_var);
49106         return ret_arr;
49107 }
49108
49109 int64_t  CS_LDK_ChannelTransactionParameters_read(int8_tArray ser) {
49110         LDKu8slice ser_ref;
49111         ser_ref.datalen = ser->arr_len;
49112         ser_ref.data = ser->elems;
49113         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
49114         *ret_conv = ChannelTransactionParameters_read(ser_ref);
49115         FREE(ser);
49116         return tag_ptr(ret_conv, true);
49117 }
49118
49119 void  CS_LDK_DirectedChannelTransactionParameters_free(int64_t this_obj) {
49120         LDKDirectedChannelTransactionParameters this_obj_conv;
49121         this_obj_conv.inner = untag_ptr(this_obj);
49122         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49124         DirectedChannelTransactionParameters_free(this_obj_conv);
49125 }
49126
49127 int64_t  CS_LDK_DirectedChannelTransactionParameters_broadcaster_pubkeys(int64_t this_arg) {
49128         LDKDirectedChannelTransactionParameters this_arg_conv;
49129         this_arg_conv.inner = untag_ptr(this_arg);
49130         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49132         this_arg_conv.is_owned = false;
49133         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
49134         int64_t ret_ref = 0;
49135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49137         return ret_ref;
49138 }
49139
49140 int64_t  CS_LDK_DirectedChannelTransactionParameters_countersignatory_pubkeys(int64_t this_arg) {
49141         LDKDirectedChannelTransactionParameters this_arg_conv;
49142         this_arg_conv.inner = untag_ptr(this_arg);
49143         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49145         this_arg_conv.is_owned = false;
49146         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
49147         int64_t ret_ref = 0;
49148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49150         return ret_ref;
49151 }
49152
49153 int16_t  CS_LDK_DirectedChannelTransactionParameters_contest_delay(int64_t this_arg) {
49154         LDKDirectedChannelTransactionParameters this_arg_conv;
49155         this_arg_conv.inner = untag_ptr(this_arg);
49156         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49158         this_arg_conv.is_owned = false;
49159         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
49160         return ret_conv;
49161 }
49162
49163 jboolean  CS_LDK_DirectedChannelTransactionParameters_is_outbound(int64_t this_arg) {
49164         LDKDirectedChannelTransactionParameters this_arg_conv;
49165         this_arg_conv.inner = untag_ptr(this_arg);
49166         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49168         this_arg_conv.is_owned = false;
49169         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
49170         return ret_conv;
49171 }
49172
49173 int64_t  CS_LDK_DirectedChannelTransactionParameters_funding_outpoint(int64_t this_arg) {
49174         LDKDirectedChannelTransactionParameters this_arg_conv;
49175         this_arg_conv.inner = untag_ptr(this_arg);
49176         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49178         this_arg_conv.is_owned = false;
49179         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
49180         int64_t ret_ref = 0;
49181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49182         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49183         return ret_ref;
49184 }
49185
49186 int64_t  CS_LDK_DirectedChannelTransactionParameters_channel_type_features(int64_t this_arg) {
49187         LDKDirectedChannelTransactionParameters this_arg_conv;
49188         this_arg_conv.inner = untag_ptr(this_arg);
49189         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49191         this_arg_conv.is_owned = false;
49192         LDKChannelTypeFeatures ret_var = DirectedChannelTransactionParameters_channel_type_features(&this_arg_conv);
49193         int64_t ret_ref = 0;
49194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49195         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49196         return ret_ref;
49197 }
49198
49199 void  CS_LDK_HolderCommitmentTransaction_free(int64_t this_obj) {
49200         LDKHolderCommitmentTransaction this_obj_conv;
49201         this_obj_conv.inner = untag_ptr(this_obj);
49202         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49204         HolderCommitmentTransaction_free(this_obj_conv);
49205 }
49206
49207 int8_tArray  CS_LDK_HolderCommitmentTransaction_get_counterparty_sig(int64_t this_ptr) {
49208         LDKHolderCommitmentTransaction this_ptr_conv;
49209         this_ptr_conv.inner = untag_ptr(this_ptr);
49210         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49212         this_ptr_conv.is_owned = false;
49213         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
49214         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
49215         return ret_arr;
49216 }
49217
49218 void  CS_LDK_HolderCommitmentTransaction_set_counterparty_sig(int64_t this_ptr, int8_tArray val) {
49219         LDKHolderCommitmentTransaction this_ptr_conv;
49220         this_ptr_conv.inner = untag_ptr(this_ptr);
49221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49223         this_ptr_conv.is_owned = false;
49224         LDKECDSASignature val_ref;
49225         CHECK(val->arr_len == 64);
49226         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
49227         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
49228 }
49229
49230 ptrArray  CS_LDK_HolderCommitmentTransaction_get_counterparty_htlc_sigs(int64_t this_ptr) {
49231         LDKHolderCommitmentTransaction this_ptr_conv;
49232         this_ptr_conv.inner = untag_ptr(this_ptr);
49233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49235         this_ptr_conv.is_owned = false;
49236         LDKCVec_ECDSASignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
49237         ptrArray ret_arr = NULL;
49238         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
49239         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
49240         for (size_t i = 0; i < ret_var.datalen; i++) {
49241                 int8_tArray ret_conv_8_arr = init_int8_tArray(64, __LINE__);
49242                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compact_form, 64);
49243                 ret_arr_ptr[i] = ret_conv_8_arr;
49244         }
49245         
49246         FREE(ret_var.data);
49247         return ret_arr;
49248 }
49249
49250 void  CS_LDK_HolderCommitmentTransaction_set_counterparty_htlc_sigs(int64_t this_ptr, ptrArray val) {
49251         LDKHolderCommitmentTransaction this_ptr_conv;
49252         this_ptr_conv.inner = untag_ptr(this_ptr);
49253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49255         this_ptr_conv.is_owned = false;
49256         LDKCVec_ECDSASignatureZ val_constr;
49257         val_constr.datalen = val->arr_len;
49258         if (val_constr.datalen > 0)
49259                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
49260         else
49261                 val_constr.data = NULL;
49262         int8_tArray* val_vals = (void*) val->elems;
49263         for (size_t i = 0; i < val_constr.datalen; i++) {
49264                 int8_tArray val_conv_8 = val_vals[i];
49265                 LDKECDSASignature val_conv_8_ref;
49266                 CHECK(val_conv_8->arr_len == 64);
49267                 memcpy(val_conv_8_ref.compact_form, val_conv_8->elems, 64); FREE(val_conv_8);
49268                 val_constr.data[i] = val_conv_8_ref;
49269         }
49270         FREE(val);
49271         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
49272 }
49273
49274 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
49275         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
49276         int64_t ret_ref = 0;
49277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49279         return ret_ref;
49280 }
49281 int64_t  CS_LDK_HolderCommitmentTransaction_clone_ptr(int64_t arg) {
49282         LDKHolderCommitmentTransaction arg_conv;
49283         arg_conv.inner = untag_ptr(arg);
49284         arg_conv.is_owned = ptr_is_owned(arg);
49285         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49286         arg_conv.is_owned = false;
49287         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
49288         return ret_conv;
49289 }
49290
49291 int64_t  CS_LDK_HolderCommitmentTransaction_clone(int64_t orig) {
49292         LDKHolderCommitmentTransaction orig_conv;
49293         orig_conv.inner = untag_ptr(orig);
49294         orig_conv.is_owned = ptr_is_owned(orig);
49295         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49296         orig_conv.is_owned = false;
49297         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
49298         int64_t ret_ref = 0;
49299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49300         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49301         return ret_ref;
49302 }
49303
49304 int8_tArray  CS_LDK_HolderCommitmentTransaction_write(int64_t obj) {
49305         LDKHolderCommitmentTransaction obj_conv;
49306         obj_conv.inner = untag_ptr(obj);
49307         obj_conv.is_owned = ptr_is_owned(obj);
49308         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49309         obj_conv.is_owned = false;
49310         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
49311         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49312         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49313         CVec_u8Z_free(ret_var);
49314         return ret_arr;
49315 }
49316
49317 int64_t  CS_LDK_HolderCommitmentTransaction_read(int8_tArray ser) {
49318         LDKu8slice ser_ref;
49319         ser_ref.datalen = ser->arr_len;
49320         ser_ref.data = ser->elems;
49321         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
49322         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
49323         FREE(ser);
49324         return tag_ptr(ret_conv, true);
49325 }
49326
49327 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) {
49328         LDKCommitmentTransaction commitment_tx_conv;
49329         commitment_tx_conv.inner = untag_ptr(commitment_tx);
49330         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
49331         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
49332         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
49333         LDKECDSASignature counterparty_sig_ref;
49334         CHECK(counterparty_sig->arr_len == 64);
49335         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
49336         LDKCVec_ECDSASignatureZ counterparty_htlc_sigs_constr;
49337         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
49338         if (counterparty_htlc_sigs_constr.datalen > 0)
49339                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
49340         else
49341                 counterparty_htlc_sigs_constr.data = NULL;
49342         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
49343         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
49344                 int8_tArray counterparty_htlc_sigs_conv_8 = counterparty_htlc_sigs_vals[i];
49345                 LDKECDSASignature counterparty_htlc_sigs_conv_8_ref;
49346                 CHECK(counterparty_htlc_sigs_conv_8->arr_len == 64);
49347                 memcpy(counterparty_htlc_sigs_conv_8_ref.compact_form, counterparty_htlc_sigs_conv_8->elems, 64); FREE(counterparty_htlc_sigs_conv_8);
49348                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
49349         }
49350         FREE(counterparty_htlc_sigs);
49351         LDKPublicKey holder_funding_key_ref;
49352         CHECK(holder_funding_key->arr_len == 33);
49353         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
49354         LDKPublicKey counterparty_funding_key_ref;
49355         CHECK(counterparty_funding_key->arr_len == 33);
49356         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
49357         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
49358         int64_t ret_ref = 0;
49359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49361         return ret_ref;
49362 }
49363
49364 void  CS_LDK_BuiltCommitmentTransaction_free(int64_t this_obj) {
49365         LDKBuiltCommitmentTransaction this_obj_conv;
49366         this_obj_conv.inner = untag_ptr(this_obj);
49367         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49369         BuiltCommitmentTransaction_free(this_obj_conv);
49370 }
49371
49372 int8_tArray  CS_LDK_BuiltCommitmentTransaction_get_transaction(int64_t this_ptr) {
49373         LDKBuiltCommitmentTransaction this_ptr_conv;
49374         this_ptr_conv.inner = untag_ptr(this_ptr);
49375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49377         this_ptr_conv.is_owned = false;
49378         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
49379         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49380         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49381         Transaction_free(ret_var);
49382         return ret_arr;
49383 }
49384
49385 void  CS_LDK_BuiltCommitmentTransaction_set_transaction(int64_t this_ptr, int8_tArray val) {
49386         LDKBuiltCommitmentTransaction this_ptr_conv;
49387         this_ptr_conv.inner = untag_ptr(this_ptr);
49388         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49390         this_ptr_conv.is_owned = false;
49391         LDKTransaction val_ref;
49392         val_ref.datalen = val->arr_len;
49393         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
49394         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
49395         val_ref.data_is_owned = true;
49396         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
49397 }
49398
49399 int8_tArray  CS_LDK_BuiltCommitmentTransaction_get_txid(int64_t this_ptr) {
49400         LDKBuiltCommitmentTransaction this_ptr_conv;
49401         this_ptr_conv.inner = untag_ptr(this_ptr);
49402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49404         this_ptr_conv.is_owned = false;
49405         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
49406         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
49407         return ret_arr;
49408 }
49409
49410 void  CS_LDK_BuiltCommitmentTransaction_set_txid(int64_t this_ptr, int8_tArray val) {
49411         LDKBuiltCommitmentTransaction this_ptr_conv;
49412         this_ptr_conv.inner = untag_ptr(this_ptr);
49413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49415         this_ptr_conv.is_owned = false;
49416         LDKThirtyTwoBytes val_ref;
49417         CHECK(val->arr_len == 32);
49418         memcpy(val_ref.data, val->elems, 32); FREE(val);
49419         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
49420 }
49421
49422 int64_t  CS_LDK_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
49423         LDKTransaction transaction_arg_ref;
49424         transaction_arg_ref.datalen = transaction_arg->arr_len;
49425         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
49426         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
49427         transaction_arg_ref.data_is_owned = true;
49428         LDKThirtyTwoBytes txid_arg_ref;
49429         CHECK(txid_arg->arr_len == 32);
49430         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
49431         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
49432         int64_t ret_ref = 0;
49433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49434         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49435         return ret_ref;
49436 }
49437
49438 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
49439         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
49440         int64_t ret_ref = 0;
49441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49442         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49443         return ret_ref;
49444 }
49445 int64_t  CS_LDK_BuiltCommitmentTransaction_clone_ptr(int64_t arg) {
49446         LDKBuiltCommitmentTransaction arg_conv;
49447         arg_conv.inner = untag_ptr(arg);
49448         arg_conv.is_owned = ptr_is_owned(arg);
49449         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49450         arg_conv.is_owned = false;
49451         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
49452         return ret_conv;
49453 }
49454
49455 int64_t  CS_LDK_BuiltCommitmentTransaction_clone(int64_t orig) {
49456         LDKBuiltCommitmentTransaction orig_conv;
49457         orig_conv.inner = untag_ptr(orig);
49458         orig_conv.is_owned = ptr_is_owned(orig);
49459         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49460         orig_conv.is_owned = false;
49461         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
49462         int64_t ret_ref = 0;
49463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49465         return ret_ref;
49466 }
49467
49468 int8_tArray  CS_LDK_BuiltCommitmentTransaction_write(int64_t obj) {
49469         LDKBuiltCommitmentTransaction obj_conv;
49470         obj_conv.inner = untag_ptr(obj);
49471         obj_conv.is_owned = ptr_is_owned(obj);
49472         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49473         obj_conv.is_owned = false;
49474         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
49475         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49476         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49477         CVec_u8Z_free(ret_var);
49478         return ret_arr;
49479 }
49480
49481 int64_t  CS_LDK_BuiltCommitmentTransaction_read(int8_tArray ser) {
49482         LDKu8slice ser_ref;
49483         ser_ref.datalen = ser->arr_len;
49484         ser_ref.data = ser->elems;
49485         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
49486         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
49487         FREE(ser);
49488         return tag_ptr(ret_conv, true);
49489 }
49490
49491 int8_tArray  CS_LDK_BuiltCommitmentTransaction_get_sighash_all(int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
49492         LDKBuiltCommitmentTransaction this_arg_conv;
49493         this_arg_conv.inner = untag_ptr(this_arg);
49494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49496         this_arg_conv.is_owned = false;
49497         LDKu8slice funding_redeemscript_ref;
49498         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49499         funding_redeemscript_ref.data = funding_redeemscript->elems;
49500         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
49501         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
49502         FREE(funding_redeemscript);
49503         return ret_arr;
49504 }
49505
49506 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) {
49507         LDKBuiltCommitmentTransaction this_arg_conv;
49508         this_arg_conv.inner = untag_ptr(this_arg);
49509         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49511         this_arg_conv.is_owned = false;
49512         uint8_t funding_key_arr[32];
49513         CHECK(funding_key->arr_len == 32);
49514         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
49515         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
49516         LDKu8slice funding_redeemscript_ref;
49517         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49518         funding_redeemscript_ref.data = funding_redeemscript->elems;
49519         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
49520         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign_counterparty_commitment(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
49521         FREE(funding_redeemscript);
49522         return ret_arr;
49523 }
49524
49525 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) {
49526         LDKBuiltCommitmentTransaction this_arg_conv;
49527         this_arg_conv.inner = untag_ptr(this_arg);
49528         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49530         this_arg_conv.is_owned = false;
49531         uint8_t funding_key_arr[32];
49532         CHECK(funding_key->arr_len == 32);
49533         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
49534         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
49535         LDKu8slice funding_redeemscript_ref;
49536         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49537         funding_redeemscript_ref.data = funding_redeemscript->elems;
49538         void* entropy_source_ptr = untag_ptr(entropy_source);
49539         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
49540         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
49541         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
49542         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);
49543         FREE(funding_redeemscript);
49544         return ret_arr;
49545 }
49546
49547 void  CS_LDK_ClosingTransaction_free(int64_t this_obj) {
49548         LDKClosingTransaction this_obj_conv;
49549         this_obj_conv.inner = untag_ptr(this_obj);
49550         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49552         ClosingTransaction_free(this_obj_conv);
49553 }
49554
49555 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
49556         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
49557         int64_t ret_ref = 0;
49558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49560         return ret_ref;
49561 }
49562 int64_t  CS_LDK_ClosingTransaction_clone_ptr(int64_t arg) {
49563         LDKClosingTransaction arg_conv;
49564         arg_conv.inner = untag_ptr(arg);
49565         arg_conv.is_owned = ptr_is_owned(arg);
49566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49567         arg_conv.is_owned = false;
49568         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
49569         return ret_conv;
49570 }
49571
49572 int64_t  CS_LDK_ClosingTransaction_clone(int64_t orig) {
49573         LDKClosingTransaction orig_conv;
49574         orig_conv.inner = untag_ptr(orig);
49575         orig_conv.is_owned = ptr_is_owned(orig);
49576         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49577         orig_conv.is_owned = false;
49578         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
49579         int64_t ret_ref = 0;
49580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49582         return ret_ref;
49583 }
49584
49585 int64_t  CS_LDK_ClosingTransaction_hash(int64_t o) {
49586         LDKClosingTransaction o_conv;
49587         o_conv.inner = untag_ptr(o);
49588         o_conv.is_owned = ptr_is_owned(o);
49589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49590         o_conv.is_owned = false;
49591         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
49592         return ret_conv;
49593 }
49594
49595 jboolean  CS_LDK_ClosingTransaction_eq(int64_t a, int64_t b) {
49596         LDKClosingTransaction a_conv;
49597         a_conv.inner = untag_ptr(a);
49598         a_conv.is_owned = ptr_is_owned(a);
49599         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49600         a_conv.is_owned = false;
49601         LDKClosingTransaction b_conv;
49602         b_conv.inner = untag_ptr(b);
49603         b_conv.is_owned = ptr_is_owned(b);
49604         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49605         b_conv.is_owned = false;
49606         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
49607         return ret_conv;
49608 }
49609
49610 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) {
49611         LDKCVec_u8Z to_holder_script_ref;
49612         to_holder_script_ref.datalen = to_holder_script->arr_len;
49613         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
49614         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
49615         LDKCVec_u8Z to_counterparty_script_ref;
49616         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
49617         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
49618         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
49619         LDKOutPoint funding_outpoint_conv;
49620         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
49621         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
49622         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
49623         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
49624         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
49625         int64_t ret_ref = 0;
49626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49628         return ret_ref;
49629 }
49630
49631 int64_t  CS_LDK_ClosingTransaction_trust(int64_t this_arg) {
49632         LDKClosingTransaction this_arg_conv;
49633         this_arg_conv.inner = untag_ptr(this_arg);
49634         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49636         this_arg_conv.is_owned = false;
49637         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
49638         int64_t ret_ref = 0;
49639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49640         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49641         return ret_ref;
49642 }
49643
49644 int64_t  CS_LDK_ClosingTransaction_verify(int64_t this_arg, int64_t funding_outpoint) {
49645         LDKClosingTransaction this_arg_conv;
49646         this_arg_conv.inner = untag_ptr(this_arg);
49647         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49649         this_arg_conv.is_owned = false;
49650         LDKOutPoint funding_outpoint_conv;
49651         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
49652         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
49653         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
49654         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
49655         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
49656         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
49657         return tag_ptr(ret_conv, true);
49658 }
49659
49660 int64_t  CS_LDK_ClosingTransaction_to_holder_value_sat(int64_t this_arg) {
49661         LDKClosingTransaction this_arg_conv;
49662         this_arg_conv.inner = untag_ptr(this_arg);
49663         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49665         this_arg_conv.is_owned = false;
49666         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
49667         return ret_conv;
49668 }
49669
49670 int64_t  CS_LDK_ClosingTransaction_to_counterparty_value_sat(int64_t this_arg) {
49671         LDKClosingTransaction this_arg_conv;
49672         this_arg_conv.inner = untag_ptr(this_arg);
49673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49675         this_arg_conv.is_owned = false;
49676         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
49677         return ret_conv;
49678 }
49679
49680 int8_tArray  CS_LDK_ClosingTransaction_to_holder_script(int64_t this_arg) {
49681         LDKClosingTransaction this_arg_conv;
49682         this_arg_conv.inner = untag_ptr(this_arg);
49683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49685         this_arg_conv.is_owned = false;
49686         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
49687         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49688         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49689         return ret_arr;
49690 }
49691
49692 int8_tArray  CS_LDK_ClosingTransaction_to_counterparty_script(int64_t this_arg) {
49693         LDKClosingTransaction this_arg_conv;
49694         this_arg_conv.inner = untag_ptr(this_arg);
49695         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49697         this_arg_conv.is_owned = false;
49698         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
49699         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49700         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49701         return ret_arr;
49702 }
49703
49704 void  CS_LDK_TrustedClosingTransaction_free(int64_t this_obj) {
49705         LDKTrustedClosingTransaction this_obj_conv;
49706         this_obj_conv.inner = untag_ptr(this_obj);
49707         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49709         TrustedClosingTransaction_free(this_obj_conv);
49710 }
49711
49712 int8_tArray  CS_LDK_TrustedClosingTransaction_built_transaction(int64_t this_arg) {
49713         LDKTrustedClosingTransaction this_arg_conv;
49714         this_arg_conv.inner = untag_ptr(this_arg);
49715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49717         this_arg_conv.is_owned = false;
49718         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
49719         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49720         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49721         Transaction_free(ret_var);
49722         return ret_arr;
49723 }
49724
49725 int8_tArray  CS_LDK_TrustedClosingTransaction_get_sighash_all(int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
49726         LDKTrustedClosingTransaction this_arg_conv;
49727         this_arg_conv.inner = untag_ptr(this_arg);
49728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49730         this_arg_conv.is_owned = false;
49731         LDKu8slice funding_redeemscript_ref;
49732         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49733         funding_redeemscript_ref.data = funding_redeemscript->elems;
49734         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
49735         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
49736         FREE(funding_redeemscript);
49737         return ret_arr;
49738 }
49739
49740 int8_tArray  CS_LDK_TrustedClosingTransaction_sign(int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
49741         LDKTrustedClosingTransaction this_arg_conv;
49742         this_arg_conv.inner = untag_ptr(this_arg);
49743         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49745         this_arg_conv.is_owned = false;
49746         uint8_t funding_key_arr[32];
49747         CHECK(funding_key->arr_len == 32);
49748         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
49749         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
49750         LDKu8slice funding_redeemscript_ref;
49751         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49752         funding_redeemscript_ref.data = funding_redeemscript->elems;
49753         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
49754         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
49755         FREE(funding_redeemscript);
49756         return ret_arr;
49757 }
49758
49759 void  CS_LDK_CommitmentTransaction_free(int64_t this_obj) {
49760         LDKCommitmentTransaction this_obj_conv;
49761         this_obj_conv.inner = untag_ptr(this_obj);
49762         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49764         CommitmentTransaction_free(this_obj_conv);
49765 }
49766
49767 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
49768         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
49769         int64_t ret_ref = 0;
49770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49771         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49772         return ret_ref;
49773 }
49774 int64_t  CS_LDK_CommitmentTransaction_clone_ptr(int64_t arg) {
49775         LDKCommitmentTransaction arg_conv;
49776         arg_conv.inner = untag_ptr(arg);
49777         arg_conv.is_owned = ptr_is_owned(arg);
49778         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49779         arg_conv.is_owned = false;
49780         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
49781         return ret_conv;
49782 }
49783
49784 int64_t  CS_LDK_CommitmentTransaction_clone(int64_t orig) {
49785         LDKCommitmentTransaction orig_conv;
49786         orig_conv.inner = untag_ptr(orig);
49787         orig_conv.is_owned = ptr_is_owned(orig);
49788         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49789         orig_conv.is_owned = false;
49790         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
49791         int64_t ret_ref = 0;
49792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49793         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49794         return ret_ref;
49795 }
49796
49797 int8_tArray  CS_LDK_CommitmentTransaction_write(int64_t obj) {
49798         LDKCommitmentTransaction obj_conv;
49799         obj_conv.inner = untag_ptr(obj);
49800         obj_conv.is_owned = ptr_is_owned(obj);
49801         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49802         obj_conv.is_owned = false;
49803         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
49804         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49805         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49806         CVec_u8Z_free(ret_var);
49807         return ret_arr;
49808 }
49809
49810 int64_t  CS_LDK_CommitmentTransaction_read(int8_tArray ser) {
49811         LDKu8slice ser_ref;
49812         ser_ref.datalen = ser->arr_len;
49813         ser_ref.data = ser->elems;
49814         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
49815         *ret_conv = CommitmentTransaction_read(ser_ref);
49816         FREE(ser);
49817         return tag_ptr(ret_conv, true);
49818 }
49819
49820 int64_t  CS_LDK_CommitmentTransaction_commitment_number(int64_t this_arg) {
49821         LDKCommitmentTransaction this_arg_conv;
49822         this_arg_conv.inner = untag_ptr(this_arg);
49823         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49825         this_arg_conv.is_owned = false;
49826         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
49827         return ret_conv;
49828 }
49829
49830 int8_tArray  CS_LDK_CommitmentTransaction_per_commitment_point(int64_t this_arg) {
49831         LDKCommitmentTransaction this_arg_conv;
49832         this_arg_conv.inner = untag_ptr(this_arg);
49833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49835         this_arg_conv.is_owned = false;
49836         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
49837         memcpy(ret_arr->elems, CommitmentTransaction_per_commitment_point(&this_arg_conv).compressed_form, 33);
49838         return ret_arr;
49839 }
49840
49841 int64_t  CS_LDK_CommitmentTransaction_to_broadcaster_value_sat(int64_t this_arg) {
49842         LDKCommitmentTransaction this_arg_conv;
49843         this_arg_conv.inner = untag_ptr(this_arg);
49844         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49846         this_arg_conv.is_owned = false;
49847         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
49848         return ret_conv;
49849 }
49850
49851 int64_t  CS_LDK_CommitmentTransaction_to_countersignatory_value_sat(int64_t this_arg) {
49852         LDKCommitmentTransaction this_arg_conv;
49853         this_arg_conv.inner = untag_ptr(this_arg);
49854         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49856         this_arg_conv.is_owned = false;
49857         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
49858         return ret_conv;
49859 }
49860
49861 int32_t  CS_LDK_CommitmentTransaction_feerate_per_kw(int64_t this_arg) {
49862         LDKCommitmentTransaction this_arg_conv;
49863         this_arg_conv.inner = untag_ptr(this_arg);
49864         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49866         this_arg_conv.is_owned = false;
49867         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
49868         return ret_conv;
49869 }
49870
49871 int64_t  CS_LDK_CommitmentTransaction_trust(int64_t this_arg) {
49872         LDKCommitmentTransaction this_arg_conv;
49873         this_arg_conv.inner = untag_ptr(this_arg);
49874         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49876         this_arg_conv.is_owned = false;
49877         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
49878         int64_t ret_ref = 0;
49879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49880         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49881         return ret_ref;
49882 }
49883
49884 int64_t  CS_LDK_CommitmentTransaction_verify(int64_t this_arg, int64_t channel_parameters, int64_t broadcaster_keys, int64_t countersignatory_keys) {
49885         LDKCommitmentTransaction this_arg_conv;
49886         this_arg_conv.inner = untag_ptr(this_arg);
49887         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49889         this_arg_conv.is_owned = false;
49890         LDKDirectedChannelTransactionParameters channel_parameters_conv;
49891         channel_parameters_conv.inner = untag_ptr(channel_parameters);
49892         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
49893         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
49894         channel_parameters_conv.is_owned = false;
49895         LDKChannelPublicKeys broadcaster_keys_conv;
49896         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
49897         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
49898         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
49899         broadcaster_keys_conv.is_owned = false;
49900         LDKChannelPublicKeys countersignatory_keys_conv;
49901         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
49902         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
49903         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
49904         countersignatory_keys_conv.is_owned = false;
49905         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
49906         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
49907         return tag_ptr(ret_conv, true);
49908 }
49909
49910 void  CS_LDK_TrustedCommitmentTransaction_free(int64_t this_obj) {
49911         LDKTrustedCommitmentTransaction this_obj_conv;
49912         this_obj_conv.inner = untag_ptr(this_obj);
49913         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49915         TrustedCommitmentTransaction_free(this_obj_conv);
49916 }
49917
49918 int8_tArray  CS_LDK_TrustedCommitmentTransaction_txid(int64_t this_arg) {
49919         LDKTrustedCommitmentTransaction this_arg_conv;
49920         this_arg_conv.inner = untag_ptr(this_arg);
49921         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49923         this_arg_conv.is_owned = false;
49924         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
49925         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
49926         return ret_arr;
49927 }
49928
49929 int64_t  CS_LDK_TrustedCommitmentTransaction_built_transaction(int64_t this_arg) {
49930         LDKTrustedCommitmentTransaction this_arg_conv;
49931         this_arg_conv.inner = untag_ptr(this_arg);
49932         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49934         this_arg_conv.is_owned = false;
49935         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
49936         int64_t ret_ref = 0;
49937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49939         return ret_ref;
49940 }
49941
49942 int64_t  CS_LDK_TrustedCommitmentTransaction_keys(int64_t this_arg) {
49943         LDKTrustedCommitmentTransaction this_arg_conv;
49944         this_arg_conv.inner = untag_ptr(this_arg);
49945         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49947         this_arg_conv.is_owned = false;
49948         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
49949         int64_t ret_ref = 0;
49950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49952         return ret_ref;
49953 }
49954
49955 int64_t  CS_LDK_TrustedCommitmentTransaction_channel_type_features(int64_t this_arg) {
49956         LDKTrustedCommitmentTransaction this_arg_conv;
49957         this_arg_conv.inner = untag_ptr(this_arg);
49958         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49960         this_arg_conv.is_owned = false;
49961         LDKChannelTypeFeatures ret_var = TrustedCommitmentTransaction_channel_type_features(&this_arg_conv);
49962         int64_t ret_ref = 0;
49963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49964         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49965         return ret_ref;
49966 }
49967
49968 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) {
49969         LDKTrustedCommitmentTransaction this_arg_conv;
49970         this_arg_conv.inner = untag_ptr(this_arg);
49971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49973         this_arg_conv.is_owned = false;
49974         uint8_t htlc_base_key_arr[32];
49975         CHECK(htlc_base_key->arr_len == 32);
49976         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
49977         uint8_t (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
49978         LDKDirectedChannelTransactionParameters channel_parameters_conv;
49979         channel_parameters_conv.inner = untag_ptr(channel_parameters);
49980         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
49981         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
49982         channel_parameters_conv.is_owned = false;
49983         void* entropy_source_ptr = untag_ptr(entropy_source);
49984         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
49985         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
49986         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
49987         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv, entropy_source_conv);
49988         return tag_ptr(ret_conv, true);
49989 }
49990
49991 int64_t  CS_LDK_TrustedCommitmentTransaction_revokeable_output_index(int64_t this_arg) {
49992         LDKTrustedCommitmentTransaction this_arg_conv;
49993         this_arg_conv.inner = untag_ptr(this_arg);
49994         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49996         this_arg_conv.is_owned = false;
49997         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
49998         *ret_copy = TrustedCommitmentTransaction_revokeable_output_index(&this_arg_conv);
49999         int64_t ret_ref = tag_ptr(ret_copy, true);
50000         return ret_ref;
50001 }
50002
50003 int64_t  CS_LDK_TrustedCommitmentTransaction_build_to_local_justice_tx(int64_t this_arg, int64_t feerate_per_kw, int8_tArray destination_script) {
50004         LDKTrustedCommitmentTransaction this_arg_conv;
50005         this_arg_conv.inner = untag_ptr(this_arg);
50006         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50008         this_arg_conv.is_owned = false;
50009         LDKCVec_u8Z destination_script_ref;
50010         destination_script_ref.datalen = destination_script->arr_len;
50011         destination_script_ref.data = MALLOC(destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
50012         memcpy(destination_script_ref.data, destination_script->elems, destination_script_ref.datalen); FREE(destination_script);
50013         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
50014         *ret_conv = TrustedCommitmentTransaction_build_to_local_justice_tx(&this_arg_conv, feerate_per_kw, destination_script_ref);
50015         return tag_ptr(ret_conv, true);
50016 }
50017
50018 int64_t  CS_LDK_get_commitment_transaction_number_obscure_factor(int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
50019         LDKPublicKey broadcaster_payment_basepoint_ref;
50020         CHECK(broadcaster_payment_basepoint->arr_len == 33);
50021         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
50022         LDKPublicKey countersignatory_payment_basepoint_ref;
50023         CHECK(countersignatory_payment_basepoint->arr_len == 33);
50024         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
50025         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
50026         return ret_conv;
50027 }
50028
50029 jboolean  CS_LDK_InitFeatures_eq(int64_t a, int64_t b) {
50030         LDKInitFeatures a_conv;
50031         a_conv.inner = untag_ptr(a);
50032         a_conv.is_owned = ptr_is_owned(a);
50033         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50034         a_conv.is_owned = false;
50035         LDKInitFeatures b_conv;
50036         b_conv.inner = untag_ptr(b);
50037         b_conv.is_owned = ptr_is_owned(b);
50038         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50039         b_conv.is_owned = false;
50040         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
50041         return ret_conv;
50042 }
50043
50044 jboolean  CS_LDK_NodeFeatures_eq(int64_t a, int64_t b) {
50045         LDKNodeFeatures a_conv;
50046         a_conv.inner = untag_ptr(a);
50047         a_conv.is_owned = ptr_is_owned(a);
50048         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50049         a_conv.is_owned = false;
50050         LDKNodeFeatures b_conv;
50051         b_conv.inner = untag_ptr(b);
50052         b_conv.is_owned = ptr_is_owned(b);
50053         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50054         b_conv.is_owned = false;
50055         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
50056         return ret_conv;
50057 }
50058
50059 jboolean  CS_LDK_ChannelFeatures_eq(int64_t a, int64_t b) {
50060         LDKChannelFeatures a_conv;
50061         a_conv.inner = untag_ptr(a);
50062         a_conv.is_owned = ptr_is_owned(a);
50063         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50064         a_conv.is_owned = false;
50065         LDKChannelFeatures b_conv;
50066         b_conv.inner = untag_ptr(b);
50067         b_conv.is_owned = ptr_is_owned(b);
50068         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50069         b_conv.is_owned = false;
50070         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
50071         return ret_conv;
50072 }
50073
50074 jboolean  CS_LDK_Bolt11InvoiceFeatures_eq(int64_t a, int64_t b) {
50075         LDKBolt11InvoiceFeatures a_conv;
50076         a_conv.inner = untag_ptr(a);
50077         a_conv.is_owned = ptr_is_owned(a);
50078         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50079         a_conv.is_owned = false;
50080         LDKBolt11InvoiceFeatures b_conv;
50081         b_conv.inner = untag_ptr(b);
50082         b_conv.is_owned = ptr_is_owned(b);
50083         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50084         b_conv.is_owned = false;
50085         jboolean ret_conv = Bolt11InvoiceFeatures_eq(&a_conv, &b_conv);
50086         return ret_conv;
50087 }
50088
50089 jboolean  CS_LDK_OfferFeatures_eq(int64_t a, int64_t b) {
50090         LDKOfferFeatures a_conv;
50091         a_conv.inner = untag_ptr(a);
50092         a_conv.is_owned = ptr_is_owned(a);
50093         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50094         a_conv.is_owned = false;
50095         LDKOfferFeatures b_conv;
50096         b_conv.inner = untag_ptr(b);
50097         b_conv.is_owned = ptr_is_owned(b);
50098         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50099         b_conv.is_owned = false;
50100         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
50101         return ret_conv;
50102 }
50103
50104 jboolean  CS_LDK_InvoiceRequestFeatures_eq(int64_t a, int64_t b) {
50105         LDKInvoiceRequestFeatures a_conv;
50106         a_conv.inner = untag_ptr(a);
50107         a_conv.is_owned = ptr_is_owned(a);
50108         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50109         a_conv.is_owned = false;
50110         LDKInvoiceRequestFeatures b_conv;
50111         b_conv.inner = untag_ptr(b);
50112         b_conv.is_owned = ptr_is_owned(b);
50113         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50114         b_conv.is_owned = false;
50115         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
50116         return ret_conv;
50117 }
50118
50119 jboolean  CS_LDK_Bolt12InvoiceFeatures_eq(int64_t a, int64_t b) {
50120         LDKBolt12InvoiceFeatures a_conv;
50121         a_conv.inner = untag_ptr(a);
50122         a_conv.is_owned = ptr_is_owned(a);
50123         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50124         a_conv.is_owned = false;
50125         LDKBolt12InvoiceFeatures b_conv;
50126         b_conv.inner = untag_ptr(b);
50127         b_conv.is_owned = ptr_is_owned(b);
50128         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50129         b_conv.is_owned = false;
50130         jboolean ret_conv = Bolt12InvoiceFeatures_eq(&a_conv, &b_conv);
50131         return ret_conv;
50132 }
50133
50134 jboolean  CS_LDK_BlindedHopFeatures_eq(int64_t a, int64_t b) {
50135         LDKBlindedHopFeatures a_conv;
50136         a_conv.inner = untag_ptr(a);
50137         a_conv.is_owned = ptr_is_owned(a);
50138         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50139         a_conv.is_owned = false;
50140         LDKBlindedHopFeatures b_conv;
50141         b_conv.inner = untag_ptr(b);
50142         b_conv.is_owned = ptr_is_owned(b);
50143         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50144         b_conv.is_owned = false;
50145         jboolean ret_conv = BlindedHopFeatures_eq(&a_conv, &b_conv);
50146         return ret_conv;
50147 }
50148
50149 jboolean  CS_LDK_ChannelTypeFeatures_eq(int64_t a, int64_t b) {
50150         LDKChannelTypeFeatures a_conv;
50151         a_conv.inner = untag_ptr(a);
50152         a_conv.is_owned = ptr_is_owned(a);
50153         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50154         a_conv.is_owned = false;
50155         LDKChannelTypeFeatures b_conv;
50156         b_conv.inner = untag_ptr(b);
50157         b_conv.is_owned = ptr_is_owned(b);
50158         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50159         b_conv.is_owned = false;
50160         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
50161         return ret_conv;
50162 }
50163
50164 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
50165         LDKInitFeatures ret_var = InitFeatures_clone(arg);
50166         int64_t ret_ref = 0;
50167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50169         return ret_ref;
50170 }
50171 int64_t  CS_LDK_InitFeatures_clone_ptr(int64_t arg) {
50172         LDKInitFeatures arg_conv;
50173         arg_conv.inner = untag_ptr(arg);
50174         arg_conv.is_owned = ptr_is_owned(arg);
50175         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50176         arg_conv.is_owned = false;
50177         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
50178         return ret_conv;
50179 }
50180
50181 int64_t  CS_LDK_InitFeatures_clone(int64_t orig) {
50182         LDKInitFeatures orig_conv;
50183         orig_conv.inner = untag_ptr(orig);
50184         orig_conv.is_owned = ptr_is_owned(orig);
50185         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50186         orig_conv.is_owned = false;
50187         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
50188         int64_t ret_ref = 0;
50189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50190         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50191         return ret_ref;
50192 }
50193
50194 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
50195         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
50196         int64_t ret_ref = 0;
50197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50199         return ret_ref;
50200 }
50201 int64_t  CS_LDK_NodeFeatures_clone_ptr(int64_t arg) {
50202         LDKNodeFeatures arg_conv;
50203         arg_conv.inner = untag_ptr(arg);
50204         arg_conv.is_owned = ptr_is_owned(arg);
50205         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50206         arg_conv.is_owned = false;
50207         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
50208         return ret_conv;
50209 }
50210
50211 int64_t  CS_LDK_NodeFeatures_clone(int64_t orig) {
50212         LDKNodeFeatures orig_conv;
50213         orig_conv.inner = untag_ptr(orig);
50214         orig_conv.is_owned = ptr_is_owned(orig);
50215         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50216         orig_conv.is_owned = false;
50217         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
50218         int64_t ret_ref = 0;
50219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50220         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50221         return ret_ref;
50222 }
50223
50224 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
50225         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
50226         int64_t ret_ref = 0;
50227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50229         return ret_ref;
50230 }
50231 int64_t  CS_LDK_ChannelFeatures_clone_ptr(int64_t arg) {
50232         LDKChannelFeatures arg_conv;
50233         arg_conv.inner = untag_ptr(arg);
50234         arg_conv.is_owned = ptr_is_owned(arg);
50235         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50236         arg_conv.is_owned = false;
50237         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
50238         return ret_conv;
50239 }
50240
50241 int64_t  CS_LDK_ChannelFeatures_clone(int64_t orig) {
50242         LDKChannelFeatures orig_conv;
50243         orig_conv.inner = untag_ptr(orig);
50244         orig_conv.is_owned = ptr_is_owned(orig);
50245         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50246         orig_conv.is_owned = false;
50247         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
50248         int64_t ret_ref = 0;
50249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50251         return ret_ref;
50252 }
50253
50254 static inline uint64_t Bolt11InvoiceFeatures_clone_ptr(LDKBolt11InvoiceFeatures *NONNULL_PTR arg) {
50255         LDKBolt11InvoiceFeatures ret_var = Bolt11InvoiceFeatures_clone(arg);
50256         int64_t ret_ref = 0;
50257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50259         return ret_ref;
50260 }
50261 int64_t  CS_LDK_Bolt11InvoiceFeatures_clone_ptr(int64_t arg) {
50262         LDKBolt11InvoiceFeatures arg_conv;
50263         arg_conv.inner = untag_ptr(arg);
50264         arg_conv.is_owned = ptr_is_owned(arg);
50265         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50266         arg_conv.is_owned = false;
50267         int64_t ret_conv = Bolt11InvoiceFeatures_clone_ptr(&arg_conv);
50268         return ret_conv;
50269 }
50270
50271 int64_t  CS_LDK_Bolt11InvoiceFeatures_clone(int64_t orig) {
50272         LDKBolt11InvoiceFeatures orig_conv;
50273         orig_conv.inner = untag_ptr(orig);
50274         orig_conv.is_owned = ptr_is_owned(orig);
50275         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50276         orig_conv.is_owned = false;
50277         LDKBolt11InvoiceFeatures ret_var = Bolt11InvoiceFeatures_clone(&orig_conv);
50278         int64_t ret_ref = 0;
50279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50280         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50281         return ret_ref;
50282 }
50283
50284 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
50285         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
50286         int64_t ret_ref = 0;
50287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50288         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50289         return ret_ref;
50290 }
50291 int64_t  CS_LDK_OfferFeatures_clone_ptr(int64_t arg) {
50292         LDKOfferFeatures arg_conv;
50293         arg_conv.inner = untag_ptr(arg);
50294         arg_conv.is_owned = ptr_is_owned(arg);
50295         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50296         arg_conv.is_owned = false;
50297         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
50298         return ret_conv;
50299 }
50300
50301 int64_t  CS_LDK_OfferFeatures_clone(int64_t orig) {
50302         LDKOfferFeatures orig_conv;
50303         orig_conv.inner = untag_ptr(orig);
50304         orig_conv.is_owned = ptr_is_owned(orig);
50305         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50306         orig_conv.is_owned = false;
50307         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
50308         int64_t ret_ref = 0;
50309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50310         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50311         return ret_ref;
50312 }
50313
50314 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
50315         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
50316         int64_t ret_ref = 0;
50317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50318         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50319         return ret_ref;
50320 }
50321 int64_t  CS_LDK_InvoiceRequestFeatures_clone_ptr(int64_t arg) {
50322         LDKInvoiceRequestFeatures arg_conv;
50323         arg_conv.inner = untag_ptr(arg);
50324         arg_conv.is_owned = ptr_is_owned(arg);
50325         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50326         arg_conv.is_owned = false;
50327         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
50328         return ret_conv;
50329 }
50330
50331 int64_t  CS_LDK_InvoiceRequestFeatures_clone(int64_t orig) {
50332         LDKInvoiceRequestFeatures orig_conv;
50333         orig_conv.inner = untag_ptr(orig);
50334         orig_conv.is_owned = ptr_is_owned(orig);
50335         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50336         orig_conv.is_owned = false;
50337         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
50338         int64_t ret_ref = 0;
50339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50340         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50341         return ret_ref;
50342 }
50343
50344 static inline uint64_t Bolt12InvoiceFeatures_clone_ptr(LDKBolt12InvoiceFeatures *NONNULL_PTR arg) {
50345         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(arg);
50346         int64_t ret_ref = 0;
50347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50349         return ret_ref;
50350 }
50351 int64_t  CS_LDK_Bolt12InvoiceFeatures_clone_ptr(int64_t arg) {
50352         LDKBolt12InvoiceFeatures arg_conv;
50353         arg_conv.inner = untag_ptr(arg);
50354         arg_conv.is_owned = ptr_is_owned(arg);
50355         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50356         arg_conv.is_owned = false;
50357         int64_t ret_conv = Bolt12InvoiceFeatures_clone_ptr(&arg_conv);
50358         return ret_conv;
50359 }
50360
50361 int64_t  CS_LDK_Bolt12InvoiceFeatures_clone(int64_t orig) {
50362         LDKBolt12InvoiceFeatures orig_conv;
50363         orig_conv.inner = untag_ptr(orig);
50364         orig_conv.is_owned = ptr_is_owned(orig);
50365         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50366         orig_conv.is_owned = false;
50367         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(&orig_conv);
50368         int64_t ret_ref = 0;
50369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50370         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50371         return ret_ref;
50372 }
50373
50374 static inline uint64_t BlindedHopFeatures_clone_ptr(LDKBlindedHopFeatures *NONNULL_PTR arg) {
50375         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(arg);
50376         int64_t ret_ref = 0;
50377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50378         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50379         return ret_ref;
50380 }
50381 int64_t  CS_LDK_BlindedHopFeatures_clone_ptr(int64_t arg) {
50382         LDKBlindedHopFeatures arg_conv;
50383         arg_conv.inner = untag_ptr(arg);
50384         arg_conv.is_owned = ptr_is_owned(arg);
50385         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50386         arg_conv.is_owned = false;
50387         int64_t ret_conv = BlindedHopFeatures_clone_ptr(&arg_conv);
50388         return ret_conv;
50389 }
50390
50391 int64_t  CS_LDK_BlindedHopFeatures_clone(int64_t orig) {
50392         LDKBlindedHopFeatures orig_conv;
50393         orig_conv.inner = untag_ptr(orig);
50394         orig_conv.is_owned = ptr_is_owned(orig);
50395         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50396         orig_conv.is_owned = false;
50397         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(&orig_conv);
50398         int64_t ret_ref = 0;
50399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50401         return ret_ref;
50402 }
50403
50404 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
50405         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
50406         int64_t ret_ref = 0;
50407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50408         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50409         return ret_ref;
50410 }
50411 int64_t  CS_LDK_ChannelTypeFeatures_clone_ptr(int64_t arg) {
50412         LDKChannelTypeFeatures arg_conv;
50413         arg_conv.inner = untag_ptr(arg);
50414         arg_conv.is_owned = ptr_is_owned(arg);
50415         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50416         arg_conv.is_owned = false;
50417         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
50418         return ret_conv;
50419 }
50420
50421 int64_t  CS_LDK_ChannelTypeFeatures_clone(int64_t orig) {
50422         LDKChannelTypeFeatures orig_conv;
50423         orig_conv.inner = untag_ptr(orig);
50424         orig_conv.is_owned = ptr_is_owned(orig);
50425         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50426         orig_conv.is_owned = false;
50427         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
50428         int64_t ret_ref = 0;
50429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50431         return ret_ref;
50432 }
50433
50434 void  CS_LDK_InitFeatures_free(int64_t this_obj) {
50435         LDKInitFeatures this_obj_conv;
50436         this_obj_conv.inner = untag_ptr(this_obj);
50437         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50439         InitFeatures_free(this_obj_conv);
50440 }
50441
50442 void  CS_LDK_NodeFeatures_free(int64_t this_obj) {
50443         LDKNodeFeatures this_obj_conv;
50444         this_obj_conv.inner = untag_ptr(this_obj);
50445         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50447         NodeFeatures_free(this_obj_conv);
50448 }
50449
50450 void  CS_LDK_ChannelFeatures_free(int64_t this_obj) {
50451         LDKChannelFeatures this_obj_conv;
50452         this_obj_conv.inner = untag_ptr(this_obj);
50453         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50455         ChannelFeatures_free(this_obj_conv);
50456 }
50457
50458 void  CS_LDK_Bolt11InvoiceFeatures_free(int64_t this_obj) {
50459         LDKBolt11InvoiceFeatures this_obj_conv;
50460         this_obj_conv.inner = untag_ptr(this_obj);
50461         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50463         Bolt11InvoiceFeatures_free(this_obj_conv);
50464 }
50465
50466 void  CS_LDK_OfferFeatures_free(int64_t this_obj) {
50467         LDKOfferFeatures this_obj_conv;
50468         this_obj_conv.inner = untag_ptr(this_obj);
50469         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50471         OfferFeatures_free(this_obj_conv);
50472 }
50473
50474 void  CS_LDK_InvoiceRequestFeatures_free(int64_t this_obj) {
50475         LDKInvoiceRequestFeatures this_obj_conv;
50476         this_obj_conv.inner = untag_ptr(this_obj);
50477         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50479         InvoiceRequestFeatures_free(this_obj_conv);
50480 }
50481
50482 void  CS_LDK_Bolt12InvoiceFeatures_free(int64_t this_obj) {
50483         LDKBolt12InvoiceFeatures this_obj_conv;
50484         this_obj_conv.inner = untag_ptr(this_obj);
50485         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50487         Bolt12InvoiceFeatures_free(this_obj_conv);
50488 }
50489
50490 void  CS_LDK_BlindedHopFeatures_free(int64_t this_obj) {
50491         LDKBlindedHopFeatures this_obj_conv;
50492         this_obj_conv.inner = untag_ptr(this_obj);
50493         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50495         BlindedHopFeatures_free(this_obj_conv);
50496 }
50497
50498 void  CS_LDK_ChannelTypeFeatures_free(int64_t this_obj) {
50499         LDKChannelTypeFeatures this_obj_conv;
50500         this_obj_conv.inner = untag_ptr(this_obj);
50501         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50503         ChannelTypeFeatures_free(this_obj_conv);
50504 }
50505
50506 int64_t  CS_LDK_InitFeatures_empty() {
50507         LDKInitFeatures ret_var = InitFeatures_empty();
50508         int64_t ret_ref = 0;
50509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50511         return ret_ref;
50512 }
50513
50514 jboolean  CS_LDK_InitFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50515         LDKInitFeatures this_arg_conv;
50516         this_arg_conv.inner = untag_ptr(this_arg);
50517         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50519         this_arg_conv.is_owned = false;
50520         LDKInitFeatures other_conv;
50521         other_conv.inner = untag_ptr(other);
50522         other_conv.is_owned = ptr_is_owned(other);
50523         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50524         other_conv.is_owned = false;
50525         jboolean ret_conv = InitFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50526         return ret_conv;
50527 }
50528
50529 jboolean  CS_LDK_InitFeatures_requires_unknown_bits(int64_t this_arg) {
50530         LDKInitFeatures this_arg_conv;
50531         this_arg_conv.inner = untag_ptr(this_arg);
50532         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50534         this_arg_conv.is_owned = false;
50535         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
50536         return ret_conv;
50537 }
50538
50539 int64_t  CS_LDK_InitFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50540         LDKInitFeatures this_arg_conv;
50541         this_arg_conv.inner = untag_ptr(this_arg);
50542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50544         this_arg_conv.is_owned = false;
50545         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50546         *ret_conv = InitFeatures_set_required_feature_bit(&this_arg_conv, bit);
50547         return tag_ptr(ret_conv, true);
50548 }
50549
50550 int64_t  CS_LDK_InitFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50551         LDKInitFeatures this_arg_conv;
50552         this_arg_conv.inner = untag_ptr(this_arg);
50553         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50555         this_arg_conv.is_owned = false;
50556         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50557         *ret_conv = InitFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50558         return tag_ptr(ret_conv, true);
50559 }
50560
50561 int64_t  CS_LDK_InitFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50562         LDKInitFeatures this_arg_conv;
50563         this_arg_conv.inner = untag_ptr(this_arg);
50564         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50566         this_arg_conv.is_owned = false;
50567         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50568         *ret_conv = InitFeatures_set_required_custom_bit(&this_arg_conv, bit);
50569         return tag_ptr(ret_conv, true);
50570 }
50571
50572 int64_t  CS_LDK_InitFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50573         LDKInitFeatures this_arg_conv;
50574         this_arg_conv.inner = untag_ptr(this_arg);
50575         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50577         this_arg_conv.is_owned = false;
50578         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50579         *ret_conv = InitFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50580         return tag_ptr(ret_conv, true);
50581 }
50582
50583 int64_t  CS_LDK_NodeFeatures_empty() {
50584         LDKNodeFeatures ret_var = NodeFeatures_empty();
50585         int64_t ret_ref = 0;
50586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50588         return ret_ref;
50589 }
50590
50591 jboolean  CS_LDK_NodeFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50592         LDKNodeFeatures this_arg_conv;
50593         this_arg_conv.inner = untag_ptr(this_arg);
50594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50596         this_arg_conv.is_owned = false;
50597         LDKNodeFeatures other_conv;
50598         other_conv.inner = untag_ptr(other);
50599         other_conv.is_owned = ptr_is_owned(other);
50600         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50601         other_conv.is_owned = false;
50602         jboolean ret_conv = NodeFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50603         return ret_conv;
50604 }
50605
50606 jboolean  CS_LDK_NodeFeatures_requires_unknown_bits(int64_t this_arg) {
50607         LDKNodeFeatures this_arg_conv;
50608         this_arg_conv.inner = untag_ptr(this_arg);
50609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50611         this_arg_conv.is_owned = false;
50612         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
50613         return ret_conv;
50614 }
50615
50616 int64_t  CS_LDK_NodeFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50617         LDKNodeFeatures this_arg_conv;
50618         this_arg_conv.inner = untag_ptr(this_arg);
50619         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50621         this_arg_conv.is_owned = false;
50622         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50623         *ret_conv = NodeFeatures_set_required_feature_bit(&this_arg_conv, bit);
50624         return tag_ptr(ret_conv, true);
50625 }
50626
50627 int64_t  CS_LDK_NodeFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50628         LDKNodeFeatures this_arg_conv;
50629         this_arg_conv.inner = untag_ptr(this_arg);
50630         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50632         this_arg_conv.is_owned = false;
50633         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50634         *ret_conv = NodeFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50635         return tag_ptr(ret_conv, true);
50636 }
50637
50638 int64_t  CS_LDK_NodeFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50639         LDKNodeFeatures this_arg_conv;
50640         this_arg_conv.inner = untag_ptr(this_arg);
50641         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50643         this_arg_conv.is_owned = false;
50644         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50645         *ret_conv = NodeFeatures_set_required_custom_bit(&this_arg_conv, bit);
50646         return tag_ptr(ret_conv, true);
50647 }
50648
50649 int64_t  CS_LDK_NodeFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50650         LDKNodeFeatures this_arg_conv;
50651         this_arg_conv.inner = untag_ptr(this_arg);
50652         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50654         this_arg_conv.is_owned = false;
50655         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50656         *ret_conv = NodeFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50657         return tag_ptr(ret_conv, true);
50658 }
50659
50660 int64_t  CS_LDK_ChannelFeatures_empty() {
50661         LDKChannelFeatures ret_var = ChannelFeatures_empty();
50662         int64_t ret_ref = 0;
50663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50664         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50665         return ret_ref;
50666 }
50667
50668 jboolean  CS_LDK_ChannelFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50669         LDKChannelFeatures this_arg_conv;
50670         this_arg_conv.inner = untag_ptr(this_arg);
50671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50673         this_arg_conv.is_owned = false;
50674         LDKChannelFeatures other_conv;
50675         other_conv.inner = untag_ptr(other);
50676         other_conv.is_owned = ptr_is_owned(other);
50677         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50678         other_conv.is_owned = false;
50679         jboolean ret_conv = ChannelFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50680         return ret_conv;
50681 }
50682
50683 jboolean  CS_LDK_ChannelFeatures_requires_unknown_bits(int64_t this_arg) {
50684         LDKChannelFeatures this_arg_conv;
50685         this_arg_conv.inner = untag_ptr(this_arg);
50686         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50688         this_arg_conv.is_owned = false;
50689         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
50690         return ret_conv;
50691 }
50692
50693 int64_t  CS_LDK_ChannelFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50694         LDKChannelFeatures this_arg_conv;
50695         this_arg_conv.inner = untag_ptr(this_arg);
50696         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50698         this_arg_conv.is_owned = false;
50699         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50700         *ret_conv = ChannelFeatures_set_required_feature_bit(&this_arg_conv, bit);
50701         return tag_ptr(ret_conv, true);
50702 }
50703
50704 int64_t  CS_LDK_ChannelFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50705         LDKChannelFeatures this_arg_conv;
50706         this_arg_conv.inner = untag_ptr(this_arg);
50707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50709         this_arg_conv.is_owned = false;
50710         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50711         *ret_conv = ChannelFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50712         return tag_ptr(ret_conv, true);
50713 }
50714
50715 int64_t  CS_LDK_ChannelFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50716         LDKChannelFeatures this_arg_conv;
50717         this_arg_conv.inner = untag_ptr(this_arg);
50718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50720         this_arg_conv.is_owned = false;
50721         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50722         *ret_conv = ChannelFeatures_set_required_custom_bit(&this_arg_conv, bit);
50723         return tag_ptr(ret_conv, true);
50724 }
50725
50726 int64_t  CS_LDK_ChannelFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50727         LDKChannelFeatures this_arg_conv;
50728         this_arg_conv.inner = untag_ptr(this_arg);
50729         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50731         this_arg_conv.is_owned = false;
50732         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50733         *ret_conv = ChannelFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50734         return tag_ptr(ret_conv, true);
50735 }
50736
50737 int64_t  CS_LDK_Bolt11InvoiceFeatures_empty() {
50738         LDKBolt11InvoiceFeatures ret_var = Bolt11InvoiceFeatures_empty();
50739         int64_t ret_ref = 0;
50740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50742         return ret_ref;
50743 }
50744
50745 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50746         LDKBolt11InvoiceFeatures this_arg_conv;
50747         this_arg_conv.inner = untag_ptr(this_arg);
50748         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50750         this_arg_conv.is_owned = false;
50751         LDKBolt11InvoiceFeatures other_conv;
50752         other_conv.inner = untag_ptr(other);
50753         other_conv.is_owned = ptr_is_owned(other);
50754         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50755         other_conv.is_owned = false;
50756         jboolean ret_conv = Bolt11InvoiceFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50757         return ret_conv;
50758 }
50759
50760 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_unknown_bits(int64_t this_arg) {
50761         LDKBolt11InvoiceFeatures this_arg_conv;
50762         this_arg_conv.inner = untag_ptr(this_arg);
50763         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50765         this_arg_conv.is_owned = false;
50766         jboolean ret_conv = Bolt11InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
50767         return ret_conv;
50768 }
50769
50770 int64_t  CS_LDK_Bolt11InvoiceFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50771         LDKBolt11InvoiceFeatures this_arg_conv;
50772         this_arg_conv.inner = untag_ptr(this_arg);
50773         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50775         this_arg_conv.is_owned = false;
50776         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50777         *ret_conv = Bolt11InvoiceFeatures_set_required_feature_bit(&this_arg_conv, bit);
50778         return tag_ptr(ret_conv, true);
50779 }
50780
50781 int64_t  CS_LDK_Bolt11InvoiceFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50782         LDKBolt11InvoiceFeatures this_arg_conv;
50783         this_arg_conv.inner = untag_ptr(this_arg);
50784         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50786         this_arg_conv.is_owned = false;
50787         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50788         *ret_conv = Bolt11InvoiceFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50789         return tag_ptr(ret_conv, true);
50790 }
50791
50792 int64_t  CS_LDK_Bolt11InvoiceFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50793         LDKBolt11InvoiceFeatures this_arg_conv;
50794         this_arg_conv.inner = untag_ptr(this_arg);
50795         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50797         this_arg_conv.is_owned = false;
50798         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50799         *ret_conv = Bolt11InvoiceFeatures_set_required_custom_bit(&this_arg_conv, bit);
50800         return tag_ptr(ret_conv, true);
50801 }
50802
50803 int64_t  CS_LDK_Bolt11InvoiceFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50804         LDKBolt11InvoiceFeatures this_arg_conv;
50805         this_arg_conv.inner = untag_ptr(this_arg);
50806         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50808         this_arg_conv.is_owned = false;
50809         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50810         *ret_conv = Bolt11InvoiceFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50811         return tag_ptr(ret_conv, true);
50812 }
50813
50814 int64_t  CS_LDK_OfferFeatures_empty() {
50815         LDKOfferFeatures ret_var = OfferFeatures_empty();
50816         int64_t ret_ref = 0;
50817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50818         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50819         return ret_ref;
50820 }
50821
50822 jboolean  CS_LDK_OfferFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50823         LDKOfferFeatures this_arg_conv;
50824         this_arg_conv.inner = untag_ptr(this_arg);
50825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50827         this_arg_conv.is_owned = false;
50828         LDKOfferFeatures other_conv;
50829         other_conv.inner = untag_ptr(other);
50830         other_conv.is_owned = ptr_is_owned(other);
50831         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50832         other_conv.is_owned = false;
50833         jboolean ret_conv = OfferFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50834         return ret_conv;
50835 }
50836
50837 jboolean  CS_LDK_OfferFeatures_requires_unknown_bits(int64_t this_arg) {
50838         LDKOfferFeatures this_arg_conv;
50839         this_arg_conv.inner = untag_ptr(this_arg);
50840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50842         this_arg_conv.is_owned = false;
50843         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
50844         return ret_conv;
50845 }
50846
50847 int64_t  CS_LDK_OfferFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50848         LDKOfferFeatures this_arg_conv;
50849         this_arg_conv.inner = untag_ptr(this_arg);
50850         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50852         this_arg_conv.is_owned = false;
50853         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50854         *ret_conv = OfferFeatures_set_required_feature_bit(&this_arg_conv, bit);
50855         return tag_ptr(ret_conv, true);
50856 }
50857
50858 int64_t  CS_LDK_OfferFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50859         LDKOfferFeatures this_arg_conv;
50860         this_arg_conv.inner = untag_ptr(this_arg);
50861         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50863         this_arg_conv.is_owned = false;
50864         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50865         *ret_conv = OfferFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50866         return tag_ptr(ret_conv, true);
50867 }
50868
50869 int64_t  CS_LDK_OfferFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50870         LDKOfferFeatures this_arg_conv;
50871         this_arg_conv.inner = untag_ptr(this_arg);
50872         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50874         this_arg_conv.is_owned = false;
50875         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50876         *ret_conv = OfferFeatures_set_required_custom_bit(&this_arg_conv, bit);
50877         return tag_ptr(ret_conv, true);
50878 }
50879
50880 int64_t  CS_LDK_OfferFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50881         LDKOfferFeatures this_arg_conv;
50882         this_arg_conv.inner = untag_ptr(this_arg);
50883         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50885         this_arg_conv.is_owned = false;
50886         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50887         *ret_conv = OfferFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50888         return tag_ptr(ret_conv, true);
50889 }
50890
50891 int64_t  CS_LDK_InvoiceRequestFeatures_empty() {
50892         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
50893         int64_t ret_ref = 0;
50894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50896         return ret_ref;
50897 }
50898
50899 jboolean  CS_LDK_InvoiceRequestFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50900         LDKInvoiceRequestFeatures this_arg_conv;
50901         this_arg_conv.inner = untag_ptr(this_arg);
50902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50904         this_arg_conv.is_owned = false;
50905         LDKInvoiceRequestFeatures other_conv;
50906         other_conv.inner = untag_ptr(other);
50907         other_conv.is_owned = ptr_is_owned(other);
50908         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50909         other_conv.is_owned = false;
50910         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50911         return ret_conv;
50912 }
50913
50914 jboolean  CS_LDK_InvoiceRequestFeatures_requires_unknown_bits(int64_t this_arg) {
50915         LDKInvoiceRequestFeatures this_arg_conv;
50916         this_arg_conv.inner = untag_ptr(this_arg);
50917         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50919         this_arg_conv.is_owned = false;
50920         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
50921         return ret_conv;
50922 }
50923
50924 int64_t  CS_LDK_InvoiceRequestFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50925         LDKInvoiceRequestFeatures this_arg_conv;
50926         this_arg_conv.inner = untag_ptr(this_arg);
50927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50929         this_arg_conv.is_owned = false;
50930         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50931         *ret_conv = InvoiceRequestFeatures_set_required_feature_bit(&this_arg_conv, bit);
50932         return tag_ptr(ret_conv, true);
50933 }
50934
50935 int64_t  CS_LDK_InvoiceRequestFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50936         LDKInvoiceRequestFeatures this_arg_conv;
50937         this_arg_conv.inner = untag_ptr(this_arg);
50938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50940         this_arg_conv.is_owned = false;
50941         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50942         *ret_conv = InvoiceRequestFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50943         return tag_ptr(ret_conv, true);
50944 }
50945
50946 int64_t  CS_LDK_InvoiceRequestFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50947         LDKInvoiceRequestFeatures this_arg_conv;
50948         this_arg_conv.inner = untag_ptr(this_arg);
50949         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50951         this_arg_conv.is_owned = false;
50952         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50953         *ret_conv = InvoiceRequestFeatures_set_required_custom_bit(&this_arg_conv, bit);
50954         return tag_ptr(ret_conv, true);
50955 }
50956
50957 int64_t  CS_LDK_InvoiceRequestFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50958         LDKInvoiceRequestFeatures this_arg_conv;
50959         this_arg_conv.inner = untag_ptr(this_arg);
50960         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50962         this_arg_conv.is_owned = false;
50963         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50964         *ret_conv = InvoiceRequestFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50965         return tag_ptr(ret_conv, true);
50966 }
50967
50968 int64_t  CS_LDK_Bolt12InvoiceFeatures_empty() {
50969         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_empty();
50970         int64_t ret_ref = 0;
50971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50972         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50973         return ret_ref;
50974 }
50975
50976 jboolean  CS_LDK_Bolt12InvoiceFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50977         LDKBolt12InvoiceFeatures this_arg_conv;
50978         this_arg_conv.inner = untag_ptr(this_arg);
50979         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50981         this_arg_conv.is_owned = false;
50982         LDKBolt12InvoiceFeatures other_conv;
50983         other_conv.inner = untag_ptr(other);
50984         other_conv.is_owned = ptr_is_owned(other);
50985         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50986         other_conv.is_owned = false;
50987         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50988         return ret_conv;
50989 }
50990
50991 jboolean  CS_LDK_Bolt12InvoiceFeatures_requires_unknown_bits(int64_t this_arg) {
50992         LDKBolt12InvoiceFeatures this_arg_conv;
50993         this_arg_conv.inner = untag_ptr(this_arg);
50994         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50996         this_arg_conv.is_owned = false;
50997         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
50998         return ret_conv;
50999 }
51000
51001 int64_t  CS_LDK_Bolt12InvoiceFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
51002         LDKBolt12InvoiceFeatures this_arg_conv;
51003         this_arg_conv.inner = untag_ptr(this_arg);
51004         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51006         this_arg_conv.is_owned = false;
51007         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51008         *ret_conv = Bolt12InvoiceFeatures_set_required_feature_bit(&this_arg_conv, bit);
51009         return tag_ptr(ret_conv, true);
51010 }
51011
51012 int64_t  CS_LDK_Bolt12InvoiceFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
51013         LDKBolt12InvoiceFeatures this_arg_conv;
51014         this_arg_conv.inner = untag_ptr(this_arg);
51015         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51017         this_arg_conv.is_owned = false;
51018         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51019         *ret_conv = Bolt12InvoiceFeatures_set_optional_feature_bit(&this_arg_conv, bit);
51020         return tag_ptr(ret_conv, true);
51021 }
51022
51023 int64_t  CS_LDK_Bolt12InvoiceFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
51024         LDKBolt12InvoiceFeatures this_arg_conv;
51025         this_arg_conv.inner = untag_ptr(this_arg);
51026         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51028         this_arg_conv.is_owned = false;
51029         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51030         *ret_conv = Bolt12InvoiceFeatures_set_required_custom_bit(&this_arg_conv, bit);
51031         return tag_ptr(ret_conv, true);
51032 }
51033
51034 int64_t  CS_LDK_Bolt12InvoiceFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
51035         LDKBolt12InvoiceFeatures this_arg_conv;
51036         this_arg_conv.inner = untag_ptr(this_arg);
51037         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51039         this_arg_conv.is_owned = false;
51040         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51041         *ret_conv = Bolt12InvoiceFeatures_set_optional_custom_bit(&this_arg_conv, bit);
51042         return tag_ptr(ret_conv, true);
51043 }
51044
51045 int64_t  CS_LDK_BlindedHopFeatures_empty() {
51046         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_empty();
51047         int64_t ret_ref = 0;
51048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51050         return ret_ref;
51051 }
51052
51053 jboolean  CS_LDK_BlindedHopFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
51054         LDKBlindedHopFeatures this_arg_conv;
51055         this_arg_conv.inner = untag_ptr(this_arg);
51056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51058         this_arg_conv.is_owned = false;
51059         LDKBlindedHopFeatures other_conv;
51060         other_conv.inner = untag_ptr(other);
51061         other_conv.is_owned = ptr_is_owned(other);
51062         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
51063         other_conv.is_owned = false;
51064         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
51065         return ret_conv;
51066 }
51067
51068 jboolean  CS_LDK_BlindedHopFeatures_requires_unknown_bits(int64_t this_arg) {
51069         LDKBlindedHopFeatures this_arg_conv;
51070         this_arg_conv.inner = untag_ptr(this_arg);
51071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51073         this_arg_conv.is_owned = false;
51074         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits(&this_arg_conv);
51075         return ret_conv;
51076 }
51077
51078 int64_t  CS_LDK_BlindedHopFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
51079         LDKBlindedHopFeatures this_arg_conv;
51080         this_arg_conv.inner = untag_ptr(this_arg);
51081         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51083         this_arg_conv.is_owned = false;
51084         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51085         *ret_conv = BlindedHopFeatures_set_required_feature_bit(&this_arg_conv, bit);
51086         return tag_ptr(ret_conv, true);
51087 }
51088
51089 int64_t  CS_LDK_BlindedHopFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
51090         LDKBlindedHopFeatures this_arg_conv;
51091         this_arg_conv.inner = untag_ptr(this_arg);
51092         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51094         this_arg_conv.is_owned = false;
51095         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51096         *ret_conv = BlindedHopFeatures_set_optional_feature_bit(&this_arg_conv, bit);
51097         return tag_ptr(ret_conv, true);
51098 }
51099
51100 int64_t  CS_LDK_BlindedHopFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
51101         LDKBlindedHopFeatures this_arg_conv;
51102         this_arg_conv.inner = untag_ptr(this_arg);
51103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51105         this_arg_conv.is_owned = false;
51106         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51107         *ret_conv = BlindedHopFeatures_set_required_custom_bit(&this_arg_conv, bit);
51108         return tag_ptr(ret_conv, true);
51109 }
51110
51111 int64_t  CS_LDK_BlindedHopFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
51112         LDKBlindedHopFeatures this_arg_conv;
51113         this_arg_conv.inner = untag_ptr(this_arg);
51114         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51116         this_arg_conv.is_owned = false;
51117         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51118         *ret_conv = BlindedHopFeatures_set_optional_custom_bit(&this_arg_conv, bit);
51119         return tag_ptr(ret_conv, true);
51120 }
51121
51122 int64_t  CS_LDK_ChannelTypeFeatures_empty() {
51123         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
51124         int64_t ret_ref = 0;
51125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51127         return ret_ref;
51128 }
51129
51130 jboolean  CS_LDK_ChannelTypeFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
51131         LDKChannelTypeFeatures this_arg_conv;
51132         this_arg_conv.inner = untag_ptr(this_arg);
51133         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51135         this_arg_conv.is_owned = false;
51136         LDKChannelTypeFeatures other_conv;
51137         other_conv.inner = untag_ptr(other);
51138         other_conv.is_owned = ptr_is_owned(other);
51139         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
51140         other_conv.is_owned = false;
51141         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
51142         return ret_conv;
51143 }
51144
51145 jboolean  CS_LDK_ChannelTypeFeatures_requires_unknown_bits(int64_t this_arg) {
51146         LDKChannelTypeFeatures this_arg_conv;
51147         this_arg_conv.inner = untag_ptr(this_arg);
51148         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51150         this_arg_conv.is_owned = false;
51151         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
51152         return ret_conv;
51153 }
51154
51155 int64_t  CS_LDK_ChannelTypeFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
51156         LDKChannelTypeFeatures this_arg_conv;
51157         this_arg_conv.inner = untag_ptr(this_arg);
51158         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51160         this_arg_conv.is_owned = false;
51161         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51162         *ret_conv = ChannelTypeFeatures_set_required_feature_bit(&this_arg_conv, bit);
51163         return tag_ptr(ret_conv, true);
51164 }
51165
51166 int64_t  CS_LDK_ChannelTypeFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
51167         LDKChannelTypeFeatures this_arg_conv;
51168         this_arg_conv.inner = untag_ptr(this_arg);
51169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51171         this_arg_conv.is_owned = false;
51172         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51173         *ret_conv = ChannelTypeFeatures_set_optional_feature_bit(&this_arg_conv, bit);
51174         return tag_ptr(ret_conv, true);
51175 }
51176
51177 int64_t  CS_LDK_ChannelTypeFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
51178         LDKChannelTypeFeatures this_arg_conv;
51179         this_arg_conv.inner = untag_ptr(this_arg);
51180         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51182         this_arg_conv.is_owned = false;
51183         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51184         *ret_conv = ChannelTypeFeatures_set_required_custom_bit(&this_arg_conv, bit);
51185         return tag_ptr(ret_conv, true);
51186 }
51187
51188 int64_t  CS_LDK_ChannelTypeFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
51189         LDKChannelTypeFeatures this_arg_conv;
51190         this_arg_conv.inner = untag_ptr(this_arg);
51191         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51193         this_arg_conv.is_owned = false;
51194         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51195         *ret_conv = ChannelTypeFeatures_set_optional_custom_bit(&this_arg_conv, bit);
51196         return tag_ptr(ret_conv, true);
51197 }
51198
51199 int8_tArray  CS_LDK_InitFeatures_write(int64_t obj) {
51200         LDKInitFeatures obj_conv;
51201         obj_conv.inner = untag_ptr(obj);
51202         obj_conv.is_owned = ptr_is_owned(obj);
51203         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51204         obj_conv.is_owned = false;
51205         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
51206         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51207         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51208         CVec_u8Z_free(ret_var);
51209         return ret_arr;
51210 }
51211
51212 int64_t  CS_LDK_InitFeatures_read(int8_tArray ser) {
51213         LDKu8slice ser_ref;
51214         ser_ref.datalen = ser->arr_len;
51215         ser_ref.data = ser->elems;
51216         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
51217         *ret_conv = InitFeatures_read(ser_ref);
51218         FREE(ser);
51219         return tag_ptr(ret_conv, true);
51220 }
51221
51222 int8_tArray  CS_LDK_ChannelFeatures_write(int64_t obj) {
51223         LDKChannelFeatures obj_conv;
51224         obj_conv.inner = untag_ptr(obj);
51225         obj_conv.is_owned = ptr_is_owned(obj);
51226         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51227         obj_conv.is_owned = false;
51228         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
51229         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51230         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51231         CVec_u8Z_free(ret_var);
51232         return ret_arr;
51233 }
51234
51235 int64_t  CS_LDK_ChannelFeatures_read(int8_tArray ser) {
51236         LDKu8slice ser_ref;
51237         ser_ref.datalen = ser->arr_len;
51238         ser_ref.data = ser->elems;
51239         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
51240         *ret_conv = ChannelFeatures_read(ser_ref);
51241         FREE(ser);
51242         return tag_ptr(ret_conv, true);
51243 }
51244
51245 int8_tArray  CS_LDK_NodeFeatures_write(int64_t obj) {
51246         LDKNodeFeatures obj_conv;
51247         obj_conv.inner = untag_ptr(obj);
51248         obj_conv.is_owned = ptr_is_owned(obj);
51249         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51250         obj_conv.is_owned = false;
51251         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
51252         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51253         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51254         CVec_u8Z_free(ret_var);
51255         return ret_arr;
51256 }
51257
51258 int64_t  CS_LDK_NodeFeatures_read(int8_tArray ser) {
51259         LDKu8slice ser_ref;
51260         ser_ref.datalen = ser->arr_len;
51261         ser_ref.data = ser->elems;
51262         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
51263         *ret_conv = NodeFeatures_read(ser_ref);
51264         FREE(ser);
51265         return tag_ptr(ret_conv, true);
51266 }
51267
51268 int8_tArray  CS_LDK_Bolt11InvoiceFeatures_write(int64_t obj) {
51269         LDKBolt11InvoiceFeatures obj_conv;
51270         obj_conv.inner = untag_ptr(obj);
51271         obj_conv.is_owned = ptr_is_owned(obj);
51272         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51273         obj_conv.is_owned = false;
51274         LDKCVec_u8Z ret_var = Bolt11InvoiceFeatures_write(&obj_conv);
51275         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51276         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51277         CVec_u8Z_free(ret_var);
51278         return ret_arr;
51279 }
51280
51281 int64_t  CS_LDK_Bolt11InvoiceFeatures_read(int8_tArray ser) {
51282         LDKu8slice ser_ref;
51283         ser_ref.datalen = ser->arr_len;
51284         ser_ref.data = ser->elems;
51285         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
51286         *ret_conv = Bolt11InvoiceFeatures_read(ser_ref);
51287         FREE(ser);
51288         return tag_ptr(ret_conv, true);
51289 }
51290
51291 int8_tArray  CS_LDK_Bolt12InvoiceFeatures_write(int64_t obj) {
51292         LDKBolt12InvoiceFeatures obj_conv;
51293         obj_conv.inner = untag_ptr(obj);
51294         obj_conv.is_owned = ptr_is_owned(obj);
51295         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51296         obj_conv.is_owned = false;
51297         LDKCVec_u8Z ret_var = Bolt12InvoiceFeatures_write(&obj_conv);
51298         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51299         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51300         CVec_u8Z_free(ret_var);
51301         return ret_arr;
51302 }
51303
51304 int64_t  CS_LDK_Bolt12InvoiceFeatures_read(int8_tArray ser) {
51305         LDKu8slice ser_ref;
51306         ser_ref.datalen = ser->arr_len;
51307         ser_ref.data = ser->elems;
51308         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
51309         *ret_conv = Bolt12InvoiceFeatures_read(ser_ref);
51310         FREE(ser);
51311         return tag_ptr(ret_conv, true);
51312 }
51313
51314 int8_tArray  CS_LDK_BlindedHopFeatures_write(int64_t obj) {
51315         LDKBlindedHopFeatures obj_conv;
51316         obj_conv.inner = untag_ptr(obj);
51317         obj_conv.is_owned = ptr_is_owned(obj);
51318         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51319         obj_conv.is_owned = false;
51320         LDKCVec_u8Z ret_var = BlindedHopFeatures_write(&obj_conv);
51321         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51322         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51323         CVec_u8Z_free(ret_var);
51324         return ret_arr;
51325 }
51326
51327 int64_t  CS_LDK_BlindedHopFeatures_read(int8_tArray ser) {
51328         LDKu8slice ser_ref;
51329         ser_ref.datalen = ser->arr_len;
51330         ser_ref.data = ser->elems;
51331         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
51332         *ret_conv = BlindedHopFeatures_read(ser_ref);
51333         FREE(ser);
51334         return tag_ptr(ret_conv, true);
51335 }
51336
51337 int8_tArray  CS_LDK_ChannelTypeFeatures_write(int64_t obj) {
51338         LDKChannelTypeFeatures obj_conv;
51339         obj_conv.inner = untag_ptr(obj);
51340         obj_conv.is_owned = ptr_is_owned(obj);
51341         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51342         obj_conv.is_owned = false;
51343         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
51344         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51345         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51346         CVec_u8Z_free(ret_var);
51347         return ret_arr;
51348 }
51349
51350 int64_t  CS_LDK_ChannelTypeFeatures_read(int8_tArray ser) {
51351         LDKu8slice ser_ref;
51352         ser_ref.datalen = ser->arr_len;
51353         ser_ref.data = ser->elems;
51354         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
51355         *ret_conv = ChannelTypeFeatures_read(ser_ref);
51356         FREE(ser);
51357         return tag_ptr(ret_conv, true);
51358 }
51359
51360 void  CS_LDK_InitFeatures_set_data_loss_protect_optional(int64_t this_arg) {
51361         LDKInitFeatures this_arg_conv;
51362         this_arg_conv.inner = untag_ptr(this_arg);
51363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51365         this_arg_conv.is_owned = false;
51366         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
51367 }
51368
51369 void  CS_LDK_InitFeatures_set_data_loss_protect_required(int64_t this_arg) {
51370         LDKInitFeatures this_arg_conv;
51371         this_arg_conv.inner = untag_ptr(this_arg);
51372         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51374         this_arg_conv.is_owned = false;
51375         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
51376 }
51377
51378 jboolean  CS_LDK_InitFeatures_supports_data_loss_protect(int64_t this_arg) {
51379         LDKInitFeatures this_arg_conv;
51380         this_arg_conv.inner = untag_ptr(this_arg);
51381         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51383         this_arg_conv.is_owned = false;
51384         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
51385         return ret_conv;
51386 }
51387
51388 void  CS_LDK_NodeFeatures_set_data_loss_protect_optional(int64_t this_arg) {
51389         LDKNodeFeatures this_arg_conv;
51390         this_arg_conv.inner = untag_ptr(this_arg);
51391         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51393         this_arg_conv.is_owned = false;
51394         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
51395 }
51396
51397 void  CS_LDK_NodeFeatures_set_data_loss_protect_required(int64_t this_arg) {
51398         LDKNodeFeatures this_arg_conv;
51399         this_arg_conv.inner = untag_ptr(this_arg);
51400         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51402         this_arg_conv.is_owned = false;
51403         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
51404 }
51405
51406 jboolean  CS_LDK_NodeFeatures_supports_data_loss_protect(int64_t this_arg) {
51407         LDKNodeFeatures this_arg_conv;
51408         this_arg_conv.inner = untag_ptr(this_arg);
51409         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51411         this_arg_conv.is_owned = false;
51412         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
51413         return ret_conv;
51414 }
51415
51416 jboolean  CS_LDK_InitFeatures_requires_data_loss_protect(int64_t this_arg) {
51417         LDKInitFeatures this_arg_conv;
51418         this_arg_conv.inner = untag_ptr(this_arg);
51419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51421         this_arg_conv.is_owned = false;
51422         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
51423         return ret_conv;
51424 }
51425
51426 jboolean  CS_LDK_NodeFeatures_requires_data_loss_protect(int64_t this_arg) {
51427         LDKNodeFeatures this_arg_conv;
51428         this_arg_conv.inner = untag_ptr(this_arg);
51429         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51431         this_arg_conv.is_owned = false;
51432         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
51433         return ret_conv;
51434 }
51435
51436 void  CS_LDK_InitFeatures_set_initial_routing_sync_optional(int64_t this_arg) {
51437         LDKInitFeatures this_arg_conv;
51438         this_arg_conv.inner = untag_ptr(this_arg);
51439         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51441         this_arg_conv.is_owned = false;
51442         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
51443 }
51444
51445 void  CS_LDK_InitFeatures_set_initial_routing_sync_required(int64_t this_arg) {
51446         LDKInitFeatures this_arg_conv;
51447         this_arg_conv.inner = untag_ptr(this_arg);
51448         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51450         this_arg_conv.is_owned = false;
51451         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
51452 }
51453
51454 jboolean  CS_LDK_InitFeatures_initial_routing_sync(int64_t this_arg) {
51455         LDKInitFeatures this_arg_conv;
51456         this_arg_conv.inner = untag_ptr(this_arg);
51457         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51459         this_arg_conv.is_owned = false;
51460         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
51461         return ret_conv;
51462 }
51463
51464 void  CS_LDK_InitFeatures_set_upfront_shutdown_script_optional(int64_t this_arg) {
51465         LDKInitFeatures this_arg_conv;
51466         this_arg_conv.inner = untag_ptr(this_arg);
51467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51469         this_arg_conv.is_owned = false;
51470         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
51471 }
51472
51473 void  CS_LDK_InitFeatures_set_upfront_shutdown_script_required(int64_t this_arg) {
51474         LDKInitFeatures this_arg_conv;
51475         this_arg_conv.inner = untag_ptr(this_arg);
51476         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51478         this_arg_conv.is_owned = false;
51479         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
51480 }
51481
51482 jboolean  CS_LDK_InitFeatures_supports_upfront_shutdown_script(int64_t this_arg) {
51483         LDKInitFeatures this_arg_conv;
51484         this_arg_conv.inner = untag_ptr(this_arg);
51485         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51487         this_arg_conv.is_owned = false;
51488         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
51489         return ret_conv;
51490 }
51491
51492 void  CS_LDK_NodeFeatures_set_upfront_shutdown_script_optional(int64_t this_arg) {
51493         LDKNodeFeatures this_arg_conv;
51494         this_arg_conv.inner = untag_ptr(this_arg);
51495         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51497         this_arg_conv.is_owned = false;
51498         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
51499 }
51500
51501 void  CS_LDK_NodeFeatures_set_upfront_shutdown_script_required(int64_t this_arg) {
51502         LDKNodeFeatures this_arg_conv;
51503         this_arg_conv.inner = untag_ptr(this_arg);
51504         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51506         this_arg_conv.is_owned = false;
51507         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
51508 }
51509
51510 jboolean  CS_LDK_NodeFeatures_supports_upfront_shutdown_script(int64_t this_arg) {
51511         LDKNodeFeatures this_arg_conv;
51512         this_arg_conv.inner = untag_ptr(this_arg);
51513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51515         this_arg_conv.is_owned = false;
51516         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
51517         return ret_conv;
51518 }
51519
51520 jboolean  CS_LDK_InitFeatures_requires_upfront_shutdown_script(int64_t this_arg) {
51521         LDKInitFeatures this_arg_conv;
51522         this_arg_conv.inner = untag_ptr(this_arg);
51523         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51525         this_arg_conv.is_owned = false;
51526         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
51527         return ret_conv;
51528 }
51529
51530 jboolean  CS_LDK_NodeFeatures_requires_upfront_shutdown_script(int64_t this_arg) {
51531         LDKNodeFeatures this_arg_conv;
51532         this_arg_conv.inner = untag_ptr(this_arg);
51533         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51535         this_arg_conv.is_owned = false;
51536         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
51537         return ret_conv;
51538 }
51539
51540 void  CS_LDK_InitFeatures_set_gossip_queries_optional(int64_t this_arg) {
51541         LDKInitFeatures this_arg_conv;
51542         this_arg_conv.inner = untag_ptr(this_arg);
51543         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51545         this_arg_conv.is_owned = false;
51546         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
51547 }
51548
51549 void  CS_LDK_InitFeatures_set_gossip_queries_required(int64_t this_arg) {
51550         LDKInitFeatures this_arg_conv;
51551         this_arg_conv.inner = untag_ptr(this_arg);
51552         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51554         this_arg_conv.is_owned = false;
51555         InitFeatures_set_gossip_queries_required(&this_arg_conv);
51556 }
51557
51558 jboolean  CS_LDK_InitFeatures_supports_gossip_queries(int64_t this_arg) {
51559         LDKInitFeatures this_arg_conv;
51560         this_arg_conv.inner = untag_ptr(this_arg);
51561         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51563         this_arg_conv.is_owned = false;
51564         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
51565         return ret_conv;
51566 }
51567
51568 void  CS_LDK_NodeFeatures_set_gossip_queries_optional(int64_t this_arg) {
51569         LDKNodeFeatures this_arg_conv;
51570         this_arg_conv.inner = untag_ptr(this_arg);
51571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51573         this_arg_conv.is_owned = false;
51574         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
51575 }
51576
51577 void  CS_LDK_NodeFeatures_set_gossip_queries_required(int64_t this_arg) {
51578         LDKNodeFeatures this_arg_conv;
51579         this_arg_conv.inner = untag_ptr(this_arg);
51580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51582         this_arg_conv.is_owned = false;
51583         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
51584 }
51585
51586 jboolean  CS_LDK_NodeFeatures_supports_gossip_queries(int64_t this_arg) {
51587         LDKNodeFeatures this_arg_conv;
51588         this_arg_conv.inner = untag_ptr(this_arg);
51589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51591         this_arg_conv.is_owned = false;
51592         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
51593         return ret_conv;
51594 }
51595
51596 jboolean  CS_LDK_InitFeatures_requires_gossip_queries(int64_t this_arg) {
51597         LDKInitFeatures this_arg_conv;
51598         this_arg_conv.inner = untag_ptr(this_arg);
51599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51601         this_arg_conv.is_owned = false;
51602         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
51603         return ret_conv;
51604 }
51605
51606 jboolean  CS_LDK_NodeFeatures_requires_gossip_queries(int64_t this_arg) {
51607         LDKNodeFeatures this_arg_conv;
51608         this_arg_conv.inner = untag_ptr(this_arg);
51609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51611         this_arg_conv.is_owned = false;
51612         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
51613         return ret_conv;
51614 }
51615
51616 void  CS_LDK_InitFeatures_set_variable_length_onion_optional(int64_t this_arg) {
51617         LDKInitFeatures this_arg_conv;
51618         this_arg_conv.inner = untag_ptr(this_arg);
51619         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51621         this_arg_conv.is_owned = false;
51622         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
51623 }
51624
51625 void  CS_LDK_InitFeatures_set_variable_length_onion_required(int64_t this_arg) {
51626         LDKInitFeatures this_arg_conv;
51627         this_arg_conv.inner = untag_ptr(this_arg);
51628         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51630         this_arg_conv.is_owned = false;
51631         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
51632 }
51633
51634 jboolean  CS_LDK_InitFeatures_supports_variable_length_onion(int64_t this_arg) {
51635         LDKInitFeatures this_arg_conv;
51636         this_arg_conv.inner = untag_ptr(this_arg);
51637         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51639         this_arg_conv.is_owned = false;
51640         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
51641         return ret_conv;
51642 }
51643
51644 void  CS_LDK_NodeFeatures_set_variable_length_onion_optional(int64_t this_arg) {
51645         LDKNodeFeatures this_arg_conv;
51646         this_arg_conv.inner = untag_ptr(this_arg);
51647         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51649         this_arg_conv.is_owned = false;
51650         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
51651 }
51652
51653 void  CS_LDK_NodeFeatures_set_variable_length_onion_required(int64_t this_arg) {
51654         LDKNodeFeatures this_arg_conv;
51655         this_arg_conv.inner = untag_ptr(this_arg);
51656         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51658         this_arg_conv.is_owned = false;
51659         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
51660 }
51661
51662 jboolean  CS_LDK_NodeFeatures_supports_variable_length_onion(int64_t this_arg) {
51663         LDKNodeFeatures this_arg_conv;
51664         this_arg_conv.inner = untag_ptr(this_arg);
51665         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51667         this_arg_conv.is_owned = false;
51668         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
51669         return ret_conv;
51670 }
51671
51672 void  CS_LDK_Bolt11InvoiceFeatures_set_variable_length_onion_optional(int64_t this_arg) {
51673         LDKBolt11InvoiceFeatures this_arg_conv;
51674         this_arg_conv.inner = untag_ptr(this_arg);
51675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51677         this_arg_conv.is_owned = false;
51678         Bolt11InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
51679 }
51680
51681 void  CS_LDK_Bolt11InvoiceFeatures_set_variable_length_onion_required(int64_t this_arg) {
51682         LDKBolt11InvoiceFeatures this_arg_conv;
51683         this_arg_conv.inner = untag_ptr(this_arg);
51684         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51686         this_arg_conv.is_owned = false;
51687         Bolt11InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
51688 }
51689
51690 jboolean  CS_LDK_Bolt11InvoiceFeatures_supports_variable_length_onion(int64_t this_arg) {
51691         LDKBolt11InvoiceFeatures this_arg_conv;
51692         this_arg_conv.inner = untag_ptr(this_arg);
51693         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51695         this_arg_conv.is_owned = false;
51696         jboolean ret_conv = Bolt11InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
51697         return ret_conv;
51698 }
51699
51700 jboolean  CS_LDK_InitFeatures_requires_variable_length_onion(int64_t this_arg) {
51701         LDKInitFeatures this_arg_conv;
51702         this_arg_conv.inner = untag_ptr(this_arg);
51703         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51705         this_arg_conv.is_owned = false;
51706         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
51707         return ret_conv;
51708 }
51709
51710 jboolean  CS_LDK_NodeFeatures_requires_variable_length_onion(int64_t this_arg) {
51711         LDKNodeFeatures this_arg_conv;
51712         this_arg_conv.inner = untag_ptr(this_arg);
51713         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51715         this_arg_conv.is_owned = false;
51716         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
51717         return ret_conv;
51718 }
51719
51720 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_variable_length_onion(int64_t this_arg) {
51721         LDKBolt11InvoiceFeatures this_arg_conv;
51722         this_arg_conv.inner = untag_ptr(this_arg);
51723         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51725         this_arg_conv.is_owned = false;
51726         jboolean ret_conv = Bolt11InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
51727         return ret_conv;
51728 }
51729
51730 void  CS_LDK_InitFeatures_set_static_remote_key_optional(int64_t this_arg) {
51731         LDKInitFeatures this_arg_conv;
51732         this_arg_conv.inner = untag_ptr(this_arg);
51733         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51735         this_arg_conv.is_owned = false;
51736         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
51737 }
51738
51739 void  CS_LDK_InitFeatures_set_static_remote_key_required(int64_t this_arg) {
51740         LDKInitFeatures this_arg_conv;
51741         this_arg_conv.inner = untag_ptr(this_arg);
51742         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51744         this_arg_conv.is_owned = false;
51745         InitFeatures_set_static_remote_key_required(&this_arg_conv);
51746 }
51747
51748 jboolean  CS_LDK_InitFeatures_supports_static_remote_key(int64_t this_arg) {
51749         LDKInitFeatures this_arg_conv;
51750         this_arg_conv.inner = untag_ptr(this_arg);
51751         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51753         this_arg_conv.is_owned = false;
51754         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
51755         return ret_conv;
51756 }
51757
51758 void  CS_LDK_NodeFeatures_set_static_remote_key_optional(int64_t this_arg) {
51759         LDKNodeFeatures this_arg_conv;
51760         this_arg_conv.inner = untag_ptr(this_arg);
51761         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51763         this_arg_conv.is_owned = false;
51764         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
51765 }
51766
51767 void  CS_LDK_NodeFeatures_set_static_remote_key_required(int64_t this_arg) {
51768         LDKNodeFeatures this_arg_conv;
51769         this_arg_conv.inner = untag_ptr(this_arg);
51770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51772         this_arg_conv.is_owned = false;
51773         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
51774 }
51775
51776 jboolean  CS_LDK_NodeFeatures_supports_static_remote_key(int64_t this_arg) {
51777         LDKNodeFeatures this_arg_conv;
51778         this_arg_conv.inner = untag_ptr(this_arg);
51779         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51781         this_arg_conv.is_owned = false;
51782         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
51783         return ret_conv;
51784 }
51785
51786 void  CS_LDK_ChannelTypeFeatures_set_static_remote_key_optional(int64_t this_arg) {
51787         LDKChannelTypeFeatures this_arg_conv;
51788         this_arg_conv.inner = untag_ptr(this_arg);
51789         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51791         this_arg_conv.is_owned = false;
51792         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
51793 }
51794
51795 void  CS_LDK_ChannelTypeFeatures_set_static_remote_key_required(int64_t this_arg) {
51796         LDKChannelTypeFeatures this_arg_conv;
51797         this_arg_conv.inner = untag_ptr(this_arg);
51798         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51800         this_arg_conv.is_owned = false;
51801         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
51802 }
51803
51804 jboolean  CS_LDK_ChannelTypeFeatures_supports_static_remote_key(int64_t this_arg) {
51805         LDKChannelTypeFeatures this_arg_conv;
51806         this_arg_conv.inner = untag_ptr(this_arg);
51807         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51809         this_arg_conv.is_owned = false;
51810         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
51811         return ret_conv;
51812 }
51813
51814 jboolean  CS_LDK_InitFeatures_requires_static_remote_key(int64_t this_arg) {
51815         LDKInitFeatures this_arg_conv;
51816         this_arg_conv.inner = untag_ptr(this_arg);
51817         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51819         this_arg_conv.is_owned = false;
51820         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
51821         return ret_conv;
51822 }
51823
51824 jboolean  CS_LDK_NodeFeatures_requires_static_remote_key(int64_t this_arg) {
51825         LDKNodeFeatures this_arg_conv;
51826         this_arg_conv.inner = untag_ptr(this_arg);
51827         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51829         this_arg_conv.is_owned = false;
51830         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
51831         return ret_conv;
51832 }
51833
51834 jboolean  CS_LDK_ChannelTypeFeatures_requires_static_remote_key(int64_t this_arg) {
51835         LDKChannelTypeFeatures this_arg_conv;
51836         this_arg_conv.inner = untag_ptr(this_arg);
51837         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51839         this_arg_conv.is_owned = false;
51840         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
51841         return ret_conv;
51842 }
51843
51844 void  CS_LDK_InitFeatures_set_payment_secret_optional(int64_t this_arg) {
51845         LDKInitFeatures this_arg_conv;
51846         this_arg_conv.inner = untag_ptr(this_arg);
51847         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51849         this_arg_conv.is_owned = false;
51850         InitFeatures_set_payment_secret_optional(&this_arg_conv);
51851 }
51852
51853 void  CS_LDK_InitFeatures_set_payment_secret_required(int64_t this_arg) {
51854         LDKInitFeatures this_arg_conv;
51855         this_arg_conv.inner = untag_ptr(this_arg);
51856         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51858         this_arg_conv.is_owned = false;
51859         InitFeatures_set_payment_secret_required(&this_arg_conv);
51860 }
51861
51862 jboolean  CS_LDK_InitFeatures_supports_payment_secret(int64_t this_arg) {
51863         LDKInitFeatures this_arg_conv;
51864         this_arg_conv.inner = untag_ptr(this_arg);
51865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51867         this_arg_conv.is_owned = false;
51868         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
51869         return ret_conv;
51870 }
51871
51872 void  CS_LDK_NodeFeatures_set_payment_secret_optional(int64_t this_arg) {
51873         LDKNodeFeatures this_arg_conv;
51874         this_arg_conv.inner = untag_ptr(this_arg);
51875         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51877         this_arg_conv.is_owned = false;
51878         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
51879 }
51880
51881 void  CS_LDK_NodeFeatures_set_payment_secret_required(int64_t this_arg) {
51882         LDKNodeFeatures this_arg_conv;
51883         this_arg_conv.inner = untag_ptr(this_arg);
51884         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51886         this_arg_conv.is_owned = false;
51887         NodeFeatures_set_payment_secret_required(&this_arg_conv);
51888 }
51889
51890 jboolean  CS_LDK_NodeFeatures_supports_payment_secret(int64_t this_arg) {
51891         LDKNodeFeatures this_arg_conv;
51892         this_arg_conv.inner = untag_ptr(this_arg);
51893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51895         this_arg_conv.is_owned = false;
51896         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
51897         return ret_conv;
51898 }
51899
51900 void  CS_LDK_Bolt11InvoiceFeatures_set_payment_secret_optional(int64_t this_arg) {
51901         LDKBolt11InvoiceFeatures this_arg_conv;
51902         this_arg_conv.inner = untag_ptr(this_arg);
51903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51905         this_arg_conv.is_owned = false;
51906         Bolt11InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
51907 }
51908
51909 void  CS_LDK_Bolt11InvoiceFeatures_set_payment_secret_required(int64_t this_arg) {
51910         LDKBolt11InvoiceFeatures this_arg_conv;
51911         this_arg_conv.inner = untag_ptr(this_arg);
51912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51914         this_arg_conv.is_owned = false;
51915         Bolt11InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
51916 }
51917
51918 jboolean  CS_LDK_Bolt11InvoiceFeatures_supports_payment_secret(int64_t this_arg) {
51919         LDKBolt11InvoiceFeatures this_arg_conv;
51920         this_arg_conv.inner = untag_ptr(this_arg);
51921         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51923         this_arg_conv.is_owned = false;
51924         jboolean ret_conv = Bolt11InvoiceFeatures_supports_payment_secret(&this_arg_conv);
51925         return ret_conv;
51926 }
51927
51928 jboolean  CS_LDK_InitFeatures_requires_payment_secret(int64_t this_arg) {
51929         LDKInitFeatures this_arg_conv;
51930         this_arg_conv.inner = untag_ptr(this_arg);
51931         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51933         this_arg_conv.is_owned = false;
51934         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
51935         return ret_conv;
51936 }
51937
51938 jboolean  CS_LDK_NodeFeatures_requires_payment_secret(int64_t this_arg) {
51939         LDKNodeFeatures this_arg_conv;
51940         this_arg_conv.inner = untag_ptr(this_arg);
51941         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51943         this_arg_conv.is_owned = false;
51944         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
51945         return ret_conv;
51946 }
51947
51948 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_payment_secret(int64_t this_arg) {
51949         LDKBolt11InvoiceFeatures this_arg_conv;
51950         this_arg_conv.inner = untag_ptr(this_arg);
51951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51953         this_arg_conv.is_owned = false;
51954         jboolean ret_conv = Bolt11InvoiceFeatures_requires_payment_secret(&this_arg_conv);
51955         return ret_conv;
51956 }
51957
51958 void  CS_LDK_InitFeatures_set_basic_mpp_optional(int64_t this_arg) {
51959         LDKInitFeatures this_arg_conv;
51960         this_arg_conv.inner = untag_ptr(this_arg);
51961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51963         this_arg_conv.is_owned = false;
51964         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
51965 }
51966
51967 void  CS_LDK_InitFeatures_set_basic_mpp_required(int64_t this_arg) {
51968         LDKInitFeatures this_arg_conv;
51969         this_arg_conv.inner = untag_ptr(this_arg);
51970         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51972         this_arg_conv.is_owned = false;
51973         InitFeatures_set_basic_mpp_required(&this_arg_conv);
51974 }
51975
51976 jboolean  CS_LDK_InitFeatures_supports_basic_mpp(int64_t this_arg) {
51977         LDKInitFeatures this_arg_conv;
51978         this_arg_conv.inner = untag_ptr(this_arg);
51979         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51981         this_arg_conv.is_owned = false;
51982         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
51983         return ret_conv;
51984 }
51985
51986 void  CS_LDK_NodeFeatures_set_basic_mpp_optional(int64_t this_arg) {
51987         LDKNodeFeatures this_arg_conv;
51988         this_arg_conv.inner = untag_ptr(this_arg);
51989         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51991         this_arg_conv.is_owned = false;
51992         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
51993 }
51994
51995 void  CS_LDK_NodeFeatures_set_basic_mpp_required(int64_t this_arg) {
51996         LDKNodeFeatures this_arg_conv;
51997         this_arg_conv.inner = untag_ptr(this_arg);
51998         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52000         this_arg_conv.is_owned = false;
52001         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
52002 }
52003
52004 jboolean  CS_LDK_NodeFeatures_supports_basic_mpp(int64_t this_arg) {
52005         LDKNodeFeatures this_arg_conv;
52006         this_arg_conv.inner = untag_ptr(this_arg);
52007         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52009         this_arg_conv.is_owned = false;
52010         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
52011         return ret_conv;
52012 }
52013
52014 void  CS_LDK_Bolt11InvoiceFeatures_set_basic_mpp_optional(int64_t this_arg) {
52015         LDKBolt11InvoiceFeatures this_arg_conv;
52016         this_arg_conv.inner = untag_ptr(this_arg);
52017         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52019         this_arg_conv.is_owned = false;
52020         Bolt11InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
52021 }
52022
52023 void  CS_LDK_Bolt11InvoiceFeatures_set_basic_mpp_required(int64_t this_arg) {
52024         LDKBolt11InvoiceFeatures this_arg_conv;
52025         this_arg_conv.inner = untag_ptr(this_arg);
52026         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52028         this_arg_conv.is_owned = false;
52029         Bolt11InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
52030 }
52031
52032 jboolean  CS_LDK_Bolt11InvoiceFeatures_supports_basic_mpp(int64_t this_arg) {
52033         LDKBolt11InvoiceFeatures this_arg_conv;
52034         this_arg_conv.inner = untag_ptr(this_arg);
52035         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52037         this_arg_conv.is_owned = false;
52038         jboolean ret_conv = Bolt11InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
52039         return ret_conv;
52040 }
52041
52042 void  CS_LDK_Bolt12InvoiceFeatures_set_basic_mpp_optional(int64_t this_arg) {
52043         LDKBolt12InvoiceFeatures this_arg_conv;
52044         this_arg_conv.inner = untag_ptr(this_arg);
52045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52047         this_arg_conv.is_owned = false;
52048         Bolt12InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
52049 }
52050
52051 void  CS_LDK_Bolt12InvoiceFeatures_set_basic_mpp_required(int64_t this_arg) {
52052         LDKBolt12InvoiceFeatures this_arg_conv;
52053         this_arg_conv.inner = untag_ptr(this_arg);
52054         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52056         this_arg_conv.is_owned = false;
52057         Bolt12InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
52058 }
52059
52060 jboolean  CS_LDK_Bolt12InvoiceFeatures_supports_basic_mpp(int64_t this_arg) {
52061         LDKBolt12InvoiceFeatures this_arg_conv;
52062         this_arg_conv.inner = untag_ptr(this_arg);
52063         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52065         this_arg_conv.is_owned = false;
52066         jboolean ret_conv = Bolt12InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
52067         return ret_conv;
52068 }
52069
52070 jboolean  CS_LDK_InitFeatures_requires_basic_mpp(int64_t this_arg) {
52071         LDKInitFeatures this_arg_conv;
52072         this_arg_conv.inner = untag_ptr(this_arg);
52073         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52075         this_arg_conv.is_owned = false;
52076         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
52077         return ret_conv;
52078 }
52079
52080 jboolean  CS_LDK_NodeFeatures_requires_basic_mpp(int64_t this_arg) {
52081         LDKNodeFeatures this_arg_conv;
52082         this_arg_conv.inner = untag_ptr(this_arg);
52083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52085         this_arg_conv.is_owned = false;
52086         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
52087         return ret_conv;
52088 }
52089
52090 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_basic_mpp(int64_t this_arg) {
52091         LDKBolt11InvoiceFeatures this_arg_conv;
52092         this_arg_conv.inner = untag_ptr(this_arg);
52093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52095         this_arg_conv.is_owned = false;
52096         jboolean ret_conv = Bolt11InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
52097         return ret_conv;
52098 }
52099
52100 jboolean  CS_LDK_Bolt12InvoiceFeatures_requires_basic_mpp(int64_t this_arg) {
52101         LDKBolt12InvoiceFeatures this_arg_conv;
52102         this_arg_conv.inner = untag_ptr(this_arg);
52103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52105         this_arg_conv.is_owned = false;
52106         jboolean ret_conv = Bolt12InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
52107         return ret_conv;
52108 }
52109
52110 void  CS_LDK_InitFeatures_set_wumbo_optional(int64_t this_arg) {
52111         LDKInitFeatures this_arg_conv;
52112         this_arg_conv.inner = untag_ptr(this_arg);
52113         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52115         this_arg_conv.is_owned = false;
52116         InitFeatures_set_wumbo_optional(&this_arg_conv);
52117 }
52118
52119 void  CS_LDK_InitFeatures_set_wumbo_required(int64_t this_arg) {
52120         LDKInitFeatures this_arg_conv;
52121         this_arg_conv.inner = untag_ptr(this_arg);
52122         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52124         this_arg_conv.is_owned = false;
52125         InitFeatures_set_wumbo_required(&this_arg_conv);
52126 }
52127
52128 jboolean  CS_LDK_InitFeatures_supports_wumbo(int64_t this_arg) {
52129         LDKInitFeatures this_arg_conv;
52130         this_arg_conv.inner = untag_ptr(this_arg);
52131         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52133         this_arg_conv.is_owned = false;
52134         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
52135         return ret_conv;
52136 }
52137
52138 void  CS_LDK_NodeFeatures_set_wumbo_optional(int64_t this_arg) {
52139         LDKNodeFeatures this_arg_conv;
52140         this_arg_conv.inner = untag_ptr(this_arg);
52141         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52143         this_arg_conv.is_owned = false;
52144         NodeFeatures_set_wumbo_optional(&this_arg_conv);
52145 }
52146
52147 void  CS_LDK_NodeFeatures_set_wumbo_required(int64_t this_arg) {
52148         LDKNodeFeatures this_arg_conv;
52149         this_arg_conv.inner = untag_ptr(this_arg);
52150         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52152         this_arg_conv.is_owned = false;
52153         NodeFeatures_set_wumbo_required(&this_arg_conv);
52154 }
52155
52156 jboolean  CS_LDK_NodeFeatures_supports_wumbo(int64_t this_arg) {
52157         LDKNodeFeatures this_arg_conv;
52158         this_arg_conv.inner = untag_ptr(this_arg);
52159         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52161         this_arg_conv.is_owned = false;
52162         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
52163         return ret_conv;
52164 }
52165
52166 jboolean  CS_LDK_InitFeatures_requires_wumbo(int64_t this_arg) {
52167         LDKInitFeatures this_arg_conv;
52168         this_arg_conv.inner = untag_ptr(this_arg);
52169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52171         this_arg_conv.is_owned = false;
52172         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
52173         return ret_conv;
52174 }
52175
52176 jboolean  CS_LDK_NodeFeatures_requires_wumbo(int64_t this_arg) {
52177         LDKNodeFeatures this_arg_conv;
52178         this_arg_conv.inner = untag_ptr(this_arg);
52179         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52181         this_arg_conv.is_owned = false;
52182         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
52183         return ret_conv;
52184 }
52185
52186 void  CS_LDK_InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(int64_t this_arg) {
52187         LDKInitFeatures this_arg_conv;
52188         this_arg_conv.inner = untag_ptr(this_arg);
52189         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52191         this_arg_conv.is_owned = false;
52192         InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(&this_arg_conv);
52193 }
52194
52195 void  CS_LDK_InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(int64_t this_arg) {
52196         LDKInitFeatures this_arg_conv;
52197         this_arg_conv.inner = untag_ptr(this_arg);
52198         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52200         this_arg_conv.is_owned = false;
52201         InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(&this_arg_conv);
52202 }
52203
52204 jboolean  CS_LDK_InitFeatures_supports_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52205         LDKInitFeatures this_arg_conv;
52206         this_arg_conv.inner = untag_ptr(this_arg);
52207         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52209         this_arg_conv.is_owned = false;
52210         jboolean ret_conv = InitFeatures_supports_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52211         return ret_conv;
52212 }
52213
52214 void  CS_LDK_NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(int64_t this_arg) {
52215         LDKNodeFeatures this_arg_conv;
52216         this_arg_conv.inner = untag_ptr(this_arg);
52217         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52219         this_arg_conv.is_owned = false;
52220         NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(&this_arg_conv);
52221 }
52222
52223 void  CS_LDK_NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(int64_t this_arg) {
52224         LDKNodeFeatures this_arg_conv;
52225         this_arg_conv.inner = untag_ptr(this_arg);
52226         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52228         this_arg_conv.is_owned = false;
52229         NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(&this_arg_conv);
52230 }
52231
52232 jboolean  CS_LDK_NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52233         LDKNodeFeatures this_arg_conv;
52234         this_arg_conv.inner = untag_ptr(this_arg);
52235         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52237         this_arg_conv.is_owned = false;
52238         jboolean ret_conv = NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52239         return ret_conv;
52240 }
52241
52242 void  CS_LDK_ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(int64_t this_arg) {
52243         LDKChannelTypeFeatures this_arg_conv;
52244         this_arg_conv.inner = untag_ptr(this_arg);
52245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52247         this_arg_conv.is_owned = false;
52248         ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(&this_arg_conv);
52249 }
52250
52251 void  CS_LDK_ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(int64_t this_arg) {
52252         LDKChannelTypeFeatures this_arg_conv;
52253         this_arg_conv.inner = untag_ptr(this_arg);
52254         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52256         this_arg_conv.is_owned = false;
52257         ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(&this_arg_conv);
52258 }
52259
52260 jboolean  CS_LDK_ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52261         LDKChannelTypeFeatures this_arg_conv;
52262         this_arg_conv.inner = untag_ptr(this_arg);
52263         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52265         this_arg_conv.is_owned = false;
52266         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52267         return ret_conv;
52268 }
52269
52270 jboolean  CS_LDK_InitFeatures_requires_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52271         LDKInitFeatures this_arg_conv;
52272         this_arg_conv.inner = untag_ptr(this_arg);
52273         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52275         this_arg_conv.is_owned = false;
52276         jboolean ret_conv = InitFeatures_requires_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52277         return ret_conv;
52278 }
52279
52280 jboolean  CS_LDK_NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52281         LDKNodeFeatures this_arg_conv;
52282         this_arg_conv.inner = untag_ptr(this_arg);
52283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52285         this_arg_conv.is_owned = false;
52286         jboolean ret_conv = NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52287         return ret_conv;
52288 }
52289
52290 jboolean  CS_LDK_ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52291         LDKChannelTypeFeatures this_arg_conv;
52292         this_arg_conv.inner = untag_ptr(this_arg);
52293         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52295         this_arg_conv.is_owned = false;
52296         jboolean ret_conv = ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52297         return ret_conv;
52298 }
52299
52300 void  CS_LDK_InitFeatures_set_anchors_zero_fee_htlc_tx_optional(int64_t this_arg) {
52301         LDKInitFeatures this_arg_conv;
52302         this_arg_conv.inner = untag_ptr(this_arg);
52303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52305         this_arg_conv.is_owned = false;
52306         InitFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
52307 }
52308
52309 void  CS_LDK_InitFeatures_set_anchors_zero_fee_htlc_tx_required(int64_t this_arg) {
52310         LDKInitFeatures this_arg_conv;
52311         this_arg_conv.inner = untag_ptr(this_arg);
52312         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52314         this_arg_conv.is_owned = false;
52315         InitFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
52316 }
52317
52318 jboolean  CS_LDK_InitFeatures_supports_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52319         LDKInitFeatures this_arg_conv;
52320         this_arg_conv.inner = untag_ptr(this_arg);
52321         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52323         this_arg_conv.is_owned = false;
52324         jboolean ret_conv = InitFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
52325         return ret_conv;
52326 }
52327
52328 void  CS_LDK_NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(int64_t this_arg) {
52329         LDKNodeFeatures this_arg_conv;
52330         this_arg_conv.inner = untag_ptr(this_arg);
52331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52333         this_arg_conv.is_owned = false;
52334         NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
52335 }
52336
52337 void  CS_LDK_NodeFeatures_set_anchors_zero_fee_htlc_tx_required(int64_t this_arg) {
52338         LDKNodeFeatures this_arg_conv;
52339         this_arg_conv.inner = untag_ptr(this_arg);
52340         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52342         this_arg_conv.is_owned = false;
52343         NodeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
52344 }
52345
52346 jboolean  CS_LDK_NodeFeatures_supports_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52347         LDKNodeFeatures this_arg_conv;
52348         this_arg_conv.inner = untag_ptr(this_arg);
52349         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52351         this_arg_conv.is_owned = false;
52352         jboolean ret_conv = NodeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
52353         return ret_conv;
52354 }
52355
52356 void  CS_LDK_ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(int64_t this_arg) {
52357         LDKChannelTypeFeatures this_arg_conv;
52358         this_arg_conv.inner = untag_ptr(this_arg);
52359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52361         this_arg_conv.is_owned = false;
52362         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
52363 }
52364
52365 void  CS_LDK_ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(int64_t this_arg) {
52366         LDKChannelTypeFeatures this_arg_conv;
52367         this_arg_conv.inner = untag_ptr(this_arg);
52368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52370         this_arg_conv.is_owned = false;
52371         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
52372 }
52373
52374 jboolean  CS_LDK_ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52375         LDKChannelTypeFeatures this_arg_conv;
52376         this_arg_conv.inner = untag_ptr(this_arg);
52377         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52379         this_arg_conv.is_owned = false;
52380         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
52381         return ret_conv;
52382 }
52383
52384 jboolean  CS_LDK_InitFeatures_requires_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52385         LDKInitFeatures this_arg_conv;
52386         this_arg_conv.inner = untag_ptr(this_arg);
52387         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52389         this_arg_conv.is_owned = false;
52390         jboolean ret_conv = InitFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
52391         return ret_conv;
52392 }
52393
52394 jboolean  CS_LDK_NodeFeatures_requires_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52395         LDKNodeFeatures this_arg_conv;
52396         this_arg_conv.inner = untag_ptr(this_arg);
52397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52399         this_arg_conv.is_owned = false;
52400         jboolean ret_conv = NodeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
52401         return ret_conv;
52402 }
52403
52404 jboolean  CS_LDK_ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52405         LDKChannelTypeFeatures this_arg_conv;
52406         this_arg_conv.inner = untag_ptr(this_arg);
52407         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52409         this_arg_conv.is_owned = false;
52410         jboolean ret_conv = ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
52411         return ret_conv;
52412 }
52413
52414 void  CS_LDK_InitFeatures_set_shutdown_any_segwit_optional(int64_t this_arg) {
52415         LDKInitFeatures this_arg_conv;
52416         this_arg_conv.inner = untag_ptr(this_arg);
52417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52419         this_arg_conv.is_owned = false;
52420         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
52421 }
52422
52423 void  CS_LDK_InitFeatures_set_shutdown_any_segwit_required(int64_t this_arg) {
52424         LDKInitFeatures this_arg_conv;
52425         this_arg_conv.inner = untag_ptr(this_arg);
52426         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52428         this_arg_conv.is_owned = false;
52429         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
52430 }
52431
52432 jboolean  CS_LDK_InitFeatures_supports_shutdown_anysegwit(int64_t this_arg) {
52433         LDKInitFeatures this_arg_conv;
52434         this_arg_conv.inner = untag_ptr(this_arg);
52435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52437         this_arg_conv.is_owned = false;
52438         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
52439         return ret_conv;
52440 }
52441
52442 void  CS_LDK_NodeFeatures_set_shutdown_any_segwit_optional(int64_t this_arg) {
52443         LDKNodeFeatures this_arg_conv;
52444         this_arg_conv.inner = untag_ptr(this_arg);
52445         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52447         this_arg_conv.is_owned = false;
52448         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
52449 }
52450
52451 void  CS_LDK_NodeFeatures_set_shutdown_any_segwit_required(int64_t this_arg) {
52452         LDKNodeFeatures this_arg_conv;
52453         this_arg_conv.inner = untag_ptr(this_arg);
52454         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52456         this_arg_conv.is_owned = false;
52457         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
52458 }
52459
52460 jboolean  CS_LDK_NodeFeatures_supports_shutdown_anysegwit(int64_t this_arg) {
52461         LDKNodeFeatures this_arg_conv;
52462         this_arg_conv.inner = untag_ptr(this_arg);
52463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52465         this_arg_conv.is_owned = false;
52466         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
52467         return ret_conv;
52468 }
52469
52470 jboolean  CS_LDK_InitFeatures_requires_shutdown_anysegwit(int64_t this_arg) {
52471         LDKInitFeatures this_arg_conv;
52472         this_arg_conv.inner = untag_ptr(this_arg);
52473         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52475         this_arg_conv.is_owned = false;
52476         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
52477         return ret_conv;
52478 }
52479
52480 jboolean  CS_LDK_NodeFeatures_requires_shutdown_anysegwit(int64_t this_arg) {
52481         LDKNodeFeatures this_arg_conv;
52482         this_arg_conv.inner = untag_ptr(this_arg);
52483         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52485         this_arg_conv.is_owned = false;
52486         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
52487         return ret_conv;
52488 }
52489
52490 void  CS_LDK_InitFeatures_set_taproot_optional(int64_t this_arg) {
52491         LDKInitFeatures this_arg_conv;
52492         this_arg_conv.inner = untag_ptr(this_arg);
52493         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52495         this_arg_conv.is_owned = false;
52496         InitFeatures_set_taproot_optional(&this_arg_conv);
52497 }
52498
52499 void  CS_LDK_InitFeatures_set_taproot_required(int64_t this_arg) {
52500         LDKInitFeatures this_arg_conv;
52501         this_arg_conv.inner = untag_ptr(this_arg);
52502         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52504         this_arg_conv.is_owned = false;
52505         InitFeatures_set_taproot_required(&this_arg_conv);
52506 }
52507
52508 jboolean  CS_LDK_InitFeatures_supports_taproot(int64_t this_arg) {
52509         LDKInitFeatures this_arg_conv;
52510         this_arg_conv.inner = untag_ptr(this_arg);
52511         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52513         this_arg_conv.is_owned = false;
52514         jboolean ret_conv = InitFeatures_supports_taproot(&this_arg_conv);
52515         return ret_conv;
52516 }
52517
52518 void  CS_LDK_NodeFeatures_set_taproot_optional(int64_t this_arg) {
52519         LDKNodeFeatures this_arg_conv;
52520         this_arg_conv.inner = untag_ptr(this_arg);
52521         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52523         this_arg_conv.is_owned = false;
52524         NodeFeatures_set_taproot_optional(&this_arg_conv);
52525 }
52526
52527 void  CS_LDK_NodeFeatures_set_taproot_required(int64_t this_arg) {
52528         LDKNodeFeatures this_arg_conv;
52529         this_arg_conv.inner = untag_ptr(this_arg);
52530         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52532         this_arg_conv.is_owned = false;
52533         NodeFeatures_set_taproot_required(&this_arg_conv);
52534 }
52535
52536 jboolean  CS_LDK_NodeFeatures_supports_taproot(int64_t this_arg) {
52537         LDKNodeFeatures this_arg_conv;
52538         this_arg_conv.inner = untag_ptr(this_arg);
52539         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52541         this_arg_conv.is_owned = false;
52542         jboolean ret_conv = NodeFeatures_supports_taproot(&this_arg_conv);
52543         return ret_conv;
52544 }
52545
52546 void  CS_LDK_ChannelTypeFeatures_set_taproot_optional(int64_t this_arg) {
52547         LDKChannelTypeFeatures this_arg_conv;
52548         this_arg_conv.inner = untag_ptr(this_arg);
52549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52551         this_arg_conv.is_owned = false;
52552         ChannelTypeFeatures_set_taproot_optional(&this_arg_conv);
52553 }
52554
52555 void  CS_LDK_ChannelTypeFeatures_set_taproot_required(int64_t this_arg) {
52556         LDKChannelTypeFeatures this_arg_conv;
52557         this_arg_conv.inner = untag_ptr(this_arg);
52558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52560         this_arg_conv.is_owned = false;
52561         ChannelTypeFeatures_set_taproot_required(&this_arg_conv);
52562 }
52563
52564 jboolean  CS_LDK_ChannelTypeFeatures_supports_taproot(int64_t this_arg) {
52565         LDKChannelTypeFeatures this_arg_conv;
52566         this_arg_conv.inner = untag_ptr(this_arg);
52567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52569         this_arg_conv.is_owned = false;
52570         jboolean ret_conv = ChannelTypeFeatures_supports_taproot(&this_arg_conv);
52571         return ret_conv;
52572 }
52573
52574 jboolean  CS_LDK_InitFeatures_requires_taproot(int64_t this_arg) {
52575         LDKInitFeatures this_arg_conv;
52576         this_arg_conv.inner = untag_ptr(this_arg);
52577         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52579         this_arg_conv.is_owned = false;
52580         jboolean ret_conv = InitFeatures_requires_taproot(&this_arg_conv);
52581         return ret_conv;
52582 }
52583
52584 jboolean  CS_LDK_NodeFeatures_requires_taproot(int64_t this_arg) {
52585         LDKNodeFeatures this_arg_conv;
52586         this_arg_conv.inner = untag_ptr(this_arg);
52587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52589         this_arg_conv.is_owned = false;
52590         jboolean ret_conv = NodeFeatures_requires_taproot(&this_arg_conv);
52591         return ret_conv;
52592 }
52593
52594 jboolean  CS_LDK_ChannelTypeFeatures_requires_taproot(int64_t this_arg) {
52595         LDKChannelTypeFeatures this_arg_conv;
52596         this_arg_conv.inner = untag_ptr(this_arg);
52597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52599         this_arg_conv.is_owned = false;
52600         jboolean ret_conv = ChannelTypeFeatures_requires_taproot(&this_arg_conv);
52601         return ret_conv;
52602 }
52603
52604 void  CS_LDK_InitFeatures_set_onion_messages_optional(int64_t this_arg) {
52605         LDKInitFeatures this_arg_conv;
52606         this_arg_conv.inner = untag_ptr(this_arg);
52607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52609         this_arg_conv.is_owned = false;
52610         InitFeatures_set_onion_messages_optional(&this_arg_conv);
52611 }
52612
52613 void  CS_LDK_InitFeatures_set_onion_messages_required(int64_t this_arg) {
52614         LDKInitFeatures this_arg_conv;
52615         this_arg_conv.inner = untag_ptr(this_arg);
52616         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52618         this_arg_conv.is_owned = false;
52619         InitFeatures_set_onion_messages_required(&this_arg_conv);
52620 }
52621
52622 jboolean  CS_LDK_InitFeatures_supports_onion_messages(int64_t this_arg) {
52623         LDKInitFeatures this_arg_conv;
52624         this_arg_conv.inner = untag_ptr(this_arg);
52625         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52627         this_arg_conv.is_owned = false;
52628         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
52629         return ret_conv;
52630 }
52631
52632 void  CS_LDK_NodeFeatures_set_onion_messages_optional(int64_t this_arg) {
52633         LDKNodeFeatures this_arg_conv;
52634         this_arg_conv.inner = untag_ptr(this_arg);
52635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52637         this_arg_conv.is_owned = false;
52638         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
52639 }
52640
52641 void  CS_LDK_NodeFeatures_set_onion_messages_required(int64_t this_arg) {
52642         LDKNodeFeatures this_arg_conv;
52643         this_arg_conv.inner = untag_ptr(this_arg);
52644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52646         this_arg_conv.is_owned = false;
52647         NodeFeatures_set_onion_messages_required(&this_arg_conv);
52648 }
52649
52650 jboolean  CS_LDK_NodeFeatures_supports_onion_messages(int64_t this_arg) {
52651         LDKNodeFeatures this_arg_conv;
52652         this_arg_conv.inner = untag_ptr(this_arg);
52653         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52655         this_arg_conv.is_owned = false;
52656         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
52657         return ret_conv;
52658 }
52659
52660 jboolean  CS_LDK_InitFeatures_requires_onion_messages(int64_t this_arg) {
52661         LDKInitFeatures this_arg_conv;
52662         this_arg_conv.inner = untag_ptr(this_arg);
52663         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52665         this_arg_conv.is_owned = false;
52666         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
52667         return ret_conv;
52668 }
52669
52670 jboolean  CS_LDK_NodeFeatures_requires_onion_messages(int64_t this_arg) {
52671         LDKNodeFeatures this_arg_conv;
52672         this_arg_conv.inner = untag_ptr(this_arg);
52673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52675         this_arg_conv.is_owned = false;
52676         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
52677         return ret_conv;
52678 }
52679
52680 void  CS_LDK_InitFeatures_set_channel_type_optional(int64_t this_arg) {
52681         LDKInitFeatures this_arg_conv;
52682         this_arg_conv.inner = untag_ptr(this_arg);
52683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52685         this_arg_conv.is_owned = false;
52686         InitFeatures_set_channel_type_optional(&this_arg_conv);
52687 }
52688
52689 void  CS_LDK_InitFeatures_set_channel_type_required(int64_t this_arg) {
52690         LDKInitFeatures this_arg_conv;
52691         this_arg_conv.inner = untag_ptr(this_arg);
52692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52694         this_arg_conv.is_owned = false;
52695         InitFeatures_set_channel_type_required(&this_arg_conv);
52696 }
52697
52698 jboolean  CS_LDK_InitFeatures_supports_channel_type(int64_t this_arg) {
52699         LDKInitFeatures this_arg_conv;
52700         this_arg_conv.inner = untag_ptr(this_arg);
52701         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52703         this_arg_conv.is_owned = false;
52704         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
52705         return ret_conv;
52706 }
52707
52708 void  CS_LDK_NodeFeatures_set_channel_type_optional(int64_t this_arg) {
52709         LDKNodeFeatures this_arg_conv;
52710         this_arg_conv.inner = untag_ptr(this_arg);
52711         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52713         this_arg_conv.is_owned = false;
52714         NodeFeatures_set_channel_type_optional(&this_arg_conv);
52715 }
52716
52717 void  CS_LDK_NodeFeatures_set_channel_type_required(int64_t this_arg) {
52718         LDKNodeFeatures this_arg_conv;
52719         this_arg_conv.inner = untag_ptr(this_arg);
52720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52722         this_arg_conv.is_owned = false;
52723         NodeFeatures_set_channel_type_required(&this_arg_conv);
52724 }
52725
52726 jboolean  CS_LDK_NodeFeatures_supports_channel_type(int64_t this_arg) {
52727         LDKNodeFeatures this_arg_conv;
52728         this_arg_conv.inner = untag_ptr(this_arg);
52729         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52731         this_arg_conv.is_owned = false;
52732         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
52733         return ret_conv;
52734 }
52735
52736 jboolean  CS_LDK_InitFeatures_requires_channel_type(int64_t this_arg) {
52737         LDKInitFeatures this_arg_conv;
52738         this_arg_conv.inner = untag_ptr(this_arg);
52739         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52741         this_arg_conv.is_owned = false;
52742         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
52743         return ret_conv;
52744 }
52745
52746 jboolean  CS_LDK_NodeFeatures_requires_channel_type(int64_t this_arg) {
52747         LDKNodeFeatures this_arg_conv;
52748         this_arg_conv.inner = untag_ptr(this_arg);
52749         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52751         this_arg_conv.is_owned = false;
52752         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
52753         return ret_conv;
52754 }
52755
52756 void  CS_LDK_InitFeatures_set_scid_privacy_optional(int64_t this_arg) {
52757         LDKInitFeatures this_arg_conv;
52758         this_arg_conv.inner = untag_ptr(this_arg);
52759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52761         this_arg_conv.is_owned = false;
52762         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
52763 }
52764
52765 void  CS_LDK_InitFeatures_set_scid_privacy_required(int64_t this_arg) {
52766         LDKInitFeatures this_arg_conv;
52767         this_arg_conv.inner = untag_ptr(this_arg);
52768         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52770         this_arg_conv.is_owned = false;
52771         InitFeatures_set_scid_privacy_required(&this_arg_conv);
52772 }
52773
52774 jboolean  CS_LDK_InitFeatures_supports_scid_privacy(int64_t this_arg) {
52775         LDKInitFeatures this_arg_conv;
52776         this_arg_conv.inner = untag_ptr(this_arg);
52777         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52779         this_arg_conv.is_owned = false;
52780         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
52781         return ret_conv;
52782 }
52783
52784 void  CS_LDK_NodeFeatures_set_scid_privacy_optional(int64_t this_arg) {
52785         LDKNodeFeatures this_arg_conv;
52786         this_arg_conv.inner = untag_ptr(this_arg);
52787         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52789         this_arg_conv.is_owned = false;
52790         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
52791 }
52792
52793 void  CS_LDK_NodeFeatures_set_scid_privacy_required(int64_t this_arg) {
52794         LDKNodeFeatures this_arg_conv;
52795         this_arg_conv.inner = untag_ptr(this_arg);
52796         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52798         this_arg_conv.is_owned = false;
52799         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
52800 }
52801
52802 jboolean  CS_LDK_NodeFeatures_supports_scid_privacy(int64_t this_arg) {
52803         LDKNodeFeatures this_arg_conv;
52804         this_arg_conv.inner = untag_ptr(this_arg);
52805         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52807         this_arg_conv.is_owned = false;
52808         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
52809         return ret_conv;
52810 }
52811
52812 void  CS_LDK_ChannelTypeFeatures_set_scid_privacy_optional(int64_t this_arg) {
52813         LDKChannelTypeFeatures this_arg_conv;
52814         this_arg_conv.inner = untag_ptr(this_arg);
52815         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52817         this_arg_conv.is_owned = false;
52818         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
52819 }
52820
52821 void  CS_LDK_ChannelTypeFeatures_set_scid_privacy_required(int64_t this_arg) {
52822         LDKChannelTypeFeatures this_arg_conv;
52823         this_arg_conv.inner = untag_ptr(this_arg);
52824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52826         this_arg_conv.is_owned = false;
52827         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
52828 }
52829
52830 jboolean  CS_LDK_ChannelTypeFeatures_supports_scid_privacy(int64_t this_arg) {
52831         LDKChannelTypeFeatures this_arg_conv;
52832         this_arg_conv.inner = untag_ptr(this_arg);
52833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52835         this_arg_conv.is_owned = false;
52836         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
52837         return ret_conv;
52838 }
52839
52840 jboolean  CS_LDK_InitFeatures_requires_scid_privacy(int64_t this_arg) {
52841         LDKInitFeatures this_arg_conv;
52842         this_arg_conv.inner = untag_ptr(this_arg);
52843         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52845         this_arg_conv.is_owned = false;
52846         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
52847         return ret_conv;
52848 }
52849
52850 jboolean  CS_LDK_NodeFeatures_requires_scid_privacy(int64_t this_arg) {
52851         LDKNodeFeatures this_arg_conv;
52852         this_arg_conv.inner = untag_ptr(this_arg);
52853         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52855         this_arg_conv.is_owned = false;
52856         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
52857         return ret_conv;
52858 }
52859
52860 jboolean  CS_LDK_ChannelTypeFeatures_requires_scid_privacy(int64_t this_arg) {
52861         LDKChannelTypeFeatures this_arg_conv;
52862         this_arg_conv.inner = untag_ptr(this_arg);
52863         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52865         this_arg_conv.is_owned = false;
52866         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
52867         return ret_conv;
52868 }
52869
52870 void  CS_LDK_Bolt11InvoiceFeatures_set_payment_metadata_optional(int64_t this_arg) {
52871         LDKBolt11InvoiceFeatures this_arg_conv;
52872         this_arg_conv.inner = untag_ptr(this_arg);
52873         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52875         this_arg_conv.is_owned = false;
52876         Bolt11InvoiceFeatures_set_payment_metadata_optional(&this_arg_conv);
52877 }
52878
52879 void  CS_LDK_Bolt11InvoiceFeatures_set_payment_metadata_required(int64_t this_arg) {
52880         LDKBolt11InvoiceFeatures this_arg_conv;
52881         this_arg_conv.inner = untag_ptr(this_arg);
52882         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52884         this_arg_conv.is_owned = false;
52885         Bolt11InvoiceFeatures_set_payment_metadata_required(&this_arg_conv);
52886 }
52887
52888 jboolean  CS_LDK_Bolt11InvoiceFeatures_supports_payment_metadata(int64_t this_arg) {
52889         LDKBolt11InvoiceFeatures this_arg_conv;
52890         this_arg_conv.inner = untag_ptr(this_arg);
52891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52893         this_arg_conv.is_owned = false;
52894         jboolean ret_conv = Bolt11InvoiceFeatures_supports_payment_metadata(&this_arg_conv);
52895         return ret_conv;
52896 }
52897
52898 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_payment_metadata(int64_t this_arg) {
52899         LDKBolt11InvoiceFeatures this_arg_conv;
52900         this_arg_conv.inner = untag_ptr(this_arg);
52901         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52903         this_arg_conv.is_owned = false;
52904         jboolean ret_conv = Bolt11InvoiceFeatures_requires_payment_metadata(&this_arg_conv);
52905         return ret_conv;
52906 }
52907
52908 void  CS_LDK_InitFeatures_set_zero_conf_optional(int64_t this_arg) {
52909         LDKInitFeatures this_arg_conv;
52910         this_arg_conv.inner = untag_ptr(this_arg);
52911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52913         this_arg_conv.is_owned = false;
52914         InitFeatures_set_zero_conf_optional(&this_arg_conv);
52915 }
52916
52917 void  CS_LDK_InitFeatures_set_zero_conf_required(int64_t this_arg) {
52918         LDKInitFeatures this_arg_conv;
52919         this_arg_conv.inner = untag_ptr(this_arg);
52920         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52922         this_arg_conv.is_owned = false;
52923         InitFeatures_set_zero_conf_required(&this_arg_conv);
52924 }
52925
52926 jboolean  CS_LDK_InitFeatures_supports_zero_conf(int64_t this_arg) {
52927         LDKInitFeatures this_arg_conv;
52928         this_arg_conv.inner = untag_ptr(this_arg);
52929         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52931         this_arg_conv.is_owned = false;
52932         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
52933         return ret_conv;
52934 }
52935
52936 void  CS_LDK_NodeFeatures_set_zero_conf_optional(int64_t this_arg) {
52937         LDKNodeFeatures this_arg_conv;
52938         this_arg_conv.inner = untag_ptr(this_arg);
52939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52941         this_arg_conv.is_owned = false;
52942         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
52943 }
52944
52945 void  CS_LDK_NodeFeatures_set_zero_conf_required(int64_t this_arg) {
52946         LDKNodeFeatures this_arg_conv;
52947         this_arg_conv.inner = untag_ptr(this_arg);
52948         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52950         this_arg_conv.is_owned = false;
52951         NodeFeatures_set_zero_conf_required(&this_arg_conv);
52952 }
52953
52954 jboolean  CS_LDK_NodeFeatures_supports_zero_conf(int64_t this_arg) {
52955         LDKNodeFeatures this_arg_conv;
52956         this_arg_conv.inner = untag_ptr(this_arg);
52957         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52959         this_arg_conv.is_owned = false;
52960         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
52961         return ret_conv;
52962 }
52963
52964 void  CS_LDK_ChannelTypeFeatures_set_zero_conf_optional(int64_t this_arg) {
52965         LDKChannelTypeFeatures this_arg_conv;
52966         this_arg_conv.inner = untag_ptr(this_arg);
52967         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52969         this_arg_conv.is_owned = false;
52970         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
52971 }
52972
52973 void  CS_LDK_ChannelTypeFeatures_set_zero_conf_required(int64_t this_arg) {
52974         LDKChannelTypeFeatures this_arg_conv;
52975         this_arg_conv.inner = untag_ptr(this_arg);
52976         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52978         this_arg_conv.is_owned = false;
52979         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
52980 }
52981
52982 jboolean  CS_LDK_ChannelTypeFeatures_supports_zero_conf(int64_t this_arg) {
52983         LDKChannelTypeFeatures this_arg_conv;
52984         this_arg_conv.inner = untag_ptr(this_arg);
52985         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52987         this_arg_conv.is_owned = false;
52988         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
52989         return ret_conv;
52990 }
52991
52992 jboolean  CS_LDK_InitFeatures_requires_zero_conf(int64_t this_arg) {
52993         LDKInitFeatures this_arg_conv;
52994         this_arg_conv.inner = untag_ptr(this_arg);
52995         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52997         this_arg_conv.is_owned = false;
52998         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
52999         return ret_conv;
53000 }
53001
53002 jboolean  CS_LDK_NodeFeatures_requires_zero_conf(int64_t this_arg) {
53003         LDKNodeFeatures this_arg_conv;
53004         this_arg_conv.inner = untag_ptr(this_arg);
53005         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53007         this_arg_conv.is_owned = false;
53008         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
53009         return ret_conv;
53010 }
53011
53012 jboolean  CS_LDK_ChannelTypeFeatures_requires_zero_conf(int64_t this_arg) {
53013         LDKChannelTypeFeatures this_arg_conv;
53014         this_arg_conv.inner = untag_ptr(this_arg);
53015         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53017         this_arg_conv.is_owned = false;
53018         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
53019         return ret_conv;
53020 }
53021
53022 void  CS_LDK_NodeFeatures_set_keysend_optional(int64_t this_arg) {
53023         LDKNodeFeatures this_arg_conv;
53024         this_arg_conv.inner = untag_ptr(this_arg);
53025         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53027         this_arg_conv.is_owned = false;
53028         NodeFeatures_set_keysend_optional(&this_arg_conv);
53029 }
53030
53031 void  CS_LDK_NodeFeatures_set_keysend_required(int64_t this_arg) {
53032         LDKNodeFeatures this_arg_conv;
53033         this_arg_conv.inner = untag_ptr(this_arg);
53034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53036         this_arg_conv.is_owned = false;
53037         NodeFeatures_set_keysend_required(&this_arg_conv);
53038 }
53039
53040 jboolean  CS_LDK_NodeFeatures_supports_keysend(int64_t this_arg) {
53041         LDKNodeFeatures this_arg_conv;
53042         this_arg_conv.inner = untag_ptr(this_arg);
53043         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53045         this_arg_conv.is_owned = false;
53046         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
53047         return ret_conv;
53048 }
53049
53050 jboolean  CS_LDK_NodeFeatures_requires_keysend(int64_t this_arg) {
53051         LDKNodeFeatures this_arg_conv;
53052         this_arg_conv.inner = untag_ptr(this_arg);
53053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53055         this_arg_conv.is_owned = false;
53056         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
53057         return ret_conv;
53058 }
53059
53060 void  CS_LDK_ShutdownScript_free(int64_t this_obj) {
53061         LDKShutdownScript this_obj_conv;
53062         this_obj_conv.inner = untag_ptr(this_obj);
53063         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53065         ShutdownScript_free(this_obj_conv);
53066 }
53067
53068 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
53069         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
53070         int64_t ret_ref = 0;
53071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53072         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53073         return ret_ref;
53074 }
53075 int64_t  CS_LDK_ShutdownScript_clone_ptr(int64_t arg) {
53076         LDKShutdownScript arg_conv;
53077         arg_conv.inner = untag_ptr(arg);
53078         arg_conv.is_owned = ptr_is_owned(arg);
53079         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53080         arg_conv.is_owned = false;
53081         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
53082         return ret_conv;
53083 }
53084
53085 int64_t  CS_LDK_ShutdownScript_clone(int64_t orig) {
53086         LDKShutdownScript orig_conv;
53087         orig_conv.inner = untag_ptr(orig);
53088         orig_conv.is_owned = ptr_is_owned(orig);
53089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53090         orig_conv.is_owned = false;
53091         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
53092         int64_t ret_ref = 0;
53093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53095         return ret_ref;
53096 }
53097
53098 jboolean  CS_LDK_ShutdownScript_eq(int64_t a, int64_t b) {
53099         LDKShutdownScript a_conv;
53100         a_conv.inner = untag_ptr(a);
53101         a_conv.is_owned = ptr_is_owned(a);
53102         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53103         a_conv.is_owned = false;
53104         LDKShutdownScript b_conv;
53105         b_conv.inner = untag_ptr(b);
53106         b_conv.is_owned = ptr_is_owned(b);
53107         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53108         b_conv.is_owned = false;
53109         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
53110         return ret_conv;
53111 }
53112
53113 void  CS_LDK_InvalidShutdownScript_free(int64_t this_obj) {
53114         LDKInvalidShutdownScript this_obj_conv;
53115         this_obj_conv.inner = untag_ptr(this_obj);
53116         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53118         InvalidShutdownScript_free(this_obj_conv);
53119 }
53120
53121 int8_tArray  CS_LDK_InvalidShutdownScript_get_script(int64_t this_ptr) {
53122         LDKInvalidShutdownScript this_ptr_conv;
53123         this_ptr_conv.inner = untag_ptr(this_ptr);
53124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53126         this_ptr_conv.is_owned = false;
53127         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
53128         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53129         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53130         return ret_arr;
53131 }
53132
53133 void  CS_LDK_InvalidShutdownScript_set_script(int64_t this_ptr, int8_tArray val) {
53134         LDKInvalidShutdownScript this_ptr_conv;
53135         this_ptr_conv.inner = untag_ptr(this_ptr);
53136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53138         this_ptr_conv.is_owned = false;
53139         LDKCVec_u8Z val_ref;
53140         val_ref.datalen = val->arr_len;
53141         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
53142         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
53143         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
53144 }
53145
53146 int64_t  CS_LDK_InvalidShutdownScript_new(int8_tArray script_arg) {
53147         LDKCVec_u8Z script_arg_ref;
53148         script_arg_ref.datalen = script_arg->arr_len;
53149         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
53150         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
53151         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
53152         int64_t ret_ref = 0;
53153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53155         return ret_ref;
53156 }
53157
53158 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
53159         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
53160         int64_t ret_ref = 0;
53161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53162         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53163         return ret_ref;
53164 }
53165 int64_t  CS_LDK_InvalidShutdownScript_clone_ptr(int64_t arg) {
53166         LDKInvalidShutdownScript arg_conv;
53167         arg_conv.inner = untag_ptr(arg);
53168         arg_conv.is_owned = ptr_is_owned(arg);
53169         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53170         arg_conv.is_owned = false;
53171         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
53172         return ret_conv;
53173 }
53174
53175 int64_t  CS_LDK_InvalidShutdownScript_clone(int64_t orig) {
53176         LDKInvalidShutdownScript orig_conv;
53177         orig_conv.inner = untag_ptr(orig);
53178         orig_conv.is_owned = ptr_is_owned(orig);
53179         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53180         orig_conv.is_owned = false;
53181         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
53182         int64_t ret_ref = 0;
53183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53184         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53185         return ret_ref;
53186 }
53187
53188 int8_tArray  CS_LDK_ShutdownScript_write(int64_t obj) {
53189         LDKShutdownScript obj_conv;
53190         obj_conv.inner = untag_ptr(obj);
53191         obj_conv.is_owned = ptr_is_owned(obj);
53192         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53193         obj_conv.is_owned = false;
53194         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
53195         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53196         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53197         CVec_u8Z_free(ret_var);
53198         return ret_arr;
53199 }
53200
53201 int64_t  CS_LDK_ShutdownScript_read(int8_tArray ser) {
53202         LDKu8slice ser_ref;
53203         ser_ref.datalen = ser->arr_len;
53204         ser_ref.data = ser->elems;
53205         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
53206         *ret_conv = ShutdownScript_read(ser_ref);
53207         FREE(ser);
53208         return tag_ptr(ret_conv, true);
53209 }
53210
53211 int64_t  CS_LDK_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
53212         uint8_t pubkey_hash_arr[20];
53213         CHECK(pubkey_hash->arr_len == 20);
53214         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
53215         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
53216         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
53217         int64_t ret_ref = 0;
53218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53219         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53220         return ret_ref;
53221 }
53222
53223 int64_t  CS_LDK_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
53224         uint8_t script_hash_arr[32];
53225         CHECK(script_hash->arr_len == 32);
53226         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
53227         uint8_t (*script_hash_ref)[32] = &script_hash_arr;
53228         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
53229         int64_t ret_ref = 0;
53230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53231         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53232         return ret_ref;
53233 }
53234
53235 int64_t  CS_LDK_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
53236         
53237         LDKu8slice program_ref;
53238         program_ref.datalen = program->arr_len;
53239         program_ref.data = program->elems;
53240         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
53241         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
53242         FREE(program);
53243         return tag_ptr(ret_conv, true);
53244 }
53245
53246 int8_tArray  CS_LDK_ShutdownScript_into_inner(int64_t this_arg) {
53247         LDKShutdownScript this_arg_conv;
53248         this_arg_conv.inner = untag_ptr(this_arg);
53249         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53251         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
53252         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
53253         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53254         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53255         CVec_u8Z_free(ret_var);
53256         return ret_arr;
53257 }
53258
53259 int8_tArray  CS_LDK_ShutdownScript_as_legacy_pubkey(int64_t this_arg) {
53260         LDKShutdownScript this_arg_conv;
53261         this_arg_conv.inner = untag_ptr(this_arg);
53262         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53264         this_arg_conv.is_owned = false;
53265         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
53266         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
53267         return ret_arr;
53268 }
53269
53270 jboolean  CS_LDK_ShutdownScript_is_compatible(int64_t this_arg, int64_t features) {
53271         LDKShutdownScript this_arg_conv;
53272         this_arg_conv.inner = untag_ptr(this_arg);
53273         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53275         this_arg_conv.is_owned = false;
53276         LDKInitFeatures features_conv;
53277         features_conv.inner = untag_ptr(features);
53278         features_conv.is_owned = ptr_is_owned(features);
53279         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
53280         features_conv.is_owned = false;
53281         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
53282         return ret_conv;
53283 }
53284
53285 void  CS_LDK_Retry_free(int64_t this_ptr) {
53286         if (!ptr_is_owned(this_ptr)) return;
53287         void* this_ptr_ptr = untag_ptr(this_ptr);
53288         CHECK_ACCESS(this_ptr_ptr);
53289         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
53290         FREE(untag_ptr(this_ptr));
53291         Retry_free(this_ptr_conv);
53292 }
53293
53294 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
53295         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
53296         *ret_copy = Retry_clone(arg);
53297         int64_t ret_ref = tag_ptr(ret_copy, true);
53298         return ret_ref;
53299 }
53300 int64_t  CS_LDK_Retry_clone_ptr(int64_t arg) {
53301         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
53302         int64_t ret_conv = Retry_clone_ptr(arg_conv);
53303         return ret_conv;
53304 }
53305
53306 int64_t  CS_LDK_Retry_clone(int64_t orig) {
53307         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
53308         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
53309         *ret_copy = Retry_clone(orig_conv);
53310         int64_t ret_ref = tag_ptr(ret_copy, true);
53311         return ret_ref;
53312 }
53313
53314 int64_t  CS_LDK_Retry_attempts(int32_t a) {
53315         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
53316         *ret_copy = Retry_attempts(a);
53317         int64_t ret_ref = tag_ptr(ret_copy, true);
53318         return ret_ref;
53319 }
53320
53321 int64_t  CS_LDK_Retry_timeout(int64_t a) {
53322         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
53323         *ret_copy = Retry_timeout(a);
53324         int64_t ret_ref = tag_ptr(ret_copy, true);
53325         return ret_ref;
53326 }
53327
53328 jboolean  CS_LDK_Retry_eq(int64_t a, int64_t b) {
53329         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
53330         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
53331         jboolean ret_conv = Retry_eq(a_conv, b_conv);
53332         return ret_conv;
53333 }
53334
53335 int64_t  CS_LDK_Retry_hash(int64_t o) {
53336         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
53337         int64_t ret_conv = Retry_hash(o_conv);
53338         return ret_conv;
53339 }
53340
53341 int8_tArray  CS_LDK_Retry_write(int64_t obj) {
53342         LDKRetry* obj_conv = (LDKRetry*)untag_ptr(obj);
53343         LDKCVec_u8Z ret_var = Retry_write(obj_conv);
53344         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53345         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53346         CVec_u8Z_free(ret_var);
53347         return ret_arr;
53348 }
53349
53350 int64_t  CS_LDK_Retry_read(int8_tArray ser) {
53351         LDKu8slice ser_ref;
53352         ser_ref.datalen = ser->arr_len;
53353         ser_ref.data = ser->elems;
53354         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
53355         *ret_conv = Retry_read(ser_ref);
53356         FREE(ser);
53357         return tag_ptr(ret_conv, true);
53358 }
53359
53360 int32_t  CS_LDK_RetryableSendFailure_clone(int64_t orig) {
53361         LDKRetryableSendFailure* orig_conv = (LDKRetryableSendFailure*)untag_ptr(orig);
53362         int32_t ret_conv = LDKRetryableSendFailure_to_cs(RetryableSendFailure_clone(orig_conv));
53363         return ret_conv;
53364 }
53365
53366 int32_t  CS_LDK_RetryableSendFailure_payment_expired() {
53367         int32_t ret_conv = LDKRetryableSendFailure_to_cs(RetryableSendFailure_payment_expired());
53368         return ret_conv;
53369 }
53370
53371 int32_t  CS_LDK_RetryableSendFailure_route_not_found() {
53372         int32_t ret_conv = LDKRetryableSendFailure_to_cs(RetryableSendFailure_route_not_found());
53373         return ret_conv;
53374 }
53375
53376 int32_t  CS_LDK_RetryableSendFailure_duplicate_payment() {
53377         int32_t ret_conv = LDKRetryableSendFailure_to_cs(RetryableSendFailure_duplicate_payment());
53378         return ret_conv;
53379 }
53380
53381 jboolean  CS_LDK_RetryableSendFailure_eq(int64_t a, int64_t b) {
53382         LDKRetryableSendFailure* a_conv = (LDKRetryableSendFailure*)untag_ptr(a);
53383         LDKRetryableSendFailure* b_conv = (LDKRetryableSendFailure*)untag_ptr(b);
53384         jboolean ret_conv = RetryableSendFailure_eq(a_conv, b_conv);
53385         return ret_conv;
53386 }
53387
53388 void  CS_LDK_PaymentSendFailure_free(int64_t this_ptr) {
53389         if (!ptr_is_owned(this_ptr)) return;
53390         void* this_ptr_ptr = untag_ptr(this_ptr);
53391         CHECK_ACCESS(this_ptr_ptr);
53392         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
53393         FREE(untag_ptr(this_ptr));
53394         PaymentSendFailure_free(this_ptr_conv);
53395 }
53396
53397 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
53398         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53399         *ret_copy = PaymentSendFailure_clone(arg);
53400         int64_t ret_ref = tag_ptr(ret_copy, true);
53401         return ret_ref;
53402 }
53403 int64_t  CS_LDK_PaymentSendFailure_clone_ptr(int64_t arg) {
53404         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
53405         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
53406         return ret_conv;
53407 }
53408
53409 int64_t  CS_LDK_PaymentSendFailure_clone(int64_t orig) {
53410         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
53411         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53412         *ret_copy = PaymentSendFailure_clone(orig_conv);
53413         int64_t ret_ref = tag_ptr(ret_copy, true);
53414         return ret_ref;
53415 }
53416
53417 int64_t  CS_LDK_PaymentSendFailure_parameter_error(int64_t a) {
53418         void* a_ptr = untag_ptr(a);
53419         CHECK_ACCESS(a_ptr);
53420         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
53421         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
53422         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53423         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
53424         int64_t ret_ref = tag_ptr(ret_copy, true);
53425         return ret_ref;
53426 }
53427
53428 int64_t  CS_LDK_PaymentSendFailure_path_parameter_error(int64_tArray a) {
53429         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
53430         a_constr.datalen = a->arr_len;
53431         if (a_constr.datalen > 0)
53432                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
53433         else
53434                 a_constr.data = NULL;
53435         int64_t* a_vals = a->elems;
53436         for (size_t w = 0; w < a_constr.datalen; w++) {
53437                 int64_t a_conv_22 = a_vals[w];
53438                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
53439                 CHECK_ACCESS(a_conv_22_ptr);
53440                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
53441                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
53442                 a_constr.data[w] = a_conv_22_conv;
53443         }
53444         FREE(a);
53445         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53446         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
53447         int64_t ret_ref = tag_ptr(ret_copy, true);
53448         return ret_ref;
53449 }
53450
53451 int64_t  CS_LDK_PaymentSendFailure_all_failed_resend_safe(int64_tArray a) {
53452         LDKCVec_APIErrorZ a_constr;
53453         a_constr.datalen = a->arr_len;
53454         if (a_constr.datalen > 0)
53455                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
53456         else
53457                 a_constr.data = NULL;
53458         int64_t* a_vals = a->elems;
53459         for (size_t k = 0; k < a_constr.datalen; k++) {
53460                 int64_t a_conv_10 = a_vals[k];
53461                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
53462                 CHECK_ACCESS(a_conv_10_ptr);
53463                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
53464                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
53465                 a_constr.data[k] = a_conv_10_conv;
53466         }
53467         FREE(a);
53468         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53469         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
53470         int64_t ret_ref = tag_ptr(ret_copy, true);
53471         return ret_ref;
53472 }
53473
53474 int64_t  CS_LDK_PaymentSendFailure_duplicate_payment() {
53475         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53476         *ret_copy = PaymentSendFailure_duplicate_payment();
53477         int64_t ret_ref = tag_ptr(ret_copy, true);
53478         return ret_ref;
53479 }
53480
53481 int64_t  CS_LDK_PaymentSendFailure_partial_failure(int64_tArray results, int64_t failed_paths_retry, int8_tArray payment_id) {
53482         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
53483         results_constr.datalen = results->arr_len;
53484         if (results_constr.datalen > 0)
53485                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
53486         else
53487                 results_constr.data = NULL;
53488         int64_t* results_vals = results->elems;
53489         for (size_t w = 0; w < results_constr.datalen; w++) {
53490                 int64_t results_conv_22 = results_vals[w];
53491                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
53492                 CHECK_ACCESS(results_conv_22_ptr);
53493                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
53494                 results_constr.data[w] = results_conv_22_conv;
53495         }
53496         FREE(results);
53497         LDKRouteParameters failed_paths_retry_conv;
53498         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
53499         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
53500         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
53501         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
53502         LDKThirtyTwoBytes payment_id_ref;
53503         CHECK(payment_id->arr_len == 32);
53504         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
53505         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53506         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
53507         int64_t ret_ref = tag_ptr(ret_copy, true);
53508         return ret_ref;
53509 }
53510
53511 jboolean  CS_LDK_PaymentSendFailure_eq(int64_t a, int64_t b) {
53512         LDKPaymentSendFailure* a_conv = (LDKPaymentSendFailure*)untag_ptr(a);
53513         LDKPaymentSendFailure* b_conv = (LDKPaymentSendFailure*)untag_ptr(b);
53514         jboolean ret_conv = PaymentSendFailure_eq(a_conv, b_conv);
53515         return ret_conv;
53516 }
53517
53518 void  CS_LDK_ProbeSendFailure_free(int64_t this_ptr) {
53519         if (!ptr_is_owned(this_ptr)) return;
53520         void* this_ptr_ptr = untag_ptr(this_ptr);
53521         CHECK_ACCESS(this_ptr_ptr);
53522         LDKProbeSendFailure this_ptr_conv = *(LDKProbeSendFailure*)(this_ptr_ptr);
53523         FREE(untag_ptr(this_ptr));
53524         ProbeSendFailure_free(this_ptr_conv);
53525 }
53526
53527 static inline uint64_t ProbeSendFailure_clone_ptr(LDKProbeSendFailure *NONNULL_PTR arg) {
53528         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
53529         *ret_copy = ProbeSendFailure_clone(arg);
53530         int64_t ret_ref = tag_ptr(ret_copy, true);
53531         return ret_ref;
53532 }
53533 int64_t  CS_LDK_ProbeSendFailure_clone_ptr(int64_t arg) {
53534         LDKProbeSendFailure* arg_conv = (LDKProbeSendFailure*)untag_ptr(arg);
53535         int64_t ret_conv = ProbeSendFailure_clone_ptr(arg_conv);
53536         return ret_conv;
53537 }
53538
53539 int64_t  CS_LDK_ProbeSendFailure_clone(int64_t orig) {
53540         LDKProbeSendFailure* orig_conv = (LDKProbeSendFailure*)untag_ptr(orig);
53541         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
53542         *ret_copy = ProbeSendFailure_clone(orig_conv);
53543         int64_t ret_ref = tag_ptr(ret_copy, true);
53544         return ret_ref;
53545 }
53546
53547 int64_t  CS_LDK_ProbeSendFailure_route_not_found() {
53548         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
53549         *ret_copy = ProbeSendFailure_route_not_found();
53550         int64_t ret_ref = tag_ptr(ret_copy, true);
53551         return ret_ref;
53552 }
53553
53554 int64_t  CS_LDK_ProbeSendFailure_sending_failed(int64_t a) {
53555         void* a_ptr = untag_ptr(a);
53556         CHECK_ACCESS(a_ptr);
53557         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
53558         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
53559         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
53560         *ret_copy = ProbeSendFailure_sending_failed(a_conv);
53561         int64_t ret_ref = tag_ptr(ret_copy, true);
53562         return ret_ref;
53563 }
53564
53565 jboolean  CS_LDK_ProbeSendFailure_eq(int64_t a, int64_t b) {
53566         LDKProbeSendFailure* a_conv = (LDKProbeSendFailure*)untag_ptr(a);
53567         LDKProbeSendFailure* b_conv = (LDKProbeSendFailure*)untag_ptr(b);
53568         jboolean ret_conv = ProbeSendFailure_eq(a_conv, b_conv);
53569         return ret_conv;
53570 }
53571
53572 void  CS_LDK_RecipientOnionFields_free(int64_t this_obj) {
53573         LDKRecipientOnionFields this_obj_conv;
53574         this_obj_conv.inner = untag_ptr(this_obj);
53575         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53577         RecipientOnionFields_free(this_obj_conv);
53578 }
53579
53580 int64_t  CS_LDK_RecipientOnionFields_get_payment_secret(int64_t this_ptr) {
53581         LDKRecipientOnionFields this_ptr_conv;
53582         this_ptr_conv.inner = untag_ptr(this_ptr);
53583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53585         this_ptr_conv.is_owned = false;
53586         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
53587         *ret_copy = RecipientOnionFields_get_payment_secret(&this_ptr_conv);
53588         int64_t ret_ref = tag_ptr(ret_copy, true);
53589         return ret_ref;
53590 }
53591
53592 void  CS_LDK_RecipientOnionFields_set_payment_secret(int64_t this_ptr, int64_t val) {
53593         LDKRecipientOnionFields this_ptr_conv;
53594         this_ptr_conv.inner = untag_ptr(this_ptr);
53595         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53597         this_ptr_conv.is_owned = false;
53598         void* val_ptr = untag_ptr(val);
53599         CHECK_ACCESS(val_ptr);
53600         LDKCOption_ThirtyTwoBytesZ val_conv = *(LDKCOption_ThirtyTwoBytesZ*)(val_ptr);
53601         val_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(val));
53602         RecipientOnionFields_set_payment_secret(&this_ptr_conv, val_conv);
53603 }
53604
53605 int64_t  CS_LDK_RecipientOnionFields_get_payment_metadata(int64_t this_ptr) {
53606         LDKRecipientOnionFields this_ptr_conv;
53607         this_ptr_conv.inner = untag_ptr(this_ptr);
53608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53610         this_ptr_conv.is_owned = false;
53611         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
53612         *ret_copy = RecipientOnionFields_get_payment_metadata(&this_ptr_conv);
53613         int64_t ret_ref = tag_ptr(ret_copy, true);
53614         return ret_ref;
53615 }
53616
53617 void  CS_LDK_RecipientOnionFields_set_payment_metadata(int64_t this_ptr, int64_t val) {
53618         LDKRecipientOnionFields this_ptr_conv;
53619         this_ptr_conv.inner = untag_ptr(this_ptr);
53620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53622         this_ptr_conv.is_owned = false;
53623         void* val_ptr = untag_ptr(val);
53624         CHECK_ACCESS(val_ptr);
53625         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
53626         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
53627         RecipientOnionFields_set_payment_metadata(&this_ptr_conv, val_conv);
53628 }
53629
53630 static inline uint64_t RecipientOnionFields_clone_ptr(LDKRecipientOnionFields *NONNULL_PTR arg) {
53631         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(arg);
53632         int64_t ret_ref = 0;
53633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53634         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53635         return ret_ref;
53636 }
53637 int64_t  CS_LDK_RecipientOnionFields_clone_ptr(int64_t arg) {
53638         LDKRecipientOnionFields arg_conv;
53639         arg_conv.inner = untag_ptr(arg);
53640         arg_conv.is_owned = ptr_is_owned(arg);
53641         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53642         arg_conv.is_owned = false;
53643         int64_t ret_conv = RecipientOnionFields_clone_ptr(&arg_conv);
53644         return ret_conv;
53645 }
53646
53647 int64_t  CS_LDK_RecipientOnionFields_clone(int64_t orig) {
53648         LDKRecipientOnionFields orig_conv;
53649         orig_conv.inner = untag_ptr(orig);
53650         orig_conv.is_owned = ptr_is_owned(orig);
53651         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53652         orig_conv.is_owned = false;
53653         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(&orig_conv);
53654         int64_t ret_ref = 0;
53655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53656         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53657         return ret_ref;
53658 }
53659
53660 jboolean  CS_LDK_RecipientOnionFields_eq(int64_t a, int64_t b) {
53661         LDKRecipientOnionFields a_conv;
53662         a_conv.inner = untag_ptr(a);
53663         a_conv.is_owned = ptr_is_owned(a);
53664         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53665         a_conv.is_owned = false;
53666         LDKRecipientOnionFields b_conv;
53667         b_conv.inner = untag_ptr(b);
53668         b_conv.is_owned = ptr_is_owned(b);
53669         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53670         b_conv.is_owned = false;
53671         jboolean ret_conv = RecipientOnionFields_eq(&a_conv, &b_conv);
53672         return ret_conv;
53673 }
53674
53675 int8_tArray  CS_LDK_RecipientOnionFields_write(int64_t obj) {
53676         LDKRecipientOnionFields obj_conv;
53677         obj_conv.inner = untag_ptr(obj);
53678         obj_conv.is_owned = ptr_is_owned(obj);
53679         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53680         obj_conv.is_owned = false;
53681         LDKCVec_u8Z ret_var = RecipientOnionFields_write(&obj_conv);
53682         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53683         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53684         CVec_u8Z_free(ret_var);
53685         return ret_arr;
53686 }
53687
53688 int64_t  CS_LDK_RecipientOnionFields_read(int8_tArray ser) {
53689         LDKu8slice ser_ref;
53690         ser_ref.datalen = ser->arr_len;
53691         ser_ref.data = ser->elems;
53692         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
53693         *ret_conv = RecipientOnionFields_read(ser_ref);
53694         FREE(ser);
53695         return tag_ptr(ret_conv, true);
53696 }
53697
53698 int64_t  CS_LDK_RecipientOnionFields_secret_only(int8_tArray payment_secret) {
53699         LDKThirtyTwoBytes payment_secret_ref;
53700         CHECK(payment_secret->arr_len == 32);
53701         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
53702         LDKRecipientOnionFields ret_var = RecipientOnionFields_secret_only(payment_secret_ref);
53703         int64_t ret_ref = 0;
53704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53706         return ret_ref;
53707 }
53708
53709 int64_t  CS_LDK_RecipientOnionFields_spontaneous_empty() {
53710         LDKRecipientOnionFields ret_var = RecipientOnionFields_spontaneous_empty();
53711         int64_t ret_ref = 0;
53712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53714         return ret_ref;
53715 }
53716
53717 int64_t  CS_LDK_RecipientOnionFields_with_custom_tlvs(int64_t this_arg, int64_tArray custom_tlvs) {
53718         LDKRecipientOnionFields this_arg_conv;
53719         this_arg_conv.inner = untag_ptr(this_arg);
53720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53722         this_arg_conv = RecipientOnionFields_clone(&this_arg_conv);
53723         LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs_constr;
53724         custom_tlvs_constr.datalen = custom_tlvs->arr_len;
53725         if (custom_tlvs_constr.datalen > 0)
53726                 custom_tlvs_constr.data = MALLOC(custom_tlvs_constr.datalen * sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKCVec_C2Tuple_u64CVec_u8ZZZ Elements");
53727         else
53728                 custom_tlvs_constr.data = NULL;
53729         int64_t* custom_tlvs_vals = custom_tlvs->elems;
53730         for (size_t x = 0; x < custom_tlvs_constr.datalen; x++) {
53731                 int64_t custom_tlvs_conv_23 = custom_tlvs_vals[x];
53732                 void* custom_tlvs_conv_23_ptr = untag_ptr(custom_tlvs_conv_23);
53733                 CHECK_ACCESS(custom_tlvs_conv_23_ptr);
53734                 LDKC2Tuple_u64CVec_u8ZZ custom_tlvs_conv_23_conv = *(LDKC2Tuple_u64CVec_u8ZZ*)(custom_tlvs_conv_23_ptr);
53735                 custom_tlvs_conv_23_conv = C2Tuple_u64CVec_u8ZZ_clone((LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(custom_tlvs_conv_23));
53736                 custom_tlvs_constr.data[x] = custom_tlvs_conv_23_conv;
53737         }
53738         FREE(custom_tlvs);
53739         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
53740         *ret_conv = RecipientOnionFields_with_custom_tlvs(this_arg_conv, custom_tlvs_constr);
53741         return tag_ptr(ret_conv, true);
53742 }
53743
53744 int64_tArray  CS_LDK_RecipientOnionFields_custom_tlvs(int64_t this_arg) {
53745         LDKRecipientOnionFields this_arg_conv;
53746         this_arg_conv.inner = untag_ptr(this_arg);
53747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53749         this_arg_conv.is_owned = false;
53750         LDKCVec_C2Tuple_u64CVec_u8ZZZ ret_var = RecipientOnionFields_custom_tlvs(&this_arg_conv);
53751         int64_tArray ret_arr = NULL;
53752         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
53753         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
53754         for (size_t x = 0; x < ret_var.datalen; x++) {
53755                 LDKC2Tuple_u64CVec_u8ZZ* ret_conv_23_conv = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKC2Tuple_u64CVec_u8ZZ");
53756                 *ret_conv_23_conv = ret_var.data[x];
53757                 ret_arr_ptr[x] = tag_ptr(ret_conv_23_conv, true);
53758         }
53759         
53760         FREE(ret_var.data);
53761         return ret_arr;
53762 }
53763
53764 void  CS_LDK_CustomMessageReader_free(int64_t this_ptr) {
53765         if (!ptr_is_owned(this_ptr)) return;
53766         void* this_ptr_ptr = untag_ptr(this_ptr);
53767         CHECK_ACCESS(this_ptr_ptr);
53768         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
53769         FREE(untag_ptr(this_ptr));
53770         CustomMessageReader_free(this_ptr_conv);
53771 }
53772
53773 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
53774         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
53775         *ret_ret = Type_clone(arg);
53776         return tag_ptr(ret_ret, true);
53777 }
53778 int64_t  CS_LDK_Type_clone_ptr(int64_t arg) {
53779         void* arg_ptr = untag_ptr(arg);
53780         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
53781         LDKType* arg_conv = (LDKType*)arg_ptr;
53782         int64_t ret_conv = Type_clone_ptr(arg_conv);
53783         return ret_conv;
53784 }
53785
53786 int64_t  CS_LDK_Type_clone(int64_t orig) {
53787         void* orig_ptr = untag_ptr(orig);
53788         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
53789         LDKType* orig_conv = (LDKType*)orig_ptr;
53790         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
53791         *ret_ret = Type_clone(orig_conv);
53792         return tag_ptr(ret_ret, true);
53793 }
53794
53795 void  CS_LDK_Type_free(int64_t this_ptr) {
53796         if (!ptr_is_owned(this_ptr)) return;
53797         void* this_ptr_ptr = untag_ptr(this_ptr);
53798         CHECK_ACCESS(this_ptr_ptr);
53799         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
53800         FREE(untag_ptr(this_ptr));
53801         Type_free(this_ptr_conv);
53802 }
53803
53804 void  CS_LDK_Offer_free(int64_t this_obj) {
53805         LDKOffer this_obj_conv;
53806         this_obj_conv.inner = untag_ptr(this_obj);
53807         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53809         Offer_free(this_obj_conv);
53810 }
53811
53812 static inline uint64_t Offer_clone_ptr(LDKOffer *NONNULL_PTR arg) {
53813         LDKOffer ret_var = Offer_clone(arg);
53814         int64_t ret_ref = 0;
53815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53816         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53817         return ret_ref;
53818 }
53819 int64_t  CS_LDK_Offer_clone_ptr(int64_t arg) {
53820         LDKOffer arg_conv;
53821         arg_conv.inner = untag_ptr(arg);
53822         arg_conv.is_owned = ptr_is_owned(arg);
53823         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53824         arg_conv.is_owned = false;
53825         int64_t ret_conv = Offer_clone_ptr(&arg_conv);
53826         return ret_conv;
53827 }
53828
53829 int64_t  CS_LDK_Offer_clone(int64_t orig) {
53830         LDKOffer orig_conv;
53831         orig_conv.inner = untag_ptr(orig);
53832         orig_conv.is_owned = ptr_is_owned(orig);
53833         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53834         orig_conv.is_owned = false;
53835         LDKOffer ret_var = Offer_clone(&orig_conv);
53836         int64_t ret_ref = 0;
53837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53839         return ret_ref;
53840 }
53841
53842 ptrArray  CS_LDK_Offer_chains(int64_t this_arg) {
53843         LDKOffer this_arg_conv;
53844         this_arg_conv.inner = untag_ptr(this_arg);
53845         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53847         this_arg_conv.is_owned = false;
53848         LDKCVec_ThirtyTwoBytesZ ret_var = Offer_chains(&this_arg_conv);
53849         ptrArray ret_arr = NULL;
53850         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
53851         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
53852         for (size_t i = 0; i < ret_var.datalen; i++) {
53853                 int8_tArray ret_conv_8_arr = init_int8_tArray(32, __LINE__);
53854                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].data, 32);
53855                 ret_arr_ptr[i] = ret_conv_8_arr;
53856         }
53857         
53858         FREE(ret_var.data);
53859         return ret_arr;
53860 }
53861
53862 int64_t  CS_LDK_Offer_metadata(int64_t this_arg) {
53863         LDKOffer this_arg_conv;
53864         this_arg_conv.inner = untag_ptr(this_arg);
53865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53867         this_arg_conv.is_owned = false;
53868         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
53869         *ret_copy = Offer_metadata(&this_arg_conv);
53870         int64_t ret_ref = tag_ptr(ret_copy, true);
53871         return ret_ref;
53872 }
53873
53874 int64_t  CS_LDK_Offer_amount(int64_t this_arg) {
53875         LDKOffer this_arg_conv;
53876         this_arg_conv.inner = untag_ptr(this_arg);
53877         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53879         this_arg_conv.is_owned = false;
53880         LDKAmount ret_var = Offer_amount(&this_arg_conv);
53881         int64_t ret_ref = 0;
53882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53884         return ret_ref;
53885 }
53886
53887 int64_t  CS_LDK_Offer_description(int64_t this_arg) {
53888         LDKOffer this_arg_conv;
53889         this_arg_conv.inner = untag_ptr(this_arg);
53890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53892         this_arg_conv.is_owned = false;
53893         LDKPrintableString ret_var = Offer_description(&this_arg_conv);
53894         int64_t ret_ref = 0;
53895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53897         return ret_ref;
53898 }
53899
53900 int64_t  CS_LDK_Offer_offer_features(int64_t this_arg) {
53901         LDKOffer this_arg_conv;
53902         this_arg_conv.inner = untag_ptr(this_arg);
53903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53905         this_arg_conv.is_owned = false;
53906         LDKOfferFeatures ret_var = Offer_offer_features(&this_arg_conv);
53907         int64_t ret_ref = 0;
53908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53910         return ret_ref;
53911 }
53912
53913 int64_t  CS_LDK_Offer_absolute_expiry(int64_t this_arg) {
53914         LDKOffer this_arg_conv;
53915         this_arg_conv.inner = untag_ptr(this_arg);
53916         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53918         this_arg_conv.is_owned = false;
53919         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
53920         *ret_copy = Offer_absolute_expiry(&this_arg_conv);
53921         int64_t ret_ref = tag_ptr(ret_copy, true);
53922         return ret_ref;
53923 }
53924
53925 int64_t  CS_LDK_Offer_issuer(int64_t this_arg) {
53926         LDKOffer this_arg_conv;
53927         this_arg_conv.inner = untag_ptr(this_arg);
53928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53930         this_arg_conv.is_owned = false;
53931         LDKPrintableString ret_var = Offer_issuer(&this_arg_conv);
53932         int64_t ret_ref = 0;
53933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53935         return ret_ref;
53936 }
53937
53938 int64_tArray  CS_LDK_Offer_paths(int64_t this_arg) {
53939         LDKOffer this_arg_conv;
53940         this_arg_conv.inner = untag_ptr(this_arg);
53941         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53943         this_arg_conv.is_owned = false;
53944         LDKCVec_BlindedPathZ ret_var = Offer_paths(&this_arg_conv);
53945         int64_tArray ret_arr = NULL;
53946         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
53947         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
53948         for (size_t n = 0; n < ret_var.datalen; n++) {
53949                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
53950                 int64_t ret_conv_13_ref = 0;
53951                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
53952                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
53953                 ret_arr_ptr[n] = ret_conv_13_ref;
53954         }
53955         
53956         FREE(ret_var.data);
53957         return ret_arr;
53958 }
53959
53960 int64_t  CS_LDK_Offer_supported_quantity(int64_t this_arg) {
53961         LDKOffer this_arg_conv;
53962         this_arg_conv.inner = untag_ptr(this_arg);
53963         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53965         this_arg_conv.is_owned = false;
53966         LDKQuantity ret_var = Offer_supported_quantity(&this_arg_conv);
53967         int64_t ret_ref = 0;
53968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53969         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53970         return ret_ref;
53971 }
53972
53973 int8_tArray  CS_LDK_Offer_signing_pubkey(int64_t this_arg) {
53974         LDKOffer this_arg_conv;
53975         this_arg_conv.inner = untag_ptr(this_arg);
53976         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53978         this_arg_conv.is_owned = false;
53979         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
53980         memcpy(ret_arr->elems, Offer_signing_pubkey(&this_arg_conv).compressed_form, 33);
53981         return ret_arr;
53982 }
53983
53984 jboolean  CS_LDK_Offer_supports_chain(int64_t this_arg, int8_tArray chain) {
53985         LDKOffer this_arg_conv;
53986         this_arg_conv.inner = untag_ptr(this_arg);
53987         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53989         this_arg_conv.is_owned = false;
53990         LDKThirtyTwoBytes chain_ref;
53991         CHECK(chain->arr_len == 32);
53992         memcpy(chain_ref.data, chain->elems, 32); FREE(chain);
53993         jboolean ret_conv = Offer_supports_chain(&this_arg_conv, chain_ref);
53994         return ret_conv;
53995 }
53996
53997 jboolean  CS_LDK_Offer_is_expired(int64_t this_arg) {
53998         LDKOffer this_arg_conv;
53999         this_arg_conv.inner = untag_ptr(this_arg);
54000         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54002         this_arg_conv.is_owned = false;
54003         jboolean ret_conv = Offer_is_expired(&this_arg_conv);
54004         return ret_conv;
54005 }
54006
54007 jboolean  CS_LDK_Offer_is_valid_quantity(int64_t this_arg, int64_t quantity) {
54008         LDKOffer this_arg_conv;
54009         this_arg_conv.inner = untag_ptr(this_arg);
54010         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54012         this_arg_conv.is_owned = false;
54013         jboolean ret_conv = Offer_is_valid_quantity(&this_arg_conv, quantity);
54014         return ret_conv;
54015 }
54016
54017 jboolean  CS_LDK_Offer_expects_quantity(int64_t this_arg) {
54018         LDKOffer this_arg_conv;
54019         this_arg_conv.inner = untag_ptr(this_arg);
54020         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54022         this_arg_conv.is_owned = false;
54023         jboolean ret_conv = Offer_expects_quantity(&this_arg_conv);
54024         return ret_conv;
54025 }
54026
54027 int8_tArray  CS_LDK_Offer_write(int64_t obj) {
54028         LDKOffer obj_conv;
54029         obj_conv.inner = untag_ptr(obj);
54030         obj_conv.is_owned = ptr_is_owned(obj);
54031         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
54032         obj_conv.is_owned = false;
54033         LDKCVec_u8Z ret_var = Offer_write(&obj_conv);
54034         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54035         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54036         CVec_u8Z_free(ret_var);
54037         return ret_arr;
54038 }
54039
54040 void  CS_LDK_Amount_free(int64_t this_obj) {
54041         LDKAmount this_obj_conv;
54042         this_obj_conv.inner = untag_ptr(this_obj);
54043         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54045         Amount_free(this_obj_conv);
54046 }
54047
54048 static inline uint64_t Amount_clone_ptr(LDKAmount *NONNULL_PTR arg) {
54049         LDKAmount ret_var = Amount_clone(arg);
54050         int64_t ret_ref = 0;
54051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54053         return ret_ref;
54054 }
54055 int64_t  CS_LDK_Amount_clone_ptr(int64_t arg) {
54056         LDKAmount arg_conv;
54057         arg_conv.inner = untag_ptr(arg);
54058         arg_conv.is_owned = ptr_is_owned(arg);
54059         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
54060         arg_conv.is_owned = false;
54061         int64_t ret_conv = Amount_clone_ptr(&arg_conv);
54062         return ret_conv;
54063 }
54064
54065 int64_t  CS_LDK_Amount_clone(int64_t orig) {
54066         LDKAmount orig_conv;
54067         orig_conv.inner = untag_ptr(orig);
54068         orig_conv.is_owned = ptr_is_owned(orig);
54069         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
54070         orig_conv.is_owned = false;
54071         LDKAmount ret_var = Amount_clone(&orig_conv);
54072         int64_t ret_ref = 0;
54073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54074         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54075         return ret_ref;
54076 }
54077
54078 void  CS_LDK_Quantity_free(int64_t this_obj) {
54079         LDKQuantity this_obj_conv;
54080         this_obj_conv.inner = untag_ptr(this_obj);
54081         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54083         Quantity_free(this_obj_conv);
54084 }
54085
54086 static inline uint64_t Quantity_clone_ptr(LDKQuantity *NONNULL_PTR arg) {
54087         LDKQuantity ret_var = Quantity_clone(arg);
54088         int64_t ret_ref = 0;
54089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54091         return ret_ref;
54092 }
54093 int64_t  CS_LDK_Quantity_clone_ptr(int64_t arg) {
54094         LDKQuantity arg_conv;
54095         arg_conv.inner = untag_ptr(arg);
54096         arg_conv.is_owned = ptr_is_owned(arg);
54097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
54098         arg_conv.is_owned = false;
54099         int64_t ret_conv = Quantity_clone_ptr(&arg_conv);
54100         return ret_conv;
54101 }
54102
54103 int64_t  CS_LDK_Quantity_clone(int64_t orig) {
54104         LDKQuantity orig_conv;
54105         orig_conv.inner = untag_ptr(orig);
54106         orig_conv.is_owned = ptr_is_owned(orig);
54107         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
54108         orig_conv.is_owned = false;
54109         LDKQuantity ret_var = Quantity_clone(&orig_conv);
54110         int64_t ret_ref = 0;
54111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54113         return ret_ref;
54114 }
54115
54116 int64_t  CS_LDK_Offer_from_str(jstring s) {
54117         LDKStr s_conv = str_ref_to_owned_c(s);
54118         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
54119         *ret_conv = Offer_from_str(s_conv);
54120         return tag_ptr(ret_conv, true);
54121 }
54122
54123 void  CS_LDK_UnsignedBolt12Invoice_free(int64_t this_obj) {
54124         LDKUnsignedBolt12Invoice this_obj_conv;
54125         this_obj_conv.inner = untag_ptr(this_obj);
54126         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54128         UnsignedBolt12Invoice_free(this_obj_conv);
54129 }
54130
54131 int64_t  CS_LDK_UnsignedBolt12Invoice_tagged_hash(int64_t this_arg) {
54132         LDKUnsignedBolt12Invoice this_arg_conv;
54133         this_arg_conv.inner = untag_ptr(this_arg);
54134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54136         this_arg_conv.is_owned = false;
54137         LDKTaggedHash ret_var = UnsignedBolt12Invoice_tagged_hash(&this_arg_conv);
54138         int64_t ret_ref = 0;
54139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54140         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54141         return ret_ref;
54142 }
54143
54144 void  CS_LDK_Bolt12Invoice_free(int64_t this_obj) {
54145         LDKBolt12Invoice this_obj_conv;
54146         this_obj_conv.inner = untag_ptr(this_obj);
54147         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54149         Bolt12Invoice_free(this_obj_conv);
54150 }
54151
54152 static inline uint64_t Bolt12Invoice_clone_ptr(LDKBolt12Invoice *NONNULL_PTR arg) {
54153         LDKBolt12Invoice ret_var = Bolt12Invoice_clone(arg);
54154         int64_t ret_ref = 0;
54155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54156         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54157         return ret_ref;
54158 }
54159 int64_t  CS_LDK_Bolt12Invoice_clone_ptr(int64_t arg) {
54160         LDKBolt12Invoice arg_conv;
54161         arg_conv.inner = untag_ptr(arg);
54162         arg_conv.is_owned = ptr_is_owned(arg);
54163         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
54164         arg_conv.is_owned = false;
54165         int64_t ret_conv = Bolt12Invoice_clone_ptr(&arg_conv);
54166         return ret_conv;
54167 }
54168
54169 int64_t  CS_LDK_Bolt12Invoice_clone(int64_t orig) {
54170         LDKBolt12Invoice orig_conv;
54171         orig_conv.inner = untag_ptr(orig);
54172         orig_conv.is_owned = ptr_is_owned(orig);
54173         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
54174         orig_conv.is_owned = false;
54175         LDKBolt12Invoice ret_var = Bolt12Invoice_clone(&orig_conv);
54176         int64_t ret_ref = 0;
54177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54179         return ret_ref;
54180 }
54181
54182 int64_t  CS_LDK_UnsignedBolt12Invoice_offer_chains(int64_t this_arg) {
54183         LDKUnsignedBolt12Invoice this_arg_conv;
54184         this_arg_conv.inner = untag_ptr(this_arg);
54185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54187         this_arg_conv.is_owned = false;
54188         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
54189         *ret_copy = UnsignedBolt12Invoice_offer_chains(&this_arg_conv);
54190         int64_t ret_ref = tag_ptr(ret_copy, true);
54191         return ret_ref;
54192 }
54193
54194 int8_tArray  CS_LDK_UnsignedBolt12Invoice_chain(int64_t this_arg) {
54195         LDKUnsignedBolt12Invoice this_arg_conv;
54196         this_arg_conv.inner = untag_ptr(this_arg);
54197         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54199         this_arg_conv.is_owned = false;
54200         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54201         memcpy(ret_arr->elems, UnsignedBolt12Invoice_chain(&this_arg_conv).data, 32);
54202         return ret_arr;
54203 }
54204
54205 int64_t  CS_LDK_UnsignedBolt12Invoice_metadata(int64_t this_arg) {
54206         LDKUnsignedBolt12Invoice this_arg_conv;
54207         this_arg_conv.inner = untag_ptr(this_arg);
54208         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54210         this_arg_conv.is_owned = false;
54211         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
54212         *ret_copy = UnsignedBolt12Invoice_metadata(&this_arg_conv);
54213         int64_t ret_ref = tag_ptr(ret_copy, true);
54214         return ret_ref;
54215 }
54216
54217 int64_t  CS_LDK_UnsignedBolt12Invoice_amount(int64_t this_arg) {
54218         LDKUnsignedBolt12Invoice this_arg_conv;
54219         this_arg_conv.inner = untag_ptr(this_arg);
54220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54222         this_arg_conv.is_owned = false;
54223         LDKAmount ret_var = UnsignedBolt12Invoice_amount(&this_arg_conv);
54224         int64_t ret_ref = 0;
54225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54226         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54227         return ret_ref;
54228 }
54229
54230 int64_t  CS_LDK_UnsignedBolt12Invoice_offer_features(int64_t this_arg) {
54231         LDKUnsignedBolt12Invoice this_arg_conv;
54232         this_arg_conv.inner = untag_ptr(this_arg);
54233         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54235         this_arg_conv.is_owned = false;
54236         LDKOfferFeatures ret_var = UnsignedBolt12Invoice_offer_features(&this_arg_conv);
54237         int64_t ret_ref = 0;
54238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54239         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54240         return ret_ref;
54241 }
54242
54243 int64_t  CS_LDK_UnsignedBolt12Invoice_description(int64_t this_arg) {
54244         LDKUnsignedBolt12Invoice this_arg_conv;
54245         this_arg_conv.inner = untag_ptr(this_arg);
54246         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54248         this_arg_conv.is_owned = false;
54249         LDKPrintableString ret_var = UnsignedBolt12Invoice_description(&this_arg_conv);
54250         int64_t ret_ref = 0;
54251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54253         return ret_ref;
54254 }
54255
54256 int64_t  CS_LDK_UnsignedBolt12Invoice_absolute_expiry(int64_t this_arg) {
54257         LDKUnsignedBolt12Invoice this_arg_conv;
54258         this_arg_conv.inner = untag_ptr(this_arg);
54259         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54261         this_arg_conv.is_owned = false;
54262         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54263         *ret_copy = UnsignedBolt12Invoice_absolute_expiry(&this_arg_conv);
54264         int64_t ret_ref = tag_ptr(ret_copy, true);
54265         return ret_ref;
54266 }
54267
54268 int64_t  CS_LDK_UnsignedBolt12Invoice_issuer(int64_t this_arg) {
54269         LDKUnsignedBolt12Invoice this_arg_conv;
54270         this_arg_conv.inner = untag_ptr(this_arg);
54271         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54273         this_arg_conv.is_owned = false;
54274         LDKPrintableString ret_var = UnsignedBolt12Invoice_issuer(&this_arg_conv);
54275         int64_t ret_ref = 0;
54276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54277         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54278         return ret_ref;
54279 }
54280
54281 int64_tArray  CS_LDK_UnsignedBolt12Invoice_message_paths(int64_t this_arg) {
54282         LDKUnsignedBolt12Invoice this_arg_conv;
54283         this_arg_conv.inner = untag_ptr(this_arg);
54284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54286         this_arg_conv.is_owned = false;
54287         LDKCVec_BlindedPathZ ret_var = UnsignedBolt12Invoice_message_paths(&this_arg_conv);
54288         int64_tArray ret_arr = NULL;
54289         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
54290         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
54291         for (size_t n = 0; n < ret_var.datalen; n++) {
54292                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
54293                 int64_t ret_conv_13_ref = 0;
54294                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
54295                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
54296                 ret_arr_ptr[n] = ret_conv_13_ref;
54297         }
54298         
54299         FREE(ret_var.data);
54300         return ret_arr;
54301 }
54302
54303 int64_t  CS_LDK_UnsignedBolt12Invoice_supported_quantity(int64_t this_arg) {
54304         LDKUnsignedBolt12Invoice this_arg_conv;
54305         this_arg_conv.inner = untag_ptr(this_arg);
54306         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54308         this_arg_conv.is_owned = false;
54309         LDKQuantity ret_var = UnsignedBolt12Invoice_supported_quantity(&this_arg_conv);
54310         int64_t ret_ref = 0;
54311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54313         return ret_ref;
54314 }
54315
54316 int8_tArray  CS_LDK_UnsignedBolt12Invoice_payer_metadata(int64_t this_arg) {
54317         LDKUnsignedBolt12Invoice this_arg_conv;
54318         this_arg_conv.inner = untag_ptr(this_arg);
54319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54321         this_arg_conv.is_owned = false;
54322         LDKu8slice ret_var = UnsignedBolt12Invoice_payer_metadata(&this_arg_conv);
54323         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54324         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54325         return ret_arr;
54326 }
54327
54328 int64_t  CS_LDK_UnsignedBolt12Invoice_invoice_request_features(int64_t this_arg) {
54329         LDKUnsignedBolt12Invoice this_arg_conv;
54330         this_arg_conv.inner = untag_ptr(this_arg);
54331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54333         this_arg_conv.is_owned = false;
54334         LDKInvoiceRequestFeatures ret_var = UnsignedBolt12Invoice_invoice_request_features(&this_arg_conv);
54335         int64_t ret_ref = 0;
54336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54337         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54338         return ret_ref;
54339 }
54340
54341 int64_t  CS_LDK_UnsignedBolt12Invoice_quantity(int64_t this_arg) {
54342         LDKUnsignedBolt12Invoice this_arg_conv;
54343         this_arg_conv.inner = untag_ptr(this_arg);
54344         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54346         this_arg_conv.is_owned = false;
54347         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54348         *ret_copy = UnsignedBolt12Invoice_quantity(&this_arg_conv);
54349         int64_t ret_ref = tag_ptr(ret_copy, true);
54350         return ret_ref;
54351 }
54352
54353 int8_tArray  CS_LDK_UnsignedBolt12Invoice_payer_id(int64_t this_arg) {
54354         LDKUnsignedBolt12Invoice this_arg_conv;
54355         this_arg_conv.inner = untag_ptr(this_arg);
54356         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54358         this_arg_conv.is_owned = false;
54359         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
54360         memcpy(ret_arr->elems, UnsignedBolt12Invoice_payer_id(&this_arg_conv).compressed_form, 33);
54361         return ret_arr;
54362 }
54363
54364 int64_t  CS_LDK_UnsignedBolt12Invoice_payer_note(int64_t this_arg) {
54365         LDKUnsignedBolt12Invoice this_arg_conv;
54366         this_arg_conv.inner = untag_ptr(this_arg);
54367         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54369         this_arg_conv.is_owned = false;
54370         LDKPrintableString ret_var = UnsignedBolt12Invoice_payer_note(&this_arg_conv);
54371         int64_t ret_ref = 0;
54372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54374         return ret_ref;
54375 }
54376
54377 int64_t  CS_LDK_UnsignedBolt12Invoice_created_at(int64_t this_arg) {
54378         LDKUnsignedBolt12Invoice this_arg_conv;
54379         this_arg_conv.inner = untag_ptr(this_arg);
54380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54382         this_arg_conv.is_owned = false;
54383         int64_t ret_conv = UnsignedBolt12Invoice_created_at(&this_arg_conv);
54384         return ret_conv;
54385 }
54386
54387 int64_t  CS_LDK_UnsignedBolt12Invoice_relative_expiry(int64_t this_arg) {
54388         LDKUnsignedBolt12Invoice this_arg_conv;
54389         this_arg_conv.inner = untag_ptr(this_arg);
54390         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54392         this_arg_conv.is_owned = false;
54393         int64_t ret_conv = UnsignedBolt12Invoice_relative_expiry(&this_arg_conv);
54394         return ret_conv;
54395 }
54396
54397 jboolean  CS_LDK_UnsignedBolt12Invoice_is_expired(int64_t this_arg) {
54398         LDKUnsignedBolt12Invoice this_arg_conv;
54399         this_arg_conv.inner = untag_ptr(this_arg);
54400         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54402         this_arg_conv.is_owned = false;
54403         jboolean ret_conv = UnsignedBolt12Invoice_is_expired(&this_arg_conv);
54404         return ret_conv;
54405 }
54406
54407 int8_tArray  CS_LDK_UnsignedBolt12Invoice_payment_hash(int64_t this_arg) {
54408         LDKUnsignedBolt12Invoice this_arg_conv;
54409         this_arg_conv.inner = untag_ptr(this_arg);
54410         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54412         this_arg_conv.is_owned = false;
54413         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54414         memcpy(ret_arr->elems, UnsignedBolt12Invoice_payment_hash(&this_arg_conv).data, 32);
54415         return ret_arr;
54416 }
54417
54418 int64_t  CS_LDK_UnsignedBolt12Invoice_amount_msats(int64_t this_arg) {
54419         LDKUnsignedBolt12Invoice this_arg_conv;
54420         this_arg_conv.inner = untag_ptr(this_arg);
54421         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54423         this_arg_conv.is_owned = false;
54424         int64_t ret_conv = UnsignedBolt12Invoice_amount_msats(&this_arg_conv);
54425         return ret_conv;
54426 }
54427
54428 int64_t  CS_LDK_UnsignedBolt12Invoice_invoice_features(int64_t this_arg) {
54429         LDKUnsignedBolt12Invoice this_arg_conv;
54430         this_arg_conv.inner = untag_ptr(this_arg);
54431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54433         this_arg_conv.is_owned = false;
54434         LDKBolt12InvoiceFeatures ret_var = UnsignedBolt12Invoice_invoice_features(&this_arg_conv);
54435         int64_t ret_ref = 0;
54436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54438         return ret_ref;
54439 }
54440
54441 int8_tArray  CS_LDK_UnsignedBolt12Invoice_signing_pubkey(int64_t this_arg) {
54442         LDKUnsignedBolt12Invoice this_arg_conv;
54443         this_arg_conv.inner = untag_ptr(this_arg);
54444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54446         this_arg_conv.is_owned = false;
54447         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
54448         memcpy(ret_arr->elems, UnsignedBolt12Invoice_signing_pubkey(&this_arg_conv).compressed_form, 33);
54449         return ret_arr;
54450 }
54451
54452 int64_t  CS_LDK_Bolt12Invoice_offer_chains(int64_t this_arg) {
54453         LDKBolt12Invoice this_arg_conv;
54454         this_arg_conv.inner = untag_ptr(this_arg);
54455         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54457         this_arg_conv.is_owned = false;
54458         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
54459         *ret_copy = Bolt12Invoice_offer_chains(&this_arg_conv);
54460         int64_t ret_ref = tag_ptr(ret_copy, true);
54461         return ret_ref;
54462 }
54463
54464 int8_tArray  CS_LDK_Bolt12Invoice_chain(int64_t this_arg) {
54465         LDKBolt12Invoice this_arg_conv;
54466         this_arg_conv.inner = untag_ptr(this_arg);
54467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54469         this_arg_conv.is_owned = false;
54470         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54471         memcpy(ret_arr->elems, Bolt12Invoice_chain(&this_arg_conv).data, 32);
54472         return ret_arr;
54473 }
54474
54475 int64_t  CS_LDK_Bolt12Invoice_metadata(int64_t this_arg) {
54476         LDKBolt12Invoice this_arg_conv;
54477         this_arg_conv.inner = untag_ptr(this_arg);
54478         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54480         this_arg_conv.is_owned = false;
54481         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
54482         *ret_copy = Bolt12Invoice_metadata(&this_arg_conv);
54483         int64_t ret_ref = tag_ptr(ret_copy, true);
54484         return ret_ref;
54485 }
54486
54487 int64_t  CS_LDK_Bolt12Invoice_amount(int64_t this_arg) {
54488         LDKBolt12Invoice this_arg_conv;
54489         this_arg_conv.inner = untag_ptr(this_arg);
54490         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54492         this_arg_conv.is_owned = false;
54493         LDKAmount ret_var = Bolt12Invoice_amount(&this_arg_conv);
54494         int64_t ret_ref = 0;
54495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54497         return ret_ref;
54498 }
54499
54500 int64_t  CS_LDK_Bolt12Invoice_offer_features(int64_t this_arg) {
54501         LDKBolt12Invoice this_arg_conv;
54502         this_arg_conv.inner = untag_ptr(this_arg);
54503         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54505         this_arg_conv.is_owned = false;
54506         LDKOfferFeatures ret_var = Bolt12Invoice_offer_features(&this_arg_conv);
54507         int64_t ret_ref = 0;
54508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54510         return ret_ref;
54511 }
54512
54513 int64_t  CS_LDK_Bolt12Invoice_description(int64_t this_arg) {
54514         LDKBolt12Invoice this_arg_conv;
54515         this_arg_conv.inner = untag_ptr(this_arg);
54516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54518         this_arg_conv.is_owned = false;
54519         LDKPrintableString ret_var = Bolt12Invoice_description(&this_arg_conv);
54520         int64_t ret_ref = 0;
54521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54523         return ret_ref;
54524 }
54525
54526 int64_t  CS_LDK_Bolt12Invoice_absolute_expiry(int64_t this_arg) {
54527         LDKBolt12Invoice this_arg_conv;
54528         this_arg_conv.inner = untag_ptr(this_arg);
54529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54531         this_arg_conv.is_owned = false;
54532         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54533         *ret_copy = Bolt12Invoice_absolute_expiry(&this_arg_conv);
54534         int64_t ret_ref = tag_ptr(ret_copy, true);
54535         return ret_ref;
54536 }
54537
54538 int64_t  CS_LDK_Bolt12Invoice_issuer(int64_t this_arg) {
54539         LDKBolt12Invoice this_arg_conv;
54540         this_arg_conv.inner = untag_ptr(this_arg);
54541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54543         this_arg_conv.is_owned = false;
54544         LDKPrintableString ret_var = Bolt12Invoice_issuer(&this_arg_conv);
54545         int64_t ret_ref = 0;
54546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54548         return ret_ref;
54549 }
54550
54551 int64_tArray  CS_LDK_Bolt12Invoice_message_paths(int64_t this_arg) {
54552         LDKBolt12Invoice this_arg_conv;
54553         this_arg_conv.inner = untag_ptr(this_arg);
54554         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54556         this_arg_conv.is_owned = false;
54557         LDKCVec_BlindedPathZ ret_var = Bolt12Invoice_message_paths(&this_arg_conv);
54558         int64_tArray ret_arr = NULL;
54559         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
54560         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
54561         for (size_t n = 0; n < ret_var.datalen; n++) {
54562                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
54563                 int64_t ret_conv_13_ref = 0;
54564                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
54565                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
54566                 ret_arr_ptr[n] = ret_conv_13_ref;
54567         }
54568         
54569         FREE(ret_var.data);
54570         return ret_arr;
54571 }
54572
54573 int64_t  CS_LDK_Bolt12Invoice_supported_quantity(int64_t this_arg) {
54574         LDKBolt12Invoice this_arg_conv;
54575         this_arg_conv.inner = untag_ptr(this_arg);
54576         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54578         this_arg_conv.is_owned = false;
54579         LDKQuantity ret_var = Bolt12Invoice_supported_quantity(&this_arg_conv);
54580         int64_t ret_ref = 0;
54581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54582         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54583         return ret_ref;
54584 }
54585
54586 int8_tArray  CS_LDK_Bolt12Invoice_payer_metadata(int64_t this_arg) {
54587         LDKBolt12Invoice this_arg_conv;
54588         this_arg_conv.inner = untag_ptr(this_arg);
54589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54591         this_arg_conv.is_owned = false;
54592         LDKu8slice ret_var = Bolt12Invoice_payer_metadata(&this_arg_conv);
54593         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54594         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54595         return ret_arr;
54596 }
54597
54598 int64_t  CS_LDK_Bolt12Invoice_invoice_request_features(int64_t this_arg) {
54599         LDKBolt12Invoice this_arg_conv;
54600         this_arg_conv.inner = untag_ptr(this_arg);
54601         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54603         this_arg_conv.is_owned = false;
54604         LDKInvoiceRequestFeatures ret_var = Bolt12Invoice_invoice_request_features(&this_arg_conv);
54605         int64_t ret_ref = 0;
54606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54608         return ret_ref;
54609 }
54610
54611 int64_t  CS_LDK_Bolt12Invoice_quantity(int64_t this_arg) {
54612         LDKBolt12Invoice this_arg_conv;
54613         this_arg_conv.inner = untag_ptr(this_arg);
54614         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54616         this_arg_conv.is_owned = false;
54617         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54618         *ret_copy = Bolt12Invoice_quantity(&this_arg_conv);
54619         int64_t ret_ref = tag_ptr(ret_copy, true);
54620         return ret_ref;
54621 }
54622
54623 int8_tArray  CS_LDK_Bolt12Invoice_payer_id(int64_t this_arg) {
54624         LDKBolt12Invoice this_arg_conv;
54625         this_arg_conv.inner = untag_ptr(this_arg);
54626         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54628         this_arg_conv.is_owned = false;
54629         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
54630         memcpy(ret_arr->elems, Bolt12Invoice_payer_id(&this_arg_conv).compressed_form, 33);
54631         return ret_arr;
54632 }
54633
54634 int64_t  CS_LDK_Bolt12Invoice_payer_note(int64_t this_arg) {
54635         LDKBolt12Invoice this_arg_conv;
54636         this_arg_conv.inner = untag_ptr(this_arg);
54637         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54639         this_arg_conv.is_owned = false;
54640         LDKPrintableString ret_var = Bolt12Invoice_payer_note(&this_arg_conv);
54641         int64_t ret_ref = 0;
54642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54643         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54644         return ret_ref;
54645 }
54646
54647 int64_t  CS_LDK_Bolt12Invoice_created_at(int64_t this_arg) {
54648         LDKBolt12Invoice this_arg_conv;
54649         this_arg_conv.inner = untag_ptr(this_arg);
54650         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54652         this_arg_conv.is_owned = false;
54653         int64_t ret_conv = Bolt12Invoice_created_at(&this_arg_conv);
54654         return ret_conv;
54655 }
54656
54657 int64_t  CS_LDK_Bolt12Invoice_relative_expiry(int64_t this_arg) {
54658         LDKBolt12Invoice this_arg_conv;
54659         this_arg_conv.inner = untag_ptr(this_arg);
54660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54662         this_arg_conv.is_owned = false;
54663         int64_t ret_conv = Bolt12Invoice_relative_expiry(&this_arg_conv);
54664         return ret_conv;
54665 }
54666
54667 jboolean  CS_LDK_Bolt12Invoice_is_expired(int64_t this_arg) {
54668         LDKBolt12Invoice this_arg_conv;
54669         this_arg_conv.inner = untag_ptr(this_arg);
54670         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54672         this_arg_conv.is_owned = false;
54673         jboolean ret_conv = Bolt12Invoice_is_expired(&this_arg_conv);
54674         return ret_conv;
54675 }
54676
54677 int8_tArray  CS_LDK_Bolt12Invoice_payment_hash(int64_t this_arg) {
54678         LDKBolt12Invoice this_arg_conv;
54679         this_arg_conv.inner = untag_ptr(this_arg);
54680         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54682         this_arg_conv.is_owned = false;
54683         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54684         memcpy(ret_arr->elems, Bolt12Invoice_payment_hash(&this_arg_conv).data, 32);
54685         return ret_arr;
54686 }
54687
54688 int64_t  CS_LDK_Bolt12Invoice_amount_msats(int64_t this_arg) {
54689         LDKBolt12Invoice this_arg_conv;
54690         this_arg_conv.inner = untag_ptr(this_arg);
54691         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54693         this_arg_conv.is_owned = false;
54694         int64_t ret_conv = Bolt12Invoice_amount_msats(&this_arg_conv);
54695         return ret_conv;
54696 }
54697
54698 int64_t  CS_LDK_Bolt12Invoice_invoice_features(int64_t this_arg) {
54699         LDKBolt12Invoice this_arg_conv;
54700         this_arg_conv.inner = untag_ptr(this_arg);
54701         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54703         this_arg_conv.is_owned = false;
54704         LDKBolt12InvoiceFeatures ret_var = Bolt12Invoice_invoice_features(&this_arg_conv);
54705         int64_t ret_ref = 0;
54706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54708         return ret_ref;
54709 }
54710
54711 int8_tArray  CS_LDK_Bolt12Invoice_signing_pubkey(int64_t this_arg) {
54712         LDKBolt12Invoice this_arg_conv;
54713         this_arg_conv.inner = untag_ptr(this_arg);
54714         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54716         this_arg_conv.is_owned = false;
54717         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
54718         memcpy(ret_arr->elems, Bolt12Invoice_signing_pubkey(&this_arg_conv).compressed_form, 33);
54719         return ret_arr;
54720 }
54721
54722 int8_tArray  CS_LDK_Bolt12Invoice_signature(int64_t this_arg) {
54723         LDKBolt12Invoice this_arg_conv;
54724         this_arg_conv.inner = untag_ptr(this_arg);
54725         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54727         this_arg_conv.is_owned = false;
54728         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
54729         memcpy(ret_arr->elems, Bolt12Invoice_signature(&this_arg_conv).compact_form, 64);
54730         return ret_arr;
54731 }
54732
54733 int8_tArray  CS_LDK_Bolt12Invoice_signable_hash(int64_t this_arg) {
54734         LDKBolt12Invoice this_arg_conv;
54735         this_arg_conv.inner = untag_ptr(this_arg);
54736         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54738         this_arg_conv.is_owned = false;
54739         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54740         memcpy(ret_arr->elems, Bolt12Invoice_signable_hash(&this_arg_conv).data, 32);
54741         return ret_arr;
54742 }
54743
54744 int64_t  CS_LDK_Bolt12Invoice_verify(int64_t this_arg, int64_t key) {
54745         LDKBolt12Invoice this_arg_conv;
54746         this_arg_conv.inner = untag_ptr(this_arg);
54747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54749         this_arg_conv.is_owned = false;
54750         LDKExpandedKey key_conv;
54751         key_conv.inner = untag_ptr(key);
54752         key_conv.is_owned = ptr_is_owned(key);
54753         CHECK_INNER_FIELD_ACCESS_OR_NULL(key_conv);
54754         key_conv.is_owned = false;
54755         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
54756         *ret_conv = Bolt12Invoice_verify(&this_arg_conv, &key_conv);
54757         return tag_ptr(ret_conv, true);
54758 }
54759
54760 int8_tArray  CS_LDK_UnsignedBolt12Invoice_write(int64_t obj) {
54761         LDKUnsignedBolt12Invoice obj_conv;
54762         obj_conv.inner = untag_ptr(obj);
54763         obj_conv.is_owned = ptr_is_owned(obj);
54764         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
54765         obj_conv.is_owned = false;
54766         LDKCVec_u8Z ret_var = UnsignedBolt12Invoice_write(&obj_conv);
54767         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54768         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54769         CVec_u8Z_free(ret_var);
54770         return ret_arr;
54771 }
54772
54773 int8_tArray  CS_LDK_Bolt12Invoice_write(int64_t obj) {
54774         LDKBolt12Invoice obj_conv;
54775         obj_conv.inner = untag_ptr(obj);
54776         obj_conv.is_owned = ptr_is_owned(obj);
54777         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
54778         obj_conv.is_owned = false;
54779         LDKCVec_u8Z ret_var = Bolt12Invoice_write(&obj_conv);
54780         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54781         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54782         CVec_u8Z_free(ret_var);
54783         return ret_arr;
54784 }
54785
54786 void  CS_LDK_BlindedPayInfo_free(int64_t this_obj) {
54787         LDKBlindedPayInfo this_obj_conv;
54788         this_obj_conv.inner = untag_ptr(this_obj);
54789         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54791         BlindedPayInfo_free(this_obj_conv);
54792 }
54793
54794 int32_t  CS_LDK_BlindedPayInfo_get_fee_base_msat(int64_t this_ptr) {
54795         LDKBlindedPayInfo this_ptr_conv;
54796         this_ptr_conv.inner = untag_ptr(this_ptr);
54797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54799         this_ptr_conv.is_owned = false;
54800         int32_t ret_conv = BlindedPayInfo_get_fee_base_msat(&this_ptr_conv);
54801         return ret_conv;
54802 }
54803
54804 void  CS_LDK_BlindedPayInfo_set_fee_base_msat(int64_t this_ptr, int32_t val) {
54805         LDKBlindedPayInfo this_ptr_conv;
54806         this_ptr_conv.inner = untag_ptr(this_ptr);
54807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54809         this_ptr_conv.is_owned = false;
54810         BlindedPayInfo_set_fee_base_msat(&this_ptr_conv, val);
54811 }
54812
54813 int32_t  CS_LDK_BlindedPayInfo_get_fee_proportional_millionths(int64_t this_ptr) {
54814         LDKBlindedPayInfo this_ptr_conv;
54815         this_ptr_conv.inner = untag_ptr(this_ptr);
54816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54818         this_ptr_conv.is_owned = false;
54819         int32_t ret_conv = BlindedPayInfo_get_fee_proportional_millionths(&this_ptr_conv);
54820         return ret_conv;
54821 }
54822
54823 void  CS_LDK_BlindedPayInfo_set_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
54824         LDKBlindedPayInfo this_ptr_conv;
54825         this_ptr_conv.inner = untag_ptr(this_ptr);
54826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54828         this_ptr_conv.is_owned = false;
54829         BlindedPayInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
54830 }
54831
54832 int16_t  CS_LDK_BlindedPayInfo_get_cltv_expiry_delta(int64_t this_ptr) {
54833         LDKBlindedPayInfo this_ptr_conv;
54834         this_ptr_conv.inner = untag_ptr(this_ptr);
54835         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54837         this_ptr_conv.is_owned = false;
54838         int16_t ret_conv = BlindedPayInfo_get_cltv_expiry_delta(&this_ptr_conv);
54839         return ret_conv;
54840 }
54841
54842 void  CS_LDK_BlindedPayInfo_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
54843         LDKBlindedPayInfo this_ptr_conv;
54844         this_ptr_conv.inner = untag_ptr(this_ptr);
54845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54847         this_ptr_conv.is_owned = false;
54848         BlindedPayInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
54849 }
54850
54851 int64_t  CS_LDK_BlindedPayInfo_get_htlc_minimum_msat(int64_t this_ptr) {
54852         LDKBlindedPayInfo this_ptr_conv;
54853         this_ptr_conv.inner = untag_ptr(this_ptr);
54854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54856         this_ptr_conv.is_owned = false;
54857         int64_t ret_conv = BlindedPayInfo_get_htlc_minimum_msat(&this_ptr_conv);
54858         return ret_conv;
54859 }
54860
54861 void  CS_LDK_BlindedPayInfo_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
54862         LDKBlindedPayInfo this_ptr_conv;
54863         this_ptr_conv.inner = untag_ptr(this_ptr);
54864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54866         this_ptr_conv.is_owned = false;
54867         BlindedPayInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
54868 }
54869
54870 int64_t  CS_LDK_BlindedPayInfo_get_htlc_maximum_msat(int64_t this_ptr) {
54871         LDKBlindedPayInfo this_ptr_conv;
54872         this_ptr_conv.inner = untag_ptr(this_ptr);
54873         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54875         this_ptr_conv.is_owned = false;
54876         int64_t ret_conv = BlindedPayInfo_get_htlc_maximum_msat(&this_ptr_conv);
54877         return ret_conv;
54878 }
54879
54880 void  CS_LDK_BlindedPayInfo_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
54881         LDKBlindedPayInfo this_ptr_conv;
54882         this_ptr_conv.inner = untag_ptr(this_ptr);
54883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54885         this_ptr_conv.is_owned = false;
54886         BlindedPayInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
54887 }
54888
54889 int64_t  CS_LDK_BlindedPayInfo_get_features(int64_t this_ptr) {
54890         LDKBlindedPayInfo this_ptr_conv;
54891         this_ptr_conv.inner = untag_ptr(this_ptr);
54892         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54894         this_ptr_conv.is_owned = false;
54895         LDKBlindedHopFeatures ret_var = BlindedPayInfo_get_features(&this_ptr_conv);
54896         int64_t ret_ref = 0;
54897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54899         return ret_ref;
54900 }
54901
54902 void  CS_LDK_BlindedPayInfo_set_features(int64_t this_ptr, int64_t val) {
54903         LDKBlindedPayInfo this_ptr_conv;
54904         this_ptr_conv.inner = untag_ptr(this_ptr);
54905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54907         this_ptr_conv.is_owned = false;
54908         LDKBlindedHopFeatures val_conv;
54909         val_conv.inner = untag_ptr(val);
54910         val_conv.is_owned = ptr_is_owned(val);
54911         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
54912         val_conv = BlindedHopFeatures_clone(&val_conv);
54913         BlindedPayInfo_set_features(&this_ptr_conv, val_conv);
54914 }
54915
54916 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) {
54917         LDKBlindedHopFeatures features_arg_conv;
54918         features_arg_conv.inner = untag_ptr(features_arg);
54919         features_arg_conv.is_owned = ptr_is_owned(features_arg);
54920         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
54921         features_arg_conv = BlindedHopFeatures_clone(&features_arg_conv);
54922         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);
54923         int64_t ret_ref = 0;
54924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54926         return ret_ref;
54927 }
54928
54929 static inline uint64_t BlindedPayInfo_clone_ptr(LDKBlindedPayInfo *NONNULL_PTR arg) {
54930         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(arg);
54931         int64_t ret_ref = 0;
54932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54933         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54934         return ret_ref;
54935 }
54936 int64_t  CS_LDK_BlindedPayInfo_clone_ptr(int64_t arg) {
54937         LDKBlindedPayInfo arg_conv;
54938         arg_conv.inner = untag_ptr(arg);
54939         arg_conv.is_owned = ptr_is_owned(arg);
54940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
54941         arg_conv.is_owned = false;
54942         int64_t ret_conv = BlindedPayInfo_clone_ptr(&arg_conv);
54943         return ret_conv;
54944 }
54945
54946 int64_t  CS_LDK_BlindedPayInfo_clone(int64_t orig) {
54947         LDKBlindedPayInfo orig_conv;
54948         orig_conv.inner = untag_ptr(orig);
54949         orig_conv.is_owned = ptr_is_owned(orig);
54950         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
54951         orig_conv.is_owned = false;
54952         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(&orig_conv);
54953         int64_t ret_ref = 0;
54954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54955         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54956         return ret_ref;
54957 }
54958
54959 int64_t  CS_LDK_BlindedPayInfo_hash(int64_t o) {
54960         LDKBlindedPayInfo o_conv;
54961         o_conv.inner = untag_ptr(o);
54962         o_conv.is_owned = ptr_is_owned(o);
54963         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
54964         o_conv.is_owned = false;
54965         int64_t ret_conv = BlindedPayInfo_hash(&o_conv);
54966         return ret_conv;
54967 }
54968
54969 jboolean  CS_LDK_BlindedPayInfo_eq(int64_t a, int64_t b) {
54970         LDKBlindedPayInfo a_conv;
54971         a_conv.inner = untag_ptr(a);
54972         a_conv.is_owned = ptr_is_owned(a);
54973         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
54974         a_conv.is_owned = false;
54975         LDKBlindedPayInfo b_conv;
54976         b_conv.inner = untag_ptr(b);
54977         b_conv.is_owned = ptr_is_owned(b);
54978         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
54979         b_conv.is_owned = false;
54980         jboolean ret_conv = BlindedPayInfo_eq(&a_conv, &b_conv);
54981         return ret_conv;
54982 }
54983
54984 int8_tArray  CS_LDK_BlindedPayInfo_write(int64_t obj) {
54985         LDKBlindedPayInfo obj_conv;
54986         obj_conv.inner = untag_ptr(obj);
54987         obj_conv.is_owned = ptr_is_owned(obj);
54988         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
54989         obj_conv.is_owned = false;
54990         LDKCVec_u8Z ret_var = BlindedPayInfo_write(&obj_conv);
54991         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54992         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54993         CVec_u8Z_free(ret_var);
54994         return ret_arr;
54995 }
54996
54997 int64_t  CS_LDK_BlindedPayInfo_read(int8_tArray ser) {
54998         LDKu8slice ser_ref;
54999         ser_ref.datalen = ser->arr_len;
55000         ser_ref.data = ser->elems;
55001         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
55002         *ret_conv = BlindedPayInfo_read(ser_ref);
55003         FREE(ser);
55004         return tag_ptr(ret_conv, true);
55005 }
55006
55007 void  CS_LDK_InvoiceError_free(int64_t this_obj) {
55008         LDKInvoiceError this_obj_conv;
55009         this_obj_conv.inner = untag_ptr(this_obj);
55010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55012         InvoiceError_free(this_obj_conv);
55013 }
55014
55015 int64_t  CS_LDK_InvoiceError_get_erroneous_field(int64_t this_ptr) {
55016         LDKInvoiceError this_ptr_conv;
55017         this_ptr_conv.inner = untag_ptr(this_ptr);
55018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55020         this_ptr_conv.is_owned = false;
55021         LDKErroneousField ret_var = InvoiceError_get_erroneous_field(&this_ptr_conv);
55022         int64_t ret_ref = 0;
55023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55024         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55025         return ret_ref;
55026 }
55027
55028 void  CS_LDK_InvoiceError_set_erroneous_field(int64_t this_ptr, int64_t val) {
55029         LDKInvoiceError this_ptr_conv;
55030         this_ptr_conv.inner = untag_ptr(this_ptr);
55031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55033         this_ptr_conv.is_owned = false;
55034         LDKErroneousField val_conv;
55035         val_conv.inner = untag_ptr(val);
55036         val_conv.is_owned = ptr_is_owned(val);
55037         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55038         val_conv = ErroneousField_clone(&val_conv);
55039         InvoiceError_set_erroneous_field(&this_ptr_conv, val_conv);
55040 }
55041
55042 int64_t  CS_LDK_InvoiceError_get_message(int64_t this_ptr) {
55043         LDKInvoiceError this_ptr_conv;
55044         this_ptr_conv.inner = untag_ptr(this_ptr);
55045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55047         this_ptr_conv.is_owned = false;
55048         LDKUntrustedString ret_var = InvoiceError_get_message(&this_ptr_conv);
55049         int64_t ret_ref = 0;
55050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55051         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55052         return ret_ref;
55053 }
55054
55055 void  CS_LDK_InvoiceError_set_message(int64_t this_ptr, int64_t val) {
55056         LDKInvoiceError this_ptr_conv;
55057         this_ptr_conv.inner = untag_ptr(this_ptr);
55058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55060         this_ptr_conv.is_owned = false;
55061         LDKUntrustedString val_conv;
55062         val_conv.inner = untag_ptr(val);
55063         val_conv.is_owned = ptr_is_owned(val);
55064         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55065         val_conv = UntrustedString_clone(&val_conv);
55066         InvoiceError_set_message(&this_ptr_conv, val_conv);
55067 }
55068
55069 int64_t  CS_LDK_InvoiceError_new(int64_t erroneous_field_arg, int64_t message_arg) {
55070         LDKErroneousField erroneous_field_arg_conv;
55071         erroneous_field_arg_conv.inner = untag_ptr(erroneous_field_arg);
55072         erroneous_field_arg_conv.is_owned = ptr_is_owned(erroneous_field_arg);
55073         CHECK_INNER_FIELD_ACCESS_OR_NULL(erroneous_field_arg_conv);
55074         erroneous_field_arg_conv = ErroneousField_clone(&erroneous_field_arg_conv);
55075         LDKUntrustedString message_arg_conv;
55076         message_arg_conv.inner = untag_ptr(message_arg);
55077         message_arg_conv.is_owned = ptr_is_owned(message_arg);
55078         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_arg_conv);
55079         message_arg_conv = UntrustedString_clone(&message_arg_conv);
55080         LDKInvoiceError ret_var = InvoiceError_new(erroneous_field_arg_conv, message_arg_conv);
55081         int64_t ret_ref = 0;
55082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55084         return ret_ref;
55085 }
55086
55087 static inline uint64_t InvoiceError_clone_ptr(LDKInvoiceError *NONNULL_PTR arg) {
55088         LDKInvoiceError ret_var = InvoiceError_clone(arg);
55089         int64_t ret_ref = 0;
55090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55091         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55092         return ret_ref;
55093 }
55094 int64_t  CS_LDK_InvoiceError_clone_ptr(int64_t arg) {
55095         LDKInvoiceError arg_conv;
55096         arg_conv.inner = untag_ptr(arg);
55097         arg_conv.is_owned = ptr_is_owned(arg);
55098         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55099         arg_conv.is_owned = false;
55100         int64_t ret_conv = InvoiceError_clone_ptr(&arg_conv);
55101         return ret_conv;
55102 }
55103
55104 int64_t  CS_LDK_InvoiceError_clone(int64_t orig) {
55105         LDKInvoiceError orig_conv;
55106         orig_conv.inner = untag_ptr(orig);
55107         orig_conv.is_owned = ptr_is_owned(orig);
55108         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55109         orig_conv.is_owned = false;
55110         LDKInvoiceError ret_var = InvoiceError_clone(&orig_conv);
55111         int64_t ret_ref = 0;
55112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55114         return ret_ref;
55115 }
55116
55117 void  CS_LDK_ErroneousField_free(int64_t this_obj) {
55118         LDKErroneousField this_obj_conv;
55119         this_obj_conv.inner = untag_ptr(this_obj);
55120         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55122         ErroneousField_free(this_obj_conv);
55123 }
55124
55125 int64_t  CS_LDK_ErroneousField_get_tlv_fieldnum(int64_t this_ptr) {
55126         LDKErroneousField this_ptr_conv;
55127         this_ptr_conv.inner = untag_ptr(this_ptr);
55128         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55130         this_ptr_conv.is_owned = false;
55131         int64_t ret_conv = ErroneousField_get_tlv_fieldnum(&this_ptr_conv);
55132         return ret_conv;
55133 }
55134
55135 void  CS_LDK_ErroneousField_set_tlv_fieldnum(int64_t this_ptr, int64_t val) {
55136         LDKErroneousField this_ptr_conv;
55137         this_ptr_conv.inner = untag_ptr(this_ptr);
55138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55140         this_ptr_conv.is_owned = false;
55141         ErroneousField_set_tlv_fieldnum(&this_ptr_conv, val);
55142 }
55143
55144 int64_t  CS_LDK_ErroneousField_get_suggested_value(int64_t this_ptr) {
55145         LDKErroneousField this_ptr_conv;
55146         this_ptr_conv.inner = untag_ptr(this_ptr);
55147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55149         this_ptr_conv.is_owned = false;
55150         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
55151         *ret_copy = ErroneousField_get_suggested_value(&this_ptr_conv);
55152         int64_t ret_ref = tag_ptr(ret_copy, true);
55153         return ret_ref;
55154 }
55155
55156 void  CS_LDK_ErroneousField_set_suggested_value(int64_t this_ptr, int64_t val) {
55157         LDKErroneousField this_ptr_conv;
55158         this_ptr_conv.inner = untag_ptr(this_ptr);
55159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55161         this_ptr_conv.is_owned = false;
55162         void* val_ptr = untag_ptr(val);
55163         CHECK_ACCESS(val_ptr);
55164         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
55165         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
55166         ErroneousField_set_suggested_value(&this_ptr_conv, val_conv);
55167 }
55168
55169 int64_t  CS_LDK_ErroneousField_new(int64_t tlv_fieldnum_arg, int64_t suggested_value_arg) {
55170         void* suggested_value_arg_ptr = untag_ptr(suggested_value_arg);
55171         CHECK_ACCESS(suggested_value_arg_ptr);
55172         LDKCOption_CVec_u8ZZ suggested_value_arg_conv = *(LDKCOption_CVec_u8ZZ*)(suggested_value_arg_ptr);
55173         suggested_value_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(suggested_value_arg));
55174         LDKErroneousField ret_var = ErroneousField_new(tlv_fieldnum_arg, suggested_value_arg_conv);
55175         int64_t ret_ref = 0;
55176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55178         return ret_ref;
55179 }
55180
55181 static inline uint64_t ErroneousField_clone_ptr(LDKErroneousField *NONNULL_PTR arg) {
55182         LDKErroneousField ret_var = ErroneousField_clone(arg);
55183         int64_t ret_ref = 0;
55184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55185         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55186         return ret_ref;
55187 }
55188 int64_t  CS_LDK_ErroneousField_clone_ptr(int64_t arg) {
55189         LDKErroneousField arg_conv;
55190         arg_conv.inner = untag_ptr(arg);
55191         arg_conv.is_owned = ptr_is_owned(arg);
55192         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55193         arg_conv.is_owned = false;
55194         int64_t ret_conv = ErroneousField_clone_ptr(&arg_conv);
55195         return ret_conv;
55196 }
55197
55198 int64_t  CS_LDK_ErroneousField_clone(int64_t orig) {
55199         LDKErroneousField orig_conv;
55200         orig_conv.inner = untag_ptr(orig);
55201         orig_conv.is_owned = ptr_is_owned(orig);
55202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55203         orig_conv.is_owned = false;
55204         LDKErroneousField ret_var = ErroneousField_clone(&orig_conv);
55205         int64_t ret_ref = 0;
55206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55207         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55208         return ret_ref;
55209 }
55210
55211 int64_t  CS_LDK_InvoiceError_from_string(jstring s) {
55212         LDKStr s_conv = str_ref_to_owned_c(s);
55213         LDKInvoiceError ret_var = InvoiceError_from_string(s_conv);
55214         int64_t ret_ref = 0;
55215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55217         return ret_ref;
55218 }
55219
55220 int8_tArray  CS_LDK_InvoiceError_write(int64_t obj) {
55221         LDKInvoiceError obj_conv;
55222         obj_conv.inner = untag_ptr(obj);
55223         obj_conv.is_owned = ptr_is_owned(obj);
55224         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
55225         obj_conv.is_owned = false;
55226         LDKCVec_u8Z ret_var = InvoiceError_write(&obj_conv);
55227         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
55228         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
55229         CVec_u8Z_free(ret_var);
55230         return ret_arr;
55231 }
55232
55233 int64_t  CS_LDK_InvoiceError_read(int8_tArray ser) {
55234         LDKu8slice ser_ref;
55235         ser_ref.datalen = ser->arr_len;
55236         ser_ref.data = ser->elems;
55237         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
55238         *ret_conv = InvoiceError_read(ser_ref);
55239         FREE(ser);
55240         return tag_ptr(ret_conv, true);
55241 }
55242
55243 void  CS_LDK_UnsignedInvoiceRequest_free(int64_t this_obj) {
55244         LDKUnsignedInvoiceRequest this_obj_conv;
55245         this_obj_conv.inner = untag_ptr(this_obj);
55246         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55248         UnsignedInvoiceRequest_free(this_obj_conv);
55249 }
55250
55251 int64_t  CS_LDK_UnsignedInvoiceRequest_tagged_hash(int64_t this_arg) {
55252         LDKUnsignedInvoiceRequest this_arg_conv;
55253         this_arg_conv.inner = untag_ptr(this_arg);
55254         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55256         this_arg_conv.is_owned = false;
55257         LDKTaggedHash ret_var = UnsignedInvoiceRequest_tagged_hash(&this_arg_conv);
55258         int64_t ret_ref = 0;
55259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55260         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55261         return ret_ref;
55262 }
55263
55264 void  CS_LDK_InvoiceRequest_free(int64_t this_obj) {
55265         LDKInvoiceRequest this_obj_conv;
55266         this_obj_conv.inner = untag_ptr(this_obj);
55267         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55269         InvoiceRequest_free(this_obj_conv);
55270 }
55271
55272 static inline uint64_t InvoiceRequest_clone_ptr(LDKInvoiceRequest *NONNULL_PTR arg) {
55273         LDKInvoiceRequest ret_var = InvoiceRequest_clone(arg);
55274         int64_t ret_ref = 0;
55275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55277         return ret_ref;
55278 }
55279 int64_t  CS_LDK_InvoiceRequest_clone_ptr(int64_t arg) {
55280         LDKInvoiceRequest arg_conv;
55281         arg_conv.inner = untag_ptr(arg);
55282         arg_conv.is_owned = ptr_is_owned(arg);
55283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55284         arg_conv.is_owned = false;
55285         int64_t ret_conv = InvoiceRequest_clone_ptr(&arg_conv);
55286         return ret_conv;
55287 }
55288
55289 int64_t  CS_LDK_InvoiceRequest_clone(int64_t orig) {
55290         LDKInvoiceRequest orig_conv;
55291         orig_conv.inner = untag_ptr(orig);
55292         orig_conv.is_owned = ptr_is_owned(orig);
55293         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55294         orig_conv.is_owned = false;
55295         LDKInvoiceRequest ret_var = InvoiceRequest_clone(&orig_conv);
55296         int64_t ret_ref = 0;
55297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55299         return ret_ref;
55300 }
55301
55302 void  CS_LDK_VerifiedInvoiceRequest_free(int64_t this_obj) {
55303         LDKVerifiedInvoiceRequest this_obj_conv;
55304         this_obj_conv.inner = untag_ptr(this_obj);
55305         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55307         VerifiedInvoiceRequest_free(this_obj_conv);
55308 }
55309
55310 int64_t  CS_LDK_VerifiedInvoiceRequest_get_keys(int64_t this_ptr) {
55311         LDKVerifiedInvoiceRequest this_ptr_conv;
55312         this_ptr_conv.inner = untag_ptr(this_ptr);
55313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55315         this_ptr_conv.is_owned = false;
55316         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
55317         *ret_copy = VerifiedInvoiceRequest_get_keys(&this_ptr_conv);
55318         int64_t ret_ref = tag_ptr(ret_copy, true);
55319         return ret_ref;
55320 }
55321
55322 void  CS_LDK_VerifiedInvoiceRequest_set_keys(int64_t this_ptr, int64_t val) {
55323         LDKVerifiedInvoiceRequest this_ptr_conv;
55324         this_ptr_conv.inner = untag_ptr(this_ptr);
55325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55327         this_ptr_conv.is_owned = false;
55328         void* val_ptr = untag_ptr(val);
55329         CHECK_ACCESS(val_ptr);
55330         LDKCOption_SecretKeyZ val_conv = *(LDKCOption_SecretKeyZ*)(val_ptr);
55331         val_conv = COption_SecretKeyZ_clone((LDKCOption_SecretKeyZ*)untag_ptr(val));
55332         VerifiedInvoiceRequest_set_keys(&this_ptr_conv, val_conv);
55333 }
55334
55335 static inline uint64_t VerifiedInvoiceRequest_clone_ptr(LDKVerifiedInvoiceRequest *NONNULL_PTR arg) {
55336         LDKVerifiedInvoiceRequest ret_var = VerifiedInvoiceRequest_clone(arg);
55337         int64_t ret_ref = 0;
55338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55340         return ret_ref;
55341 }
55342 int64_t  CS_LDK_VerifiedInvoiceRequest_clone_ptr(int64_t arg) {
55343         LDKVerifiedInvoiceRequest arg_conv;
55344         arg_conv.inner = untag_ptr(arg);
55345         arg_conv.is_owned = ptr_is_owned(arg);
55346         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55347         arg_conv.is_owned = false;
55348         int64_t ret_conv = VerifiedInvoiceRequest_clone_ptr(&arg_conv);
55349         return ret_conv;
55350 }
55351
55352 int64_t  CS_LDK_VerifiedInvoiceRequest_clone(int64_t orig) {
55353         LDKVerifiedInvoiceRequest orig_conv;
55354         orig_conv.inner = untag_ptr(orig);
55355         orig_conv.is_owned = ptr_is_owned(orig);
55356         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55357         orig_conv.is_owned = false;
55358         LDKVerifiedInvoiceRequest ret_var = VerifiedInvoiceRequest_clone(&orig_conv);
55359         int64_t ret_ref = 0;
55360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55362         return ret_ref;
55363 }
55364
55365 ptrArray  CS_LDK_UnsignedInvoiceRequest_chains(int64_t this_arg) {
55366         LDKUnsignedInvoiceRequest this_arg_conv;
55367         this_arg_conv.inner = untag_ptr(this_arg);
55368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55370         this_arg_conv.is_owned = false;
55371         LDKCVec_ThirtyTwoBytesZ ret_var = UnsignedInvoiceRequest_chains(&this_arg_conv);
55372         ptrArray ret_arr = NULL;
55373         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
55374         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
55375         for (size_t i = 0; i < ret_var.datalen; i++) {
55376                 int8_tArray ret_conv_8_arr = init_int8_tArray(32, __LINE__);
55377                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].data, 32);
55378                 ret_arr_ptr[i] = ret_conv_8_arr;
55379         }
55380         
55381         FREE(ret_var.data);
55382         return ret_arr;
55383 }
55384
55385 int64_t  CS_LDK_UnsignedInvoiceRequest_metadata(int64_t this_arg) {
55386         LDKUnsignedInvoiceRequest this_arg_conv;
55387         this_arg_conv.inner = untag_ptr(this_arg);
55388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55390         this_arg_conv.is_owned = false;
55391         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
55392         *ret_copy = UnsignedInvoiceRequest_metadata(&this_arg_conv);
55393         int64_t ret_ref = tag_ptr(ret_copy, true);
55394         return ret_ref;
55395 }
55396
55397 int64_t  CS_LDK_UnsignedInvoiceRequest_amount(int64_t this_arg) {
55398         LDKUnsignedInvoiceRequest this_arg_conv;
55399         this_arg_conv.inner = untag_ptr(this_arg);
55400         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55402         this_arg_conv.is_owned = false;
55403         LDKAmount ret_var = UnsignedInvoiceRequest_amount(&this_arg_conv);
55404         int64_t ret_ref = 0;
55405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55407         return ret_ref;
55408 }
55409
55410 int64_t  CS_LDK_UnsignedInvoiceRequest_description(int64_t this_arg) {
55411         LDKUnsignedInvoiceRequest this_arg_conv;
55412         this_arg_conv.inner = untag_ptr(this_arg);
55413         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55415         this_arg_conv.is_owned = false;
55416         LDKPrintableString ret_var = UnsignedInvoiceRequest_description(&this_arg_conv);
55417         int64_t ret_ref = 0;
55418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55420         return ret_ref;
55421 }
55422
55423 int64_t  CS_LDK_UnsignedInvoiceRequest_offer_features(int64_t this_arg) {
55424         LDKUnsignedInvoiceRequest this_arg_conv;
55425         this_arg_conv.inner = untag_ptr(this_arg);
55426         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55428         this_arg_conv.is_owned = false;
55429         LDKOfferFeatures ret_var = UnsignedInvoiceRequest_offer_features(&this_arg_conv);
55430         int64_t ret_ref = 0;
55431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55432         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55433         return ret_ref;
55434 }
55435
55436 int64_t  CS_LDK_UnsignedInvoiceRequest_absolute_expiry(int64_t this_arg) {
55437         LDKUnsignedInvoiceRequest this_arg_conv;
55438         this_arg_conv.inner = untag_ptr(this_arg);
55439         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55441         this_arg_conv.is_owned = false;
55442         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55443         *ret_copy = UnsignedInvoiceRequest_absolute_expiry(&this_arg_conv);
55444         int64_t ret_ref = tag_ptr(ret_copy, true);
55445         return ret_ref;
55446 }
55447
55448 int64_t  CS_LDK_UnsignedInvoiceRequest_issuer(int64_t this_arg) {
55449         LDKUnsignedInvoiceRequest this_arg_conv;
55450         this_arg_conv.inner = untag_ptr(this_arg);
55451         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55453         this_arg_conv.is_owned = false;
55454         LDKPrintableString ret_var = UnsignedInvoiceRequest_issuer(&this_arg_conv);
55455         int64_t ret_ref = 0;
55456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55457         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55458         return ret_ref;
55459 }
55460
55461 int64_tArray  CS_LDK_UnsignedInvoiceRequest_paths(int64_t this_arg) {
55462         LDKUnsignedInvoiceRequest this_arg_conv;
55463         this_arg_conv.inner = untag_ptr(this_arg);
55464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55466         this_arg_conv.is_owned = false;
55467         LDKCVec_BlindedPathZ ret_var = UnsignedInvoiceRequest_paths(&this_arg_conv);
55468         int64_tArray ret_arr = NULL;
55469         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
55470         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
55471         for (size_t n = 0; n < ret_var.datalen; n++) {
55472                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
55473                 int64_t ret_conv_13_ref = 0;
55474                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
55475                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
55476                 ret_arr_ptr[n] = ret_conv_13_ref;
55477         }
55478         
55479         FREE(ret_var.data);
55480         return ret_arr;
55481 }
55482
55483 int64_t  CS_LDK_UnsignedInvoiceRequest_supported_quantity(int64_t this_arg) {
55484         LDKUnsignedInvoiceRequest this_arg_conv;
55485         this_arg_conv.inner = untag_ptr(this_arg);
55486         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55488         this_arg_conv.is_owned = false;
55489         LDKQuantity ret_var = UnsignedInvoiceRequest_supported_quantity(&this_arg_conv);
55490         int64_t ret_ref = 0;
55491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55493         return ret_ref;
55494 }
55495
55496 int8_tArray  CS_LDK_UnsignedInvoiceRequest_signing_pubkey(int64_t this_arg) {
55497         LDKUnsignedInvoiceRequest this_arg_conv;
55498         this_arg_conv.inner = untag_ptr(this_arg);
55499         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55501         this_arg_conv.is_owned = false;
55502         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55503         memcpy(ret_arr->elems, UnsignedInvoiceRequest_signing_pubkey(&this_arg_conv).compressed_form, 33);
55504         return ret_arr;
55505 }
55506
55507 int8_tArray  CS_LDK_UnsignedInvoiceRequest_payer_metadata(int64_t this_arg) {
55508         LDKUnsignedInvoiceRequest this_arg_conv;
55509         this_arg_conv.inner = untag_ptr(this_arg);
55510         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55512         this_arg_conv.is_owned = false;
55513         LDKu8slice ret_var = UnsignedInvoiceRequest_payer_metadata(&this_arg_conv);
55514         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
55515         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
55516         return ret_arr;
55517 }
55518
55519 int8_tArray  CS_LDK_UnsignedInvoiceRequest_chain(int64_t this_arg) {
55520         LDKUnsignedInvoiceRequest this_arg_conv;
55521         this_arg_conv.inner = untag_ptr(this_arg);
55522         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55524         this_arg_conv.is_owned = false;
55525         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
55526         memcpy(ret_arr->elems, UnsignedInvoiceRequest_chain(&this_arg_conv).data, 32);
55527         return ret_arr;
55528 }
55529
55530 int64_t  CS_LDK_UnsignedInvoiceRequest_amount_msats(int64_t this_arg) {
55531         LDKUnsignedInvoiceRequest this_arg_conv;
55532         this_arg_conv.inner = untag_ptr(this_arg);
55533         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55535         this_arg_conv.is_owned = false;
55536         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55537         *ret_copy = UnsignedInvoiceRequest_amount_msats(&this_arg_conv);
55538         int64_t ret_ref = tag_ptr(ret_copy, true);
55539         return ret_ref;
55540 }
55541
55542 int64_t  CS_LDK_UnsignedInvoiceRequest_invoice_request_features(int64_t this_arg) {
55543         LDKUnsignedInvoiceRequest this_arg_conv;
55544         this_arg_conv.inner = untag_ptr(this_arg);
55545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55547         this_arg_conv.is_owned = false;
55548         LDKInvoiceRequestFeatures ret_var = UnsignedInvoiceRequest_invoice_request_features(&this_arg_conv);
55549         int64_t ret_ref = 0;
55550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55552         return ret_ref;
55553 }
55554
55555 int64_t  CS_LDK_UnsignedInvoiceRequest_quantity(int64_t this_arg) {
55556         LDKUnsignedInvoiceRequest this_arg_conv;
55557         this_arg_conv.inner = untag_ptr(this_arg);
55558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55560         this_arg_conv.is_owned = false;
55561         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55562         *ret_copy = UnsignedInvoiceRequest_quantity(&this_arg_conv);
55563         int64_t ret_ref = tag_ptr(ret_copy, true);
55564         return ret_ref;
55565 }
55566
55567 int8_tArray  CS_LDK_UnsignedInvoiceRequest_payer_id(int64_t this_arg) {
55568         LDKUnsignedInvoiceRequest this_arg_conv;
55569         this_arg_conv.inner = untag_ptr(this_arg);
55570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55572         this_arg_conv.is_owned = false;
55573         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55574         memcpy(ret_arr->elems, UnsignedInvoiceRequest_payer_id(&this_arg_conv).compressed_form, 33);
55575         return ret_arr;
55576 }
55577
55578 int64_t  CS_LDK_UnsignedInvoiceRequest_payer_note(int64_t this_arg) {
55579         LDKUnsignedInvoiceRequest this_arg_conv;
55580         this_arg_conv.inner = untag_ptr(this_arg);
55581         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55583         this_arg_conv.is_owned = false;
55584         LDKPrintableString ret_var = UnsignedInvoiceRequest_payer_note(&this_arg_conv);
55585         int64_t ret_ref = 0;
55586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55588         return ret_ref;
55589 }
55590
55591 ptrArray  CS_LDK_InvoiceRequest_chains(int64_t this_arg) {
55592         LDKInvoiceRequest this_arg_conv;
55593         this_arg_conv.inner = untag_ptr(this_arg);
55594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55596         this_arg_conv.is_owned = false;
55597         LDKCVec_ThirtyTwoBytesZ ret_var = InvoiceRequest_chains(&this_arg_conv);
55598         ptrArray ret_arr = NULL;
55599         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
55600         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
55601         for (size_t i = 0; i < ret_var.datalen; i++) {
55602                 int8_tArray ret_conv_8_arr = init_int8_tArray(32, __LINE__);
55603                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].data, 32);
55604                 ret_arr_ptr[i] = ret_conv_8_arr;
55605         }
55606         
55607         FREE(ret_var.data);
55608         return ret_arr;
55609 }
55610
55611 int64_t  CS_LDK_InvoiceRequest_metadata(int64_t this_arg) {
55612         LDKInvoiceRequest this_arg_conv;
55613         this_arg_conv.inner = untag_ptr(this_arg);
55614         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55616         this_arg_conv.is_owned = false;
55617         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
55618         *ret_copy = InvoiceRequest_metadata(&this_arg_conv);
55619         int64_t ret_ref = tag_ptr(ret_copy, true);
55620         return ret_ref;
55621 }
55622
55623 int64_t  CS_LDK_InvoiceRequest_amount(int64_t this_arg) {
55624         LDKInvoiceRequest this_arg_conv;
55625         this_arg_conv.inner = untag_ptr(this_arg);
55626         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55628         this_arg_conv.is_owned = false;
55629         LDKAmount ret_var = InvoiceRequest_amount(&this_arg_conv);
55630         int64_t ret_ref = 0;
55631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55632         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55633         return ret_ref;
55634 }
55635
55636 int64_t  CS_LDK_InvoiceRequest_description(int64_t this_arg) {
55637         LDKInvoiceRequest this_arg_conv;
55638         this_arg_conv.inner = untag_ptr(this_arg);
55639         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55641         this_arg_conv.is_owned = false;
55642         LDKPrintableString ret_var = InvoiceRequest_description(&this_arg_conv);
55643         int64_t ret_ref = 0;
55644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55645         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55646         return ret_ref;
55647 }
55648
55649 int64_t  CS_LDK_InvoiceRequest_offer_features(int64_t this_arg) {
55650         LDKInvoiceRequest this_arg_conv;
55651         this_arg_conv.inner = untag_ptr(this_arg);
55652         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55654         this_arg_conv.is_owned = false;
55655         LDKOfferFeatures ret_var = InvoiceRequest_offer_features(&this_arg_conv);
55656         int64_t ret_ref = 0;
55657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55658         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55659         return ret_ref;
55660 }
55661
55662 int64_t  CS_LDK_InvoiceRequest_absolute_expiry(int64_t this_arg) {
55663         LDKInvoiceRequest this_arg_conv;
55664         this_arg_conv.inner = untag_ptr(this_arg);
55665         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55667         this_arg_conv.is_owned = false;
55668         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55669         *ret_copy = InvoiceRequest_absolute_expiry(&this_arg_conv);
55670         int64_t ret_ref = tag_ptr(ret_copy, true);
55671         return ret_ref;
55672 }
55673
55674 int64_t  CS_LDK_InvoiceRequest_issuer(int64_t this_arg) {
55675         LDKInvoiceRequest this_arg_conv;
55676         this_arg_conv.inner = untag_ptr(this_arg);
55677         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55679         this_arg_conv.is_owned = false;
55680         LDKPrintableString ret_var = InvoiceRequest_issuer(&this_arg_conv);
55681         int64_t ret_ref = 0;
55682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55684         return ret_ref;
55685 }
55686
55687 int64_tArray  CS_LDK_InvoiceRequest_paths(int64_t this_arg) {
55688         LDKInvoiceRequest this_arg_conv;
55689         this_arg_conv.inner = untag_ptr(this_arg);
55690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55692         this_arg_conv.is_owned = false;
55693         LDKCVec_BlindedPathZ ret_var = InvoiceRequest_paths(&this_arg_conv);
55694         int64_tArray ret_arr = NULL;
55695         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
55696         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
55697         for (size_t n = 0; n < ret_var.datalen; n++) {
55698                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
55699                 int64_t ret_conv_13_ref = 0;
55700                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
55701                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
55702                 ret_arr_ptr[n] = ret_conv_13_ref;
55703         }
55704         
55705         FREE(ret_var.data);
55706         return ret_arr;
55707 }
55708
55709 int64_t  CS_LDK_InvoiceRequest_supported_quantity(int64_t this_arg) {
55710         LDKInvoiceRequest this_arg_conv;
55711         this_arg_conv.inner = untag_ptr(this_arg);
55712         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55714         this_arg_conv.is_owned = false;
55715         LDKQuantity ret_var = InvoiceRequest_supported_quantity(&this_arg_conv);
55716         int64_t ret_ref = 0;
55717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55718         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55719         return ret_ref;
55720 }
55721
55722 int8_tArray  CS_LDK_InvoiceRequest_signing_pubkey(int64_t this_arg) {
55723         LDKInvoiceRequest this_arg_conv;
55724         this_arg_conv.inner = untag_ptr(this_arg);
55725         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55727         this_arg_conv.is_owned = false;
55728         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55729         memcpy(ret_arr->elems, InvoiceRequest_signing_pubkey(&this_arg_conv).compressed_form, 33);
55730         return ret_arr;
55731 }
55732
55733 int8_tArray  CS_LDK_InvoiceRequest_payer_metadata(int64_t this_arg) {
55734         LDKInvoiceRequest this_arg_conv;
55735         this_arg_conv.inner = untag_ptr(this_arg);
55736         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55738         this_arg_conv.is_owned = false;
55739         LDKu8slice ret_var = InvoiceRequest_payer_metadata(&this_arg_conv);
55740         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
55741         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
55742         return ret_arr;
55743 }
55744
55745 int8_tArray  CS_LDK_InvoiceRequest_chain(int64_t this_arg) {
55746         LDKInvoiceRequest this_arg_conv;
55747         this_arg_conv.inner = untag_ptr(this_arg);
55748         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55750         this_arg_conv.is_owned = false;
55751         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
55752         memcpy(ret_arr->elems, InvoiceRequest_chain(&this_arg_conv).data, 32);
55753         return ret_arr;
55754 }
55755
55756 int64_t  CS_LDK_InvoiceRequest_amount_msats(int64_t this_arg) {
55757         LDKInvoiceRequest this_arg_conv;
55758         this_arg_conv.inner = untag_ptr(this_arg);
55759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55761         this_arg_conv.is_owned = false;
55762         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55763         *ret_copy = InvoiceRequest_amount_msats(&this_arg_conv);
55764         int64_t ret_ref = tag_ptr(ret_copy, true);
55765         return ret_ref;
55766 }
55767
55768 int64_t  CS_LDK_InvoiceRequest_invoice_request_features(int64_t this_arg) {
55769         LDKInvoiceRequest this_arg_conv;
55770         this_arg_conv.inner = untag_ptr(this_arg);
55771         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55773         this_arg_conv.is_owned = false;
55774         LDKInvoiceRequestFeatures ret_var = InvoiceRequest_invoice_request_features(&this_arg_conv);
55775         int64_t ret_ref = 0;
55776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55778         return ret_ref;
55779 }
55780
55781 int64_t  CS_LDK_InvoiceRequest_quantity(int64_t this_arg) {
55782         LDKInvoiceRequest this_arg_conv;
55783         this_arg_conv.inner = untag_ptr(this_arg);
55784         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55786         this_arg_conv.is_owned = false;
55787         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55788         *ret_copy = InvoiceRequest_quantity(&this_arg_conv);
55789         int64_t ret_ref = tag_ptr(ret_copy, true);
55790         return ret_ref;
55791 }
55792
55793 int8_tArray  CS_LDK_InvoiceRequest_payer_id(int64_t this_arg) {
55794         LDKInvoiceRequest this_arg_conv;
55795         this_arg_conv.inner = untag_ptr(this_arg);
55796         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55798         this_arg_conv.is_owned = false;
55799         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55800         memcpy(ret_arr->elems, InvoiceRequest_payer_id(&this_arg_conv).compressed_form, 33);
55801         return ret_arr;
55802 }
55803
55804 int64_t  CS_LDK_InvoiceRequest_payer_note(int64_t this_arg) {
55805         LDKInvoiceRequest this_arg_conv;
55806         this_arg_conv.inner = untag_ptr(this_arg);
55807         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55809         this_arg_conv.is_owned = false;
55810         LDKPrintableString ret_var = InvoiceRequest_payer_note(&this_arg_conv);
55811         int64_t ret_ref = 0;
55812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55813         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55814         return ret_ref;
55815 }
55816
55817 int8_tArray  CS_LDK_InvoiceRequest_signature(int64_t this_arg) {
55818         LDKInvoiceRequest this_arg_conv;
55819         this_arg_conv.inner = untag_ptr(this_arg);
55820         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55822         this_arg_conv.is_owned = false;
55823         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
55824         memcpy(ret_arr->elems, InvoiceRequest_signature(&this_arg_conv).compact_form, 64);
55825         return ret_arr;
55826 }
55827
55828 int64_t  CS_LDK_InvoiceRequest_verify(int64_t this_arg, int64_t key) {
55829         LDKInvoiceRequest this_arg_conv;
55830         this_arg_conv.inner = untag_ptr(this_arg);
55831         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55833         this_arg_conv = InvoiceRequest_clone(&this_arg_conv);
55834         LDKExpandedKey key_conv;
55835         key_conv.inner = untag_ptr(key);
55836         key_conv.is_owned = ptr_is_owned(key);
55837         CHECK_INNER_FIELD_ACCESS_OR_NULL(key_conv);
55838         key_conv.is_owned = false;
55839         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
55840         *ret_conv = InvoiceRequest_verify(this_arg_conv, &key_conv);
55841         return tag_ptr(ret_conv, true);
55842 }
55843
55844 ptrArray  CS_LDK_VerifiedInvoiceRequest_chains(int64_t this_arg) {
55845         LDKVerifiedInvoiceRequest this_arg_conv;
55846         this_arg_conv.inner = untag_ptr(this_arg);
55847         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55849         this_arg_conv.is_owned = false;
55850         LDKCVec_ThirtyTwoBytesZ ret_var = VerifiedInvoiceRequest_chains(&this_arg_conv);
55851         ptrArray ret_arr = NULL;
55852         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
55853         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
55854         for (size_t i = 0; i < ret_var.datalen; i++) {
55855                 int8_tArray ret_conv_8_arr = init_int8_tArray(32, __LINE__);
55856                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].data, 32);
55857                 ret_arr_ptr[i] = ret_conv_8_arr;
55858         }
55859         
55860         FREE(ret_var.data);
55861         return ret_arr;
55862 }
55863
55864 int64_t  CS_LDK_VerifiedInvoiceRequest_metadata(int64_t this_arg) {
55865         LDKVerifiedInvoiceRequest this_arg_conv;
55866         this_arg_conv.inner = untag_ptr(this_arg);
55867         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55869         this_arg_conv.is_owned = false;
55870         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
55871         *ret_copy = VerifiedInvoiceRequest_metadata(&this_arg_conv);
55872         int64_t ret_ref = tag_ptr(ret_copy, true);
55873         return ret_ref;
55874 }
55875
55876 int64_t  CS_LDK_VerifiedInvoiceRequest_amount(int64_t this_arg) {
55877         LDKVerifiedInvoiceRequest this_arg_conv;
55878         this_arg_conv.inner = untag_ptr(this_arg);
55879         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55881         this_arg_conv.is_owned = false;
55882         LDKAmount ret_var = VerifiedInvoiceRequest_amount(&this_arg_conv);
55883         int64_t ret_ref = 0;
55884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55886         return ret_ref;
55887 }
55888
55889 int64_t  CS_LDK_VerifiedInvoiceRequest_description(int64_t this_arg) {
55890         LDKVerifiedInvoiceRequest this_arg_conv;
55891         this_arg_conv.inner = untag_ptr(this_arg);
55892         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55894         this_arg_conv.is_owned = false;
55895         LDKPrintableString ret_var = VerifiedInvoiceRequest_description(&this_arg_conv);
55896         int64_t ret_ref = 0;
55897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55899         return ret_ref;
55900 }
55901
55902 int64_t  CS_LDK_VerifiedInvoiceRequest_offer_features(int64_t this_arg) {
55903         LDKVerifiedInvoiceRequest this_arg_conv;
55904         this_arg_conv.inner = untag_ptr(this_arg);
55905         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55907         this_arg_conv.is_owned = false;
55908         LDKOfferFeatures ret_var = VerifiedInvoiceRequest_offer_features(&this_arg_conv);
55909         int64_t ret_ref = 0;
55910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55911         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55912         return ret_ref;
55913 }
55914
55915 int64_t  CS_LDK_VerifiedInvoiceRequest_absolute_expiry(int64_t this_arg) {
55916         LDKVerifiedInvoiceRequest this_arg_conv;
55917         this_arg_conv.inner = untag_ptr(this_arg);
55918         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55920         this_arg_conv.is_owned = false;
55921         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55922         *ret_copy = VerifiedInvoiceRequest_absolute_expiry(&this_arg_conv);
55923         int64_t ret_ref = tag_ptr(ret_copy, true);
55924         return ret_ref;
55925 }
55926
55927 int64_t  CS_LDK_VerifiedInvoiceRequest_issuer(int64_t this_arg) {
55928         LDKVerifiedInvoiceRequest this_arg_conv;
55929         this_arg_conv.inner = untag_ptr(this_arg);
55930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55932         this_arg_conv.is_owned = false;
55933         LDKPrintableString ret_var = VerifiedInvoiceRequest_issuer(&this_arg_conv);
55934         int64_t ret_ref = 0;
55935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55937         return ret_ref;
55938 }
55939
55940 int64_tArray  CS_LDK_VerifiedInvoiceRequest_paths(int64_t this_arg) {
55941         LDKVerifiedInvoiceRequest this_arg_conv;
55942         this_arg_conv.inner = untag_ptr(this_arg);
55943         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55945         this_arg_conv.is_owned = false;
55946         LDKCVec_BlindedPathZ ret_var = VerifiedInvoiceRequest_paths(&this_arg_conv);
55947         int64_tArray ret_arr = NULL;
55948         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
55949         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
55950         for (size_t n = 0; n < ret_var.datalen; n++) {
55951                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
55952                 int64_t ret_conv_13_ref = 0;
55953                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
55954                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
55955                 ret_arr_ptr[n] = ret_conv_13_ref;
55956         }
55957         
55958         FREE(ret_var.data);
55959         return ret_arr;
55960 }
55961
55962 int64_t  CS_LDK_VerifiedInvoiceRequest_supported_quantity(int64_t this_arg) {
55963         LDKVerifiedInvoiceRequest this_arg_conv;
55964         this_arg_conv.inner = untag_ptr(this_arg);
55965         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55967         this_arg_conv.is_owned = false;
55968         LDKQuantity ret_var = VerifiedInvoiceRequest_supported_quantity(&this_arg_conv);
55969         int64_t ret_ref = 0;
55970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55971         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55972         return ret_ref;
55973 }
55974
55975 int8_tArray  CS_LDK_VerifiedInvoiceRequest_signing_pubkey(int64_t this_arg) {
55976         LDKVerifiedInvoiceRequest this_arg_conv;
55977         this_arg_conv.inner = untag_ptr(this_arg);
55978         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55980         this_arg_conv.is_owned = false;
55981         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55982         memcpy(ret_arr->elems, VerifiedInvoiceRequest_signing_pubkey(&this_arg_conv).compressed_form, 33);
55983         return ret_arr;
55984 }
55985
55986 int8_tArray  CS_LDK_VerifiedInvoiceRequest_payer_metadata(int64_t this_arg) {
55987         LDKVerifiedInvoiceRequest this_arg_conv;
55988         this_arg_conv.inner = untag_ptr(this_arg);
55989         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55991         this_arg_conv.is_owned = false;
55992         LDKu8slice ret_var = VerifiedInvoiceRequest_payer_metadata(&this_arg_conv);
55993         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
55994         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
55995         return ret_arr;
55996 }
55997
55998 int8_tArray  CS_LDK_VerifiedInvoiceRequest_chain(int64_t this_arg) {
55999         LDKVerifiedInvoiceRequest this_arg_conv;
56000         this_arg_conv.inner = untag_ptr(this_arg);
56001         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56003         this_arg_conv.is_owned = false;
56004         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
56005         memcpy(ret_arr->elems, VerifiedInvoiceRequest_chain(&this_arg_conv).data, 32);
56006         return ret_arr;
56007 }
56008
56009 int64_t  CS_LDK_VerifiedInvoiceRequest_amount_msats(int64_t this_arg) {
56010         LDKVerifiedInvoiceRequest this_arg_conv;
56011         this_arg_conv.inner = untag_ptr(this_arg);
56012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56014         this_arg_conv.is_owned = false;
56015         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56016         *ret_copy = VerifiedInvoiceRequest_amount_msats(&this_arg_conv);
56017         int64_t ret_ref = tag_ptr(ret_copy, true);
56018         return ret_ref;
56019 }
56020
56021 int64_t  CS_LDK_VerifiedInvoiceRequest_invoice_request_features(int64_t this_arg) {
56022         LDKVerifiedInvoiceRequest this_arg_conv;
56023         this_arg_conv.inner = untag_ptr(this_arg);
56024         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56026         this_arg_conv.is_owned = false;
56027         LDKInvoiceRequestFeatures ret_var = VerifiedInvoiceRequest_invoice_request_features(&this_arg_conv);
56028         int64_t ret_ref = 0;
56029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56030         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56031         return ret_ref;
56032 }
56033
56034 int64_t  CS_LDK_VerifiedInvoiceRequest_quantity(int64_t this_arg) {
56035         LDKVerifiedInvoiceRequest this_arg_conv;
56036         this_arg_conv.inner = untag_ptr(this_arg);
56037         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56039         this_arg_conv.is_owned = false;
56040         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56041         *ret_copy = VerifiedInvoiceRequest_quantity(&this_arg_conv);
56042         int64_t ret_ref = tag_ptr(ret_copy, true);
56043         return ret_ref;
56044 }
56045
56046 int8_tArray  CS_LDK_VerifiedInvoiceRequest_payer_id(int64_t this_arg) {
56047         LDKVerifiedInvoiceRequest this_arg_conv;
56048         this_arg_conv.inner = untag_ptr(this_arg);
56049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56051         this_arg_conv.is_owned = false;
56052         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
56053         memcpy(ret_arr->elems, VerifiedInvoiceRequest_payer_id(&this_arg_conv).compressed_form, 33);
56054         return ret_arr;
56055 }
56056
56057 int64_t  CS_LDK_VerifiedInvoiceRequest_payer_note(int64_t this_arg) {
56058         LDKVerifiedInvoiceRequest this_arg_conv;
56059         this_arg_conv.inner = untag_ptr(this_arg);
56060         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56062         this_arg_conv.is_owned = false;
56063         LDKPrintableString ret_var = VerifiedInvoiceRequest_payer_note(&this_arg_conv);
56064         int64_t ret_ref = 0;
56065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56067         return ret_ref;
56068 }
56069
56070 int8_tArray  CS_LDK_UnsignedInvoiceRequest_write(int64_t obj) {
56071         LDKUnsignedInvoiceRequest obj_conv;
56072         obj_conv.inner = untag_ptr(obj);
56073         obj_conv.is_owned = ptr_is_owned(obj);
56074         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
56075         obj_conv.is_owned = false;
56076         LDKCVec_u8Z ret_var = UnsignedInvoiceRequest_write(&obj_conv);
56077         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56078         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56079         CVec_u8Z_free(ret_var);
56080         return ret_arr;
56081 }
56082
56083 int8_tArray  CS_LDK_InvoiceRequest_write(int64_t obj) {
56084         LDKInvoiceRequest obj_conv;
56085         obj_conv.inner = untag_ptr(obj);
56086         obj_conv.is_owned = ptr_is_owned(obj);
56087         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
56088         obj_conv.is_owned = false;
56089         LDKCVec_u8Z ret_var = InvoiceRequest_write(&obj_conv);
56090         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56091         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56092         CVec_u8Z_free(ret_var);
56093         return ret_arr;
56094 }
56095
56096 void  CS_LDK_TaggedHash_free(int64_t this_obj) {
56097         LDKTaggedHash this_obj_conv;
56098         this_obj_conv.inner = untag_ptr(this_obj);
56099         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56101         TaggedHash_free(this_obj_conv);
56102 }
56103
56104 void  CS_LDK_Bolt12ParseError_free(int64_t this_obj) {
56105         LDKBolt12ParseError this_obj_conv;
56106         this_obj_conv.inner = untag_ptr(this_obj);
56107         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56109         Bolt12ParseError_free(this_obj_conv);
56110 }
56111
56112 static inline uint64_t Bolt12ParseError_clone_ptr(LDKBolt12ParseError *NONNULL_PTR arg) {
56113         LDKBolt12ParseError ret_var = Bolt12ParseError_clone(arg);
56114         int64_t ret_ref = 0;
56115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56116         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56117         return ret_ref;
56118 }
56119 int64_t  CS_LDK_Bolt12ParseError_clone_ptr(int64_t arg) {
56120         LDKBolt12ParseError arg_conv;
56121         arg_conv.inner = untag_ptr(arg);
56122         arg_conv.is_owned = ptr_is_owned(arg);
56123         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56124         arg_conv.is_owned = false;
56125         int64_t ret_conv = Bolt12ParseError_clone_ptr(&arg_conv);
56126         return ret_conv;
56127 }
56128
56129 int64_t  CS_LDK_Bolt12ParseError_clone(int64_t orig) {
56130         LDKBolt12ParseError orig_conv;
56131         orig_conv.inner = untag_ptr(orig);
56132         orig_conv.is_owned = ptr_is_owned(orig);
56133         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56134         orig_conv.is_owned = false;
56135         LDKBolt12ParseError ret_var = Bolt12ParseError_clone(&orig_conv);
56136         int64_t ret_ref = 0;
56137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56138         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56139         return ret_ref;
56140 }
56141
56142 int32_t  CS_LDK_Bolt12SemanticError_clone(int64_t orig) {
56143         LDKBolt12SemanticError* orig_conv = (LDKBolt12SemanticError*)untag_ptr(orig);
56144         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_clone(orig_conv));
56145         return ret_conv;
56146 }
56147
56148 int32_t  CS_LDK_Bolt12SemanticError_already_expired() {
56149         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_already_expired());
56150         return ret_conv;
56151 }
56152
56153 int32_t  CS_LDK_Bolt12SemanticError_unsupported_chain() {
56154         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unsupported_chain());
56155         return ret_conv;
56156 }
56157
56158 int32_t  CS_LDK_Bolt12SemanticError_unexpected_chain() {
56159         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_chain());
56160         return ret_conv;
56161 }
56162
56163 int32_t  CS_LDK_Bolt12SemanticError_missing_amount() {
56164         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_amount());
56165         return ret_conv;
56166 }
56167
56168 int32_t  CS_LDK_Bolt12SemanticError_invalid_amount() {
56169         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_amount());
56170         return ret_conv;
56171 }
56172
56173 int32_t  CS_LDK_Bolt12SemanticError_insufficient_amount() {
56174         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_insufficient_amount());
56175         return ret_conv;
56176 }
56177
56178 int32_t  CS_LDK_Bolt12SemanticError_unexpected_amount() {
56179         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_amount());
56180         return ret_conv;
56181 }
56182
56183 int32_t  CS_LDK_Bolt12SemanticError_unsupported_currency() {
56184         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unsupported_currency());
56185         return ret_conv;
56186 }
56187
56188 int32_t  CS_LDK_Bolt12SemanticError_unknown_required_features() {
56189         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unknown_required_features());
56190         return ret_conv;
56191 }
56192
56193 int32_t  CS_LDK_Bolt12SemanticError_unexpected_features() {
56194         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_features());
56195         return ret_conv;
56196 }
56197
56198 int32_t  CS_LDK_Bolt12SemanticError_missing_description() {
56199         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_description());
56200         return ret_conv;
56201 }
56202
56203 int32_t  CS_LDK_Bolt12SemanticError_missing_signing_pubkey() {
56204         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_signing_pubkey());
56205         return ret_conv;
56206 }
56207
56208 int32_t  CS_LDK_Bolt12SemanticError_invalid_signing_pubkey() {
56209         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_signing_pubkey());
56210         return ret_conv;
56211 }
56212
56213 int32_t  CS_LDK_Bolt12SemanticError_unexpected_signing_pubkey() {
56214         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_signing_pubkey());
56215         return ret_conv;
56216 }
56217
56218 int32_t  CS_LDK_Bolt12SemanticError_missing_quantity() {
56219         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_quantity());
56220         return ret_conv;
56221 }
56222
56223 int32_t  CS_LDK_Bolt12SemanticError_invalid_quantity() {
56224         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_quantity());
56225         return ret_conv;
56226 }
56227
56228 int32_t  CS_LDK_Bolt12SemanticError_unexpected_quantity() {
56229         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_quantity());
56230         return ret_conv;
56231 }
56232
56233 int32_t  CS_LDK_Bolt12SemanticError_invalid_metadata() {
56234         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_metadata());
56235         return ret_conv;
56236 }
56237
56238 int32_t  CS_LDK_Bolt12SemanticError_unexpected_metadata() {
56239         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_metadata());
56240         return ret_conv;
56241 }
56242
56243 int32_t  CS_LDK_Bolt12SemanticError_missing_payer_metadata() {
56244         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_payer_metadata());
56245         return ret_conv;
56246 }
56247
56248 int32_t  CS_LDK_Bolt12SemanticError_missing_payer_id() {
56249         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_payer_id());
56250         return ret_conv;
56251 }
56252
56253 int32_t  CS_LDK_Bolt12SemanticError_duplicate_payment_id() {
56254         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_duplicate_payment_id());
56255         return ret_conv;
56256 }
56257
56258 int32_t  CS_LDK_Bolt12SemanticError_missing_paths() {
56259         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_paths());
56260         return ret_conv;
56261 }
56262
56263 int32_t  CS_LDK_Bolt12SemanticError_invalid_pay_info() {
56264         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_pay_info());
56265         return ret_conv;
56266 }
56267
56268 int32_t  CS_LDK_Bolt12SemanticError_missing_creation_time() {
56269         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_creation_time());
56270         return ret_conv;
56271 }
56272
56273 int32_t  CS_LDK_Bolt12SemanticError_missing_payment_hash() {
56274         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_payment_hash());
56275         return ret_conv;
56276 }
56277
56278 int32_t  CS_LDK_Bolt12SemanticError_missing_signature() {
56279         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_signature());
56280         return ret_conv;
56281 }
56282
56283 void  CS_LDK_Refund_free(int64_t this_obj) {
56284         LDKRefund this_obj_conv;
56285         this_obj_conv.inner = untag_ptr(this_obj);
56286         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56288         Refund_free(this_obj_conv);
56289 }
56290
56291 static inline uint64_t Refund_clone_ptr(LDKRefund *NONNULL_PTR arg) {
56292         LDKRefund ret_var = Refund_clone(arg);
56293         int64_t ret_ref = 0;
56294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56295         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56296         return ret_ref;
56297 }
56298 int64_t  CS_LDK_Refund_clone_ptr(int64_t arg) {
56299         LDKRefund arg_conv;
56300         arg_conv.inner = untag_ptr(arg);
56301         arg_conv.is_owned = ptr_is_owned(arg);
56302         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56303         arg_conv.is_owned = false;
56304         int64_t ret_conv = Refund_clone_ptr(&arg_conv);
56305         return ret_conv;
56306 }
56307
56308 int64_t  CS_LDK_Refund_clone(int64_t orig) {
56309         LDKRefund orig_conv;
56310         orig_conv.inner = untag_ptr(orig);
56311         orig_conv.is_owned = ptr_is_owned(orig);
56312         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56313         orig_conv.is_owned = false;
56314         LDKRefund ret_var = Refund_clone(&orig_conv);
56315         int64_t ret_ref = 0;
56316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56318         return ret_ref;
56319 }
56320
56321 int64_t  CS_LDK_Refund_description(int64_t this_arg) {
56322         LDKRefund this_arg_conv;
56323         this_arg_conv.inner = untag_ptr(this_arg);
56324         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56326         this_arg_conv.is_owned = false;
56327         LDKPrintableString ret_var = Refund_description(&this_arg_conv);
56328         int64_t ret_ref = 0;
56329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56330         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56331         return ret_ref;
56332 }
56333
56334 int64_t  CS_LDK_Refund_absolute_expiry(int64_t this_arg) {
56335         LDKRefund this_arg_conv;
56336         this_arg_conv.inner = untag_ptr(this_arg);
56337         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56339         this_arg_conv.is_owned = false;
56340         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56341         *ret_copy = Refund_absolute_expiry(&this_arg_conv);
56342         int64_t ret_ref = tag_ptr(ret_copy, true);
56343         return ret_ref;
56344 }
56345
56346 jboolean  CS_LDK_Refund_is_expired(int64_t this_arg) {
56347         LDKRefund this_arg_conv;
56348         this_arg_conv.inner = untag_ptr(this_arg);
56349         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56351         this_arg_conv.is_owned = false;
56352         jboolean ret_conv = Refund_is_expired(&this_arg_conv);
56353         return ret_conv;
56354 }
56355
56356 int64_t  CS_LDK_Refund_issuer(int64_t this_arg) {
56357         LDKRefund this_arg_conv;
56358         this_arg_conv.inner = untag_ptr(this_arg);
56359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56361         this_arg_conv.is_owned = false;
56362         LDKPrintableString ret_var = Refund_issuer(&this_arg_conv);
56363         int64_t ret_ref = 0;
56364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56366         return ret_ref;
56367 }
56368
56369 int64_tArray  CS_LDK_Refund_paths(int64_t this_arg) {
56370         LDKRefund this_arg_conv;
56371         this_arg_conv.inner = untag_ptr(this_arg);
56372         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56374         this_arg_conv.is_owned = false;
56375         LDKCVec_BlindedPathZ ret_var = Refund_paths(&this_arg_conv);
56376         int64_tArray ret_arr = NULL;
56377         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
56378         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
56379         for (size_t n = 0; n < ret_var.datalen; n++) {
56380                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
56381                 int64_t ret_conv_13_ref = 0;
56382                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
56383                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
56384                 ret_arr_ptr[n] = ret_conv_13_ref;
56385         }
56386         
56387         FREE(ret_var.data);
56388         return ret_arr;
56389 }
56390
56391 int8_tArray  CS_LDK_Refund_payer_metadata(int64_t this_arg) {
56392         LDKRefund this_arg_conv;
56393         this_arg_conv.inner = untag_ptr(this_arg);
56394         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56396         this_arg_conv.is_owned = false;
56397         LDKu8slice ret_var = Refund_payer_metadata(&this_arg_conv);
56398         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56399         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56400         return ret_arr;
56401 }
56402
56403 int8_tArray  CS_LDK_Refund_chain(int64_t this_arg) {
56404         LDKRefund this_arg_conv;
56405         this_arg_conv.inner = untag_ptr(this_arg);
56406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56408         this_arg_conv.is_owned = false;
56409         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
56410         memcpy(ret_arr->elems, Refund_chain(&this_arg_conv).data, 32);
56411         return ret_arr;
56412 }
56413
56414 int64_t  CS_LDK_Refund_amount_msats(int64_t this_arg) {
56415         LDKRefund this_arg_conv;
56416         this_arg_conv.inner = untag_ptr(this_arg);
56417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56419         this_arg_conv.is_owned = false;
56420         int64_t ret_conv = Refund_amount_msats(&this_arg_conv);
56421         return ret_conv;
56422 }
56423
56424 int64_t  CS_LDK_Refund_features(int64_t this_arg) {
56425         LDKRefund this_arg_conv;
56426         this_arg_conv.inner = untag_ptr(this_arg);
56427         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56429         this_arg_conv.is_owned = false;
56430         LDKInvoiceRequestFeatures ret_var = Refund_features(&this_arg_conv);
56431         int64_t ret_ref = 0;
56432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56433         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56434         return ret_ref;
56435 }
56436
56437 int64_t  CS_LDK_Refund_quantity(int64_t this_arg) {
56438         LDKRefund this_arg_conv;
56439         this_arg_conv.inner = untag_ptr(this_arg);
56440         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56442         this_arg_conv.is_owned = false;
56443         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56444         *ret_copy = Refund_quantity(&this_arg_conv);
56445         int64_t ret_ref = tag_ptr(ret_copy, true);
56446         return ret_ref;
56447 }
56448
56449 int8_tArray  CS_LDK_Refund_payer_id(int64_t this_arg) {
56450         LDKRefund this_arg_conv;
56451         this_arg_conv.inner = untag_ptr(this_arg);
56452         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56454         this_arg_conv.is_owned = false;
56455         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
56456         memcpy(ret_arr->elems, Refund_payer_id(&this_arg_conv).compressed_form, 33);
56457         return ret_arr;
56458 }
56459
56460 int64_t  CS_LDK_Refund_payer_note(int64_t this_arg) {
56461         LDKRefund this_arg_conv;
56462         this_arg_conv.inner = untag_ptr(this_arg);
56463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56465         this_arg_conv.is_owned = false;
56466         LDKPrintableString ret_var = Refund_payer_note(&this_arg_conv);
56467         int64_t ret_ref = 0;
56468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56470         return ret_ref;
56471 }
56472
56473 int8_tArray  CS_LDK_Refund_write(int64_t obj) {
56474         LDKRefund obj_conv;
56475         obj_conv.inner = untag_ptr(obj);
56476         obj_conv.is_owned = ptr_is_owned(obj);
56477         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
56478         obj_conv.is_owned = false;
56479         LDKCVec_u8Z ret_var = Refund_write(&obj_conv);
56480         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56481         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56482         CVec_u8Z_free(ret_var);
56483         return ret_arr;
56484 }
56485
56486 int64_t  CS_LDK_Refund_from_str(jstring s) {
56487         LDKStr s_conv = str_ref_to_owned_c(s);
56488         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
56489         *ret_conv = Refund_from_str(s_conv);
56490         return tag_ptr(ret_conv, true);
56491 }
56492
56493 int32_t  CS_LDK_UtxoLookupError_clone(int64_t orig) {
56494         LDKUtxoLookupError* orig_conv = (LDKUtxoLookupError*)untag_ptr(orig);
56495         int32_t ret_conv = LDKUtxoLookupError_to_cs(UtxoLookupError_clone(orig_conv));
56496         return ret_conv;
56497 }
56498
56499 int32_t  CS_LDK_UtxoLookupError_unknown_chain() {
56500         int32_t ret_conv = LDKUtxoLookupError_to_cs(UtxoLookupError_unknown_chain());
56501         return ret_conv;
56502 }
56503
56504 int32_t  CS_LDK_UtxoLookupError_unknown_tx() {
56505         int32_t ret_conv = LDKUtxoLookupError_to_cs(UtxoLookupError_unknown_tx());
56506         return ret_conv;
56507 }
56508
56509 void  CS_LDK_UtxoResult_free(int64_t this_ptr) {
56510         if (!ptr_is_owned(this_ptr)) return;
56511         void* this_ptr_ptr = untag_ptr(this_ptr);
56512         CHECK_ACCESS(this_ptr_ptr);
56513         LDKUtxoResult this_ptr_conv = *(LDKUtxoResult*)(this_ptr_ptr);
56514         FREE(untag_ptr(this_ptr));
56515         UtxoResult_free(this_ptr_conv);
56516 }
56517
56518 static inline uint64_t UtxoResult_clone_ptr(LDKUtxoResult *NONNULL_PTR arg) {
56519         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
56520         *ret_copy = UtxoResult_clone(arg);
56521         int64_t ret_ref = tag_ptr(ret_copy, true);
56522         return ret_ref;
56523 }
56524 int64_t  CS_LDK_UtxoResult_clone_ptr(int64_t arg) {
56525         LDKUtxoResult* arg_conv = (LDKUtxoResult*)untag_ptr(arg);
56526         int64_t ret_conv = UtxoResult_clone_ptr(arg_conv);
56527         return ret_conv;
56528 }
56529
56530 int64_t  CS_LDK_UtxoResult_clone(int64_t orig) {
56531         LDKUtxoResult* orig_conv = (LDKUtxoResult*)untag_ptr(orig);
56532         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
56533         *ret_copy = UtxoResult_clone(orig_conv);
56534         int64_t ret_ref = tag_ptr(ret_copy, true);
56535         return ret_ref;
56536 }
56537
56538 int64_t  CS_LDK_UtxoResult_sync(int64_t a) {
56539         void* a_ptr = untag_ptr(a);
56540         CHECK_ACCESS(a_ptr);
56541         LDKCResult_TxOutUtxoLookupErrorZ a_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(a_ptr);
56542         a_conv = CResult_TxOutUtxoLookupErrorZ_clone((LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(a));
56543         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
56544         *ret_copy = UtxoResult_sync(a_conv);
56545         int64_t ret_ref = tag_ptr(ret_copy, true);
56546         return ret_ref;
56547 }
56548
56549 int64_t  CS_LDK_UtxoResult_async(int64_t a) {
56550         LDKUtxoFuture a_conv;
56551         a_conv.inner = untag_ptr(a);
56552         a_conv.is_owned = ptr_is_owned(a);
56553         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56554         a_conv = UtxoFuture_clone(&a_conv);
56555         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
56556         *ret_copy = UtxoResult_async(a_conv);
56557         int64_t ret_ref = tag_ptr(ret_copy, true);
56558         return ret_ref;
56559 }
56560
56561 void  CS_LDK_UtxoLookup_free(int64_t this_ptr) {
56562         if (!ptr_is_owned(this_ptr)) return;
56563         void* this_ptr_ptr = untag_ptr(this_ptr);
56564         CHECK_ACCESS(this_ptr_ptr);
56565         LDKUtxoLookup this_ptr_conv = *(LDKUtxoLookup*)(this_ptr_ptr);
56566         FREE(untag_ptr(this_ptr));
56567         UtxoLookup_free(this_ptr_conv);
56568 }
56569
56570 void  CS_LDK_UtxoFuture_free(int64_t this_obj) {
56571         LDKUtxoFuture this_obj_conv;
56572         this_obj_conv.inner = untag_ptr(this_obj);
56573         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56575         UtxoFuture_free(this_obj_conv);
56576 }
56577
56578 static inline uint64_t UtxoFuture_clone_ptr(LDKUtxoFuture *NONNULL_PTR arg) {
56579         LDKUtxoFuture ret_var = UtxoFuture_clone(arg);
56580         int64_t ret_ref = 0;
56581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56582         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56583         return ret_ref;
56584 }
56585 int64_t  CS_LDK_UtxoFuture_clone_ptr(int64_t arg) {
56586         LDKUtxoFuture arg_conv;
56587         arg_conv.inner = untag_ptr(arg);
56588         arg_conv.is_owned = ptr_is_owned(arg);
56589         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56590         arg_conv.is_owned = false;
56591         int64_t ret_conv = UtxoFuture_clone_ptr(&arg_conv);
56592         return ret_conv;
56593 }
56594
56595 int64_t  CS_LDK_UtxoFuture_clone(int64_t orig) {
56596         LDKUtxoFuture orig_conv;
56597         orig_conv.inner = untag_ptr(orig);
56598         orig_conv.is_owned = ptr_is_owned(orig);
56599         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56600         orig_conv.is_owned = false;
56601         LDKUtxoFuture ret_var = UtxoFuture_clone(&orig_conv);
56602         int64_t ret_ref = 0;
56603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56604         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56605         return ret_ref;
56606 }
56607
56608 int64_t  CS_LDK_UtxoFuture_new() {
56609         LDKUtxoFuture ret_var = UtxoFuture_new();
56610         int64_t ret_ref = 0;
56611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56612         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56613         return ret_ref;
56614 }
56615
56616 void  CS_LDK_UtxoFuture_resolve_without_forwarding(int64_t this_arg, int64_t graph, int64_t result) {
56617         LDKUtxoFuture this_arg_conv;
56618         this_arg_conv.inner = untag_ptr(this_arg);
56619         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56621         this_arg_conv.is_owned = false;
56622         LDKNetworkGraph graph_conv;
56623         graph_conv.inner = untag_ptr(graph);
56624         graph_conv.is_owned = ptr_is_owned(graph);
56625         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
56626         graph_conv.is_owned = false;
56627         void* result_ptr = untag_ptr(result);
56628         CHECK_ACCESS(result_ptr);
56629         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
56630         UtxoFuture_resolve_without_forwarding(&this_arg_conv, &graph_conv, result_conv);
56631 }
56632
56633 void  CS_LDK_UtxoFuture_resolve(int64_t this_arg, int64_t graph, int64_t gossip, int64_t result) {
56634         LDKUtxoFuture this_arg_conv;
56635         this_arg_conv.inner = untag_ptr(this_arg);
56636         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56638         this_arg_conv.is_owned = false;
56639         LDKNetworkGraph graph_conv;
56640         graph_conv.inner = untag_ptr(graph);
56641         graph_conv.is_owned = ptr_is_owned(graph);
56642         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
56643         graph_conv.is_owned = false;
56644         LDKP2PGossipSync gossip_conv;
56645         gossip_conv.inner = untag_ptr(gossip);
56646         gossip_conv.is_owned = ptr_is_owned(gossip);
56647         CHECK_INNER_FIELD_ACCESS_OR_NULL(gossip_conv);
56648         gossip_conv.is_owned = false;
56649         void* result_ptr = untag_ptr(result);
56650         CHECK_ACCESS(result_ptr);
56651         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
56652         UtxoFuture_resolve(&this_arg_conv, &graph_conv, &gossip_conv, result_conv);
56653 }
56654
56655 void  CS_LDK_NodeId_free(int64_t this_obj) {
56656         LDKNodeId this_obj_conv;
56657         this_obj_conv.inner = untag_ptr(this_obj);
56658         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56660         NodeId_free(this_obj_conv);
56661 }
56662
56663 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
56664         LDKNodeId ret_var = NodeId_clone(arg);
56665         int64_t ret_ref = 0;
56666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56668         return ret_ref;
56669 }
56670 int64_t  CS_LDK_NodeId_clone_ptr(int64_t arg) {
56671         LDKNodeId arg_conv;
56672         arg_conv.inner = untag_ptr(arg);
56673         arg_conv.is_owned = ptr_is_owned(arg);
56674         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56675         arg_conv.is_owned = false;
56676         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
56677         return ret_conv;
56678 }
56679
56680 int64_t  CS_LDK_NodeId_clone(int64_t orig) {
56681         LDKNodeId orig_conv;
56682         orig_conv.inner = untag_ptr(orig);
56683         orig_conv.is_owned = ptr_is_owned(orig);
56684         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56685         orig_conv.is_owned = false;
56686         LDKNodeId ret_var = NodeId_clone(&orig_conv);
56687         int64_t ret_ref = 0;
56688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56690         return ret_ref;
56691 }
56692
56693 int64_t  CS_LDK_NodeId_from_pubkey(int8_tArray pubkey) {
56694         LDKPublicKey pubkey_ref;
56695         CHECK(pubkey->arr_len == 33);
56696         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
56697         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
56698         int64_t ret_ref = 0;
56699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56701         return ret_ref;
56702 }
56703
56704 int8_tArray  CS_LDK_NodeId_as_slice(int64_t this_arg) {
56705         LDKNodeId this_arg_conv;
56706         this_arg_conv.inner = untag_ptr(this_arg);
56707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56709         this_arg_conv.is_owned = false;
56710         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
56711         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56712         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56713         return ret_arr;
56714 }
56715
56716 int64_t  CS_LDK_NodeId_as_pubkey(int64_t this_arg) {
56717         LDKNodeId this_arg_conv;
56718         this_arg_conv.inner = untag_ptr(this_arg);
56719         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56721         this_arg_conv.is_owned = false;
56722         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
56723         *ret_conv = NodeId_as_pubkey(&this_arg_conv);
56724         return tag_ptr(ret_conv, true);
56725 }
56726
56727 int64_t  CS_LDK_NodeId_hash(int64_t o) {
56728         LDKNodeId o_conv;
56729         o_conv.inner = untag_ptr(o);
56730         o_conv.is_owned = ptr_is_owned(o);
56731         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56732         o_conv.is_owned = false;
56733         int64_t ret_conv = NodeId_hash(&o_conv);
56734         return ret_conv;
56735 }
56736
56737 int8_tArray  CS_LDK_NodeId_write(int64_t obj) {
56738         LDKNodeId obj_conv;
56739         obj_conv.inner = untag_ptr(obj);
56740         obj_conv.is_owned = ptr_is_owned(obj);
56741         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
56742         obj_conv.is_owned = false;
56743         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
56744         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56745         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56746         CVec_u8Z_free(ret_var);
56747         return ret_arr;
56748 }
56749
56750 int64_t  CS_LDK_NodeId_read(int8_tArray ser) {
56751         LDKu8slice ser_ref;
56752         ser_ref.datalen = ser->arr_len;
56753         ser_ref.data = ser->elems;
56754         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
56755         *ret_conv = NodeId_read(ser_ref);
56756         FREE(ser);
56757         return tag_ptr(ret_conv, true);
56758 }
56759
56760 void  CS_LDK_NetworkGraph_free(int64_t this_obj) {
56761         LDKNetworkGraph this_obj_conv;
56762         this_obj_conv.inner = untag_ptr(this_obj);
56763         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56765         NetworkGraph_free(this_obj_conv);
56766 }
56767
56768 void  CS_LDK_ReadOnlyNetworkGraph_free(int64_t this_obj) {
56769         LDKReadOnlyNetworkGraph this_obj_conv;
56770         this_obj_conv.inner = untag_ptr(this_obj);
56771         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56773         ReadOnlyNetworkGraph_free(this_obj_conv);
56774 }
56775
56776 void  CS_LDK_NetworkUpdate_free(int64_t this_ptr) {
56777         if (!ptr_is_owned(this_ptr)) return;
56778         void* this_ptr_ptr = untag_ptr(this_ptr);
56779         CHECK_ACCESS(this_ptr_ptr);
56780         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
56781         FREE(untag_ptr(this_ptr));
56782         NetworkUpdate_free(this_ptr_conv);
56783 }
56784
56785 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
56786         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56787         *ret_copy = NetworkUpdate_clone(arg);
56788         int64_t ret_ref = tag_ptr(ret_copy, true);
56789         return ret_ref;
56790 }
56791 int64_t  CS_LDK_NetworkUpdate_clone_ptr(int64_t arg) {
56792         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
56793         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
56794         return ret_conv;
56795 }
56796
56797 int64_t  CS_LDK_NetworkUpdate_clone(int64_t orig) {
56798         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
56799         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56800         *ret_copy = NetworkUpdate_clone(orig_conv);
56801         int64_t ret_ref = tag_ptr(ret_copy, true);
56802         return ret_ref;
56803 }
56804
56805 int64_t  CS_LDK_NetworkUpdate_channel_update_message(int64_t msg) {
56806         LDKChannelUpdate msg_conv;
56807         msg_conv.inner = untag_ptr(msg);
56808         msg_conv.is_owned = ptr_is_owned(msg);
56809         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
56810         msg_conv = ChannelUpdate_clone(&msg_conv);
56811         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56812         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
56813         int64_t ret_ref = tag_ptr(ret_copy, true);
56814         return ret_ref;
56815 }
56816
56817 int64_t  CS_LDK_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
56818         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56819         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
56820         int64_t ret_ref = tag_ptr(ret_copy, true);
56821         return ret_ref;
56822 }
56823
56824 int64_t  CS_LDK_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
56825         LDKPublicKey node_id_ref;
56826         CHECK(node_id->arr_len == 33);
56827         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
56828         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56829         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
56830         int64_t ret_ref = tag_ptr(ret_copy, true);
56831         return ret_ref;
56832 }
56833
56834 jboolean  CS_LDK_NetworkUpdate_eq(int64_t a, int64_t b) {
56835         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
56836         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
56837         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
56838         return ret_conv;
56839 }
56840
56841 int8_tArray  CS_LDK_NetworkUpdate_write(int64_t obj) {
56842         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
56843         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
56844         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56845         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56846         CVec_u8Z_free(ret_var);
56847         return ret_arr;
56848 }
56849
56850 int64_t  CS_LDK_NetworkUpdate_read(int8_tArray ser) {
56851         LDKu8slice ser_ref;
56852         ser_ref.datalen = ser->arr_len;
56853         ser_ref.data = ser->elems;
56854         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
56855         *ret_conv = NetworkUpdate_read(ser_ref);
56856         FREE(ser);
56857         return tag_ptr(ret_conv, true);
56858 }
56859
56860 void  CS_LDK_P2PGossipSync_free(int64_t this_obj) {
56861         LDKP2PGossipSync this_obj_conv;
56862         this_obj_conv.inner = untag_ptr(this_obj);
56863         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56865         P2PGossipSync_free(this_obj_conv);
56866 }
56867
56868 int64_t  CS_LDK_P2PGossipSync_new(int64_t network_graph, int64_t utxo_lookup, int64_t logger) {
56869         LDKNetworkGraph network_graph_conv;
56870         network_graph_conv.inner = untag_ptr(network_graph);
56871         network_graph_conv.is_owned = ptr_is_owned(network_graph);
56872         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
56873         network_graph_conv.is_owned = false;
56874         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
56875         CHECK_ACCESS(utxo_lookup_ptr);
56876         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
56877         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
56878         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
56879                 // Manually implement clone for Java trait instances
56880                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
56881                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
56882                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
56883                 }
56884         }
56885         void* logger_ptr = untag_ptr(logger);
56886         CHECK_ACCESS(logger_ptr);
56887         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
56888         if (logger_conv.free == LDKLogger_JCalls_free) {
56889                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
56890                 LDKLogger_JCalls_cloned(&logger_conv);
56891         }
56892         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, utxo_lookup_conv, logger_conv);
56893         int64_t ret_ref = 0;
56894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56896         return ret_ref;
56897 }
56898
56899 void  CS_LDK_P2PGossipSync_add_utxo_lookup(int64_t this_arg, int64_t utxo_lookup) {
56900         LDKP2PGossipSync this_arg_conv;
56901         this_arg_conv.inner = untag_ptr(this_arg);
56902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56904         this_arg_conv.is_owned = false;
56905         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
56906         CHECK_ACCESS(utxo_lookup_ptr);
56907         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
56908         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
56909         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
56910                 // Manually implement clone for Java trait instances
56911                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
56912                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
56913                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
56914                 }
56915         }
56916         P2PGossipSync_add_utxo_lookup(&this_arg_conv, utxo_lookup_conv);
56917 }
56918
56919 void  CS_LDK_NetworkGraph_handle_network_update(int64_t this_arg, int64_t network_update) {
56920         LDKNetworkGraph this_arg_conv;
56921         this_arg_conv.inner = untag_ptr(this_arg);
56922         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56924         this_arg_conv.is_owned = false;
56925         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
56926         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
56927 }
56928
56929 int8_tArray  CS_LDK_NetworkGraph_get_chain_hash(int64_t this_arg) {
56930         LDKNetworkGraph this_arg_conv;
56931         this_arg_conv.inner = untag_ptr(this_arg);
56932         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56934         this_arg_conv.is_owned = false;
56935         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
56936         memcpy(ret_arr->elems, NetworkGraph_get_chain_hash(&this_arg_conv).data, 32);
56937         return ret_arr;
56938 }
56939
56940 int64_t  CS_LDK_verify_node_announcement(int64_t msg) {
56941         LDKNodeAnnouncement msg_conv;
56942         msg_conv.inner = untag_ptr(msg);
56943         msg_conv.is_owned = ptr_is_owned(msg);
56944         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
56945         msg_conv.is_owned = false;
56946         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
56947         *ret_conv = verify_node_announcement(&msg_conv);
56948         return tag_ptr(ret_conv, true);
56949 }
56950
56951 int64_t  CS_LDK_verify_channel_announcement(int64_t msg) {
56952         LDKChannelAnnouncement msg_conv;
56953         msg_conv.inner = untag_ptr(msg);
56954         msg_conv.is_owned = ptr_is_owned(msg);
56955         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
56956         msg_conv.is_owned = false;
56957         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
56958         *ret_conv = verify_channel_announcement(&msg_conv);
56959         return tag_ptr(ret_conv, true);
56960 }
56961
56962 int64_t  CS_LDK_P2PGossipSync_as_RoutingMessageHandler(int64_t this_arg) {
56963         LDKP2PGossipSync this_arg_conv;
56964         this_arg_conv.inner = untag_ptr(this_arg);
56965         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56967         this_arg_conv.is_owned = false;
56968         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
56969         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
56970         return tag_ptr(ret_ret, true);
56971 }
56972
56973 int64_t  CS_LDK_P2PGossipSync_as_MessageSendEventsProvider(int64_t this_arg) {
56974         LDKP2PGossipSync this_arg_conv;
56975         this_arg_conv.inner = untag_ptr(this_arg);
56976         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56978         this_arg_conv.is_owned = false;
56979         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
56980         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
56981         return tag_ptr(ret_ret, true);
56982 }
56983
56984 void  CS_LDK_ChannelUpdateInfo_free(int64_t this_obj) {
56985         LDKChannelUpdateInfo this_obj_conv;
56986         this_obj_conv.inner = untag_ptr(this_obj);
56987         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56989         ChannelUpdateInfo_free(this_obj_conv);
56990 }
56991
56992 int32_t  CS_LDK_ChannelUpdateInfo_get_last_update(int64_t this_ptr) {
56993         LDKChannelUpdateInfo this_ptr_conv;
56994         this_ptr_conv.inner = untag_ptr(this_ptr);
56995         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56997         this_ptr_conv.is_owned = false;
56998         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
56999         return ret_conv;
57000 }
57001
57002 void  CS_LDK_ChannelUpdateInfo_set_last_update(int64_t this_ptr, int32_t val) {
57003         LDKChannelUpdateInfo this_ptr_conv;
57004         this_ptr_conv.inner = untag_ptr(this_ptr);
57005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57007         this_ptr_conv.is_owned = false;
57008         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
57009 }
57010
57011 jboolean  CS_LDK_ChannelUpdateInfo_get_enabled(int64_t this_ptr) {
57012         LDKChannelUpdateInfo this_ptr_conv;
57013         this_ptr_conv.inner = untag_ptr(this_ptr);
57014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57016         this_ptr_conv.is_owned = false;
57017         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
57018         return ret_conv;
57019 }
57020
57021 void  CS_LDK_ChannelUpdateInfo_set_enabled(int64_t this_ptr, jboolean val) {
57022         LDKChannelUpdateInfo this_ptr_conv;
57023         this_ptr_conv.inner = untag_ptr(this_ptr);
57024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57026         this_ptr_conv.is_owned = false;
57027         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
57028 }
57029
57030 int16_t  CS_LDK_ChannelUpdateInfo_get_cltv_expiry_delta(int64_t this_ptr) {
57031         LDKChannelUpdateInfo this_ptr_conv;
57032         this_ptr_conv.inner = untag_ptr(this_ptr);
57033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57035         this_ptr_conv.is_owned = false;
57036         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
57037         return ret_conv;
57038 }
57039
57040 void  CS_LDK_ChannelUpdateInfo_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
57041         LDKChannelUpdateInfo this_ptr_conv;
57042         this_ptr_conv.inner = untag_ptr(this_ptr);
57043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57045         this_ptr_conv.is_owned = false;
57046         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
57047 }
57048
57049 int64_t  CS_LDK_ChannelUpdateInfo_get_htlc_minimum_msat(int64_t this_ptr) {
57050         LDKChannelUpdateInfo this_ptr_conv;
57051         this_ptr_conv.inner = untag_ptr(this_ptr);
57052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57054         this_ptr_conv.is_owned = false;
57055         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
57056         return ret_conv;
57057 }
57058
57059 void  CS_LDK_ChannelUpdateInfo_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
57060         LDKChannelUpdateInfo this_ptr_conv;
57061         this_ptr_conv.inner = untag_ptr(this_ptr);
57062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57064         this_ptr_conv.is_owned = false;
57065         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
57066 }
57067
57068 int64_t  CS_LDK_ChannelUpdateInfo_get_htlc_maximum_msat(int64_t this_ptr) {
57069         LDKChannelUpdateInfo this_ptr_conv;
57070         this_ptr_conv.inner = untag_ptr(this_ptr);
57071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57073         this_ptr_conv.is_owned = false;
57074         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
57075         return ret_conv;
57076 }
57077
57078 void  CS_LDK_ChannelUpdateInfo_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
57079         LDKChannelUpdateInfo this_ptr_conv;
57080         this_ptr_conv.inner = untag_ptr(this_ptr);
57081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57083         this_ptr_conv.is_owned = false;
57084         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
57085 }
57086
57087 int64_t  CS_LDK_ChannelUpdateInfo_get_fees(int64_t this_ptr) {
57088         LDKChannelUpdateInfo this_ptr_conv;
57089         this_ptr_conv.inner = untag_ptr(this_ptr);
57090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57092         this_ptr_conv.is_owned = false;
57093         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
57094         int64_t ret_ref = 0;
57095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57097         return ret_ref;
57098 }
57099
57100 void  CS_LDK_ChannelUpdateInfo_set_fees(int64_t this_ptr, int64_t val) {
57101         LDKChannelUpdateInfo this_ptr_conv;
57102         this_ptr_conv.inner = untag_ptr(this_ptr);
57103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57105         this_ptr_conv.is_owned = false;
57106         LDKRoutingFees val_conv;
57107         val_conv.inner = untag_ptr(val);
57108         val_conv.is_owned = ptr_is_owned(val);
57109         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57110         val_conv = RoutingFees_clone(&val_conv);
57111         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
57112 }
57113
57114 int64_t  CS_LDK_ChannelUpdateInfo_get_last_update_message(int64_t this_ptr) {
57115         LDKChannelUpdateInfo this_ptr_conv;
57116         this_ptr_conv.inner = untag_ptr(this_ptr);
57117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57119         this_ptr_conv.is_owned = false;
57120         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
57121         int64_t ret_ref = 0;
57122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57124         return ret_ref;
57125 }
57126
57127 void  CS_LDK_ChannelUpdateInfo_set_last_update_message(int64_t this_ptr, int64_t val) {
57128         LDKChannelUpdateInfo this_ptr_conv;
57129         this_ptr_conv.inner = untag_ptr(this_ptr);
57130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57132         this_ptr_conv.is_owned = false;
57133         LDKChannelUpdate val_conv;
57134         val_conv.inner = untag_ptr(val);
57135         val_conv.is_owned = ptr_is_owned(val);
57136         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57137         val_conv = ChannelUpdate_clone(&val_conv);
57138         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
57139 }
57140
57141 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) {
57142         LDKRoutingFees fees_arg_conv;
57143         fees_arg_conv.inner = untag_ptr(fees_arg);
57144         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
57145         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
57146         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
57147         LDKChannelUpdate last_update_message_arg_conv;
57148         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
57149         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
57150         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
57151         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
57152         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);
57153         int64_t ret_ref = 0;
57154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57155         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57156         return ret_ref;
57157 }
57158
57159 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
57160         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
57161         int64_t ret_ref = 0;
57162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57163         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57164         return ret_ref;
57165 }
57166 int64_t  CS_LDK_ChannelUpdateInfo_clone_ptr(int64_t arg) {
57167         LDKChannelUpdateInfo arg_conv;
57168         arg_conv.inner = untag_ptr(arg);
57169         arg_conv.is_owned = ptr_is_owned(arg);
57170         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57171         arg_conv.is_owned = false;
57172         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
57173         return ret_conv;
57174 }
57175
57176 int64_t  CS_LDK_ChannelUpdateInfo_clone(int64_t orig) {
57177         LDKChannelUpdateInfo orig_conv;
57178         orig_conv.inner = untag_ptr(orig);
57179         orig_conv.is_owned = ptr_is_owned(orig);
57180         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57181         orig_conv.is_owned = false;
57182         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
57183         int64_t ret_ref = 0;
57184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57185         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57186         return ret_ref;
57187 }
57188
57189 jboolean  CS_LDK_ChannelUpdateInfo_eq(int64_t a, int64_t b) {
57190         LDKChannelUpdateInfo a_conv;
57191         a_conv.inner = untag_ptr(a);
57192         a_conv.is_owned = ptr_is_owned(a);
57193         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57194         a_conv.is_owned = false;
57195         LDKChannelUpdateInfo b_conv;
57196         b_conv.inner = untag_ptr(b);
57197         b_conv.is_owned = ptr_is_owned(b);
57198         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
57199         b_conv.is_owned = false;
57200         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
57201         return ret_conv;
57202 }
57203
57204 int8_tArray  CS_LDK_ChannelUpdateInfo_write(int64_t obj) {
57205         LDKChannelUpdateInfo obj_conv;
57206         obj_conv.inner = untag_ptr(obj);
57207         obj_conv.is_owned = ptr_is_owned(obj);
57208         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
57209         obj_conv.is_owned = false;
57210         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
57211         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
57212         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
57213         CVec_u8Z_free(ret_var);
57214         return ret_arr;
57215 }
57216
57217 int64_t  CS_LDK_ChannelUpdateInfo_read(int8_tArray ser) {
57218         LDKu8slice ser_ref;
57219         ser_ref.datalen = ser->arr_len;
57220         ser_ref.data = ser->elems;
57221         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
57222         *ret_conv = ChannelUpdateInfo_read(ser_ref);
57223         FREE(ser);
57224         return tag_ptr(ret_conv, true);
57225 }
57226
57227 void  CS_LDK_ChannelInfo_free(int64_t this_obj) {
57228         LDKChannelInfo this_obj_conv;
57229         this_obj_conv.inner = untag_ptr(this_obj);
57230         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57232         ChannelInfo_free(this_obj_conv);
57233 }
57234
57235 int64_t  CS_LDK_ChannelInfo_get_features(int64_t this_ptr) {
57236         LDKChannelInfo this_ptr_conv;
57237         this_ptr_conv.inner = untag_ptr(this_ptr);
57238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57240         this_ptr_conv.is_owned = false;
57241         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
57242         int64_t ret_ref = 0;
57243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57245         return ret_ref;
57246 }
57247
57248 void  CS_LDK_ChannelInfo_set_features(int64_t this_ptr, int64_t val) {
57249         LDKChannelInfo this_ptr_conv;
57250         this_ptr_conv.inner = untag_ptr(this_ptr);
57251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57253         this_ptr_conv.is_owned = false;
57254         LDKChannelFeatures val_conv;
57255         val_conv.inner = untag_ptr(val);
57256         val_conv.is_owned = ptr_is_owned(val);
57257         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57258         val_conv = ChannelFeatures_clone(&val_conv);
57259         ChannelInfo_set_features(&this_ptr_conv, val_conv);
57260 }
57261
57262 int64_t  CS_LDK_ChannelInfo_get_node_one(int64_t this_ptr) {
57263         LDKChannelInfo this_ptr_conv;
57264         this_ptr_conv.inner = untag_ptr(this_ptr);
57265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57267         this_ptr_conv.is_owned = false;
57268         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
57269         int64_t ret_ref = 0;
57270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57271         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57272         return ret_ref;
57273 }
57274
57275 void  CS_LDK_ChannelInfo_set_node_one(int64_t this_ptr, int64_t val) {
57276         LDKChannelInfo this_ptr_conv;
57277         this_ptr_conv.inner = untag_ptr(this_ptr);
57278         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57280         this_ptr_conv.is_owned = false;
57281         LDKNodeId val_conv;
57282         val_conv.inner = untag_ptr(val);
57283         val_conv.is_owned = ptr_is_owned(val);
57284         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57285         val_conv = NodeId_clone(&val_conv);
57286         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
57287 }
57288
57289 int64_t  CS_LDK_ChannelInfo_get_one_to_two(int64_t this_ptr) {
57290         LDKChannelInfo this_ptr_conv;
57291         this_ptr_conv.inner = untag_ptr(this_ptr);
57292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57294         this_ptr_conv.is_owned = false;
57295         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
57296         int64_t ret_ref = 0;
57297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57299         return ret_ref;
57300 }
57301
57302 void  CS_LDK_ChannelInfo_set_one_to_two(int64_t this_ptr, int64_t val) {
57303         LDKChannelInfo this_ptr_conv;
57304         this_ptr_conv.inner = untag_ptr(this_ptr);
57305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57307         this_ptr_conv.is_owned = false;
57308         LDKChannelUpdateInfo val_conv;
57309         val_conv.inner = untag_ptr(val);
57310         val_conv.is_owned = ptr_is_owned(val);
57311         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57312         val_conv = ChannelUpdateInfo_clone(&val_conv);
57313         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
57314 }
57315
57316 int64_t  CS_LDK_ChannelInfo_get_node_two(int64_t this_ptr) {
57317         LDKChannelInfo this_ptr_conv;
57318         this_ptr_conv.inner = untag_ptr(this_ptr);
57319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57321         this_ptr_conv.is_owned = false;
57322         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
57323         int64_t ret_ref = 0;
57324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57325         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57326         return ret_ref;
57327 }
57328
57329 void  CS_LDK_ChannelInfo_set_node_two(int64_t this_ptr, int64_t val) {
57330         LDKChannelInfo this_ptr_conv;
57331         this_ptr_conv.inner = untag_ptr(this_ptr);
57332         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57334         this_ptr_conv.is_owned = false;
57335         LDKNodeId val_conv;
57336         val_conv.inner = untag_ptr(val);
57337         val_conv.is_owned = ptr_is_owned(val);
57338         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57339         val_conv = NodeId_clone(&val_conv);
57340         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
57341 }
57342
57343 int64_t  CS_LDK_ChannelInfo_get_two_to_one(int64_t this_ptr) {
57344         LDKChannelInfo this_ptr_conv;
57345         this_ptr_conv.inner = untag_ptr(this_ptr);
57346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57348         this_ptr_conv.is_owned = false;
57349         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
57350         int64_t ret_ref = 0;
57351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57352         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57353         return ret_ref;
57354 }
57355
57356 void  CS_LDK_ChannelInfo_set_two_to_one(int64_t this_ptr, int64_t val) {
57357         LDKChannelInfo this_ptr_conv;
57358         this_ptr_conv.inner = untag_ptr(this_ptr);
57359         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57361         this_ptr_conv.is_owned = false;
57362         LDKChannelUpdateInfo val_conv;
57363         val_conv.inner = untag_ptr(val);
57364         val_conv.is_owned = ptr_is_owned(val);
57365         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57366         val_conv = ChannelUpdateInfo_clone(&val_conv);
57367         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
57368 }
57369
57370 int64_t  CS_LDK_ChannelInfo_get_capacity_sats(int64_t this_ptr) {
57371         LDKChannelInfo this_ptr_conv;
57372         this_ptr_conv.inner = untag_ptr(this_ptr);
57373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57375         this_ptr_conv.is_owned = false;
57376         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
57377         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
57378         int64_t ret_ref = tag_ptr(ret_copy, true);
57379         return ret_ref;
57380 }
57381
57382 void  CS_LDK_ChannelInfo_set_capacity_sats(int64_t this_ptr, int64_t val) {
57383         LDKChannelInfo this_ptr_conv;
57384         this_ptr_conv.inner = untag_ptr(this_ptr);
57385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57387         this_ptr_conv.is_owned = false;
57388         void* val_ptr = untag_ptr(val);
57389         CHECK_ACCESS(val_ptr);
57390         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
57391         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
57392         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
57393 }
57394
57395 int64_t  CS_LDK_ChannelInfo_get_announcement_message(int64_t this_ptr) {
57396         LDKChannelInfo this_ptr_conv;
57397         this_ptr_conv.inner = untag_ptr(this_ptr);
57398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57400         this_ptr_conv.is_owned = false;
57401         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
57402         int64_t ret_ref = 0;
57403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57404         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57405         return ret_ref;
57406 }
57407
57408 void  CS_LDK_ChannelInfo_set_announcement_message(int64_t this_ptr, int64_t val) {
57409         LDKChannelInfo this_ptr_conv;
57410         this_ptr_conv.inner = untag_ptr(this_ptr);
57411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57413         this_ptr_conv.is_owned = false;
57414         LDKChannelAnnouncement val_conv;
57415         val_conv.inner = untag_ptr(val);
57416         val_conv.is_owned = ptr_is_owned(val);
57417         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57418         val_conv = ChannelAnnouncement_clone(&val_conv);
57419         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
57420 }
57421
57422 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
57423         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
57424         int64_t ret_ref = 0;
57425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57426         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57427         return ret_ref;
57428 }
57429 int64_t  CS_LDK_ChannelInfo_clone_ptr(int64_t arg) {
57430         LDKChannelInfo arg_conv;
57431         arg_conv.inner = untag_ptr(arg);
57432         arg_conv.is_owned = ptr_is_owned(arg);
57433         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57434         arg_conv.is_owned = false;
57435         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
57436         return ret_conv;
57437 }
57438
57439 int64_t  CS_LDK_ChannelInfo_clone(int64_t orig) {
57440         LDKChannelInfo orig_conv;
57441         orig_conv.inner = untag_ptr(orig);
57442         orig_conv.is_owned = ptr_is_owned(orig);
57443         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57444         orig_conv.is_owned = false;
57445         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
57446         int64_t ret_ref = 0;
57447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57449         return ret_ref;
57450 }
57451
57452 jboolean  CS_LDK_ChannelInfo_eq(int64_t a, int64_t b) {
57453         LDKChannelInfo a_conv;
57454         a_conv.inner = untag_ptr(a);
57455         a_conv.is_owned = ptr_is_owned(a);
57456         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57457         a_conv.is_owned = false;
57458         LDKChannelInfo b_conv;
57459         b_conv.inner = untag_ptr(b);
57460         b_conv.is_owned = ptr_is_owned(b);
57461         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
57462         b_conv.is_owned = false;
57463         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
57464         return ret_conv;
57465 }
57466
57467 int64_t  CS_LDK_ChannelInfo_get_directional_info(int64_t this_arg, int8_t channel_flags) {
57468         LDKChannelInfo this_arg_conv;
57469         this_arg_conv.inner = untag_ptr(this_arg);
57470         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57472         this_arg_conv.is_owned = false;
57473         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
57474         int64_t ret_ref = 0;
57475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57477         return ret_ref;
57478 }
57479
57480 int8_tArray  CS_LDK_ChannelInfo_write(int64_t obj) {
57481         LDKChannelInfo obj_conv;
57482         obj_conv.inner = untag_ptr(obj);
57483         obj_conv.is_owned = ptr_is_owned(obj);
57484         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
57485         obj_conv.is_owned = false;
57486         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
57487         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
57488         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
57489         CVec_u8Z_free(ret_var);
57490         return ret_arr;
57491 }
57492
57493 int64_t  CS_LDK_ChannelInfo_read(int8_tArray ser) {
57494         LDKu8slice ser_ref;
57495         ser_ref.datalen = ser->arr_len;
57496         ser_ref.data = ser->elems;
57497         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
57498         *ret_conv = ChannelInfo_read(ser_ref);
57499         FREE(ser);
57500         return tag_ptr(ret_conv, true);
57501 }
57502
57503 void  CS_LDK_DirectedChannelInfo_free(int64_t this_obj) {
57504         LDKDirectedChannelInfo this_obj_conv;
57505         this_obj_conv.inner = untag_ptr(this_obj);
57506         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57508         DirectedChannelInfo_free(this_obj_conv);
57509 }
57510
57511 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
57512         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
57513         int64_t ret_ref = 0;
57514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57515         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57516         return ret_ref;
57517 }
57518 int64_t  CS_LDK_DirectedChannelInfo_clone_ptr(int64_t arg) {
57519         LDKDirectedChannelInfo arg_conv;
57520         arg_conv.inner = untag_ptr(arg);
57521         arg_conv.is_owned = ptr_is_owned(arg);
57522         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57523         arg_conv.is_owned = false;
57524         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
57525         return ret_conv;
57526 }
57527
57528 int64_t  CS_LDK_DirectedChannelInfo_clone(int64_t orig) {
57529         LDKDirectedChannelInfo orig_conv;
57530         orig_conv.inner = untag_ptr(orig);
57531         orig_conv.is_owned = ptr_is_owned(orig);
57532         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57533         orig_conv.is_owned = false;
57534         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
57535         int64_t ret_ref = 0;
57536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57537         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57538         return ret_ref;
57539 }
57540
57541 int64_t  CS_LDK_DirectedChannelInfo_channel(int64_t this_arg) {
57542         LDKDirectedChannelInfo this_arg_conv;
57543         this_arg_conv.inner = untag_ptr(this_arg);
57544         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57546         this_arg_conv.is_owned = false;
57547         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
57548         int64_t ret_ref = 0;
57549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57550         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57551         return ret_ref;
57552 }
57553
57554 int64_t  CS_LDK_DirectedChannelInfo_htlc_maximum_msat(int64_t this_arg) {
57555         LDKDirectedChannelInfo this_arg_conv;
57556         this_arg_conv.inner = untag_ptr(this_arg);
57557         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57559         this_arg_conv.is_owned = false;
57560         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
57561         return ret_conv;
57562 }
57563
57564 int64_t  CS_LDK_DirectedChannelInfo_effective_capacity(int64_t this_arg) {
57565         LDKDirectedChannelInfo this_arg_conv;
57566         this_arg_conv.inner = untag_ptr(this_arg);
57567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57569         this_arg_conv.is_owned = false;
57570         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57571         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
57572         int64_t ret_ref = tag_ptr(ret_copy, true);
57573         return ret_ref;
57574 }
57575
57576 void  CS_LDK_EffectiveCapacity_free(int64_t this_ptr) {
57577         if (!ptr_is_owned(this_ptr)) return;
57578         void* this_ptr_ptr = untag_ptr(this_ptr);
57579         CHECK_ACCESS(this_ptr_ptr);
57580         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
57581         FREE(untag_ptr(this_ptr));
57582         EffectiveCapacity_free(this_ptr_conv);
57583 }
57584
57585 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
57586         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57587         *ret_copy = EffectiveCapacity_clone(arg);
57588         int64_t ret_ref = tag_ptr(ret_copy, true);
57589         return ret_ref;
57590 }
57591 int64_t  CS_LDK_EffectiveCapacity_clone_ptr(int64_t arg) {
57592         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
57593         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
57594         return ret_conv;
57595 }
57596
57597 int64_t  CS_LDK_EffectiveCapacity_clone(int64_t orig) {
57598         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
57599         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57600         *ret_copy = EffectiveCapacity_clone(orig_conv);
57601         int64_t ret_ref = tag_ptr(ret_copy, true);
57602         return ret_ref;
57603 }
57604
57605 int64_t  CS_LDK_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
57606         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57607         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
57608         int64_t ret_ref = tag_ptr(ret_copy, true);
57609         return ret_ref;
57610 }
57611
57612 int64_t  CS_LDK_EffectiveCapacity_advertised_max_htlc(int64_t amount_msat) {
57613         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57614         *ret_copy = EffectiveCapacity_advertised_max_htlc(amount_msat);
57615         int64_t ret_ref = tag_ptr(ret_copy, true);
57616         return ret_ref;
57617 }
57618
57619 int64_t  CS_LDK_EffectiveCapacity_total(int64_t capacity_msat, int64_t htlc_maximum_msat) {
57620         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57621         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
57622         int64_t ret_ref = tag_ptr(ret_copy, true);
57623         return ret_ref;
57624 }
57625
57626 int64_t  CS_LDK_EffectiveCapacity_infinite() {
57627         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57628         *ret_copy = EffectiveCapacity_infinite();
57629         int64_t ret_ref = tag_ptr(ret_copy, true);
57630         return ret_ref;
57631 }
57632
57633 int64_t  CS_LDK_EffectiveCapacity_hint_max_htlc(int64_t amount_msat) {
57634         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57635         *ret_copy = EffectiveCapacity_hint_max_htlc(amount_msat);
57636         int64_t ret_ref = tag_ptr(ret_copy, true);
57637         return ret_ref;
57638 }
57639
57640 int64_t  CS_LDK_EffectiveCapacity_unknown() {
57641         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57642         *ret_copy = EffectiveCapacity_unknown();
57643         int64_t ret_ref = tag_ptr(ret_copy, true);
57644         return ret_ref;
57645 }
57646
57647 int64_t  CS_LDK_EffectiveCapacity_as_msat(int64_t this_arg) {
57648         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
57649         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
57650         return ret_conv;
57651 }
57652
57653 void  CS_LDK_RoutingFees_free(int64_t this_obj) {
57654         LDKRoutingFees this_obj_conv;
57655         this_obj_conv.inner = untag_ptr(this_obj);
57656         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57658         RoutingFees_free(this_obj_conv);
57659 }
57660
57661 int32_t  CS_LDK_RoutingFees_get_base_msat(int64_t this_ptr) {
57662         LDKRoutingFees this_ptr_conv;
57663         this_ptr_conv.inner = untag_ptr(this_ptr);
57664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57666         this_ptr_conv.is_owned = false;
57667         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
57668         return ret_conv;
57669 }
57670
57671 void  CS_LDK_RoutingFees_set_base_msat(int64_t this_ptr, int32_t val) {
57672         LDKRoutingFees this_ptr_conv;
57673         this_ptr_conv.inner = untag_ptr(this_ptr);
57674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57676         this_ptr_conv.is_owned = false;
57677         RoutingFees_set_base_msat(&this_ptr_conv, val);
57678 }
57679
57680 int32_t  CS_LDK_RoutingFees_get_proportional_millionths(int64_t this_ptr) {
57681         LDKRoutingFees this_ptr_conv;
57682         this_ptr_conv.inner = untag_ptr(this_ptr);
57683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57685         this_ptr_conv.is_owned = false;
57686         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
57687         return ret_conv;
57688 }
57689
57690 void  CS_LDK_RoutingFees_set_proportional_millionths(int64_t this_ptr, int32_t val) {
57691         LDKRoutingFees this_ptr_conv;
57692         this_ptr_conv.inner = untag_ptr(this_ptr);
57693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57695         this_ptr_conv.is_owned = false;
57696         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
57697 }
57698
57699 int64_t  CS_LDK_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
57700         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
57701         int64_t ret_ref = 0;
57702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57704         return ret_ref;
57705 }
57706
57707 jboolean  CS_LDK_RoutingFees_eq(int64_t a, int64_t b) {
57708         LDKRoutingFees a_conv;
57709         a_conv.inner = untag_ptr(a);
57710         a_conv.is_owned = ptr_is_owned(a);
57711         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57712         a_conv.is_owned = false;
57713         LDKRoutingFees b_conv;
57714         b_conv.inner = untag_ptr(b);
57715         b_conv.is_owned = ptr_is_owned(b);
57716         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
57717         b_conv.is_owned = false;
57718         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
57719         return ret_conv;
57720 }
57721
57722 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
57723         LDKRoutingFees ret_var = RoutingFees_clone(arg);
57724         int64_t ret_ref = 0;
57725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57727         return ret_ref;
57728 }
57729 int64_t  CS_LDK_RoutingFees_clone_ptr(int64_t arg) {
57730         LDKRoutingFees arg_conv;
57731         arg_conv.inner = untag_ptr(arg);
57732         arg_conv.is_owned = ptr_is_owned(arg);
57733         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57734         arg_conv.is_owned = false;
57735         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
57736         return ret_conv;
57737 }
57738
57739 int64_t  CS_LDK_RoutingFees_clone(int64_t orig) {
57740         LDKRoutingFees orig_conv;
57741         orig_conv.inner = untag_ptr(orig);
57742         orig_conv.is_owned = ptr_is_owned(orig);
57743         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57744         orig_conv.is_owned = false;
57745         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
57746         int64_t ret_ref = 0;
57747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57749         return ret_ref;
57750 }
57751
57752 int64_t  CS_LDK_RoutingFees_hash(int64_t o) {
57753         LDKRoutingFees o_conv;
57754         o_conv.inner = untag_ptr(o);
57755         o_conv.is_owned = ptr_is_owned(o);
57756         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57757         o_conv.is_owned = false;
57758         int64_t ret_conv = RoutingFees_hash(&o_conv);
57759         return ret_conv;
57760 }
57761
57762 int8_tArray  CS_LDK_RoutingFees_write(int64_t obj) {
57763         LDKRoutingFees obj_conv;
57764         obj_conv.inner = untag_ptr(obj);
57765         obj_conv.is_owned = ptr_is_owned(obj);
57766         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
57767         obj_conv.is_owned = false;
57768         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
57769         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
57770         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
57771         CVec_u8Z_free(ret_var);
57772         return ret_arr;
57773 }
57774
57775 int64_t  CS_LDK_RoutingFees_read(int8_tArray ser) {
57776         LDKu8slice ser_ref;
57777         ser_ref.datalen = ser->arr_len;
57778         ser_ref.data = ser->elems;
57779         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
57780         *ret_conv = RoutingFees_read(ser_ref);
57781         FREE(ser);
57782         return tag_ptr(ret_conv, true);
57783 }
57784
57785 void  CS_LDK_NodeAnnouncementInfo_free(int64_t this_obj) {
57786         LDKNodeAnnouncementInfo this_obj_conv;
57787         this_obj_conv.inner = untag_ptr(this_obj);
57788         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57790         NodeAnnouncementInfo_free(this_obj_conv);
57791 }
57792
57793 int64_t  CS_LDK_NodeAnnouncementInfo_get_features(int64_t this_ptr) {
57794         LDKNodeAnnouncementInfo this_ptr_conv;
57795         this_ptr_conv.inner = untag_ptr(this_ptr);
57796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57798         this_ptr_conv.is_owned = false;
57799         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
57800         int64_t ret_ref = 0;
57801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57803         return ret_ref;
57804 }
57805
57806 void  CS_LDK_NodeAnnouncementInfo_set_features(int64_t this_ptr, int64_t val) {
57807         LDKNodeAnnouncementInfo this_ptr_conv;
57808         this_ptr_conv.inner = untag_ptr(this_ptr);
57809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57811         this_ptr_conv.is_owned = false;
57812         LDKNodeFeatures val_conv;
57813         val_conv.inner = untag_ptr(val);
57814         val_conv.is_owned = ptr_is_owned(val);
57815         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57816         val_conv = NodeFeatures_clone(&val_conv);
57817         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
57818 }
57819
57820 int32_t  CS_LDK_NodeAnnouncementInfo_get_last_update(int64_t this_ptr) {
57821         LDKNodeAnnouncementInfo this_ptr_conv;
57822         this_ptr_conv.inner = untag_ptr(this_ptr);
57823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57825         this_ptr_conv.is_owned = false;
57826         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
57827         return ret_conv;
57828 }
57829
57830 void  CS_LDK_NodeAnnouncementInfo_set_last_update(int64_t this_ptr, int32_t val) {
57831         LDKNodeAnnouncementInfo this_ptr_conv;
57832         this_ptr_conv.inner = untag_ptr(this_ptr);
57833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57835         this_ptr_conv.is_owned = false;
57836         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
57837 }
57838
57839 int8_tArray  CS_LDK_NodeAnnouncementInfo_get_rgb(int64_t this_ptr) {
57840         LDKNodeAnnouncementInfo this_ptr_conv;
57841         this_ptr_conv.inner = untag_ptr(this_ptr);
57842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57844         this_ptr_conv.is_owned = false;
57845         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
57846         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
57847         return ret_arr;
57848 }
57849
57850 void  CS_LDK_NodeAnnouncementInfo_set_rgb(int64_t this_ptr, int8_tArray val) {
57851         LDKNodeAnnouncementInfo this_ptr_conv;
57852         this_ptr_conv.inner = untag_ptr(this_ptr);
57853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57855         this_ptr_conv.is_owned = false;
57856         LDKThreeBytes val_ref;
57857         CHECK(val->arr_len == 3);
57858         memcpy(val_ref.data, val->elems, 3); FREE(val);
57859         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
57860 }
57861
57862 int64_t  CS_LDK_NodeAnnouncementInfo_get_alias(int64_t this_ptr) {
57863         LDKNodeAnnouncementInfo this_ptr_conv;
57864         this_ptr_conv.inner = untag_ptr(this_ptr);
57865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57867         this_ptr_conv.is_owned = false;
57868         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
57869         int64_t ret_ref = 0;
57870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57872         return ret_ref;
57873 }
57874
57875 void  CS_LDK_NodeAnnouncementInfo_set_alias(int64_t this_ptr, int64_t val) {
57876         LDKNodeAnnouncementInfo this_ptr_conv;
57877         this_ptr_conv.inner = untag_ptr(this_ptr);
57878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57880         this_ptr_conv.is_owned = false;
57881         LDKNodeAlias val_conv;
57882         val_conv.inner = untag_ptr(val);
57883         val_conv.is_owned = ptr_is_owned(val);
57884         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57885         val_conv = NodeAlias_clone(&val_conv);
57886         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
57887 }
57888
57889 int64_t  CS_LDK_NodeAnnouncementInfo_get_announcement_message(int64_t this_ptr) {
57890         LDKNodeAnnouncementInfo this_ptr_conv;
57891         this_ptr_conv.inner = untag_ptr(this_ptr);
57892         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57894         this_ptr_conv.is_owned = false;
57895         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
57896         int64_t ret_ref = 0;
57897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57899         return ret_ref;
57900 }
57901
57902 void  CS_LDK_NodeAnnouncementInfo_set_announcement_message(int64_t this_ptr, int64_t val) {
57903         LDKNodeAnnouncementInfo this_ptr_conv;
57904         this_ptr_conv.inner = untag_ptr(this_ptr);
57905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57907         this_ptr_conv.is_owned = false;
57908         LDKNodeAnnouncement val_conv;
57909         val_conv.inner = untag_ptr(val);
57910         val_conv.is_owned = ptr_is_owned(val);
57911         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57912         val_conv = NodeAnnouncement_clone(&val_conv);
57913         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
57914 }
57915
57916 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) {
57917         LDKNodeFeatures features_arg_conv;
57918         features_arg_conv.inner = untag_ptr(features_arg);
57919         features_arg_conv.is_owned = ptr_is_owned(features_arg);
57920         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
57921         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
57922         LDKThreeBytes rgb_arg_ref;
57923         CHECK(rgb_arg->arr_len == 3);
57924         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
57925         LDKNodeAlias alias_arg_conv;
57926         alias_arg_conv.inner = untag_ptr(alias_arg);
57927         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
57928         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
57929         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
57930         LDKNodeAnnouncement announcement_message_arg_conv;
57931         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
57932         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
57933         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
57934         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
57935         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, announcement_message_arg_conv);
57936         int64_t ret_ref = 0;
57937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57939         return ret_ref;
57940 }
57941
57942 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
57943         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
57944         int64_t ret_ref = 0;
57945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57947         return ret_ref;
57948 }
57949 int64_t  CS_LDK_NodeAnnouncementInfo_clone_ptr(int64_t arg) {
57950         LDKNodeAnnouncementInfo arg_conv;
57951         arg_conv.inner = untag_ptr(arg);
57952         arg_conv.is_owned = ptr_is_owned(arg);
57953         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57954         arg_conv.is_owned = false;
57955         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
57956         return ret_conv;
57957 }
57958
57959 int64_t  CS_LDK_NodeAnnouncementInfo_clone(int64_t orig) {
57960         LDKNodeAnnouncementInfo orig_conv;
57961         orig_conv.inner = untag_ptr(orig);
57962         orig_conv.is_owned = ptr_is_owned(orig);
57963         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57964         orig_conv.is_owned = false;
57965         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
57966         int64_t ret_ref = 0;
57967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57969         return ret_ref;
57970 }
57971
57972 jboolean  CS_LDK_NodeAnnouncementInfo_eq(int64_t a, int64_t b) {
57973         LDKNodeAnnouncementInfo a_conv;
57974         a_conv.inner = untag_ptr(a);
57975         a_conv.is_owned = ptr_is_owned(a);
57976         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57977         a_conv.is_owned = false;
57978         LDKNodeAnnouncementInfo b_conv;
57979         b_conv.inner = untag_ptr(b);
57980         b_conv.is_owned = ptr_is_owned(b);
57981         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
57982         b_conv.is_owned = false;
57983         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
57984         return ret_conv;
57985 }
57986
57987 int64_tArray  CS_LDK_NodeAnnouncementInfo_addresses(int64_t this_arg) {
57988         LDKNodeAnnouncementInfo this_arg_conv;
57989         this_arg_conv.inner = untag_ptr(this_arg);
57990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57992         this_arg_conv.is_owned = false;
57993         LDKCVec_SocketAddressZ ret_var = NodeAnnouncementInfo_addresses(&this_arg_conv);
57994         int64_tArray ret_arr = NULL;
57995         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
57996         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
57997         for (size_t p = 0; p < ret_var.datalen; p++) {
57998                 LDKSocketAddress *ret_conv_15_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
57999                 *ret_conv_15_copy = ret_var.data[p];
58000                 int64_t ret_conv_15_ref = tag_ptr(ret_conv_15_copy, true);
58001                 ret_arr_ptr[p] = ret_conv_15_ref;
58002         }
58003         
58004         FREE(ret_var.data);
58005         return ret_arr;
58006 }
58007
58008 int8_tArray  CS_LDK_NodeAnnouncementInfo_write(int64_t obj) {
58009         LDKNodeAnnouncementInfo obj_conv;
58010         obj_conv.inner = untag_ptr(obj);
58011         obj_conv.is_owned = ptr_is_owned(obj);
58012         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58013         obj_conv.is_owned = false;
58014         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
58015         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58016         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58017         CVec_u8Z_free(ret_var);
58018         return ret_arr;
58019 }
58020
58021 int64_t  CS_LDK_NodeAnnouncementInfo_read(int8_tArray ser) {
58022         LDKu8slice ser_ref;
58023         ser_ref.datalen = ser->arr_len;
58024         ser_ref.data = ser->elems;
58025         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
58026         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
58027         FREE(ser);
58028         return tag_ptr(ret_conv, true);
58029 }
58030
58031 void  CS_LDK_NodeAlias_free(int64_t this_obj) {
58032         LDKNodeAlias this_obj_conv;
58033         this_obj_conv.inner = untag_ptr(this_obj);
58034         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58036         NodeAlias_free(this_obj_conv);
58037 }
58038
58039 int8_tArray  CS_LDK_NodeAlias_get_a(int64_t this_ptr) {
58040         LDKNodeAlias this_ptr_conv;
58041         this_ptr_conv.inner = untag_ptr(this_ptr);
58042         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58044         this_ptr_conv.is_owned = false;
58045         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
58046         memcpy(ret_arr->elems, *NodeAlias_get_a(&this_ptr_conv), 32);
58047         return ret_arr;
58048 }
58049
58050 void  CS_LDK_NodeAlias_set_a(int64_t this_ptr, int8_tArray val) {
58051         LDKNodeAlias this_ptr_conv;
58052         this_ptr_conv.inner = untag_ptr(this_ptr);
58053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58055         this_ptr_conv.is_owned = false;
58056         LDKThirtyTwoBytes val_ref;
58057         CHECK(val->arr_len == 32);
58058         memcpy(val_ref.data, val->elems, 32); FREE(val);
58059         NodeAlias_set_a(&this_ptr_conv, val_ref);
58060 }
58061
58062 int64_t  CS_LDK_NodeAlias_new(int8_tArray a_arg) {
58063         LDKThirtyTwoBytes a_arg_ref;
58064         CHECK(a_arg->arr_len == 32);
58065         memcpy(a_arg_ref.data, a_arg->elems, 32); FREE(a_arg);
58066         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
58067         int64_t ret_ref = 0;
58068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58070         return ret_ref;
58071 }
58072
58073 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
58074         LDKNodeAlias ret_var = NodeAlias_clone(arg);
58075         int64_t ret_ref = 0;
58076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58078         return ret_ref;
58079 }
58080 int64_t  CS_LDK_NodeAlias_clone_ptr(int64_t arg) {
58081         LDKNodeAlias arg_conv;
58082         arg_conv.inner = untag_ptr(arg);
58083         arg_conv.is_owned = ptr_is_owned(arg);
58084         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
58085         arg_conv.is_owned = false;
58086         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
58087         return ret_conv;
58088 }
58089
58090 int64_t  CS_LDK_NodeAlias_clone(int64_t orig) {
58091         LDKNodeAlias orig_conv;
58092         orig_conv.inner = untag_ptr(orig);
58093         orig_conv.is_owned = ptr_is_owned(orig);
58094         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
58095         orig_conv.is_owned = false;
58096         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
58097         int64_t ret_ref = 0;
58098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58100         return ret_ref;
58101 }
58102
58103 jboolean  CS_LDK_NodeAlias_eq(int64_t a, int64_t b) {
58104         LDKNodeAlias a_conv;
58105         a_conv.inner = untag_ptr(a);
58106         a_conv.is_owned = ptr_is_owned(a);
58107         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
58108         a_conv.is_owned = false;
58109         LDKNodeAlias b_conv;
58110         b_conv.inner = untag_ptr(b);
58111         b_conv.is_owned = ptr_is_owned(b);
58112         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
58113         b_conv.is_owned = false;
58114         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
58115         return ret_conv;
58116 }
58117
58118 int8_tArray  CS_LDK_NodeAlias_write(int64_t obj) {
58119         LDKNodeAlias obj_conv;
58120         obj_conv.inner = untag_ptr(obj);
58121         obj_conv.is_owned = ptr_is_owned(obj);
58122         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58123         obj_conv.is_owned = false;
58124         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
58125         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58126         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58127         CVec_u8Z_free(ret_var);
58128         return ret_arr;
58129 }
58130
58131 int64_t  CS_LDK_NodeAlias_read(int8_tArray ser) {
58132         LDKu8slice ser_ref;
58133         ser_ref.datalen = ser->arr_len;
58134         ser_ref.data = ser->elems;
58135         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
58136         *ret_conv = NodeAlias_read(ser_ref);
58137         FREE(ser);
58138         return tag_ptr(ret_conv, true);
58139 }
58140
58141 void  CS_LDK_NodeInfo_free(int64_t this_obj) {
58142         LDKNodeInfo this_obj_conv;
58143         this_obj_conv.inner = untag_ptr(this_obj);
58144         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58146         NodeInfo_free(this_obj_conv);
58147 }
58148
58149 int64_tArray  CS_LDK_NodeInfo_get_channels(int64_t this_ptr) {
58150         LDKNodeInfo this_ptr_conv;
58151         this_ptr_conv.inner = untag_ptr(this_ptr);
58152         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58154         this_ptr_conv.is_owned = false;
58155         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
58156         int64_tArray ret_arr = NULL;
58157         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
58158         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
58159         for (size_t g = 0; g < ret_var.datalen; g++) {
58160                 int64_t ret_conv_6_conv = ret_var.data[g];
58161                 ret_arr_ptr[g] = ret_conv_6_conv;
58162         }
58163         
58164         FREE(ret_var.data);
58165         return ret_arr;
58166 }
58167
58168 void  CS_LDK_NodeInfo_set_channels(int64_t this_ptr, int64_tArray val) {
58169         LDKNodeInfo this_ptr_conv;
58170         this_ptr_conv.inner = untag_ptr(this_ptr);
58171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58173         this_ptr_conv.is_owned = false;
58174         LDKCVec_u64Z val_constr;
58175         val_constr.datalen = val->arr_len;
58176         if (val_constr.datalen > 0)
58177                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
58178         else
58179                 val_constr.data = NULL;
58180         int64_t* val_vals = val->elems;
58181         for (size_t g = 0; g < val_constr.datalen; g++) {
58182                 int64_t val_conv_6 = val_vals[g];
58183                 val_constr.data[g] = val_conv_6;
58184         }
58185         FREE(val);
58186         NodeInfo_set_channels(&this_ptr_conv, val_constr);
58187 }
58188
58189 int64_t  CS_LDK_NodeInfo_get_announcement_info(int64_t this_ptr) {
58190         LDKNodeInfo this_ptr_conv;
58191         this_ptr_conv.inner = untag_ptr(this_ptr);
58192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58194         this_ptr_conv.is_owned = false;
58195         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
58196         int64_t ret_ref = 0;
58197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58199         return ret_ref;
58200 }
58201
58202 void  CS_LDK_NodeInfo_set_announcement_info(int64_t this_ptr, int64_t val) {
58203         LDKNodeInfo this_ptr_conv;
58204         this_ptr_conv.inner = untag_ptr(this_ptr);
58205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58207         this_ptr_conv.is_owned = false;
58208         LDKNodeAnnouncementInfo val_conv;
58209         val_conv.inner = untag_ptr(val);
58210         val_conv.is_owned = ptr_is_owned(val);
58211         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
58212         val_conv = NodeAnnouncementInfo_clone(&val_conv);
58213         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
58214 }
58215
58216 int64_t  CS_LDK_NodeInfo_new(int64_tArray channels_arg, int64_t announcement_info_arg) {
58217         LDKCVec_u64Z channels_arg_constr;
58218         channels_arg_constr.datalen = channels_arg->arr_len;
58219         if (channels_arg_constr.datalen > 0)
58220                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
58221         else
58222                 channels_arg_constr.data = NULL;
58223         int64_t* channels_arg_vals = channels_arg->elems;
58224         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
58225                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
58226                 channels_arg_constr.data[g] = channels_arg_conv_6;
58227         }
58228         FREE(channels_arg);
58229         LDKNodeAnnouncementInfo announcement_info_arg_conv;
58230         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
58231         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
58232         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
58233         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
58234         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, announcement_info_arg_conv);
58235         int64_t ret_ref = 0;
58236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58238         return ret_ref;
58239 }
58240
58241 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
58242         LDKNodeInfo ret_var = NodeInfo_clone(arg);
58243         int64_t ret_ref = 0;
58244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58245         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58246         return ret_ref;
58247 }
58248 int64_t  CS_LDK_NodeInfo_clone_ptr(int64_t arg) {
58249         LDKNodeInfo arg_conv;
58250         arg_conv.inner = untag_ptr(arg);
58251         arg_conv.is_owned = ptr_is_owned(arg);
58252         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
58253         arg_conv.is_owned = false;
58254         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
58255         return ret_conv;
58256 }
58257
58258 int64_t  CS_LDK_NodeInfo_clone(int64_t orig) {
58259         LDKNodeInfo orig_conv;
58260         orig_conv.inner = untag_ptr(orig);
58261         orig_conv.is_owned = ptr_is_owned(orig);
58262         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
58263         orig_conv.is_owned = false;
58264         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
58265         int64_t ret_ref = 0;
58266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58268         return ret_ref;
58269 }
58270
58271 jboolean  CS_LDK_NodeInfo_eq(int64_t a, int64_t b) {
58272         LDKNodeInfo a_conv;
58273         a_conv.inner = untag_ptr(a);
58274         a_conv.is_owned = ptr_is_owned(a);
58275         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
58276         a_conv.is_owned = false;
58277         LDKNodeInfo b_conv;
58278         b_conv.inner = untag_ptr(b);
58279         b_conv.is_owned = ptr_is_owned(b);
58280         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
58281         b_conv.is_owned = false;
58282         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
58283         return ret_conv;
58284 }
58285
58286 int8_tArray  CS_LDK_NodeInfo_write(int64_t obj) {
58287         LDKNodeInfo obj_conv;
58288         obj_conv.inner = untag_ptr(obj);
58289         obj_conv.is_owned = ptr_is_owned(obj);
58290         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58291         obj_conv.is_owned = false;
58292         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
58293         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58294         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58295         CVec_u8Z_free(ret_var);
58296         return ret_arr;
58297 }
58298
58299 int64_t  CS_LDK_NodeInfo_read(int8_tArray ser) {
58300         LDKu8slice ser_ref;
58301         ser_ref.datalen = ser->arr_len;
58302         ser_ref.data = ser->elems;
58303         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
58304         *ret_conv = NodeInfo_read(ser_ref);
58305         FREE(ser);
58306         return tag_ptr(ret_conv, true);
58307 }
58308
58309 int8_tArray  CS_LDK_NetworkGraph_write(int64_t obj) {
58310         LDKNetworkGraph obj_conv;
58311         obj_conv.inner = untag_ptr(obj);
58312         obj_conv.is_owned = ptr_is_owned(obj);
58313         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58314         obj_conv.is_owned = false;
58315         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
58316         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58317         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58318         CVec_u8Z_free(ret_var);
58319         return ret_arr;
58320 }
58321
58322 int64_t  CS_LDK_NetworkGraph_read(int8_tArray ser, int64_t arg) {
58323         LDKu8slice ser_ref;
58324         ser_ref.datalen = ser->arr_len;
58325         ser_ref.data = ser->elems;
58326         void* arg_ptr = untag_ptr(arg);
58327         CHECK_ACCESS(arg_ptr);
58328         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
58329         if (arg_conv.free == LDKLogger_JCalls_free) {
58330                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58331                 LDKLogger_JCalls_cloned(&arg_conv);
58332         }
58333         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
58334         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
58335         FREE(ser);
58336         return tag_ptr(ret_conv, true);
58337 }
58338
58339 int64_t  CS_LDK_NetworkGraph_new(int32_t network, int64_t logger) {
58340         LDKNetwork network_conv = LDKNetwork_from_cs(network);
58341         void* logger_ptr = untag_ptr(logger);
58342         CHECK_ACCESS(logger_ptr);
58343         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
58344         if (logger_conv.free == LDKLogger_JCalls_free) {
58345                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58346                 LDKLogger_JCalls_cloned(&logger_conv);
58347         }
58348         LDKNetworkGraph ret_var = NetworkGraph_new(network_conv, logger_conv);
58349         int64_t ret_ref = 0;
58350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58351         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58352         return ret_ref;
58353 }
58354
58355 int64_t  CS_LDK_NetworkGraph_read_only(int64_t this_arg) {
58356         LDKNetworkGraph this_arg_conv;
58357         this_arg_conv.inner = untag_ptr(this_arg);
58358         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58360         this_arg_conv.is_owned = false;
58361         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
58362         int64_t ret_ref = 0;
58363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58364         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58365         return ret_ref;
58366 }
58367
58368 int64_t  CS_LDK_NetworkGraph_get_last_rapid_gossip_sync_timestamp(int64_t this_arg) {
58369         LDKNetworkGraph this_arg_conv;
58370         this_arg_conv.inner = untag_ptr(this_arg);
58371         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58373         this_arg_conv.is_owned = false;
58374         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
58375         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
58376         int64_t ret_ref = tag_ptr(ret_copy, true);
58377         return ret_ref;
58378 }
58379
58380 void  CS_LDK_NetworkGraph_set_last_rapid_gossip_sync_timestamp(int64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
58381         LDKNetworkGraph this_arg_conv;
58382         this_arg_conv.inner = untag_ptr(this_arg);
58383         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58385         this_arg_conv.is_owned = false;
58386         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
58387 }
58388
58389 int64_t  CS_LDK_NetworkGraph_update_node_from_announcement(int64_t this_arg, int64_t msg) {
58390         LDKNetworkGraph this_arg_conv;
58391         this_arg_conv.inner = untag_ptr(this_arg);
58392         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58394         this_arg_conv.is_owned = false;
58395         LDKNodeAnnouncement msg_conv;
58396         msg_conv.inner = untag_ptr(msg);
58397         msg_conv.is_owned = ptr_is_owned(msg);
58398         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58399         msg_conv.is_owned = false;
58400         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58401         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
58402         return tag_ptr(ret_conv, true);
58403 }
58404
58405 int64_t  CS_LDK_NetworkGraph_update_node_from_unsigned_announcement(int64_t this_arg, int64_t msg) {
58406         LDKNetworkGraph this_arg_conv;
58407         this_arg_conv.inner = untag_ptr(this_arg);
58408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58410         this_arg_conv.is_owned = false;
58411         LDKUnsignedNodeAnnouncement msg_conv;
58412         msg_conv.inner = untag_ptr(msg);
58413         msg_conv.is_owned = ptr_is_owned(msg);
58414         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58415         msg_conv.is_owned = false;
58416         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58417         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
58418         return tag_ptr(ret_conv, true);
58419 }
58420
58421 int64_t  CS_LDK_NetworkGraph_update_channel_from_announcement(int64_t this_arg, int64_t msg, int64_t utxo_lookup) {
58422         LDKNetworkGraph this_arg_conv;
58423         this_arg_conv.inner = untag_ptr(this_arg);
58424         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58426         this_arg_conv.is_owned = false;
58427         LDKChannelAnnouncement msg_conv;
58428         msg_conv.inner = untag_ptr(msg);
58429         msg_conv.is_owned = ptr_is_owned(msg);
58430         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58431         msg_conv.is_owned = false;
58432         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
58433         CHECK_ACCESS(utxo_lookup_ptr);
58434         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
58435         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
58436         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
58437                 // Manually implement clone for Java trait instances
58438                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
58439                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58440                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
58441                 }
58442         }
58443         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58444         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
58445         return tag_ptr(ret_conv, true);
58446 }
58447
58448 int64_t  CS_LDK_NetworkGraph_update_channel_from_announcement_no_lookup(int64_t this_arg, int64_t msg) {
58449         LDKNetworkGraph this_arg_conv;
58450         this_arg_conv.inner = untag_ptr(this_arg);
58451         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58453         this_arg_conv.is_owned = false;
58454         LDKChannelAnnouncement msg_conv;
58455         msg_conv.inner = untag_ptr(msg);
58456         msg_conv.is_owned = ptr_is_owned(msg);
58457         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58458         msg_conv.is_owned = false;
58459         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58460         *ret_conv = NetworkGraph_update_channel_from_announcement_no_lookup(&this_arg_conv, &msg_conv);
58461         return tag_ptr(ret_conv, true);
58462 }
58463
58464 int64_t  CS_LDK_NetworkGraph_update_channel_from_unsigned_announcement(int64_t this_arg, int64_t msg, int64_t utxo_lookup) {
58465         LDKNetworkGraph this_arg_conv;
58466         this_arg_conv.inner = untag_ptr(this_arg);
58467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58469         this_arg_conv.is_owned = false;
58470         LDKUnsignedChannelAnnouncement msg_conv;
58471         msg_conv.inner = untag_ptr(msg);
58472         msg_conv.is_owned = ptr_is_owned(msg);
58473         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58474         msg_conv.is_owned = false;
58475         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
58476         CHECK_ACCESS(utxo_lookup_ptr);
58477         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
58478         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
58479         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
58480                 // Manually implement clone for Java trait instances
58481                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
58482                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58483                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
58484                 }
58485         }
58486         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58487         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
58488         return tag_ptr(ret_conv, true);
58489 }
58490
58491 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) {
58492         LDKNetworkGraph this_arg_conv;
58493         this_arg_conv.inner = untag_ptr(this_arg);
58494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58496         this_arg_conv.is_owned = false;
58497         LDKChannelFeatures features_conv;
58498         features_conv.inner = untag_ptr(features);
58499         features_conv.is_owned = ptr_is_owned(features);
58500         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
58501         features_conv = ChannelFeatures_clone(&features_conv);
58502         LDKPublicKey node_id_1_ref;
58503         CHECK(node_id_1->arr_len == 33);
58504         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
58505         LDKPublicKey node_id_2_ref;
58506         CHECK(node_id_2->arr_len == 33);
58507         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
58508         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58509         *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);
58510         return tag_ptr(ret_conv, true);
58511 }
58512
58513 void  CS_LDK_NetworkGraph_channel_failed_permanent(int64_t this_arg, int64_t short_channel_id) {
58514         LDKNetworkGraph this_arg_conv;
58515         this_arg_conv.inner = untag_ptr(this_arg);
58516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58518         this_arg_conv.is_owned = false;
58519         NetworkGraph_channel_failed_permanent(&this_arg_conv, short_channel_id);
58520 }
58521
58522 void  CS_LDK_NetworkGraph_node_failed_permanent(int64_t this_arg, int8_tArray node_id) {
58523         LDKNetworkGraph this_arg_conv;
58524         this_arg_conv.inner = untag_ptr(this_arg);
58525         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58527         this_arg_conv.is_owned = false;
58528         LDKPublicKey node_id_ref;
58529         CHECK(node_id->arr_len == 33);
58530         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
58531         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
58532 }
58533
58534 void  CS_LDK_NetworkGraph_remove_stale_channels_and_tracking(int64_t this_arg) {
58535         LDKNetworkGraph this_arg_conv;
58536         this_arg_conv.inner = untag_ptr(this_arg);
58537         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58539         this_arg_conv.is_owned = false;
58540         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
58541 }
58542
58543 void  CS_LDK_NetworkGraph_remove_stale_channels_and_tracking_with_time(int64_t this_arg, int64_t current_time_unix) {
58544         LDKNetworkGraph this_arg_conv;
58545         this_arg_conv.inner = untag_ptr(this_arg);
58546         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58548         this_arg_conv.is_owned = false;
58549         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
58550 }
58551
58552 int64_t  CS_LDK_NetworkGraph_update_channel(int64_t this_arg, int64_t msg) {
58553         LDKNetworkGraph this_arg_conv;
58554         this_arg_conv.inner = untag_ptr(this_arg);
58555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58557         this_arg_conv.is_owned = false;
58558         LDKChannelUpdate msg_conv;
58559         msg_conv.inner = untag_ptr(msg);
58560         msg_conv.is_owned = ptr_is_owned(msg);
58561         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58562         msg_conv.is_owned = false;
58563         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58564         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
58565         return tag_ptr(ret_conv, true);
58566 }
58567
58568 int64_t  CS_LDK_NetworkGraph_update_channel_unsigned(int64_t this_arg, int64_t msg) {
58569         LDKNetworkGraph this_arg_conv;
58570         this_arg_conv.inner = untag_ptr(this_arg);
58571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58573         this_arg_conv.is_owned = false;
58574         LDKUnsignedChannelUpdate msg_conv;
58575         msg_conv.inner = untag_ptr(msg);
58576         msg_conv.is_owned = ptr_is_owned(msg);
58577         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58578         msg_conv.is_owned = false;
58579         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58580         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
58581         return tag_ptr(ret_conv, true);
58582 }
58583
58584 int64_t  CS_LDK_NetworkGraph_verify_channel_update(int64_t this_arg, int64_t msg) {
58585         LDKNetworkGraph this_arg_conv;
58586         this_arg_conv.inner = untag_ptr(this_arg);
58587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58589         this_arg_conv.is_owned = false;
58590         LDKChannelUpdate msg_conv;
58591         msg_conv.inner = untag_ptr(msg);
58592         msg_conv.is_owned = ptr_is_owned(msg);
58593         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58594         msg_conv.is_owned = false;
58595         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58596         *ret_conv = NetworkGraph_verify_channel_update(&this_arg_conv, &msg_conv);
58597         return tag_ptr(ret_conv, true);
58598 }
58599
58600 int64_t  CS_LDK_ReadOnlyNetworkGraph_channel(int64_t this_arg, int64_t short_channel_id) {
58601         LDKReadOnlyNetworkGraph this_arg_conv;
58602         this_arg_conv.inner = untag_ptr(this_arg);
58603         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58605         this_arg_conv.is_owned = false;
58606         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
58607         int64_t ret_ref = 0;
58608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58610         return ret_ref;
58611 }
58612
58613 int64_tArray  CS_LDK_ReadOnlyNetworkGraph_list_channels(int64_t this_arg) {
58614         LDKReadOnlyNetworkGraph this_arg_conv;
58615         this_arg_conv.inner = untag_ptr(this_arg);
58616         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58618         this_arg_conv.is_owned = false;
58619         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
58620         int64_tArray ret_arr = NULL;
58621         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
58622         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
58623         for (size_t g = 0; g < ret_var.datalen; g++) {
58624                 int64_t ret_conv_6_conv = ret_var.data[g];
58625                 ret_arr_ptr[g] = ret_conv_6_conv;
58626         }
58627         
58628         FREE(ret_var.data);
58629         return ret_arr;
58630 }
58631
58632 int64_t  CS_LDK_ReadOnlyNetworkGraph_node(int64_t this_arg, int64_t node_id) {
58633         LDKReadOnlyNetworkGraph this_arg_conv;
58634         this_arg_conv.inner = untag_ptr(this_arg);
58635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58637         this_arg_conv.is_owned = false;
58638         LDKNodeId node_id_conv;
58639         node_id_conv.inner = untag_ptr(node_id);
58640         node_id_conv.is_owned = ptr_is_owned(node_id);
58641         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
58642         node_id_conv.is_owned = false;
58643         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
58644         int64_t ret_ref = 0;
58645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58647         return ret_ref;
58648 }
58649
58650 int64_tArray  CS_LDK_ReadOnlyNetworkGraph_list_nodes(int64_t this_arg) {
58651         LDKReadOnlyNetworkGraph this_arg_conv;
58652         this_arg_conv.inner = untag_ptr(this_arg);
58653         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58655         this_arg_conv.is_owned = false;
58656         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
58657         int64_tArray ret_arr = NULL;
58658         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
58659         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
58660         for (size_t i = 0; i < ret_var.datalen; i++) {
58661                 LDKNodeId ret_conv_8_var = ret_var.data[i];
58662                 int64_t ret_conv_8_ref = 0;
58663                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
58664                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
58665                 ret_arr_ptr[i] = ret_conv_8_ref;
58666         }
58667         
58668         FREE(ret_var.data);
58669         return ret_arr;
58670 }
58671
58672 int64_t  CS_LDK_ReadOnlyNetworkGraph_get_addresses(int64_t this_arg, int8_tArray pubkey) {
58673         LDKReadOnlyNetworkGraph this_arg_conv;
58674         this_arg_conv.inner = untag_ptr(this_arg);
58675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58677         this_arg_conv.is_owned = false;
58678         LDKPublicKey pubkey_ref;
58679         CHECK(pubkey->arr_len == 33);
58680         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
58681         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
58682         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
58683         int64_t ret_ref = tag_ptr(ret_copy, true);
58684         return ret_ref;
58685 }
58686
58687 void  CS_LDK_DefaultRouter_free(int64_t this_obj) {
58688         LDKDefaultRouter this_obj_conv;
58689         this_obj_conv.inner = untag_ptr(this_obj);
58690         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58692         DefaultRouter_free(this_obj_conv);
58693 }
58694
58695 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) {
58696         LDKNetworkGraph network_graph_conv;
58697         network_graph_conv.inner = untag_ptr(network_graph);
58698         network_graph_conv.is_owned = ptr_is_owned(network_graph);
58699         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
58700         network_graph_conv.is_owned = false;
58701         void* logger_ptr = untag_ptr(logger);
58702         CHECK_ACCESS(logger_ptr);
58703         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
58704         if (logger_conv.free == LDKLogger_JCalls_free) {
58705                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58706                 LDKLogger_JCalls_cloned(&logger_conv);
58707         }
58708         LDKThirtyTwoBytes random_seed_bytes_ref;
58709         CHECK(random_seed_bytes->arr_len == 32);
58710         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
58711         void* scorer_ptr = untag_ptr(scorer);
58712         CHECK_ACCESS(scorer_ptr);
58713         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
58714         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
58715                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58716                 LDKLockableScore_JCalls_cloned(&scorer_conv);
58717         }
58718         LDKProbabilisticScoringFeeParameters score_params_conv;
58719         score_params_conv.inner = untag_ptr(score_params);
58720         score_params_conv.is_owned = ptr_is_owned(score_params);
58721         CHECK_INNER_FIELD_ACCESS_OR_NULL(score_params_conv);
58722         score_params_conv = ProbabilisticScoringFeeParameters_clone(&score_params_conv);
58723         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv, score_params_conv);
58724         int64_t ret_ref = 0;
58725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58727         return ret_ref;
58728 }
58729
58730 int64_t  CS_LDK_DefaultRouter_as_Router(int64_t this_arg) {
58731         LDKDefaultRouter this_arg_conv;
58732         this_arg_conv.inner = untag_ptr(this_arg);
58733         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58735         this_arg_conv.is_owned = false;
58736         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
58737         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
58738         return tag_ptr(ret_ret, true);
58739 }
58740
58741 void  CS_LDK_Router_free(int64_t this_ptr) {
58742         if (!ptr_is_owned(this_ptr)) return;
58743         void* this_ptr_ptr = untag_ptr(this_ptr);
58744         CHECK_ACCESS(this_ptr_ptr);
58745         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
58746         FREE(untag_ptr(this_ptr));
58747         Router_free(this_ptr_conv);
58748 }
58749
58750 void  CS_LDK_ScorerAccountingForInFlightHtlcs_free(int64_t this_obj) {
58751         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
58752         this_obj_conv.inner = untag_ptr(this_obj);
58753         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58755         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
58756 }
58757
58758 int64_t  CS_LDK_ScorerAccountingForInFlightHtlcs_new(int64_t scorer, int64_t inflight_htlcs) {
58759         void* scorer_ptr = untag_ptr(scorer);
58760         CHECK_ACCESS(scorer_ptr);
58761         LDKScoreLookUp scorer_conv = *(LDKScoreLookUp*)(scorer_ptr);
58762         if (scorer_conv.free == LDKScoreLookUp_JCalls_free) {
58763                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58764                 LDKScoreLookUp_JCalls_cloned(&scorer_conv);
58765         }
58766         LDKInFlightHtlcs inflight_htlcs_conv;
58767         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
58768         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
58769         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
58770         inflight_htlcs_conv.is_owned = false;
58771         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, &inflight_htlcs_conv);
58772         int64_t ret_ref = 0;
58773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58775         return ret_ref;
58776 }
58777
58778 int64_t  CS_LDK_ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(int64_t this_arg) {
58779         LDKScorerAccountingForInFlightHtlcs this_arg_conv;
58780         this_arg_conv.inner = untag_ptr(this_arg);
58781         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58783         this_arg_conv.is_owned = false;
58784         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
58785         *ret_ret = ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(&this_arg_conv);
58786         return tag_ptr(ret_ret, true);
58787 }
58788
58789 void  CS_LDK_InFlightHtlcs_free(int64_t this_obj) {
58790         LDKInFlightHtlcs this_obj_conv;
58791         this_obj_conv.inner = untag_ptr(this_obj);
58792         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58794         InFlightHtlcs_free(this_obj_conv);
58795 }
58796
58797 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
58798         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
58799         int64_t ret_ref = 0;
58800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58801         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58802         return ret_ref;
58803 }
58804 int64_t  CS_LDK_InFlightHtlcs_clone_ptr(int64_t arg) {
58805         LDKInFlightHtlcs arg_conv;
58806         arg_conv.inner = untag_ptr(arg);
58807         arg_conv.is_owned = ptr_is_owned(arg);
58808         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
58809         arg_conv.is_owned = false;
58810         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
58811         return ret_conv;
58812 }
58813
58814 int64_t  CS_LDK_InFlightHtlcs_clone(int64_t orig) {
58815         LDKInFlightHtlcs orig_conv;
58816         orig_conv.inner = untag_ptr(orig);
58817         orig_conv.is_owned = ptr_is_owned(orig);
58818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
58819         orig_conv.is_owned = false;
58820         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
58821         int64_t ret_ref = 0;
58822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58824         return ret_ref;
58825 }
58826
58827 int64_t  CS_LDK_InFlightHtlcs_new() {
58828         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
58829         int64_t ret_ref = 0;
58830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58831         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58832         return ret_ref;
58833 }
58834
58835 void  CS_LDK_InFlightHtlcs_process_path(int64_t this_arg, int64_t path, int8_tArray payer_node_id) {
58836         LDKInFlightHtlcs this_arg_conv;
58837         this_arg_conv.inner = untag_ptr(this_arg);
58838         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58840         this_arg_conv.is_owned = false;
58841         LDKPath path_conv;
58842         path_conv.inner = untag_ptr(path);
58843         path_conv.is_owned = ptr_is_owned(path);
58844         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
58845         path_conv.is_owned = false;
58846         LDKPublicKey payer_node_id_ref;
58847         CHECK(payer_node_id->arr_len == 33);
58848         memcpy(payer_node_id_ref.compressed_form, payer_node_id->elems, 33); FREE(payer_node_id);
58849         InFlightHtlcs_process_path(&this_arg_conv, &path_conv, payer_node_id_ref);
58850 }
58851
58852 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) {
58853         LDKInFlightHtlcs this_arg_conv;
58854         this_arg_conv.inner = untag_ptr(this_arg);
58855         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58857         this_arg_conv.is_owned = false;
58858         LDKNodeId source_conv;
58859         source_conv.inner = untag_ptr(source);
58860         source_conv.is_owned = ptr_is_owned(source);
58861         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
58862         source_conv.is_owned = false;
58863         LDKNodeId target_conv;
58864         target_conv.inner = untag_ptr(target);
58865         target_conv.is_owned = ptr_is_owned(target);
58866         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
58867         target_conv.is_owned = false;
58868         InFlightHtlcs_add_inflight_htlc(&this_arg_conv, &source_conv, &target_conv, channel_scid, used_msat);
58869 }
58870
58871 int64_t  CS_LDK_InFlightHtlcs_used_liquidity_msat(int64_t this_arg, int64_t source, int64_t target, int64_t channel_scid) {
58872         LDKInFlightHtlcs this_arg_conv;
58873         this_arg_conv.inner = untag_ptr(this_arg);
58874         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58876         this_arg_conv.is_owned = false;
58877         LDKNodeId source_conv;
58878         source_conv.inner = untag_ptr(source);
58879         source_conv.is_owned = ptr_is_owned(source);
58880         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
58881         source_conv.is_owned = false;
58882         LDKNodeId target_conv;
58883         target_conv.inner = untag_ptr(target);
58884         target_conv.is_owned = ptr_is_owned(target);
58885         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
58886         target_conv.is_owned = false;
58887         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
58888         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
58889         int64_t ret_ref = tag_ptr(ret_copy, true);
58890         return ret_ref;
58891 }
58892
58893 int8_tArray  CS_LDK_InFlightHtlcs_write(int64_t obj) {
58894         LDKInFlightHtlcs obj_conv;
58895         obj_conv.inner = untag_ptr(obj);
58896         obj_conv.is_owned = ptr_is_owned(obj);
58897         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58898         obj_conv.is_owned = false;
58899         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
58900         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58901         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58902         CVec_u8Z_free(ret_var);
58903         return ret_arr;
58904 }
58905
58906 int64_t  CS_LDK_InFlightHtlcs_read(int8_tArray ser) {
58907         LDKu8slice ser_ref;
58908         ser_ref.datalen = ser->arr_len;
58909         ser_ref.data = ser->elems;
58910         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
58911         *ret_conv = InFlightHtlcs_read(ser_ref);
58912         FREE(ser);
58913         return tag_ptr(ret_conv, true);
58914 }
58915
58916 void  CS_LDK_RouteHop_free(int64_t this_obj) {
58917         LDKRouteHop this_obj_conv;
58918         this_obj_conv.inner = untag_ptr(this_obj);
58919         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58921         RouteHop_free(this_obj_conv);
58922 }
58923
58924 int8_tArray  CS_LDK_RouteHop_get_pubkey(int64_t this_ptr) {
58925         LDKRouteHop this_ptr_conv;
58926         this_ptr_conv.inner = untag_ptr(this_ptr);
58927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58929         this_ptr_conv.is_owned = false;
58930         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
58931         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
58932         return ret_arr;
58933 }
58934
58935 void  CS_LDK_RouteHop_set_pubkey(int64_t this_ptr, int8_tArray val) {
58936         LDKRouteHop this_ptr_conv;
58937         this_ptr_conv.inner = untag_ptr(this_ptr);
58938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58940         this_ptr_conv.is_owned = false;
58941         LDKPublicKey val_ref;
58942         CHECK(val->arr_len == 33);
58943         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
58944         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
58945 }
58946
58947 int64_t  CS_LDK_RouteHop_get_node_features(int64_t this_ptr) {
58948         LDKRouteHop this_ptr_conv;
58949         this_ptr_conv.inner = untag_ptr(this_ptr);
58950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58952         this_ptr_conv.is_owned = false;
58953         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
58954         int64_t ret_ref = 0;
58955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58957         return ret_ref;
58958 }
58959
58960 void  CS_LDK_RouteHop_set_node_features(int64_t this_ptr, int64_t val) {
58961         LDKRouteHop this_ptr_conv;
58962         this_ptr_conv.inner = untag_ptr(this_ptr);
58963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58965         this_ptr_conv.is_owned = false;
58966         LDKNodeFeatures val_conv;
58967         val_conv.inner = untag_ptr(val);
58968         val_conv.is_owned = ptr_is_owned(val);
58969         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
58970         val_conv = NodeFeatures_clone(&val_conv);
58971         RouteHop_set_node_features(&this_ptr_conv, val_conv);
58972 }
58973
58974 int64_t  CS_LDK_RouteHop_get_short_channel_id(int64_t this_ptr) {
58975         LDKRouteHop this_ptr_conv;
58976         this_ptr_conv.inner = untag_ptr(this_ptr);
58977         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58979         this_ptr_conv.is_owned = false;
58980         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
58981         return ret_conv;
58982 }
58983
58984 void  CS_LDK_RouteHop_set_short_channel_id(int64_t this_ptr, int64_t val) {
58985         LDKRouteHop this_ptr_conv;
58986         this_ptr_conv.inner = untag_ptr(this_ptr);
58987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58989         this_ptr_conv.is_owned = false;
58990         RouteHop_set_short_channel_id(&this_ptr_conv, val);
58991 }
58992
58993 int64_t  CS_LDK_RouteHop_get_channel_features(int64_t this_ptr) {
58994         LDKRouteHop this_ptr_conv;
58995         this_ptr_conv.inner = untag_ptr(this_ptr);
58996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58998         this_ptr_conv.is_owned = false;
58999         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
59000         int64_t ret_ref = 0;
59001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59002         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59003         return ret_ref;
59004 }
59005
59006 void  CS_LDK_RouteHop_set_channel_features(int64_t this_ptr, int64_t val) {
59007         LDKRouteHop this_ptr_conv;
59008         this_ptr_conv.inner = untag_ptr(this_ptr);
59009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59011         this_ptr_conv.is_owned = false;
59012         LDKChannelFeatures val_conv;
59013         val_conv.inner = untag_ptr(val);
59014         val_conv.is_owned = ptr_is_owned(val);
59015         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
59016         val_conv = ChannelFeatures_clone(&val_conv);
59017         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
59018 }
59019
59020 int64_t  CS_LDK_RouteHop_get_fee_msat(int64_t this_ptr) {
59021         LDKRouteHop this_ptr_conv;
59022         this_ptr_conv.inner = untag_ptr(this_ptr);
59023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59025         this_ptr_conv.is_owned = false;
59026         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
59027         return ret_conv;
59028 }
59029
59030 void  CS_LDK_RouteHop_set_fee_msat(int64_t this_ptr, int64_t val) {
59031         LDKRouteHop this_ptr_conv;
59032         this_ptr_conv.inner = untag_ptr(this_ptr);
59033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59035         this_ptr_conv.is_owned = false;
59036         RouteHop_set_fee_msat(&this_ptr_conv, val);
59037 }
59038
59039 int32_t  CS_LDK_RouteHop_get_cltv_expiry_delta(int64_t this_ptr) {
59040         LDKRouteHop this_ptr_conv;
59041         this_ptr_conv.inner = untag_ptr(this_ptr);
59042         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59044         this_ptr_conv.is_owned = false;
59045         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
59046         return ret_conv;
59047 }
59048
59049 void  CS_LDK_RouteHop_set_cltv_expiry_delta(int64_t this_ptr, int32_t val) {
59050         LDKRouteHop this_ptr_conv;
59051         this_ptr_conv.inner = untag_ptr(this_ptr);
59052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59054         this_ptr_conv.is_owned = false;
59055         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
59056 }
59057
59058 jboolean  CS_LDK_RouteHop_get_maybe_announced_channel(int64_t this_ptr) {
59059         LDKRouteHop this_ptr_conv;
59060         this_ptr_conv.inner = untag_ptr(this_ptr);
59061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59063         this_ptr_conv.is_owned = false;
59064         jboolean ret_conv = RouteHop_get_maybe_announced_channel(&this_ptr_conv);
59065         return ret_conv;
59066 }
59067
59068 void  CS_LDK_RouteHop_set_maybe_announced_channel(int64_t this_ptr, jboolean val) {
59069         LDKRouteHop this_ptr_conv;
59070         this_ptr_conv.inner = untag_ptr(this_ptr);
59071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59073         this_ptr_conv.is_owned = false;
59074         RouteHop_set_maybe_announced_channel(&this_ptr_conv, val);
59075 }
59076
59077 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) {
59078         LDKPublicKey pubkey_arg_ref;
59079         CHECK(pubkey_arg->arr_len == 33);
59080         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
59081         LDKNodeFeatures node_features_arg_conv;
59082         node_features_arg_conv.inner = untag_ptr(node_features_arg);
59083         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
59084         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
59085         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
59086         LDKChannelFeatures channel_features_arg_conv;
59087         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
59088         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
59089         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
59090         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
59091         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);
59092         int64_t ret_ref = 0;
59093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59095         return ret_ref;
59096 }
59097
59098 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
59099         LDKRouteHop ret_var = RouteHop_clone(arg);
59100         int64_t ret_ref = 0;
59101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59102         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59103         return ret_ref;
59104 }
59105 int64_t  CS_LDK_RouteHop_clone_ptr(int64_t arg) {
59106         LDKRouteHop arg_conv;
59107         arg_conv.inner = untag_ptr(arg);
59108         arg_conv.is_owned = ptr_is_owned(arg);
59109         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59110         arg_conv.is_owned = false;
59111         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
59112         return ret_conv;
59113 }
59114
59115 int64_t  CS_LDK_RouteHop_clone(int64_t orig) {
59116         LDKRouteHop orig_conv;
59117         orig_conv.inner = untag_ptr(orig);
59118         orig_conv.is_owned = ptr_is_owned(orig);
59119         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59120         orig_conv.is_owned = false;
59121         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
59122         int64_t ret_ref = 0;
59123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59124         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59125         return ret_ref;
59126 }
59127
59128 int64_t  CS_LDK_RouteHop_hash(int64_t o) {
59129         LDKRouteHop o_conv;
59130         o_conv.inner = untag_ptr(o);
59131         o_conv.is_owned = ptr_is_owned(o);
59132         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59133         o_conv.is_owned = false;
59134         int64_t ret_conv = RouteHop_hash(&o_conv);
59135         return ret_conv;
59136 }
59137
59138 jboolean  CS_LDK_RouteHop_eq(int64_t a, int64_t b) {
59139         LDKRouteHop a_conv;
59140         a_conv.inner = untag_ptr(a);
59141         a_conv.is_owned = ptr_is_owned(a);
59142         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59143         a_conv.is_owned = false;
59144         LDKRouteHop b_conv;
59145         b_conv.inner = untag_ptr(b);
59146         b_conv.is_owned = ptr_is_owned(b);
59147         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59148         b_conv.is_owned = false;
59149         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
59150         return ret_conv;
59151 }
59152
59153 int8_tArray  CS_LDK_RouteHop_write(int64_t obj) {
59154         LDKRouteHop obj_conv;
59155         obj_conv.inner = untag_ptr(obj);
59156         obj_conv.is_owned = ptr_is_owned(obj);
59157         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
59158         obj_conv.is_owned = false;
59159         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
59160         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
59161         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
59162         CVec_u8Z_free(ret_var);
59163         return ret_arr;
59164 }
59165
59166 int64_t  CS_LDK_RouteHop_read(int8_tArray ser) {
59167         LDKu8slice ser_ref;
59168         ser_ref.datalen = ser->arr_len;
59169         ser_ref.data = ser->elems;
59170         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
59171         *ret_conv = RouteHop_read(ser_ref);
59172         FREE(ser);
59173         return tag_ptr(ret_conv, true);
59174 }
59175
59176 void  CS_LDK_BlindedTail_free(int64_t this_obj) {
59177         LDKBlindedTail this_obj_conv;
59178         this_obj_conv.inner = untag_ptr(this_obj);
59179         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59181         BlindedTail_free(this_obj_conv);
59182 }
59183
59184 int64_tArray  CS_LDK_BlindedTail_get_hops(int64_t this_ptr) {
59185         LDKBlindedTail this_ptr_conv;
59186         this_ptr_conv.inner = untag_ptr(this_ptr);
59187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59189         this_ptr_conv.is_owned = false;
59190         LDKCVec_BlindedHopZ ret_var = BlindedTail_get_hops(&this_ptr_conv);
59191         int64_tArray ret_arr = NULL;
59192         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
59193         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
59194         for (size_t m = 0; m < ret_var.datalen; m++) {
59195                 LDKBlindedHop ret_conv_12_var = ret_var.data[m];
59196                 int64_t ret_conv_12_ref = 0;
59197                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_var);
59198                 ret_conv_12_ref = tag_ptr(ret_conv_12_var.inner, ret_conv_12_var.is_owned);
59199                 ret_arr_ptr[m] = ret_conv_12_ref;
59200         }
59201         
59202         FREE(ret_var.data);
59203         return ret_arr;
59204 }
59205
59206 void  CS_LDK_BlindedTail_set_hops(int64_t this_ptr, int64_tArray val) {
59207         LDKBlindedTail this_ptr_conv;
59208         this_ptr_conv.inner = untag_ptr(this_ptr);
59209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59211         this_ptr_conv.is_owned = false;
59212         LDKCVec_BlindedHopZ val_constr;
59213         val_constr.datalen = val->arr_len;
59214         if (val_constr.datalen > 0)
59215                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
59216         else
59217                 val_constr.data = NULL;
59218         int64_t* val_vals = val->elems;
59219         for (size_t m = 0; m < val_constr.datalen; m++) {
59220                 int64_t val_conv_12 = val_vals[m];
59221                 LDKBlindedHop val_conv_12_conv;
59222                 val_conv_12_conv.inner = untag_ptr(val_conv_12);
59223                 val_conv_12_conv.is_owned = ptr_is_owned(val_conv_12);
59224                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv);
59225                 val_conv_12_conv = BlindedHop_clone(&val_conv_12_conv);
59226                 val_constr.data[m] = val_conv_12_conv;
59227         }
59228         FREE(val);
59229         BlindedTail_set_hops(&this_ptr_conv, val_constr);
59230 }
59231
59232 int8_tArray  CS_LDK_BlindedTail_get_blinding_point(int64_t this_ptr) {
59233         LDKBlindedTail this_ptr_conv;
59234         this_ptr_conv.inner = untag_ptr(this_ptr);
59235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59237         this_ptr_conv.is_owned = false;
59238         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
59239         memcpy(ret_arr->elems, BlindedTail_get_blinding_point(&this_ptr_conv).compressed_form, 33);
59240         return ret_arr;
59241 }
59242
59243 void  CS_LDK_BlindedTail_set_blinding_point(int64_t this_ptr, int8_tArray val) {
59244         LDKBlindedTail this_ptr_conv;
59245         this_ptr_conv.inner = untag_ptr(this_ptr);
59246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59248         this_ptr_conv.is_owned = false;
59249         LDKPublicKey val_ref;
59250         CHECK(val->arr_len == 33);
59251         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
59252         BlindedTail_set_blinding_point(&this_ptr_conv, val_ref);
59253 }
59254
59255 int32_t  CS_LDK_BlindedTail_get_excess_final_cltv_expiry_delta(int64_t this_ptr) {
59256         LDKBlindedTail this_ptr_conv;
59257         this_ptr_conv.inner = untag_ptr(this_ptr);
59258         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59260         this_ptr_conv.is_owned = false;
59261         int32_t ret_conv = BlindedTail_get_excess_final_cltv_expiry_delta(&this_ptr_conv);
59262         return ret_conv;
59263 }
59264
59265 void  CS_LDK_BlindedTail_set_excess_final_cltv_expiry_delta(int64_t this_ptr, int32_t val) {
59266         LDKBlindedTail this_ptr_conv;
59267         this_ptr_conv.inner = untag_ptr(this_ptr);
59268         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59270         this_ptr_conv.is_owned = false;
59271         BlindedTail_set_excess_final_cltv_expiry_delta(&this_ptr_conv, val);
59272 }
59273
59274 int64_t  CS_LDK_BlindedTail_get_final_value_msat(int64_t this_ptr) {
59275         LDKBlindedTail this_ptr_conv;
59276         this_ptr_conv.inner = untag_ptr(this_ptr);
59277         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59279         this_ptr_conv.is_owned = false;
59280         int64_t ret_conv = BlindedTail_get_final_value_msat(&this_ptr_conv);
59281         return ret_conv;
59282 }
59283
59284 void  CS_LDK_BlindedTail_set_final_value_msat(int64_t this_ptr, int64_t val) {
59285         LDKBlindedTail this_ptr_conv;
59286         this_ptr_conv.inner = untag_ptr(this_ptr);
59287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59289         this_ptr_conv.is_owned = false;
59290         BlindedTail_set_final_value_msat(&this_ptr_conv, val);
59291 }
59292
59293 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) {
59294         LDKCVec_BlindedHopZ hops_arg_constr;
59295         hops_arg_constr.datalen = hops_arg->arr_len;
59296         if (hops_arg_constr.datalen > 0)
59297                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
59298         else
59299                 hops_arg_constr.data = NULL;
59300         int64_t* hops_arg_vals = hops_arg->elems;
59301         for (size_t m = 0; m < hops_arg_constr.datalen; m++) {
59302                 int64_t hops_arg_conv_12 = hops_arg_vals[m];
59303                 LDKBlindedHop hops_arg_conv_12_conv;
59304                 hops_arg_conv_12_conv.inner = untag_ptr(hops_arg_conv_12);
59305                 hops_arg_conv_12_conv.is_owned = ptr_is_owned(hops_arg_conv_12);
59306                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_12_conv);
59307                 hops_arg_conv_12_conv = BlindedHop_clone(&hops_arg_conv_12_conv);
59308                 hops_arg_constr.data[m] = hops_arg_conv_12_conv;
59309         }
59310         FREE(hops_arg);
59311         LDKPublicKey blinding_point_arg_ref;
59312         CHECK(blinding_point_arg->arr_len == 33);
59313         memcpy(blinding_point_arg_ref.compressed_form, blinding_point_arg->elems, 33); FREE(blinding_point_arg);
59314         LDKBlindedTail ret_var = BlindedTail_new(hops_arg_constr, blinding_point_arg_ref, excess_final_cltv_expiry_delta_arg, final_value_msat_arg);
59315         int64_t ret_ref = 0;
59316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59318         return ret_ref;
59319 }
59320
59321 static inline uint64_t BlindedTail_clone_ptr(LDKBlindedTail *NONNULL_PTR arg) {
59322         LDKBlindedTail ret_var = BlindedTail_clone(arg);
59323         int64_t ret_ref = 0;
59324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59325         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59326         return ret_ref;
59327 }
59328 int64_t  CS_LDK_BlindedTail_clone_ptr(int64_t arg) {
59329         LDKBlindedTail arg_conv;
59330         arg_conv.inner = untag_ptr(arg);
59331         arg_conv.is_owned = ptr_is_owned(arg);
59332         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59333         arg_conv.is_owned = false;
59334         int64_t ret_conv = BlindedTail_clone_ptr(&arg_conv);
59335         return ret_conv;
59336 }
59337
59338 int64_t  CS_LDK_BlindedTail_clone(int64_t orig) {
59339         LDKBlindedTail orig_conv;
59340         orig_conv.inner = untag_ptr(orig);
59341         orig_conv.is_owned = ptr_is_owned(orig);
59342         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59343         orig_conv.is_owned = false;
59344         LDKBlindedTail ret_var = BlindedTail_clone(&orig_conv);
59345         int64_t ret_ref = 0;
59346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59348         return ret_ref;
59349 }
59350
59351 int64_t  CS_LDK_BlindedTail_hash(int64_t o) {
59352         LDKBlindedTail o_conv;
59353         o_conv.inner = untag_ptr(o);
59354         o_conv.is_owned = ptr_is_owned(o);
59355         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59356         o_conv.is_owned = false;
59357         int64_t ret_conv = BlindedTail_hash(&o_conv);
59358         return ret_conv;
59359 }
59360
59361 jboolean  CS_LDK_BlindedTail_eq(int64_t a, int64_t b) {
59362         LDKBlindedTail a_conv;
59363         a_conv.inner = untag_ptr(a);
59364         a_conv.is_owned = ptr_is_owned(a);
59365         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59366         a_conv.is_owned = false;
59367         LDKBlindedTail b_conv;
59368         b_conv.inner = untag_ptr(b);
59369         b_conv.is_owned = ptr_is_owned(b);
59370         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59371         b_conv.is_owned = false;
59372         jboolean ret_conv = BlindedTail_eq(&a_conv, &b_conv);
59373         return ret_conv;
59374 }
59375
59376 int8_tArray  CS_LDK_BlindedTail_write(int64_t obj) {
59377         LDKBlindedTail obj_conv;
59378         obj_conv.inner = untag_ptr(obj);
59379         obj_conv.is_owned = ptr_is_owned(obj);
59380         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
59381         obj_conv.is_owned = false;
59382         LDKCVec_u8Z ret_var = BlindedTail_write(&obj_conv);
59383         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
59384         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
59385         CVec_u8Z_free(ret_var);
59386         return ret_arr;
59387 }
59388
59389 int64_t  CS_LDK_BlindedTail_read(int8_tArray ser) {
59390         LDKu8slice ser_ref;
59391         ser_ref.datalen = ser->arr_len;
59392         ser_ref.data = ser->elems;
59393         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
59394         *ret_conv = BlindedTail_read(ser_ref);
59395         FREE(ser);
59396         return tag_ptr(ret_conv, true);
59397 }
59398
59399 void  CS_LDK_Path_free(int64_t this_obj) {
59400         LDKPath this_obj_conv;
59401         this_obj_conv.inner = untag_ptr(this_obj);
59402         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59404         Path_free(this_obj_conv);
59405 }
59406
59407 int64_tArray  CS_LDK_Path_get_hops(int64_t this_ptr) {
59408         LDKPath this_ptr_conv;
59409         this_ptr_conv.inner = untag_ptr(this_ptr);
59410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59412         this_ptr_conv.is_owned = false;
59413         LDKCVec_RouteHopZ ret_var = Path_get_hops(&this_ptr_conv);
59414         int64_tArray ret_arr = NULL;
59415         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
59416         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
59417         for (size_t k = 0; k < ret_var.datalen; k++) {
59418                 LDKRouteHop ret_conv_10_var = ret_var.data[k];
59419                 int64_t ret_conv_10_ref = 0;
59420                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
59421                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
59422                 ret_arr_ptr[k] = ret_conv_10_ref;
59423         }
59424         
59425         FREE(ret_var.data);
59426         return ret_arr;
59427 }
59428
59429 void  CS_LDK_Path_set_hops(int64_t this_ptr, int64_tArray val) {
59430         LDKPath this_ptr_conv;
59431         this_ptr_conv.inner = untag_ptr(this_ptr);
59432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59434         this_ptr_conv.is_owned = false;
59435         LDKCVec_RouteHopZ val_constr;
59436         val_constr.datalen = val->arr_len;
59437         if (val_constr.datalen > 0)
59438                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
59439         else
59440                 val_constr.data = NULL;
59441         int64_t* val_vals = val->elems;
59442         for (size_t k = 0; k < val_constr.datalen; k++) {
59443                 int64_t val_conv_10 = val_vals[k];
59444                 LDKRouteHop val_conv_10_conv;
59445                 val_conv_10_conv.inner = untag_ptr(val_conv_10);
59446                 val_conv_10_conv.is_owned = ptr_is_owned(val_conv_10);
59447                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_10_conv);
59448                 val_conv_10_conv = RouteHop_clone(&val_conv_10_conv);
59449                 val_constr.data[k] = val_conv_10_conv;
59450         }
59451         FREE(val);
59452         Path_set_hops(&this_ptr_conv, val_constr);
59453 }
59454
59455 int64_t  CS_LDK_Path_get_blinded_tail(int64_t this_ptr) {
59456         LDKPath this_ptr_conv;
59457         this_ptr_conv.inner = untag_ptr(this_ptr);
59458         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59460         this_ptr_conv.is_owned = false;
59461         LDKBlindedTail ret_var = Path_get_blinded_tail(&this_ptr_conv);
59462         int64_t ret_ref = 0;
59463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59465         return ret_ref;
59466 }
59467
59468 void  CS_LDK_Path_set_blinded_tail(int64_t this_ptr, int64_t val) {
59469         LDKPath this_ptr_conv;
59470         this_ptr_conv.inner = untag_ptr(this_ptr);
59471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59473         this_ptr_conv.is_owned = false;
59474         LDKBlindedTail val_conv;
59475         val_conv.inner = untag_ptr(val);
59476         val_conv.is_owned = ptr_is_owned(val);
59477         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
59478         val_conv = BlindedTail_clone(&val_conv);
59479         Path_set_blinded_tail(&this_ptr_conv, val_conv);
59480 }
59481
59482 int64_t  CS_LDK_Path_new(int64_tArray hops_arg, int64_t blinded_tail_arg) {
59483         LDKCVec_RouteHopZ hops_arg_constr;
59484         hops_arg_constr.datalen = hops_arg->arr_len;
59485         if (hops_arg_constr.datalen > 0)
59486                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
59487         else
59488                 hops_arg_constr.data = NULL;
59489         int64_t* hops_arg_vals = hops_arg->elems;
59490         for (size_t k = 0; k < hops_arg_constr.datalen; k++) {
59491                 int64_t hops_arg_conv_10 = hops_arg_vals[k];
59492                 LDKRouteHop hops_arg_conv_10_conv;
59493                 hops_arg_conv_10_conv.inner = untag_ptr(hops_arg_conv_10);
59494                 hops_arg_conv_10_conv.is_owned = ptr_is_owned(hops_arg_conv_10);
59495                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_10_conv);
59496                 hops_arg_conv_10_conv = RouteHop_clone(&hops_arg_conv_10_conv);
59497                 hops_arg_constr.data[k] = hops_arg_conv_10_conv;
59498         }
59499         FREE(hops_arg);
59500         LDKBlindedTail blinded_tail_arg_conv;
59501         blinded_tail_arg_conv.inner = untag_ptr(blinded_tail_arg);
59502         blinded_tail_arg_conv.is_owned = ptr_is_owned(blinded_tail_arg);
59503         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_tail_arg_conv);
59504         blinded_tail_arg_conv = BlindedTail_clone(&blinded_tail_arg_conv);
59505         LDKPath ret_var = Path_new(hops_arg_constr, blinded_tail_arg_conv);
59506         int64_t ret_ref = 0;
59507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59509         return ret_ref;
59510 }
59511
59512 static inline uint64_t Path_clone_ptr(LDKPath *NONNULL_PTR arg) {
59513         LDKPath ret_var = Path_clone(arg);
59514         int64_t ret_ref = 0;
59515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59517         return ret_ref;
59518 }
59519 int64_t  CS_LDK_Path_clone_ptr(int64_t arg) {
59520         LDKPath arg_conv;
59521         arg_conv.inner = untag_ptr(arg);
59522         arg_conv.is_owned = ptr_is_owned(arg);
59523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59524         arg_conv.is_owned = false;
59525         int64_t ret_conv = Path_clone_ptr(&arg_conv);
59526         return ret_conv;
59527 }
59528
59529 int64_t  CS_LDK_Path_clone(int64_t orig) {
59530         LDKPath orig_conv;
59531         orig_conv.inner = untag_ptr(orig);
59532         orig_conv.is_owned = ptr_is_owned(orig);
59533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59534         orig_conv.is_owned = false;
59535         LDKPath ret_var = Path_clone(&orig_conv);
59536         int64_t ret_ref = 0;
59537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59539         return ret_ref;
59540 }
59541
59542 int64_t  CS_LDK_Path_hash(int64_t o) {
59543         LDKPath o_conv;
59544         o_conv.inner = untag_ptr(o);
59545         o_conv.is_owned = ptr_is_owned(o);
59546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59547         o_conv.is_owned = false;
59548         int64_t ret_conv = Path_hash(&o_conv);
59549         return ret_conv;
59550 }
59551
59552 jboolean  CS_LDK_Path_eq(int64_t a, int64_t b) {
59553         LDKPath a_conv;
59554         a_conv.inner = untag_ptr(a);
59555         a_conv.is_owned = ptr_is_owned(a);
59556         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59557         a_conv.is_owned = false;
59558         LDKPath b_conv;
59559         b_conv.inner = untag_ptr(b);
59560         b_conv.is_owned = ptr_is_owned(b);
59561         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59562         b_conv.is_owned = false;
59563         jboolean ret_conv = Path_eq(&a_conv, &b_conv);
59564         return ret_conv;
59565 }
59566
59567 int64_t  CS_LDK_Path_fee_msat(int64_t this_arg) {
59568         LDKPath this_arg_conv;
59569         this_arg_conv.inner = untag_ptr(this_arg);
59570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59572         this_arg_conv.is_owned = false;
59573         int64_t ret_conv = Path_fee_msat(&this_arg_conv);
59574         return ret_conv;
59575 }
59576
59577 int64_t  CS_LDK_Path_final_value_msat(int64_t this_arg) {
59578         LDKPath this_arg_conv;
59579         this_arg_conv.inner = untag_ptr(this_arg);
59580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59582         this_arg_conv.is_owned = false;
59583         int64_t ret_conv = Path_final_value_msat(&this_arg_conv);
59584         return ret_conv;
59585 }
59586
59587 int64_t  CS_LDK_Path_final_cltv_expiry_delta(int64_t this_arg) {
59588         LDKPath this_arg_conv;
59589         this_arg_conv.inner = untag_ptr(this_arg);
59590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59592         this_arg_conv.is_owned = false;
59593         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
59594         *ret_copy = Path_final_cltv_expiry_delta(&this_arg_conv);
59595         int64_t ret_ref = tag_ptr(ret_copy, true);
59596         return ret_ref;
59597 }
59598
59599 void  CS_LDK_Route_free(int64_t this_obj) {
59600         LDKRoute this_obj_conv;
59601         this_obj_conv.inner = untag_ptr(this_obj);
59602         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59604         Route_free(this_obj_conv);
59605 }
59606
59607 int64_tArray  CS_LDK_Route_get_paths(int64_t this_ptr) {
59608         LDKRoute this_ptr_conv;
59609         this_ptr_conv.inner = untag_ptr(this_ptr);
59610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59612         this_ptr_conv.is_owned = false;
59613         LDKCVec_PathZ ret_var = Route_get_paths(&this_ptr_conv);
59614         int64_tArray ret_arr = NULL;
59615         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
59616         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
59617         for (size_t g = 0; g < ret_var.datalen; g++) {
59618                 LDKPath ret_conv_6_var = ret_var.data[g];
59619                 int64_t ret_conv_6_ref = 0;
59620                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
59621                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
59622                 ret_arr_ptr[g] = ret_conv_6_ref;
59623         }
59624         
59625         FREE(ret_var.data);
59626         return ret_arr;
59627 }
59628
59629 void  CS_LDK_Route_set_paths(int64_t this_ptr, int64_tArray val) {
59630         LDKRoute this_ptr_conv;
59631         this_ptr_conv.inner = untag_ptr(this_ptr);
59632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59634         this_ptr_conv.is_owned = false;
59635         LDKCVec_PathZ val_constr;
59636         val_constr.datalen = val->arr_len;
59637         if (val_constr.datalen > 0)
59638                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
59639         else
59640                 val_constr.data = NULL;
59641         int64_t* val_vals = val->elems;
59642         for (size_t g = 0; g < val_constr.datalen; g++) {
59643                 int64_t val_conv_6 = val_vals[g];
59644                 LDKPath val_conv_6_conv;
59645                 val_conv_6_conv.inner = untag_ptr(val_conv_6);
59646                 val_conv_6_conv.is_owned = ptr_is_owned(val_conv_6);
59647                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_6_conv);
59648                 val_conv_6_conv = Path_clone(&val_conv_6_conv);
59649                 val_constr.data[g] = val_conv_6_conv;
59650         }
59651         FREE(val);
59652         Route_set_paths(&this_ptr_conv, val_constr);
59653 }
59654
59655 int64_t  CS_LDK_Route_get_route_params(int64_t this_ptr) {
59656         LDKRoute this_ptr_conv;
59657         this_ptr_conv.inner = untag_ptr(this_ptr);
59658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59660         this_ptr_conv.is_owned = false;
59661         LDKRouteParameters ret_var = Route_get_route_params(&this_ptr_conv);
59662         int64_t ret_ref = 0;
59663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59664         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59665         return ret_ref;
59666 }
59667
59668 void  CS_LDK_Route_set_route_params(int64_t this_ptr, int64_t val) {
59669         LDKRoute this_ptr_conv;
59670         this_ptr_conv.inner = untag_ptr(this_ptr);
59671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59673         this_ptr_conv.is_owned = false;
59674         LDKRouteParameters val_conv;
59675         val_conv.inner = untag_ptr(val);
59676         val_conv.is_owned = ptr_is_owned(val);
59677         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
59678         val_conv = RouteParameters_clone(&val_conv);
59679         Route_set_route_params(&this_ptr_conv, val_conv);
59680 }
59681
59682 int64_t  CS_LDK_Route_new(int64_tArray paths_arg, int64_t route_params_arg) {
59683         LDKCVec_PathZ paths_arg_constr;
59684         paths_arg_constr.datalen = paths_arg->arr_len;
59685         if (paths_arg_constr.datalen > 0)
59686                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
59687         else
59688                 paths_arg_constr.data = NULL;
59689         int64_t* paths_arg_vals = paths_arg->elems;
59690         for (size_t g = 0; g < paths_arg_constr.datalen; g++) {
59691                 int64_t paths_arg_conv_6 = paths_arg_vals[g];
59692                 LDKPath paths_arg_conv_6_conv;
59693                 paths_arg_conv_6_conv.inner = untag_ptr(paths_arg_conv_6);
59694                 paths_arg_conv_6_conv.is_owned = ptr_is_owned(paths_arg_conv_6);
59695                 CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_6_conv);
59696                 paths_arg_conv_6_conv = Path_clone(&paths_arg_conv_6_conv);
59697                 paths_arg_constr.data[g] = paths_arg_conv_6_conv;
59698         }
59699         FREE(paths_arg);
59700         LDKRouteParameters route_params_arg_conv;
59701         route_params_arg_conv.inner = untag_ptr(route_params_arg);
59702         route_params_arg_conv.is_owned = ptr_is_owned(route_params_arg);
59703         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_arg_conv);
59704         route_params_arg_conv = RouteParameters_clone(&route_params_arg_conv);
59705         LDKRoute ret_var = Route_new(paths_arg_constr, route_params_arg_conv);
59706         int64_t ret_ref = 0;
59707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59708         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59709         return ret_ref;
59710 }
59711
59712 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
59713         LDKRoute ret_var = Route_clone(arg);
59714         int64_t ret_ref = 0;
59715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59717         return ret_ref;
59718 }
59719 int64_t  CS_LDK_Route_clone_ptr(int64_t arg) {
59720         LDKRoute arg_conv;
59721         arg_conv.inner = untag_ptr(arg);
59722         arg_conv.is_owned = ptr_is_owned(arg);
59723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59724         arg_conv.is_owned = false;
59725         int64_t ret_conv = Route_clone_ptr(&arg_conv);
59726         return ret_conv;
59727 }
59728
59729 int64_t  CS_LDK_Route_clone(int64_t orig) {
59730         LDKRoute orig_conv;
59731         orig_conv.inner = untag_ptr(orig);
59732         orig_conv.is_owned = ptr_is_owned(orig);
59733         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59734         orig_conv.is_owned = false;
59735         LDKRoute ret_var = Route_clone(&orig_conv);
59736         int64_t ret_ref = 0;
59737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59738         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59739         return ret_ref;
59740 }
59741
59742 int64_t  CS_LDK_Route_hash(int64_t o) {
59743         LDKRoute o_conv;
59744         o_conv.inner = untag_ptr(o);
59745         o_conv.is_owned = ptr_is_owned(o);
59746         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59747         o_conv.is_owned = false;
59748         int64_t ret_conv = Route_hash(&o_conv);
59749         return ret_conv;
59750 }
59751
59752 jboolean  CS_LDK_Route_eq(int64_t a, int64_t b) {
59753         LDKRoute a_conv;
59754         a_conv.inner = untag_ptr(a);
59755         a_conv.is_owned = ptr_is_owned(a);
59756         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59757         a_conv.is_owned = false;
59758         LDKRoute b_conv;
59759         b_conv.inner = untag_ptr(b);
59760         b_conv.is_owned = ptr_is_owned(b);
59761         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59762         b_conv.is_owned = false;
59763         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
59764         return ret_conv;
59765 }
59766
59767 int64_t  CS_LDK_Route_get_total_fees(int64_t this_arg) {
59768         LDKRoute this_arg_conv;
59769         this_arg_conv.inner = untag_ptr(this_arg);
59770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59772         this_arg_conv.is_owned = false;
59773         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
59774         return ret_conv;
59775 }
59776
59777 int64_t  CS_LDK_Route_get_total_amount(int64_t this_arg) {
59778         LDKRoute this_arg_conv;
59779         this_arg_conv.inner = untag_ptr(this_arg);
59780         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59782         this_arg_conv.is_owned = false;
59783         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
59784         return ret_conv;
59785 }
59786
59787 int8_tArray  CS_LDK_Route_write(int64_t obj) {
59788         LDKRoute obj_conv;
59789         obj_conv.inner = untag_ptr(obj);
59790         obj_conv.is_owned = ptr_is_owned(obj);
59791         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
59792         obj_conv.is_owned = false;
59793         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
59794         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
59795         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
59796         CVec_u8Z_free(ret_var);
59797         return ret_arr;
59798 }
59799
59800 int64_t  CS_LDK_Route_read(int8_tArray ser) {
59801         LDKu8slice ser_ref;
59802         ser_ref.datalen = ser->arr_len;
59803         ser_ref.data = ser->elems;
59804         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
59805         *ret_conv = Route_read(ser_ref);
59806         FREE(ser);
59807         return tag_ptr(ret_conv, true);
59808 }
59809
59810 void  CS_LDK_RouteParameters_free(int64_t this_obj) {
59811         LDKRouteParameters this_obj_conv;
59812         this_obj_conv.inner = untag_ptr(this_obj);
59813         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59815         RouteParameters_free(this_obj_conv);
59816 }
59817
59818 int64_t  CS_LDK_RouteParameters_get_payment_params(int64_t this_ptr) {
59819         LDKRouteParameters this_ptr_conv;
59820         this_ptr_conv.inner = untag_ptr(this_ptr);
59821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59823         this_ptr_conv.is_owned = false;
59824         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
59825         int64_t ret_ref = 0;
59826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59828         return ret_ref;
59829 }
59830
59831 void  CS_LDK_RouteParameters_set_payment_params(int64_t this_ptr, int64_t val) {
59832         LDKRouteParameters this_ptr_conv;
59833         this_ptr_conv.inner = untag_ptr(this_ptr);
59834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59836         this_ptr_conv.is_owned = false;
59837         LDKPaymentParameters val_conv;
59838         val_conv.inner = untag_ptr(val);
59839         val_conv.is_owned = ptr_is_owned(val);
59840         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
59841         val_conv = PaymentParameters_clone(&val_conv);
59842         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
59843 }
59844
59845 int64_t  CS_LDK_RouteParameters_get_final_value_msat(int64_t this_ptr) {
59846         LDKRouteParameters this_ptr_conv;
59847         this_ptr_conv.inner = untag_ptr(this_ptr);
59848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59850         this_ptr_conv.is_owned = false;
59851         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
59852         return ret_conv;
59853 }
59854
59855 void  CS_LDK_RouteParameters_set_final_value_msat(int64_t this_ptr, int64_t val) {
59856         LDKRouteParameters this_ptr_conv;
59857         this_ptr_conv.inner = untag_ptr(this_ptr);
59858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59860         this_ptr_conv.is_owned = false;
59861         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
59862 }
59863
59864 int64_t  CS_LDK_RouteParameters_get_max_total_routing_fee_msat(int64_t this_ptr) {
59865         LDKRouteParameters this_ptr_conv;
59866         this_ptr_conv.inner = untag_ptr(this_ptr);
59867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59869         this_ptr_conv.is_owned = false;
59870         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
59871         *ret_copy = RouteParameters_get_max_total_routing_fee_msat(&this_ptr_conv);
59872         int64_t ret_ref = tag_ptr(ret_copy, true);
59873         return ret_ref;
59874 }
59875
59876 void  CS_LDK_RouteParameters_set_max_total_routing_fee_msat(int64_t this_ptr, int64_t val) {
59877         LDKRouteParameters this_ptr_conv;
59878         this_ptr_conv.inner = untag_ptr(this_ptr);
59879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59881         this_ptr_conv.is_owned = false;
59882         void* val_ptr = untag_ptr(val);
59883         CHECK_ACCESS(val_ptr);
59884         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
59885         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
59886         RouteParameters_set_max_total_routing_fee_msat(&this_ptr_conv, val_conv);
59887 }
59888
59889 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) {
59890         LDKPaymentParameters payment_params_arg_conv;
59891         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
59892         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
59893         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
59894         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
59895         void* max_total_routing_fee_msat_arg_ptr = untag_ptr(max_total_routing_fee_msat_arg);
59896         CHECK_ACCESS(max_total_routing_fee_msat_arg_ptr);
59897         LDKCOption_u64Z max_total_routing_fee_msat_arg_conv = *(LDKCOption_u64Z*)(max_total_routing_fee_msat_arg_ptr);
59898         max_total_routing_fee_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(max_total_routing_fee_msat_arg));
59899         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, max_total_routing_fee_msat_arg_conv);
59900         int64_t ret_ref = 0;
59901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59902         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59903         return ret_ref;
59904 }
59905
59906 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
59907         LDKRouteParameters ret_var = RouteParameters_clone(arg);
59908         int64_t ret_ref = 0;
59909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59910         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59911         return ret_ref;
59912 }
59913 int64_t  CS_LDK_RouteParameters_clone_ptr(int64_t arg) {
59914         LDKRouteParameters arg_conv;
59915         arg_conv.inner = untag_ptr(arg);
59916         arg_conv.is_owned = ptr_is_owned(arg);
59917         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59918         arg_conv.is_owned = false;
59919         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
59920         return ret_conv;
59921 }
59922
59923 int64_t  CS_LDK_RouteParameters_clone(int64_t orig) {
59924         LDKRouteParameters orig_conv;
59925         orig_conv.inner = untag_ptr(orig);
59926         orig_conv.is_owned = ptr_is_owned(orig);
59927         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59928         orig_conv.is_owned = false;
59929         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
59930         int64_t ret_ref = 0;
59931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59933         return ret_ref;
59934 }
59935
59936 int64_t  CS_LDK_RouteParameters_hash(int64_t o) {
59937         LDKRouteParameters o_conv;
59938         o_conv.inner = untag_ptr(o);
59939         o_conv.is_owned = ptr_is_owned(o);
59940         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59941         o_conv.is_owned = false;
59942         int64_t ret_conv = RouteParameters_hash(&o_conv);
59943         return ret_conv;
59944 }
59945
59946 jboolean  CS_LDK_RouteParameters_eq(int64_t a, int64_t b) {
59947         LDKRouteParameters a_conv;
59948         a_conv.inner = untag_ptr(a);
59949         a_conv.is_owned = ptr_is_owned(a);
59950         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59951         a_conv.is_owned = false;
59952         LDKRouteParameters b_conv;
59953         b_conv.inner = untag_ptr(b);
59954         b_conv.is_owned = ptr_is_owned(b);
59955         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59956         b_conv.is_owned = false;
59957         jboolean ret_conv = RouteParameters_eq(&a_conv, &b_conv);
59958         return ret_conv;
59959 }
59960
59961 int64_t  CS_LDK_RouteParameters_from_payment_params_and_value(int64_t payment_params, int64_t final_value_msat) {
59962         LDKPaymentParameters payment_params_conv;
59963         payment_params_conv.inner = untag_ptr(payment_params);
59964         payment_params_conv.is_owned = ptr_is_owned(payment_params);
59965         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_conv);
59966         payment_params_conv = PaymentParameters_clone(&payment_params_conv);
59967         LDKRouteParameters ret_var = RouteParameters_from_payment_params_and_value(payment_params_conv, final_value_msat);
59968         int64_t ret_ref = 0;
59969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59970         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59971         return ret_ref;
59972 }
59973
59974 int8_tArray  CS_LDK_RouteParameters_write(int64_t obj) {
59975         LDKRouteParameters obj_conv;
59976         obj_conv.inner = untag_ptr(obj);
59977         obj_conv.is_owned = ptr_is_owned(obj);
59978         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
59979         obj_conv.is_owned = false;
59980         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
59981         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
59982         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
59983         CVec_u8Z_free(ret_var);
59984         return ret_arr;
59985 }
59986
59987 int64_t  CS_LDK_RouteParameters_read(int8_tArray ser) {
59988         LDKu8slice ser_ref;
59989         ser_ref.datalen = ser->arr_len;
59990         ser_ref.data = ser->elems;
59991         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
59992         *ret_conv = RouteParameters_read(ser_ref);
59993         FREE(ser);
59994         return tag_ptr(ret_conv, true);
59995 }
59996
59997 void  CS_LDK_PaymentParameters_free(int64_t this_obj) {
59998         LDKPaymentParameters this_obj_conv;
59999         this_obj_conv.inner = untag_ptr(this_obj);
60000         this_obj_conv.is_owned = ptr_is_owned(this_obj);
60001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
60002         PaymentParameters_free(this_obj_conv);
60003 }
60004
60005 int64_t  CS_LDK_PaymentParameters_get_payee(int64_t this_ptr) {
60006         LDKPaymentParameters this_ptr_conv;
60007         this_ptr_conv.inner = untag_ptr(this_ptr);
60008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60010         this_ptr_conv.is_owned = false;
60011         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60012         *ret_copy = PaymentParameters_get_payee(&this_ptr_conv);
60013         int64_t ret_ref = tag_ptr(ret_copy, true);
60014         return ret_ref;
60015 }
60016
60017 void  CS_LDK_PaymentParameters_set_payee(int64_t this_ptr, int64_t val) {
60018         LDKPaymentParameters this_ptr_conv;
60019         this_ptr_conv.inner = untag_ptr(this_ptr);
60020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60022         this_ptr_conv.is_owned = false;
60023         void* val_ptr = untag_ptr(val);
60024         CHECK_ACCESS(val_ptr);
60025         LDKPayee val_conv = *(LDKPayee*)(val_ptr);
60026         val_conv = Payee_clone((LDKPayee*)untag_ptr(val));
60027         PaymentParameters_set_payee(&this_ptr_conv, val_conv);
60028 }
60029
60030 int64_t  CS_LDK_PaymentParameters_get_expiry_time(int64_t this_ptr) {
60031         LDKPaymentParameters this_ptr_conv;
60032         this_ptr_conv.inner = untag_ptr(this_ptr);
60033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60035         this_ptr_conv.is_owned = false;
60036         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
60037         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
60038         int64_t ret_ref = tag_ptr(ret_copy, true);
60039         return ret_ref;
60040 }
60041
60042 void  CS_LDK_PaymentParameters_set_expiry_time(int64_t this_ptr, int64_t val) {
60043         LDKPaymentParameters this_ptr_conv;
60044         this_ptr_conv.inner = untag_ptr(this_ptr);
60045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60047         this_ptr_conv.is_owned = false;
60048         void* val_ptr = untag_ptr(val);
60049         CHECK_ACCESS(val_ptr);
60050         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
60051         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
60052         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
60053 }
60054
60055 int32_t  CS_LDK_PaymentParameters_get_max_total_cltv_expiry_delta(int64_t this_ptr) {
60056         LDKPaymentParameters this_ptr_conv;
60057         this_ptr_conv.inner = untag_ptr(this_ptr);
60058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60060         this_ptr_conv.is_owned = false;
60061         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
60062         return ret_conv;
60063 }
60064
60065 void  CS_LDK_PaymentParameters_set_max_total_cltv_expiry_delta(int64_t this_ptr, int32_t val) {
60066         LDKPaymentParameters this_ptr_conv;
60067         this_ptr_conv.inner = untag_ptr(this_ptr);
60068         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60070         this_ptr_conv.is_owned = false;
60071         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
60072 }
60073
60074 int8_t  CS_LDK_PaymentParameters_get_max_path_count(int64_t this_ptr) {
60075         LDKPaymentParameters this_ptr_conv;
60076         this_ptr_conv.inner = untag_ptr(this_ptr);
60077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60079         this_ptr_conv.is_owned = false;
60080         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
60081         return ret_conv;
60082 }
60083
60084 void  CS_LDK_PaymentParameters_set_max_path_count(int64_t this_ptr, int8_t val) {
60085         LDKPaymentParameters this_ptr_conv;
60086         this_ptr_conv.inner = untag_ptr(this_ptr);
60087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60089         this_ptr_conv.is_owned = false;
60090         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
60091 }
60092
60093 int8_t  CS_LDK_PaymentParameters_get_max_channel_saturation_power_of_half(int64_t this_ptr) {
60094         LDKPaymentParameters this_ptr_conv;
60095         this_ptr_conv.inner = untag_ptr(this_ptr);
60096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60098         this_ptr_conv.is_owned = false;
60099         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
60100         return ret_conv;
60101 }
60102
60103 void  CS_LDK_PaymentParameters_set_max_channel_saturation_power_of_half(int64_t this_ptr, int8_t val) {
60104         LDKPaymentParameters this_ptr_conv;
60105         this_ptr_conv.inner = untag_ptr(this_ptr);
60106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60108         this_ptr_conv.is_owned = false;
60109         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
60110 }
60111
60112 int64_tArray  CS_LDK_PaymentParameters_get_previously_failed_channels(int64_t this_ptr) {
60113         LDKPaymentParameters this_ptr_conv;
60114         this_ptr_conv.inner = untag_ptr(this_ptr);
60115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60117         this_ptr_conv.is_owned = false;
60118         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
60119         int64_tArray ret_arr = NULL;
60120         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
60121         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
60122         for (size_t g = 0; g < ret_var.datalen; g++) {
60123                 int64_t ret_conv_6_conv = ret_var.data[g];
60124                 ret_arr_ptr[g] = ret_conv_6_conv;
60125         }
60126         
60127         FREE(ret_var.data);
60128         return ret_arr;
60129 }
60130
60131 void  CS_LDK_PaymentParameters_set_previously_failed_channels(int64_t this_ptr, int64_tArray val) {
60132         LDKPaymentParameters this_ptr_conv;
60133         this_ptr_conv.inner = untag_ptr(this_ptr);
60134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60136         this_ptr_conv.is_owned = false;
60137         LDKCVec_u64Z val_constr;
60138         val_constr.datalen = val->arr_len;
60139         if (val_constr.datalen > 0)
60140                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
60141         else
60142                 val_constr.data = NULL;
60143         int64_t* val_vals = val->elems;
60144         for (size_t g = 0; g < val_constr.datalen; g++) {
60145                 int64_t val_conv_6 = val_vals[g];
60146                 val_constr.data[g] = val_conv_6;
60147         }
60148         FREE(val);
60149         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
60150 }
60151
60152 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) {
60153         void* payee_arg_ptr = untag_ptr(payee_arg);
60154         CHECK_ACCESS(payee_arg_ptr);
60155         LDKPayee payee_arg_conv = *(LDKPayee*)(payee_arg_ptr);
60156         payee_arg_conv = Payee_clone((LDKPayee*)untag_ptr(payee_arg));
60157         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
60158         CHECK_ACCESS(expiry_time_arg_ptr);
60159         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
60160         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
60161         LDKCVec_u64Z previously_failed_channels_arg_constr;
60162         previously_failed_channels_arg_constr.datalen = previously_failed_channels_arg->arr_len;
60163         if (previously_failed_channels_arg_constr.datalen > 0)
60164                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
60165         else
60166                 previously_failed_channels_arg_constr.data = NULL;
60167         int64_t* previously_failed_channels_arg_vals = previously_failed_channels_arg->elems;
60168         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
60169                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
60170                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
60171         }
60172         FREE(previously_failed_channels_arg);
60173         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);
60174         int64_t ret_ref = 0;
60175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60177         return ret_ref;
60178 }
60179
60180 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
60181         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
60182         int64_t ret_ref = 0;
60183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60184         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60185         return ret_ref;
60186 }
60187 int64_t  CS_LDK_PaymentParameters_clone_ptr(int64_t arg) {
60188         LDKPaymentParameters arg_conv;
60189         arg_conv.inner = untag_ptr(arg);
60190         arg_conv.is_owned = ptr_is_owned(arg);
60191         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
60192         arg_conv.is_owned = false;
60193         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
60194         return ret_conv;
60195 }
60196
60197 int64_t  CS_LDK_PaymentParameters_clone(int64_t orig) {
60198         LDKPaymentParameters orig_conv;
60199         orig_conv.inner = untag_ptr(orig);
60200         orig_conv.is_owned = ptr_is_owned(orig);
60201         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
60202         orig_conv.is_owned = false;
60203         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
60204         int64_t ret_ref = 0;
60205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60206         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60207         return ret_ref;
60208 }
60209
60210 int64_t  CS_LDK_PaymentParameters_hash(int64_t o) {
60211         LDKPaymentParameters o_conv;
60212         o_conv.inner = untag_ptr(o);
60213         o_conv.is_owned = ptr_is_owned(o);
60214         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
60215         o_conv.is_owned = false;
60216         int64_t ret_conv = PaymentParameters_hash(&o_conv);
60217         return ret_conv;
60218 }
60219
60220 jboolean  CS_LDK_PaymentParameters_eq(int64_t a, int64_t b) {
60221         LDKPaymentParameters a_conv;
60222         a_conv.inner = untag_ptr(a);
60223         a_conv.is_owned = ptr_is_owned(a);
60224         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
60225         a_conv.is_owned = false;
60226         LDKPaymentParameters b_conv;
60227         b_conv.inner = untag_ptr(b);
60228         b_conv.is_owned = ptr_is_owned(b);
60229         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
60230         b_conv.is_owned = false;
60231         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
60232         return ret_conv;
60233 }
60234
60235 int8_tArray  CS_LDK_PaymentParameters_write(int64_t obj) {
60236         LDKPaymentParameters obj_conv;
60237         obj_conv.inner = untag_ptr(obj);
60238         obj_conv.is_owned = ptr_is_owned(obj);
60239         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
60240         obj_conv.is_owned = false;
60241         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
60242         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
60243         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
60244         CVec_u8Z_free(ret_var);
60245         return ret_arr;
60246 }
60247
60248 int64_t  CS_LDK_PaymentParameters_read(int8_tArray ser, int32_t arg) {
60249         LDKu8slice ser_ref;
60250         ser_ref.datalen = ser->arr_len;
60251         ser_ref.data = ser->elems;
60252         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
60253         *ret_conv = PaymentParameters_read(ser_ref, arg);
60254         FREE(ser);
60255         return tag_ptr(ret_conv, true);
60256 }
60257
60258 int64_t  CS_LDK_PaymentParameters_from_node_id(int8_tArray payee_pubkey, int32_t final_cltv_expiry_delta) {
60259         LDKPublicKey payee_pubkey_ref;
60260         CHECK(payee_pubkey->arr_len == 33);
60261         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
60262         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref, final_cltv_expiry_delta);
60263         int64_t ret_ref = 0;
60264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60266         return ret_ref;
60267 }
60268
60269 int64_t  CS_LDK_PaymentParameters_for_keysend(int8_tArray payee_pubkey, int32_t final_cltv_expiry_delta, jboolean allow_mpp) {
60270         LDKPublicKey payee_pubkey_ref;
60271         CHECK(payee_pubkey->arr_len == 33);
60272         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
60273         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref, final_cltv_expiry_delta, allow_mpp);
60274         int64_t ret_ref = 0;
60275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60277         return ret_ref;
60278 }
60279
60280 int64_t  CS_LDK_PaymentParameters_from_bolt12_invoice(int64_t invoice) {
60281         LDKBolt12Invoice invoice_conv;
60282         invoice_conv.inner = untag_ptr(invoice);
60283         invoice_conv.is_owned = ptr_is_owned(invoice);
60284         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
60285         invoice_conv.is_owned = false;
60286         LDKPaymentParameters ret_var = PaymentParameters_from_bolt12_invoice(&invoice_conv);
60287         int64_t ret_ref = 0;
60288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60290         return ret_ref;
60291 }
60292
60293 int64_t  CS_LDK_PaymentParameters_blinded(int64_tArray blinded_route_hints) {
60294         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ blinded_route_hints_constr;
60295         blinded_route_hints_constr.datalen = blinded_route_hints->arr_len;
60296         if (blinded_route_hints_constr.datalen > 0)
60297                 blinded_route_hints_constr.data = MALLOC(blinded_route_hints_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
60298         else
60299                 blinded_route_hints_constr.data = NULL;
60300         int64_t* blinded_route_hints_vals = blinded_route_hints->elems;
60301         for (size_t l = 0; l < blinded_route_hints_constr.datalen; l++) {
60302                 int64_t blinded_route_hints_conv_37 = blinded_route_hints_vals[l];
60303                 void* blinded_route_hints_conv_37_ptr = untag_ptr(blinded_route_hints_conv_37);
60304                 CHECK_ACCESS(blinded_route_hints_conv_37_ptr);
60305                 LDKC2Tuple_BlindedPayInfoBlindedPathZ blinded_route_hints_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(blinded_route_hints_conv_37_ptr);
60306                 blinded_route_hints_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(blinded_route_hints_conv_37));
60307                 blinded_route_hints_constr.data[l] = blinded_route_hints_conv_37_conv;
60308         }
60309         FREE(blinded_route_hints);
60310         LDKPaymentParameters ret_var = PaymentParameters_blinded(blinded_route_hints_constr);
60311         int64_t ret_ref = 0;
60312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60314         return ret_ref;
60315 }
60316
60317 void  CS_LDK_Payee_free(int64_t this_ptr) {
60318         if (!ptr_is_owned(this_ptr)) return;
60319         void* this_ptr_ptr = untag_ptr(this_ptr);
60320         CHECK_ACCESS(this_ptr_ptr);
60321         LDKPayee this_ptr_conv = *(LDKPayee*)(this_ptr_ptr);
60322         FREE(untag_ptr(this_ptr));
60323         Payee_free(this_ptr_conv);
60324 }
60325
60326 static inline uint64_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
60327         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60328         *ret_copy = Payee_clone(arg);
60329         int64_t ret_ref = tag_ptr(ret_copy, true);
60330         return ret_ref;
60331 }
60332 int64_t  CS_LDK_Payee_clone_ptr(int64_t arg) {
60333         LDKPayee* arg_conv = (LDKPayee*)untag_ptr(arg);
60334         int64_t ret_conv = Payee_clone_ptr(arg_conv);
60335         return ret_conv;
60336 }
60337
60338 int64_t  CS_LDK_Payee_clone(int64_t orig) {
60339         LDKPayee* orig_conv = (LDKPayee*)untag_ptr(orig);
60340         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60341         *ret_copy = Payee_clone(orig_conv);
60342         int64_t ret_ref = tag_ptr(ret_copy, true);
60343         return ret_ref;
60344 }
60345
60346 int64_t  CS_LDK_Payee_blinded(int64_tArray route_hints, int64_t features) {
60347         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints_constr;
60348         route_hints_constr.datalen = route_hints->arr_len;
60349         if (route_hints_constr.datalen > 0)
60350                 route_hints_constr.data = MALLOC(route_hints_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
60351         else
60352                 route_hints_constr.data = NULL;
60353         int64_t* route_hints_vals = route_hints->elems;
60354         for (size_t l = 0; l < route_hints_constr.datalen; l++) {
60355                 int64_t route_hints_conv_37 = route_hints_vals[l];
60356                 void* route_hints_conv_37_ptr = untag_ptr(route_hints_conv_37);
60357                 CHECK_ACCESS(route_hints_conv_37_ptr);
60358                 LDKC2Tuple_BlindedPayInfoBlindedPathZ route_hints_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(route_hints_conv_37_ptr);
60359                 route_hints_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(route_hints_conv_37));
60360                 route_hints_constr.data[l] = route_hints_conv_37_conv;
60361         }
60362         FREE(route_hints);
60363         LDKBolt12InvoiceFeatures features_conv;
60364         features_conv.inner = untag_ptr(features);
60365         features_conv.is_owned = ptr_is_owned(features);
60366         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
60367         features_conv = Bolt12InvoiceFeatures_clone(&features_conv);
60368         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60369         *ret_copy = Payee_blinded(route_hints_constr, features_conv);
60370         int64_t ret_ref = tag_ptr(ret_copy, true);
60371         return ret_ref;
60372 }
60373
60374 int64_t  CS_LDK_Payee_clear(int8_tArray node_id, int64_tArray route_hints, int64_t features, int32_t final_cltv_expiry_delta) {
60375         LDKPublicKey node_id_ref;
60376         CHECK(node_id->arr_len == 33);
60377         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
60378         LDKCVec_RouteHintZ route_hints_constr;
60379         route_hints_constr.datalen = route_hints->arr_len;
60380         if (route_hints_constr.datalen > 0)
60381                 route_hints_constr.data = MALLOC(route_hints_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
60382         else
60383                 route_hints_constr.data = NULL;
60384         int64_t* route_hints_vals = route_hints->elems;
60385         for (size_t l = 0; l < route_hints_constr.datalen; l++) {
60386                 int64_t route_hints_conv_11 = route_hints_vals[l];
60387                 LDKRouteHint route_hints_conv_11_conv;
60388                 route_hints_conv_11_conv.inner = untag_ptr(route_hints_conv_11);
60389                 route_hints_conv_11_conv.is_owned = ptr_is_owned(route_hints_conv_11);
60390                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_conv_11_conv);
60391                 route_hints_conv_11_conv = RouteHint_clone(&route_hints_conv_11_conv);
60392                 route_hints_constr.data[l] = route_hints_conv_11_conv;
60393         }
60394         FREE(route_hints);
60395         LDKBolt11InvoiceFeatures features_conv;
60396         features_conv.inner = untag_ptr(features);
60397         features_conv.is_owned = ptr_is_owned(features);
60398         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
60399         features_conv = Bolt11InvoiceFeatures_clone(&features_conv);
60400         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60401         *ret_copy = Payee_clear(node_id_ref, route_hints_constr, features_conv, final_cltv_expiry_delta);
60402         int64_t ret_ref = tag_ptr(ret_copy, true);
60403         return ret_ref;
60404 }
60405
60406 int64_t  CS_LDK_Payee_hash(int64_t o) {
60407         LDKPayee* o_conv = (LDKPayee*)untag_ptr(o);
60408         int64_t ret_conv = Payee_hash(o_conv);
60409         return ret_conv;
60410 }
60411
60412 jboolean  CS_LDK_Payee_eq(int64_t a, int64_t b) {
60413         LDKPayee* a_conv = (LDKPayee*)untag_ptr(a);
60414         LDKPayee* b_conv = (LDKPayee*)untag_ptr(b);
60415         jboolean ret_conv = Payee_eq(a_conv, b_conv);
60416         return ret_conv;
60417 }
60418
60419 void  CS_LDK_RouteHint_free(int64_t this_obj) {
60420         LDKRouteHint this_obj_conv;
60421         this_obj_conv.inner = untag_ptr(this_obj);
60422         this_obj_conv.is_owned = ptr_is_owned(this_obj);
60423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
60424         RouteHint_free(this_obj_conv);
60425 }
60426
60427 int64_tArray  CS_LDK_RouteHint_get_a(int64_t this_ptr) {
60428         LDKRouteHint this_ptr_conv;
60429         this_ptr_conv.inner = untag_ptr(this_ptr);
60430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60432         this_ptr_conv.is_owned = false;
60433         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
60434         int64_tArray ret_arr = NULL;
60435         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
60436         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
60437         for (size_t o = 0; o < ret_var.datalen; o++) {
60438                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
60439                 int64_t ret_conv_14_ref = 0;
60440                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
60441                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
60442                 ret_arr_ptr[o] = ret_conv_14_ref;
60443         }
60444         
60445         FREE(ret_var.data);
60446         return ret_arr;
60447 }
60448
60449 void  CS_LDK_RouteHint_set_a(int64_t this_ptr, int64_tArray val) {
60450         LDKRouteHint this_ptr_conv;
60451         this_ptr_conv.inner = untag_ptr(this_ptr);
60452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60454         this_ptr_conv.is_owned = false;
60455         LDKCVec_RouteHintHopZ val_constr;
60456         val_constr.datalen = val->arr_len;
60457         if (val_constr.datalen > 0)
60458                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
60459         else
60460                 val_constr.data = NULL;
60461         int64_t* val_vals = val->elems;
60462         for (size_t o = 0; o < val_constr.datalen; o++) {
60463                 int64_t val_conv_14 = val_vals[o];
60464                 LDKRouteHintHop val_conv_14_conv;
60465                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
60466                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
60467                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
60468                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
60469                 val_constr.data[o] = val_conv_14_conv;
60470         }
60471         FREE(val);
60472         RouteHint_set_a(&this_ptr_conv, val_constr);
60473 }
60474
60475 int64_t  CS_LDK_RouteHint_new(int64_tArray a_arg) {
60476         LDKCVec_RouteHintHopZ a_arg_constr;
60477         a_arg_constr.datalen = a_arg->arr_len;
60478         if (a_arg_constr.datalen > 0)
60479                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
60480         else
60481                 a_arg_constr.data = NULL;
60482         int64_t* a_arg_vals = a_arg->elems;
60483         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
60484                 int64_t a_arg_conv_14 = a_arg_vals[o];
60485                 LDKRouteHintHop a_arg_conv_14_conv;
60486                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
60487                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
60488                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
60489                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
60490                 a_arg_constr.data[o] = a_arg_conv_14_conv;
60491         }
60492         FREE(a_arg);
60493         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
60494         int64_t ret_ref = 0;
60495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60497         return ret_ref;
60498 }
60499
60500 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
60501         LDKRouteHint ret_var = RouteHint_clone(arg);
60502         int64_t ret_ref = 0;
60503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60505         return ret_ref;
60506 }
60507 int64_t  CS_LDK_RouteHint_clone_ptr(int64_t arg) {
60508         LDKRouteHint arg_conv;
60509         arg_conv.inner = untag_ptr(arg);
60510         arg_conv.is_owned = ptr_is_owned(arg);
60511         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
60512         arg_conv.is_owned = false;
60513         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
60514         return ret_conv;
60515 }
60516
60517 int64_t  CS_LDK_RouteHint_clone(int64_t orig) {
60518         LDKRouteHint orig_conv;
60519         orig_conv.inner = untag_ptr(orig);
60520         orig_conv.is_owned = ptr_is_owned(orig);
60521         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
60522         orig_conv.is_owned = false;
60523         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
60524         int64_t ret_ref = 0;
60525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60526         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60527         return ret_ref;
60528 }
60529
60530 int64_t  CS_LDK_RouteHint_hash(int64_t o) {
60531         LDKRouteHint o_conv;
60532         o_conv.inner = untag_ptr(o);
60533         o_conv.is_owned = ptr_is_owned(o);
60534         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
60535         o_conv.is_owned = false;
60536         int64_t ret_conv = RouteHint_hash(&o_conv);
60537         return ret_conv;
60538 }
60539
60540 jboolean  CS_LDK_RouteHint_eq(int64_t a, int64_t b) {
60541         LDKRouteHint a_conv;
60542         a_conv.inner = untag_ptr(a);
60543         a_conv.is_owned = ptr_is_owned(a);
60544         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
60545         a_conv.is_owned = false;
60546         LDKRouteHint b_conv;
60547         b_conv.inner = untag_ptr(b);
60548         b_conv.is_owned = ptr_is_owned(b);
60549         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
60550         b_conv.is_owned = false;
60551         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
60552         return ret_conv;
60553 }
60554
60555 int8_tArray  CS_LDK_RouteHint_write(int64_t obj) {
60556         LDKRouteHint obj_conv;
60557         obj_conv.inner = untag_ptr(obj);
60558         obj_conv.is_owned = ptr_is_owned(obj);
60559         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
60560         obj_conv.is_owned = false;
60561         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
60562         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
60563         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
60564         CVec_u8Z_free(ret_var);
60565         return ret_arr;
60566 }
60567
60568 int64_t  CS_LDK_RouteHint_read(int8_tArray ser) {
60569         LDKu8slice ser_ref;
60570         ser_ref.datalen = ser->arr_len;
60571         ser_ref.data = ser->elems;
60572         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
60573         *ret_conv = RouteHint_read(ser_ref);
60574         FREE(ser);
60575         return tag_ptr(ret_conv, true);
60576 }
60577
60578 void  CS_LDK_RouteHintHop_free(int64_t this_obj) {
60579         LDKRouteHintHop this_obj_conv;
60580         this_obj_conv.inner = untag_ptr(this_obj);
60581         this_obj_conv.is_owned = ptr_is_owned(this_obj);
60582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
60583         RouteHintHop_free(this_obj_conv);
60584 }
60585
60586 int8_tArray  CS_LDK_RouteHintHop_get_src_node_id(int64_t this_ptr) {
60587         LDKRouteHintHop this_ptr_conv;
60588         this_ptr_conv.inner = untag_ptr(this_ptr);
60589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60591         this_ptr_conv.is_owned = false;
60592         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
60593         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
60594         return ret_arr;
60595 }
60596
60597 void  CS_LDK_RouteHintHop_set_src_node_id(int64_t this_ptr, int8_tArray val) {
60598         LDKRouteHintHop this_ptr_conv;
60599         this_ptr_conv.inner = untag_ptr(this_ptr);
60600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60602         this_ptr_conv.is_owned = false;
60603         LDKPublicKey val_ref;
60604         CHECK(val->arr_len == 33);
60605         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
60606         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
60607 }
60608
60609 int64_t  CS_LDK_RouteHintHop_get_short_channel_id(int64_t this_ptr) {
60610         LDKRouteHintHop this_ptr_conv;
60611         this_ptr_conv.inner = untag_ptr(this_ptr);
60612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60614         this_ptr_conv.is_owned = false;
60615         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
60616         return ret_conv;
60617 }
60618
60619 void  CS_LDK_RouteHintHop_set_short_channel_id(int64_t this_ptr, int64_t val) {
60620         LDKRouteHintHop this_ptr_conv;
60621         this_ptr_conv.inner = untag_ptr(this_ptr);
60622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60624         this_ptr_conv.is_owned = false;
60625         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
60626 }
60627
60628 int64_t  CS_LDK_RouteHintHop_get_fees(int64_t this_ptr) {
60629         LDKRouteHintHop this_ptr_conv;
60630         this_ptr_conv.inner = untag_ptr(this_ptr);
60631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60633         this_ptr_conv.is_owned = false;
60634         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
60635         int64_t ret_ref = 0;
60636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60638         return ret_ref;
60639 }
60640
60641 void  CS_LDK_RouteHintHop_set_fees(int64_t this_ptr, int64_t val) {
60642         LDKRouteHintHop this_ptr_conv;
60643         this_ptr_conv.inner = untag_ptr(this_ptr);
60644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60646         this_ptr_conv.is_owned = false;
60647         LDKRoutingFees val_conv;
60648         val_conv.inner = untag_ptr(val);
60649         val_conv.is_owned = ptr_is_owned(val);
60650         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
60651         val_conv = RoutingFees_clone(&val_conv);
60652         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
60653 }
60654
60655 int16_t  CS_LDK_RouteHintHop_get_cltv_expiry_delta(int64_t this_ptr) {
60656         LDKRouteHintHop this_ptr_conv;
60657         this_ptr_conv.inner = untag_ptr(this_ptr);
60658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60660         this_ptr_conv.is_owned = false;
60661         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
60662         return ret_conv;
60663 }
60664
60665 void  CS_LDK_RouteHintHop_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
60666         LDKRouteHintHop this_ptr_conv;
60667         this_ptr_conv.inner = untag_ptr(this_ptr);
60668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60670         this_ptr_conv.is_owned = false;
60671         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
60672 }
60673
60674 int64_t  CS_LDK_RouteHintHop_get_htlc_minimum_msat(int64_t this_ptr) {
60675         LDKRouteHintHop this_ptr_conv;
60676         this_ptr_conv.inner = untag_ptr(this_ptr);
60677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60679         this_ptr_conv.is_owned = false;
60680         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
60681         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
60682         int64_t ret_ref = tag_ptr(ret_copy, true);
60683         return ret_ref;
60684 }
60685
60686 void  CS_LDK_RouteHintHop_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
60687         LDKRouteHintHop this_ptr_conv;
60688         this_ptr_conv.inner = untag_ptr(this_ptr);
60689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60691         this_ptr_conv.is_owned = false;
60692         void* val_ptr = untag_ptr(val);
60693         CHECK_ACCESS(val_ptr);
60694         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
60695         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
60696         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
60697 }
60698
60699 int64_t  CS_LDK_RouteHintHop_get_htlc_maximum_msat(int64_t this_ptr) {
60700         LDKRouteHintHop this_ptr_conv;
60701         this_ptr_conv.inner = untag_ptr(this_ptr);
60702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60704         this_ptr_conv.is_owned = false;
60705         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
60706         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
60707         int64_t ret_ref = tag_ptr(ret_copy, true);
60708         return ret_ref;
60709 }
60710
60711 void  CS_LDK_RouteHintHop_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
60712         LDKRouteHintHop this_ptr_conv;
60713         this_ptr_conv.inner = untag_ptr(this_ptr);
60714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60716         this_ptr_conv.is_owned = false;
60717         void* val_ptr = untag_ptr(val);
60718         CHECK_ACCESS(val_ptr);
60719         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
60720         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
60721         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
60722 }
60723
60724 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) {
60725         LDKPublicKey src_node_id_arg_ref;
60726         CHECK(src_node_id_arg->arr_len == 33);
60727         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
60728         LDKRoutingFees fees_arg_conv;
60729         fees_arg_conv.inner = untag_ptr(fees_arg);
60730         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
60731         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
60732         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
60733         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
60734         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
60735         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
60736         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
60737         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
60738         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
60739         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
60740         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
60741         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);
60742         int64_t ret_ref = 0;
60743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60745         return ret_ref;
60746 }
60747
60748 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
60749         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
60750         int64_t ret_ref = 0;
60751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60753         return ret_ref;
60754 }
60755 int64_t  CS_LDK_RouteHintHop_clone_ptr(int64_t arg) {
60756         LDKRouteHintHop arg_conv;
60757         arg_conv.inner = untag_ptr(arg);
60758         arg_conv.is_owned = ptr_is_owned(arg);
60759         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
60760         arg_conv.is_owned = false;
60761         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
60762         return ret_conv;
60763 }
60764
60765 int64_t  CS_LDK_RouteHintHop_clone(int64_t orig) {
60766         LDKRouteHintHop orig_conv;
60767         orig_conv.inner = untag_ptr(orig);
60768         orig_conv.is_owned = ptr_is_owned(orig);
60769         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
60770         orig_conv.is_owned = false;
60771         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
60772         int64_t ret_ref = 0;
60773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60775         return ret_ref;
60776 }
60777
60778 int64_t  CS_LDK_RouteHintHop_hash(int64_t o) {
60779         LDKRouteHintHop o_conv;
60780         o_conv.inner = untag_ptr(o);
60781         o_conv.is_owned = ptr_is_owned(o);
60782         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
60783         o_conv.is_owned = false;
60784         int64_t ret_conv = RouteHintHop_hash(&o_conv);
60785         return ret_conv;
60786 }
60787
60788 jboolean  CS_LDK_RouteHintHop_eq(int64_t a, int64_t b) {
60789         LDKRouteHintHop a_conv;
60790         a_conv.inner = untag_ptr(a);
60791         a_conv.is_owned = ptr_is_owned(a);
60792         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
60793         a_conv.is_owned = false;
60794         LDKRouteHintHop b_conv;
60795         b_conv.inner = untag_ptr(b);
60796         b_conv.is_owned = ptr_is_owned(b);
60797         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
60798         b_conv.is_owned = false;
60799         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
60800         return ret_conv;
60801 }
60802
60803 int8_tArray  CS_LDK_RouteHintHop_write(int64_t obj) {
60804         LDKRouteHintHop obj_conv;
60805         obj_conv.inner = untag_ptr(obj);
60806         obj_conv.is_owned = ptr_is_owned(obj);
60807         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
60808         obj_conv.is_owned = false;
60809         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
60810         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
60811         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
60812         CVec_u8Z_free(ret_var);
60813         return ret_arr;
60814 }
60815
60816 int64_t  CS_LDK_RouteHintHop_read(int8_tArray ser) {
60817         LDKu8slice ser_ref;
60818         ser_ref.datalen = ser->arr_len;
60819         ser_ref.data = ser->elems;
60820         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
60821         *ret_conv = RouteHintHop_read(ser_ref);
60822         FREE(ser);
60823         return tag_ptr(ret_conv, true);
60824 }
60825
60826 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) {
60827         LDKPublicKey our_node_pubkey_ref;
60828         CHECK(our_node_pubkey->arr_len == 33);
60829         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
60830         LDKRouteParameters route_params_conv;
60831         route_params_conv.inner = untag_ptr(route_params);
60832         route_params_conv.is_owned = ptr_is_owned(route_params);
60833         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
60834         route_params_conv.is_owned = false;
60835         LDKNetworkGraph network_graph_conv;
60836         network_graph_conv.inner = untag_ptr(network_graph);
60837         network_graph_conv.is_owned = ptr_is_owned(network_graph);
60838         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
60839         network_graph_conv.is_owned = false;
60840         LDKCVec_ChannelDetailsZ first_hops_constr;
60841         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
60842         if (first_hops != NULL) {
60843                 first_hops_constr.datalen = first_hops->arr_len;
60844                 if (first_hops_constr.datalen > 0)
60845                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
60846                 else
60847                         first_hops_constr.data = NULL;
60848                 int64_t* first_hops_vals = first_hops->elems;
60849                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
60850                         int64_t first_hops_conv_16 = first_hops_vals[q];
60851                         LDKChannelDetails first_hops_conv_16_conv;
60852                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
60853                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
60854                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
60855                         first_hops_conv_16_conv.is_owned = false;
60856                         first_hops_constr.data[q] = first_hops_conv_16_conv;
60857                 }
60858                 FREE(first_hops);
60859                 first_hops_ptr = &first_hops_constr;
60860         }
60861         void* logger_ptr = untag_ptr(logger);
60862         CHECK_ACCESS(logger_ptr);
60863         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
60864         if (logger_conv.free == LDKLogger_JCalls_free) {
60865                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
60866                 LDKLogger_JCalls_cloned(&logger_conv);
60867         }
60868         void* scorer_ptr = untag_ptr(scorer);
60869         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
60870         LDKScoreLookUp* scorer_conv = (LDKScoreLookUp*)scorer_ptr;
60871         LDKProbabilisticScoringFeeParameters score_params_conv;
60872         score_params_conv.inner = untag_ptr(score_params);
60873         score_params_conv.is_owned = ptr_is_owned(score_params);
60874         CHECK_INNER_FIELD_ACCESS_OR_NULL(score_params_conv);
60875         score_params_conv.is_owned = false;
60876         uint8_t random_seed_bytes_arr[32];
60877         CHECK(random_seed_bytes->arr_len == 32);
60878         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
60879         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
60880         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
60881         *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);
60882         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
60883         return tag_ptr(ret_conv, true);
60884 }
60885
60886 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) {
60887         LDKPublicKey our_node_pubkey_ref;
60888         CHECK(our_node_pubkey->arr_len == 33);
60889         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
60890         LDKCVec_PublicKeyZ hops_constr;
60891         hops_constr.datalen = hops->arr_len;
60892         if (hops_constr.datalen > 0)
60893                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
60894         else
60895                 hops_constr.data = NULL;
60896         int8_tArray* hops_vals = (void*) hops->elems;
60897         for (size_t i = 0; i < hops_constr.datalen; i++) {
60898                 int8_tArray hops_conv_8 = hops_vals[i];
60899                 LDKPublicKey hops_conv_8_ref;
60900                 CHECK(hops_conv_8->arr_len == 33);
60901                 memcpy(hops_conv_8_ref.compressed_form, hops_conv_8->elems, 33); FREE(hops_conv_8);
60902                 hops_constr.data[i] = hops_conv_8_ref;
60903         }
60904         FREE(hops);
60905         LDKRouteParameters route_params_conv;
60906         route_params_conv.inner = untag_ptr(route_params);
60907         route_params_conv.is_owned = ptr_is_owned(route_params);
60908         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
60909         route_params_conv.is_owned = false;
60910         LDKNetworkGraph network_graph_conv;
60911         network_graph_conv.inner = untag_ptr(network_graph);
60912         network_graph_conv.is_owned = ptr_is_owned(network_graph);
60913         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
60914         network_graph_conv.is_owned = false;
60915         void* logger_ptr = untag_ptr(logger);
60916         CHECK_ACCESS(logger_ptr);
60917         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
60918         if (logger_conv.free == LDKLogger_JCalls_free) {
60919                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
60920                 LDKLogger_JCalls_cloned(&logger_conv);
60921         }
60922         uint8_t random_seed_bytes_arr[32];
60923         CHECK(random_seed_bytes->arr_len == 32);
60924         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
60925         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
60926         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
60927         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
60928         return tag_ptr(ret_conv, true);
60929 }
60930
60931 void  CS_LDK_ScoreLookUp_free(int64_t this_ptr) {
60932         if (!ptr_is_owned(this_ptr)) return;
60933         void* this_ptr_ptr = untag_ptr(this_ptr);
60934         CHECK_ACCESS(this_ptr_ptr);
60935         LDKScoreLookUp this_ptr_conv = *(LDKScoreLookUp*)(this_ptr_ptr);
60936         FREE(untag_ptr(this_ptr));
60937         ScoreLookUp_free(this_ptr_conv);
60938 }
60939
60940 void  CS_LDK_ScoreUpdate_free(int64_t this_ptr) {
60941         if (!ptr_is_owned(this_ptr)) return;
60942         void* this_ptr_ptr = untag_ptr(this_ptr);
60943         CHECK_ACCESS(this_ptr_ptr);
60944         LDKScoreUpdate this_ptr_conv = *(LDKScoreUpdate*)(this_ptr_ptr);
60945         FREE(untag_ptr(this_ptr));
60946         ScoreUpdate_free(this_ptr_conv);
60947 }
60948
60949 void  CS_LDK_Score_free(int64_t this_ptr) {
60950         if (!ptr_is_owned(this_ptr)) return;
60951         void* this_ptr_ptr = untag_ptr(this_ptr);
60952         CHECK_ACCESS(this_ptr_ptr);
60953         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
60954         FREE(untag_ptr(this_ptr));
60955         Score_free(this_ptr_conv);
60956 }
60957
60958 void  CS_LDK_LockableScore_free(int64_t this_ptr) {
60959         if (!ptr_is_owned(this_ptr)) return;
60960         void* this_ptr_ptr = untag_ptr(this_ptr);
60961         CHECK_ACCESS(this_ptr_ptr);
60962         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
60963         FREE(untag_ptr(this_ptr));
60964         LockableScore_free(this_ptr_conv);
60965 }
60966
60967 void  CS_LDK_WriteableScore_free(int64_t this_ptr) {
60968         if (!ptr_is_owned(this_ptr)) return;
60969         void* this_ptr_ptr = untag_ptr(this_ptr);
60970         CHECK_ACCESS(this_ptr_ptr);
60971         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
60972         FREE(untag_ptr(this_ptr));
60973         WriteableScore_free(this_ptr_conv);
60974 }
60975
60976 void  CS_LDK_MultiThreadedLockableScore_free(int64_t this_obj) {
60977         LDKMultiThreadedLockableScore this_obj_conv;
60978         this_obj_conv.inner = untag_ptr(this_obj);
60979         this_obj_conv.is_owned = ptr_is_owned(this_obj);
60980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
60981         MultiThreadedLockableScore_free(this_obj_conv);
60982 }
60983
60984 int64_t  CS_LDK_MultiThreadedLockableScore_as_LockableScore(int64_t this_arg) {
60985         LDKMultiThreadedLockableScore this_arg_conv;
60986         this_arg_conv.inner = untag_ptr(this_arg);
60987         this_arg_conv.is_owned = ptr_is_owned(this_arg);
60988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
60989         this_arg_conv.is_owned = false;
60990         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
60991         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
60992         return tag_ptr(ret_ret, true);
60993 }
60994
60995 int8_tArray  CS_LDK_MultiThreadedLockableScore_write(int64_t obj) {
60996         LDKMultiThreadedLockableScore obj_conv;
60997         obj_conv.inner = untag_ptr(obj);
60998         obj_conv.is_owned = ptr_is_owned(obj);
60999         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
61000         obj_conv.is_owned = false;
61001         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
61002         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
61003         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
61004         CVec_u8Z_free(ret_var);
61005         return ret_arr;
61006 }
61007
61008 int64_t  CS_LDK_MultiThreadedLockableScore_as_WriteableScore(int64_t this_arg) {
61009         LDKMultiThreadedLockableScore this_arg_conv;
61010         this_arg_conv.inner = untag_ptr(this_arg);
61011         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61013         this_arg_conv.is_owned = false;
61014         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
61015         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
61016         return tag_ptr(ret_ret, true);
61017 }
61018
61019 int64_t  CS_LDK_MultiThreadedLockableScore_new(int64_t score) {
61020         void* score_ptr = untag_ptr(score);
61021         CHECK_ACCESS(score_ptr);
61022         LDKScore score_conv = *(LDKScore*)(score_ptr);
61023         if (score_conv.free == LDKScore_JCalls_free) {
61024                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
61025                 LDKScore_JCalls_cloned(&score_conv);
61026         }
61027         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
61028         int64_t ret_ref = 0;
61029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61030         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61031         return ret_ref;
61032 }
61033
61034 void  CS_LDK_MultiThreadedScoreLockRead_free(int64_t this_obj) {
61035         LDKMultiThreadedScoreLockRead this_obj_conv;
61036         this_obj_conv.inner = untag_ptr(this_obj);
61037         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61039         MultiThreadedScoreLockRead_free(this_obj_conv);
61040 }
61041
61042 void  CS_LDK_MultiThreadedScoreLockWrite_free(int64_t this_obj) {
61043         LDKMultiThreadedScoreLockWrite this_obj_conv;
61044         this_obj_conv.inner = untag_ptr(this_obj);
61045         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61047         MultiThreadedScoreLockWrite_free(this_obj_conv);
61048 }
61049
61050 int64_t  CS_LDK_MultiThreadedScoreLockRead_as_ScoreLookUp(int64_t this_arg) {
61051         LDKMultiThreadedScoreLockRead this_arg_conv;
61052         this_arg_conv.inner = untag_ptr(this_arg);
61053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61055         this_arg_conv.is_owned = false;
61056         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
61057         *ret_ret = MultiThreadedScoreLockRead_as_ScoreLookUp(&this_arg_conv);
61058         return tag_ptr(ret_ret, true);
61059 }
61060
61061 int8_tArray  CS_LDK_MultiThreadedScoreLockWrite_write(int64_t obj) {
61062         LDKMultiThreadedScoreLockWrite obj_conv;
61063         obj_conv.inner = untag_ptr(obj);
61064         obj_conv.is_owned = ptr_is_owned(obj);
61065         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
61066         obj_conv.is_owned = false;
61067         LDKCVec_u8Z ret_var = MultiThreadedScoreLockWrite_write(&obj_conv);
61068         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
61069         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
61070         CVec_u8Z_free(ret_var);
61071         return ret_arr;
61072 }
61073
61074 int64_t  CS_LDK_MultiThreadedScoreLockWrite_as_ScoreUpdate(int64_t this_arg) {
61075         LDKMultiThreadedScoreLockWrite this_arg_conv;
61076         this_arg_conv.inner = untag_ptr(this_arg);
61077         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61079         this_arg_conv.is_owned = false;
61080         LDKScoreUpdate* ret_ret = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
61081         *ret_ret = MultiThreadedScoreLockWrite_as_ScoreUpdate(&this_arg_conv);
61082         return tag_ptr(ret_ret, true);
61083 }
61084
61085 void  CS_LDK_ChannelUsage_free(int64_t this_obj) {
61086         LDKChannelUsage this_obj_conv;
61087         this_obj_conv.inner = untag_ptr(this_obj);
61088         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61090         ChannelUsage_free(this_obj_conv);
61091 }
61092
61093 int64_t  CS_LDK_ChannelUsage_get_amount_msat(int64_t this_ptr) {
61094         LDKChannelUsage this_ptr_conv;
61095         this_ptr_conv.inner = untag_ptr(this_ptr);
61096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61098         this_ptr_conv.is_owned = false;
61099         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
61100         return ret_conv;
61101 }
61102
61103 void  CS_LDK_ChannelUsage_set_amount_msat(int64_t this_ptr, int64_t val) {
61104         LDKChannelUsage this_ptr_conv;
61105         this_ptr_conv.inner = untag_ptr(this_ptr);
61106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61108         this_ptr_conv.is_owned = false;
61109         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
61110 }
61111
61112 int64_t  CS_LDK_ChannelUsage_get_inflight_htlc_msat(int64_t this_ptr) {
61113         LDKChannelUsage this_ptr_conv;
61114         this_ptr_conv.inner = untag_ptr(this_ptr);
61115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61117         this_ptr_conv.is_owned = false;
61118         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
61119         return ret_conv;
61120 }
61121
61122 void  CS_LDK_ChannelUsage_set_inflight_htlc_msat(int64_t this_ptr, int64_t val) {
61123         LDKChannelUsage this_ptr_conv;
61124         this_ptr_conv.inner = untag_ptr(this_ptr);
61125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61127         this_ptr_conv.is_owned = false;
61128         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
61129 }
61130
61131 int64_t  CS_LDK_ChannelUsage_get_effective_capacity(int64_t this_ptr) {
61132         LDKChannelUsage this_ptr_conv;
61133         this_ptr_conv.inner = untag_ptr(this_ptr);
61134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61136         this_ptr_conv.is_owned = false;
61137         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
61138         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
61139         int64_t ret_ref = tag_ptr(ret_copy, true);
61140         return ret_ref;
61141 }
61142
61143 void  CS_LDK_ChannelUsage_set_effective_capacity(int64_t this_ptr, int64_t val) {
61144         LDKChannelUsage this_ptr_conv;
61145         this_ptr_conv.inner = untag_ptr(this_ptr);
61146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61148         this_ptr_conv.is_owned = false;
61149         void* val_ptr = untag_ptr(val);
61150         CHECK_ACCESS(val_ptr);
61151         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
61152         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
61153         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
61154 }
61155
61156 int64_t  CS_LDK_ChannelUsage_new(int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, int64_t effective_capacity_arg) {
61157         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
61158         CHECK_ACCESS(effective_capacity_arg_ptr);
61159         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
61160         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
61161         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
61162         int64_t ret_ref = 0;
61163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61165         return ret_ref;
61166 }
61167
61168 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
61169         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
61170         int64_t ret_ref = 0;
61171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61173         return ret_ref;
61174 }
61175 int64_t  CS_LDK_ChannelUsage_clone_ptr(int64_t arg) {
61176         LDKChannelUsage arg_conv;
61177         arg_conv.inner = untag_ptr(arg);
61178         arg_conv.is_owned = ptr_is_owned(arg);
61179         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
61180         arg_conv.is_owned = false;
61181         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
61182         return ret_conv;
61183 }
61184
61185 int64_t  CS_LDK_ChannelUsage_clone(int64_t orig) {
61186         LDKChannelUsage orig_conv;
61187         orig_conv.inner = untag_ptr(orig);
61188         orig_conv.is_owned = ptr_is_owned(orig);
61189         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
61190         orig_conv.is_owned = false;
61191         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
61192         int64_t ret_ref = 0;
61193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61195         return ret_ref;
61196 }
61197
61198 void  CS_LDK_FixedPenaltyScorer_free(int64_t this_obj) {
61199         LDKFixedPenaltyScorer this_obj_conv;
61200         this_obj_conv.inner = untag_ptr(this_obj);
61201         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61203         FixedPenaltyScorer_free(this_obj_conv);
61204 }
61205
61206 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
61207         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
61208         int64_t ret_ref = 0;
61209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61211         return ret_ref;
61212 }
61213 int64_t  CS_LDK_FixedPenaltyScorer_clone_ptr(int64_t arg) {
61214         LDKFixedPenaltyScorer arg_conv;
61215         arg_conv.inner = untag_ptr(arg);
61216         arg_conv.is_owned = ptr_is_owned(arg);
61217         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
61218         arg_conv.is_owned = false;
61219         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
61220         return ret_conv;
61221 }
61222
61223 int64_t  CS_LDK_FixedPenaltyScorer_clone(int64_t orig) {
61224         LDKFixedPenaltyScorer orig_conv;
61225         orig_conv.inner = untag_ptr(orig);
61226         orig_conv.is_owned = ptr_is_owned(orig);
61227         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
61228         orig_conv.is_owned = false;
61229         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
61230         int64_t ret_ref = 0;
61231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61233         return ret_ref;
61234 }
61235
61236 int64_t  CS_LDK_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
61237         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
61238         int64_t ret_ref = 0;
61239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61241         return ret_ref;
61242 }
61243
61244 int64_t  CS_LDK_FixedPenaltyScorer_as_ScoreLookUp(int64_t this_arg) {
61245         LDKFixedPenaltyScorer this_arg_conv;
61246         this_arg_conv.inner = untag_ptr(this_arg);
61247         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61249         this_arg_conv.is_owned = false;
61250         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
61251         *ret_ret = FixedPenaltyScorer_as_ScoreLookUp(&this_arg_conv);
61252         return tag_ptr(ret_ret, true);
61253 }
61254
61255 int64_t  CS_LDK_FixedPenaltyScorer_as_ScoreUpdate(int64_t this_arg) {
61256         LDKFixedPenaltyScorer this_arg_conv;
61257         this_arg_conv.inner = untag_ptr(this_arg);
61258         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61260         this_arg_conv.is_owned = false;
61261         LDKScoreUpdate* ret_ret = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
61262         *ret_ret = FixedPenaltyScorer_as_ScoreUpdate(&this_arg_conv);
61263         return tag_ptr(ret_ret, true);
61264 }
61265
61266 int8_tArray  CS_LDK_FixedPenaltyScorer_write(int64_t obj) {
61267         LDKFixedPenaltyScorer obj_conv;
61268         obj_conv.inner = untag_ptr(obj);
61269         obj_conv.is_owned = ptr_is_owned(obj);
61270         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
61271         obj_conv.is_owned = false;
61272         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
61273         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
61274         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
61275         CVec_u8Z_free(ret_var);
61276         return ret_arr;
61277 }
61278
61279 int64_t  CS_LDK_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
61280         LDKu8slice ser_ref;
61281         ser_ref.datalen = ser->arr_len;
61282         ser_ref.data = ser->elems;
61283         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
61284         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
61285         FREE(ser);
61286         return tag_ptr(ret_conv, true);
61287 }
61288
61289 void  CS_LDK_ProbabilisticScorer_free(int64_t this_obj) {
61290         LDKProbabilisticScorer this_obj_conv;
61291         this_obj_conv.inner = untag_ptr(this_obj);
61292         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61294         ProbabilisticScorer_free(this_obj_conv);
61295 }
61296
61297 void  CS_LDK_ProbabilisticScoringFeeParameters_free(int64_t this_obj) {
61298         LDKProbabilisticScoringFeeParameters this_obj_conv;
61299         this_obj_conv.inner = untag_ptr(this_obj);
61300         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61302         ProbabilisticScoringFeeParameters_free(this_obj_conv);
61303 }
61304
61305 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_base_penalty_msat(int64_t this_ptr) {
61306         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61307         this_ptr_conv.inner = untag_ptr(this_ptr);
61308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61310         this_ptr_conv.is_owned = false;
61311         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_base_penalty_msat(&this_ptr_conv);
61312         return ret_conv;
61313 }
61314
61315 void  CS_LDK_ProbabilisticScoringFeeParameters_set_base_penalty_msat(int64_t this_ptr, int64_t val) {
61316         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61317         this_ptr_conv.inner = untag_ptr(this_ptr);
61318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61320         this_ptr_conv.is_owned = false;
61321         ProbabilisticScoringFeeParameters_set_base_penalty_msat(&this_ptr_conv, val);
61322 }
61323
61324 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(int64_t this_ptr) {
61325         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61326         this_ptr_conv.inner = untag_ptr(this_ptr);
61327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61329         this_ptr_conv.is_owned = false;
61330         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
61331         return ret_conv;
61332 }
61333
61334 void  CS_LDK_ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(int64_t this_ptr, int64_t val) {
61335         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61336         this_ptr_conv.inner = untag_ptr(this_ptr);
61337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61339         this_ptr_conv.is_owned = false;
61340         ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
61341 }
61342
61343 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(int64_t this_ptr) {
61344         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61345         this_ptr_conv.inner = untag_ptr(this_ptr);
61346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61348         this_ptr_conv.is_owned = false;
61349         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
61350         return ret_conv;
61351 }
61352
61353 void  CS_LDK_ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(int64_t this_ptr, int64_t val) {
61354         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61355         this_ptr_conv.inner = untag_ptr(this_ptr);
61356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61358         this_ptr_conv.is_owned = false;
61359         ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
61360 }
61361
61362 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(int64_t this_ptr) {
61363         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61364         this_ptr_conv.inner = untag_ptr(this_ptr);
61365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61367         this_ptr_conv.is_owned = false;
61368         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
61369         return ret_conv;
61370 }
61371
61372 void  CS_LDK_ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(int64_t this_ptr, int64_t val) {
61373         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61374         this_ptr_conv.inner = untag_ptr(this_ptr);
61375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61377         this_ptr_conv.is_owned = false;
61378         ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
61379 }
61380
61381 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(int64_t this_ptr) {
61382         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61383         this_ptr_conv.inner = untag_ptr(this_ptr);
61384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61386         this_ptr_conv.is_owned = false;
61387         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
61388         return ret_conv;
61389 }
61390
61391 void  CS_LDK_ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(int64_t this_ptr, int64_t val) {
61392         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61393         this_ptr_conv.inner = untag_ptr(this_ptr);
61394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61396         this_ptr_conv.is_owned = false;
61397         ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
61398 }
61399
61400 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(int64_t this_ptr) {
61401         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61402         this_ptr_conv.inner = untag_ptr(this_ptr);
61403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61405         this_ptr_conv.is_owned = false;
61406         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
61407         return ret_conv;
61408 }
61409
61410 void  CS_LDK_ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(int64_t this_ptr, int64_t val) {
61411         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61412         this_ptr_conv.inner = untag_ptr(this_ptr);
61413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61415         this_ptr_conv.is_owned = false;
61416         ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
61417 }
61418
61419 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(int64_t this_ptr) {
61420         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61421         this_ptr_conv.inner = untag_ptr(this_ptr);
61422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61424         this_ptr_conv.is_owned = false;
61425         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
61426         return ret_conv;
61427 }
61428
61429 void  CS_LDK_ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(int64_t this_ptr, int64_t val) {
61430         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61431         this_ptr_conv.inner = untag_ptr(this_ptr);
61432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61434         this_ptr_conv.is_owned = false;
61435         ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
61436 }
61437
61438 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(int64_t this_ptr) {
61439         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61440         this_ptr_conv.inner = untag_ptr(this_ptr);
61441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61443         this_ptr_conv.is_owned = false;
61444         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
61445         return ret_conv;
61446 }
61447
61448 void  CS_LDK_ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(int64_t this_ptr, int64_t val) {
61449         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61450         this_ptr_conv.inner = untag_ptr(this_ptr);
61451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61453         this_ptr_conv.is_owned = false;
61454         ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
61455 }
61456
61457 jboolean  CS_LDK_ProbabilisticScoringFeeParameters_get_linear_success_probability(int64_t this_ptr) {
61458         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61459         this_ptr_conv.inner = untag_ptr(this_ptr);
61460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61462         this_ptr_conv.is_owned = false;
61463         jboolean ret_conv = ProbabilisticScoringFeeParameters_get_linear_success_probability(&this_ptr_conv);
61464         return ret_conv;
61465 }
61466
61467 void  CS_LDK_ProbabilisticScoringFeeParameters_set_linear_success_probability(int64_t this_ptr, jboolean val) {
61468         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61469         this_ptr_conv.inner = untag_ptr(this_ptr);
61470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61472         this_ptr_conv.is_owned = false;
61473         ProbabilisticScoringFeeParameters_set_linear_success_probability(&this_ptr_conv, val);
61474 }
61475
61476 static inline uint64_t ProbabilisticScoringFeeParameters_clone_ptr(LDKProbabilisticScoringFeeParameters *NONNULL_PTR arg) {
61477         LDKProbabilisticScoringFeeParameters ret_var = ProbabilisticScoringFeeParameters_clone(arg);
61478         int64_t ret_ref = 0;
61479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61481         return ret_ref;
61482 }
61483 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_clone_ptr(int64_t arg) {
61484         LDKProbabilisticScoringFeeParameters arg_conv;
61485         arg_conv.inner = untag_ptr(arg);
61486         arg_conv.is_owned = ptr_is_owned(arg);
61487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
61488         arg_conv.is_owned = false;
61489         int64_t ret_conv = ProbabilisticScoringFeeParameters_clone_ptr(&arg_conv);
61490         return ret_conv;
61491 }
61492
61493 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_clone(int64_t orig) {
61494         LDKProbabilisticScoringFeeParameters orig_conv;
61495         orig_conv.inner = untag_ptr(orig);
61496         orig_conv.is_owned = ptr_is_owned(orig);
61497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
61498         orig_conv.is_owned = false;
61499         LDKProbabilisticScoringFeeParameters ret_var = ProbabilisticScoringFeeParameters_clone(&orig_conv);
61500         int64_t ret_ref = 0;
61501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61503         return ret_ref;
61504 }
61505
61506 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_default() {
61507         LDKProbabilisticScoringFeeParameters ret_var = ProbabilisticScoringFeeParameters_default();
61508         int64_t ret_ref = 0;
61509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61511         return ret_ref;
61512 }
61513
61514 void  CS_LDK_ProbabilisticScoringFeeParameters_add_banned(int64_t this_arg, int64_t node_id) {
61515         LDKProbabilisticScoringFeeParameters this_arg_conv;
61516         this_arg_conv.inner = untag_ptr(this_arg);
61517         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61519         this_arg_conv.is_owned = false;
61520         LDKNodeId node_id_conv;
61521         node_id_conv.inner = untag_ptr(node_id);
61522         node_id_conv.is_owned = ptr_is_owned(node_id);
61523         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
61524         node_id_conv.is_owned = false;
61525         ProbabilisticScoringFeeParameters_add_banned(&this_arg_conv, &node_id_conv);
61526 }
61527
61528 void  CS_LDK_ProbabilisticScoringFeeParameters_add_banned_from_list(int64_t this_arg, int64_tArray node_ids) {
61529         LDKProbabilisticScoringFeeParameters this_arg_conv;
61530         this_arg_conv.inner = untag_ptr(this_arg);
61531         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61533         this_arg_conv.is_owned = false;
61534         LDKCVec_NodeIdZ node_ids_constr;
61535         node_ids_constr.datalen = node_ids->arr_len;
61536         if (node_ids_constr.datalen > 0)
61537                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
61538         else
61539                 node_ids_constr.data = NULL;
61540         int64_t* node_ids_vals = node_ids->elems;
61541         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
61542                 int64_t node_ids_conv_8 = node_ids_vals[i];
61543                 LDKNodeId node_ids_conv_8_conv;
61544                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
61545                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
61546                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
61547                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
61548                 node_ids_constr.data[i] = node_ids_conv_8_conv;
61549         }
61550         FREE(node_ids);
61551         ProbabilisticScoringFeeParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
61552 }
61553
61554 void  CS_LDK_ProbabilisticScoringFeeParameters_remove_banned(int64_t this_arg, int64_t node_id) {
61555         LDKProbabilisticScoringFeeParameters this_arg_conv;
61556         this_arg_conv.inner = untag_ptr(this_arg);
61557         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61559         this_arg_conv.is_owned = false;
61560         LDKNodeId node_id_conv;
61561         node_id_conv.inner = untag_ptr(node_id);
61562         node_id_conv.is_owned = ptr_is_owned(node_id);
61563         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
61564         node_id_conv.is_owned = false;
61565         ProbabilisticScoringFeeParameters_remove_banned(&this_arg_conv, &node_id_conv);
61566 }
61567
61568 void  CS_LDK_ProbabilisticScoringFeeParameters_set_manual_penalty(int64_t this_arg, int64_t node_id, int64_t penalty) {
61569         LDKProbabilisticScoringFeeParameters this_arg_conv;
61570         this_arg_conv.inner = untag_ptr(this_arg);
61571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61573         this_arg_conv.is_owned = false;
61574         LDKNodeId node_id_conv;
61575         node_id_conv.inner = untag_ptr(node_id);
61576         node_id_conv.is_owned = ptr_is_owned(node_id);
61577         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
61578         node_id_conv.is_owned = false;
61579         ProbabilisticScoringFeeParameters_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
61580 }
61581
61582 void  CS_LDK_ProbabilisticScoringFeeParameters_remove_manual_penalty(int64_t this_arg, int64_t node_id) {
61583         LDKProbabilisticScoringFeeParameters this_arg_conv;
61584         this_arg_conv.inner = untag_ptr(this_arg);
61585         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61587         this_arg_conv.is_owned = false;
61588         LDKNodeId node_id_conv;
61589         node_id_conv.inner = untag_ptr(node_id);
61590         node_id_conv.is_owned = ptr_is_owned(node_id);
61591         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
61592         node_id_conv.is_owned = false;
61593         ProbabilisticScoringFeeParameters_remove_manual_penalty(&this_arg_conv, &node_id_conv);
61594 }
61595
61596 void  CS_LDK_ProbabilisticScoringFeeParameters_clear_manual_penalties(int64_t this_arg) {
61597         LDKProbabilisticScoringFeeParameters this_arg_conv;
61598         this_arg_conv.inner = untag_ptr(this_arg);
61599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61601         this_arg_conv.is_owned = false;
61602         ProbabilisticScoringFeeParameters_clear_manual_penalties(&this_arg_conv);
61603 }
61604
61605 void  CS_LDK_ProbabilisticScoringDecayParameters_free(int64_t this_obj) {
61606         LDKProbabilisticScoringDecayParameters this_obj_conv;
61607         this_obj_conv.inner = untag_ptr(this_obj);
61608         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61610         ProbabilisticScoringDecayParameters_free(this_obj_conv);
61611 }
61612
61613 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(int64_t this_ptr) {
61614         LDKProbabilisticScoringDecayParameters this_ptr_conv;
61615         this_ptr_conv.inner = untag_ptr(this_ptr);
61616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61618         this_ptr_conv.is_owned = false;
61619         int64_t ret_conv = ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(&this_ptr_conv);
61620         return ret_conv;
61621 }
61622
61623 void  CS_LDK_ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(int64_t this_ptr, int64_t val) {
61624         LDKProbabilisticScoringDecayParameters this_ptr_conv;
61625         this_ptr_conv.inner = untag_ptr(this_ptr);
61626         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61628         this_ptr_conv.is_owned = false;
61629         ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
61630 }
61631
61632 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(int64_t this_ptr) {
61633         LDKProbabilisticScoringDecayParameters this_ptr_conv;
61634         this_ptr_conv.inner = untag_ptr(this_ptr);
61635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61637         this_ptr_conv.is_owned = false;
61638         int64_t ret_conv = ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(&this_ptr_conv);
61639         return ret_conv;
61640 }
61641
61642 void  CS_LDK_ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(int64_t this_ptr, int64_t val) {
61643         LDKProbabilisticScoringDecayParameters this_ptr_conv;
61644         this_ptr_conv.inner = untag_ptr(this_ptr);
61645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61647         this_ptr_conv.is_owned = false;
61648         ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
61649 }
61650
61651 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_new(int64_t historical_no_updates_half_life_arg, int64_t liquidity_offset_half_life_arg) {
61652         LDKProbabilisticScoringDecayParameters ret_var = ProbabilisticScoringDecayParameters_new(historical_no_updates_half_life_arg, liquidity_offset_half_life_arg);
61653         int64_t ret_ref = 0;
61654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61656         return ret_ref;
61657 }
61658
61659 static inline uint64_t ProbabilisticScoringDecayParameters_clone_ptr(LDKProbabilisticScoringDecayParameters *NONNULL_PTR arg) {
61660         LDKProbabilisticScoringDecayParameters ret_var = ProbabilisticScoringDecayParameters_clone(arg);
61661         int64_t ret_ref = 0;
61662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61664         return ret_ref;
61665 }
61666 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_clone_ptr(int64_t arg) {
61667         LDKProbabilisticScoringDecayParameters arg_conv;
61668         arg_conv.inner = untag_ptr(arg);
61669         arg_conv.is_owned = ptr_is_owned(arg);
61670         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
61671         arg_conv.is_owned = false;
61672         int64_t ret_conv = ProbabilisticScoringDecayParameters_clone_ptr(&arg_conv);
61673         return ret_conv;
61674 }
61675
61676 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_clone(int64_t orig) {
61677         LDKProbabilisticScoringDecayParameters orig_conv;
61678         orig_conv.inner = untag_ptr(orig);
61679         orig_conv.is_owned = ptr_is_owned(orig);
61680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
61681         orig_conv.is_owned = false;
61682         LDKProbabilisticScoringDecayParameters ret_var = ProbabilisticScoringDecayParameters_clone(&orig_conv);
61683         int64_t ret_ref = 0;
61684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61686         return ret_ref;
61687 }
61688
61689 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_default() {
61690         LDKProbabilisticScoringDecayParameters ret_var = ProbabilisticScoringDecayParameters_default();
61691         int64_t ret_ref = 0;
61692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61694         return ret_ref;
61695 }
61696
61697 int64_t  CS_LDK_ProbabilisticScorer_new(int64_t decay_params, int64_t network_graph, int64_t logger) {
61698         LDKProbabilisticScoringDecayParameters decay_params_conv;
61699         decay_params_conv.inner = untag_ptr(decay_params);
61700         decay_params_conv.is_owned = ptr_is_owned(decay_params);
61701         CHECK_INNER_FIELD_ACCESS_OR_NULL(decay_params_conv);
61702         decay_params_conv = ProbabilisticScoringDecayParameters_clone(&decay_params_conv);
61703         LDKNetworkGraph network_graph_conv;
61704         network_graph_conv.inner = untag_ptr(network_graph);
61705         network_graph_conv.is_owned = ptr_is_owned(network_graph);
61706         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
61707         network_graph_conv.is_owned = false;
61708         void* logger_ptr = untag_ptr(logger);
61709         CHECK_ACCESS(logger_ptr);
61710         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
61711         if (logger_conv.free == LDKLogger_JCalls_free) {
61712                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
61713                 LDKLogger_JCalls_cloned(&logger_conv);
61714         }
61715         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(decay_params_conv, &network_graph_conv, logger_conv);
61716         int64_t ret_ref = 0;
61717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61718         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61719         return ret_ref;
61720 }
61721
61722 void  CS_LDK_ProbabilisticScorer_debug_log_liquidity_stats(int64_t this_arg) {
61723         LDKProbabilisticScorer this_arg_conv;
61724         this_arg_conv.inner = untag_ptr(this_arg);
61725         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61727         this_arg_conv.is_owned = false;
61728         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
61729 }
61730
61731 int64_t  CS_LDK_ProbabilisticScorer_estimated_channel_liquidity_range(int64_t this_arg, int64_t scid, int64_t target) {
61732         LDKProbabilisticScorer this_arg_conv;
61733         this_arg_conv.inner = untag_ptr(this_arg);
61734         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61736         this_arg_conv.is_owned = false;
61737         LDKNodeId target_conv;
61738         target_conv.inner = untag_ptr(target);
61739         target_conv.is_owned = ptr_is_owned(target);
61740         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
61741         target_conv.is_owned = false;
61742         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
61743         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
61744         int64_t ret_ref = tag_ptr(ret_copy, true);
61745         return ret_ref;
61746 }
61747
61748 int64_t  CS_LDK_ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(int64_t this_arg, int64_t scid, int64_t target) {
61749         LDKProbabilisticScorer this_arg_conv;
61750         this_arg_conv.inner = untag_ptr(this_arg);
61751         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61753         this_arg_conv.is_owned = false;
61754         LDKNodeId target_conv;
61755         target_conv.inner = untag_ptr(target);
61756         target_conv.is_owned = ptr_is_owned(target);
61757         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
61758         target_conv.is_owned = false;
61759         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ), "LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ");
61760         *ret_copy = ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(&this_arg_conv, scid, &target_conv);
61761         int64_t ret_ref = tag_ptr(ret_copy, true);
61762         return ret_ref;
61763 }
61764
61765 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) {
61766         LDKProbabilisticScorer this_arg_conv;
61767         this_arg_conv.inner = untag_ptr(this_arg);
61768         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61770         this_arg_conv.is_owned = false;
61771         LDKNodeId target_conv;
61772         target_conv.inner = untag_ptr(target);
61773         target_conv.is_owned = ptr_is_owned(target);
61774         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
61775         target_conv.is_owned = false;
61776         LDKProbabilisticScoringFeeParameters params_conv;
61777         params_conv.inner = untag_ptr(params);
61778         params_conv.is_owned = ptr_is_owned(params);
61779         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
61780         params_conv.is_owned = false;
61781         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
61782         *ret_copy = ProbabilisticScorer_historical_estimated_payment_success_probability(&this_arg_conv, scid, &target_conv, amount_msat, &params_conv);
61783         int64_t ret_ref = tag_ptr(ret_copy, true);
61784         return ret_ref;
61785 }
61786
61787 int64_t  CS_LDK_ProbabilisticScorer_as_ScoreLookUp(int64_t this_arg) {
61788         LDKProbabilisticScorer this_arg_conv;
61789         this_arg_conv.inner = untag_ptr(this_arg);
61790         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61792         this_arg_conv.is_owned = false;
61793         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
61794         *ret_ret = ProbabilisticScorer_as_ScoreLookUp(&this_arg_conv);
61795         return tag_ptr(ret_ret, true);
61796 }
61797
61798 int64_t  CS_LDK_ProbabilisticScorer_as_ScoreUpdate(int64_t this_arg) {
61799         LDKProbabilisticScorer this_arg_conv;
61800         this_arg_conv.inner = untag_ptr(this_arg);
61801         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61803         this_arg_conv.is_owned = false;
61804         LDKScoreUpdate* ret_ret = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
61805         *ret_ret = ProbabilisticScorer_as_ScoreUpdate(&this_arg_conv);
61806         return tag_ptr(ret_ret, true);
61807 }
61808
61809 int64_t  CS_LDK_ProbabilisticScorer_as_Score(int64_t this_arg) {
61810         LDKProbabilisticScorer this_arg_conv;
61811         this_arg_conv.inner = untag_ptr(this_arg);
61812         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61814         this_arg_conv.is_owned = false;
61815         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
61816         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
61817         return tag_ptr(ret_ret, true);
61818 }
61819
61820 int8_tArray  CS_LDK_ProbabilisticScorer_write(int64_t obj) {
61821         LDKProbabilisticScorer obj_conv;
61822         obj_conv.inner = untag_ptr(obj);
61823         obj_conv.is_owned = ptr_is_owned(obj);
61824         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
61825         obj_conv.is_owned = false;
61826         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
61827         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
61828         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
61829         CVec_u8Z_free(ret_var);
61830         return ret_arr;
61831 }
61832
61833 int64_t  CS_LDK_ProbabilisticScorer_read(int8_tArray ser, int64_t arg_a, int64_t arg_b, int64_t arg_c) {
61834         LDKu8slice ser_ref;
61835         ser_ref.datalen = ser->arr_len;
61836         ser_ref.data = ser->elems;
61837         LDKProbabilisticScoringDecayParameters arg_a_conv;
61838         arg_a_conv.inner = untag_ptr(arg_a);
61839         arg_a_conv.is_owned = ptr_is_owned(arg_a);
61840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
61841         arg_a_conv = ProbabilisticScoringDecayParameters_clone(&arg_a_conv);
61842         LDKNetworkGraph arg_b_conv;
61843         arg_b_conv.inner = untag_ptr(arg_b);
61844         arg_b_conv.is_owned = ptr_is_owned(arg_b);
61845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
61846         arg_b_conv.is_owned = false;
61847         void* arg_c_ptr = untag_ptr(arg_c);
61848         CHECK_ACCESS(arg_c_ptr);
61849         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
61850         if (arg_c_conv.free == LDKLogger_JCalls_free) {
61851                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
61852                 LDKLogger_JCalls_cloned(&arg_c_conv);
61853         }
61854         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
61855         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
61856         FREE(ser);
61857         return tag_ptr(ret_conv, true);
61858 }
61859
61860 void  CS_LDK_DelayedPaymentOutputDescriptor_free(int64_t this_obj) {
61861         LDKDelayedPaymentOutputDescriptor this_obj_conv;
61862         this_obj_conv.inner = untag_ptr(this_obj);
61863         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61865         DelayedPaymentOutputDescriptor_free(this_obj_conv);
61866 }
61867
61868 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_get_outpoint(int64_t this_ptr) {
61869         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61870         this_ptr_conv.inner = untag_ptr(this_ptr);
61871         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61873         this_ptr_conv.is_owned = false;
61874         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
61875         int64_t ret_ref = 0;
61876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61878         return ret_ref;
61879 }
61880
61881 void  CS_LDK_DelayedPaymentOutputDescriptor_set_outpoint(int64_t this_ptr, int64_t val) {
61882         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61883         this_ptr_conv.inner = untag_ptr(this_ptr);
61884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61886         this_ptr_conv.is_owned = false;
61887         LDKOutPoint val_conv;
61888         val_conv.inner = untag_ptr(val);
61889         val_conv.is_owned = ptr_is_owned(val);
61890         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
61891         val_conv = OutPoint_clone(&val_conv);
61892         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
61893 }
61894
61895 int8_tArray  CS_LDK_DelayedPaymentOutputDescriptor_get_per_commitment_point(int64_t this_ptr) {
61896         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61897         this_ptr_conv.inner = untag_ptr(this_ptr);
61898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61900         this_ptr_conv.is_owned = false;
61901         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
61902         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
61903         return ret_arr;
61904 }
61905
61906 void  CS_LDK_DelayedPaymentOutputDescriptor_set_per_commitment_point(int64_t this_ptr, int8_tArray val) {
61907         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61908         this_ptr_conv.inner = untag_ptr(this_ptr);
61909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61911         this_ptr_conv.is_owned = false;
61912         LDKPublicKey val_ref;
61913         CHECK(val->arr_len == 33);
61914         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
61915         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
61916 }
61917
61918 int16_t  CS_LDK_DelayedPaymentOutputDescriptor_get_to_self_delay(int64_t this_ptr) {
61919         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61920         this_ptr_conv.inner = untag_ptr(this_ptr);
61921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61923         this_ptr_conv.is_owned = false;
61924         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
61925         return ret_conv;
61926 }
61927
61928 void  CS_LDK_DelayedPaymentOutputDescriptor_set_to_self_delay(int64_t this_ptr, int16_t val) {
61929         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61930         this_ptr_conv.inner = untag_ptr(this_ptr);
61931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61933         this_ptr_conv.is_owned = false;
61934         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
61935 }
61936
61937 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_get_output(int64_t this_ptr) {
61938         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61939         this_ptr_conv.inner = untag_ptr(this_ptr);
61940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61942         this_ptr_conv.is_owned = false;
61943         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
61944         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
61945         return tag_ptr(ret_ref, true);
61946 }
61947
61948 void  CS_LDK_DelayedPaymentOutputDescriptor_set_output(int64_t this_ptr, int64_t val) {
61949         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61950         this_ptr_conv.inner = untag_ptr(this_ptr);
61951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61953         this_ptr_conv.is_owned = false;
61954         void* val_ptr = untag_ptr(val);
61955         CHECK_ACCESS(val_ptr);
61956         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
61957         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
61958         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
61959 }
61960
61961 int8_tArray  CS_LDK_DelayedPaymentOutputDescriptor_get_revocation_pubkey(int64_t this_ptr) {
61962         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61963         this_ptr_conv.inner = untag_ptr(this_ptr);
61964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61966         this_ptr_conv.is_owned = false;
61967         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
61968         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
61969         return ret_arr;
61970 }
61971
61972 void  CS_LDK_DelayedPaymentOutputDescriptor_set_revocation_pubkey(int64_t this_ptr, int8_tArray val) {
61973         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61974         this_ptr_conv.inner = untag_ptr(this_ptr);
61975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61977         this_ptr_conv.is_owned = false;
61978         LDKPublicKey val_ref;
61979         CHECK(val->arr_len == 33);
61980         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
61981         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
61982 }
61983
61984 int8_tArray  CS_LDK_DelayedPaymentOutputDescriptor_get_channel_keys_id(int64_t this_ptr) {
61985         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61986         this_ptr_conv.inner = untag_ptr(this_ptr);
61987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61989         this_ptr_conv.is_owned = false;
61990         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
61991         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
61992         return ret_arr;
61993 }
61994
61995 void  CS_LDK_DelayedPaymentOutputDescriptor_set_channel_keys_id(int64_t this_ptr, int8_tArray val) {
61996         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61997         this_ptr_conv.inner = untag_ptr(this_ptr);
61998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62000         this_ptr_conv.is_owned = false;
62001         LDKThirtyTwoBytes val_ref;
62002         CHECK(val->arr_len == 32);
62003         memcpy(val_ref.data, val->elems, 32); FREE(val);
62004         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
62005 }
62006
62007 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(int64_t this_ptr) {
62008         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
62009         this_ptr_conv.inner = untag_ptr(this_ptr);
62010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62012         this_ptr_conv.is_owned = false;
62013         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
62014         return ret_conv;
62015 }
62016
62017 void  CS_LDK_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(int64_t this_ptr, int64_t val) {
62018         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
62019         this_ptr_conv.inner = untag_ptr(this_ptr);
62020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62022         this_ptr_conv.is_owned = false;
62023         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
62024 }
62025
62026 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) {
62027         LDKOutPoint outpoint_arg_conv;
62028         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
62029         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
62030         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
62031         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
62032         LDKPublicKey per_commitment_point_arg_ref;
62033         CHECK(per_commitment_point_arg->arr_len == 33);
62034         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
62035         void* output_arg_ptr = untag_ptr(output_arg);
62036         CHECK_ACCESS(output_arg_ptr);
62037         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
62038         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
62039         LDKPublicKey revocation_pubkey_arg_ref;
62040         CHECK(revocation_pubkey_arg->arr_len == 33);
62041         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
62042         LDKThirtyTwoBytes channel_keys_id_arg_ref;
62043         CHECK(channel_keys_id_arg->arr_len == 32);
62044         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
62045         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);
62046         int64_t ret_ref = 0;
62047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62049         return ret_ref;
62050 }
62051
62052 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
62053         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
62054         int64_t ret_ref = 0;
62055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62057         return ret_ref;
62058 }
62059 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_clone_ptr(int64_t arg) {
62060         LDKDelayedPaymentOutputDescriptor arg_conv;
62061         arg_conv.inner = untag_ptr(arg);
62062         arg_conv.is_owned = ptr_is_owned(arg);
62063         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
62064         arg_conv.is_owned = false;
62065         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
62066         return ret_conv;
62067 }
62068
62069 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_clone(int64_t orig) {
62070         LDKDelayedPaymentOutputDescriptor orig_conv;
62071         orig_conv.inner = untag_ptr(orig);
62072         orig_conv.is_owned = ptr_is_owned(orig);
62073         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
62074         orig_conv.is_owned = false;
62075         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
62076         int64_t ret_ref = 0;
62077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62078         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62079         return ret_ref;
62080 }
62081
62082 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_hash(int64_t o) {
62083         LDKDelayedPaymentOutputDescriptor o_conv;
62084         o_conv.inner = untag_ptr(o);
62085         o_conv.is_owned = ptr_is_owned(o);
62086         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
62087         o_conv.is_owned = false;
62088         int64_t ret_conv = DelayedPaymentOutputDescriptor_hash(&o_conv);
62089         return ret_conv;
62090 }
62091
62092 jboolean  CS_LDK_DelayedPaymentOutputDescriptor_eq(int64_t a, int64_t b) {
62093         LDKDelayedPaymentOutputDescriptor a_conv;
62094         a_conv.inner = untag_ptr(a);
62095         a_conv.is_owned = ptr_is_owned(a);
62096         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62097         a_conv.is_owned = false;
62098         LDKDelayedPaymentOutputDescriptor b_conv;
62099         b_conv.inner = untag_ptr(b);
62100         b_conv.is_owned = ptr_is_owned(b);
62101         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
62102         b_conv.is_owned = false;
62103         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
62104         return ret_conv;
62105 }
62106
62107 int8_tArray  CS_LDK_DelayedPaymentOutputDescriptor_write(int64_t obj) {
62108         LDKDelayedPaymentOutputDescriptor obj_conv;
62109         obj_conv.inner = untag_ptr(obj);
62110         obj_conv.is_owned = ptr_is_owned(obj);
62111         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
62112         obj_conv.is_owned = false;
62113         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
62114         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62115         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62116         CVec_u8Z_free(ret_var);
62117         return ret_arr;
62118 }
62119
62120 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
62121         LDKu8slice ser_ref;
62122         ser_ref.datalen = ser->arr_len;
62123         ser_ref.data = ser->elems;
62124         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
62125         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
62126         FREE(ser);
62127         return tag_ptr(ret_conv, true);
62128 }
62129
62130 void  CS_LDK_StaticPaymentOutputDescriptor_free(int64_t this_obj) {
62131         LDKStaticPaymentOutputDescriptor this_obj_conv;
62132         this_obj_conv.inner = untag_ptr(this_obj);
62133         this_obj_conv.is_owned = ptr_is_owned(this_obj);
62134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
62135         StaticPaymentOutputDescriptor_free(this_obj_conv);
62136 }
62137
62138 int64_t  CS_LDK_StaticPaymentOutputDescriptor_get_outpoint(int64_t this_ptr) {
62139         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62140         this_ptr_conv.inner = untag_ptr(this_ptr);
62141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62143         this_ptr_conv.is_owned = false;
62144         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
62145         int64_t ret_ref = 0;
62146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62148         return ret_ref;
62149 }
62150
62151 void  CS_LDK_StaticPaymentOutputDescriptor_set_outpoint(int64_t this_ptr, int64_t val) {
62152         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62153         this_ptr_conv.inner = untag_ptr(this_ptr);
62154         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62156         this_ptr_conv.is_owned = false;
62157         LDKOutPoint val_conv;
62158         val_conv.inner = untag_ptr(val);
62159         val_conv.is_owned = ptr_is_owned(val);
62160         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62161         val_conv = OutPoint_clone(&val_conv);
62162         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
62163 }
62164
62165 int64_t  CS_LDK_StaticPaymentOutputDescriptor_get_output(int64_t this_ptr) {
62166         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62167         this_ptr_conv.inner = untag_ptr(this_ptr);
62168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62170         this_ptr_conv.is_owned = false;
62171         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
62172         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
62173         return tag_ptr(ret_ref, true);
62174 }
62175
62176 void  CS_LDK_StaticPaymentOutputDescriptor_set_output(int64_t this_ptr, int64_t val) {
62177         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62178         this_ptr_conv.inner = untag_ptr(this_ptr);
62179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62181         this_ptr_conv.is_owned = false;
62182         void* val_ptr = untag_ptr(val);
62183         CHECK_ACCESS(val_ptr);
62184         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
62185         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
62186         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
62187 }
62188
62189 int8_tArray  CS_LDK_StaticPaymentOutputDescriptor_get_channel_keys_id(int64_t this_ptr) {
62190         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62191         this_ptr_conv.inner = untag_ptr(this_ptr);
62192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62194         this_ptr_conv.is_owned = false;
62195         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
62196         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
62197         return ret_arr;
62198 }
62199
62200 void  CS_LDK_StaticPaymentOutputDescriptor_set_channel_keys_id(int64_t this_ptr, int8_tArray val) {
62201         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62202         this_ptr_conv.inner = untag_ptr(this_ptr);
62203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62205         this_ptr_conv.is_owned = false;
62206         LDKThirtyTwoBytes val_ref;
62207         CHECK(val->arr_len == 32);
62208         memcpy(val_ref.data, val->elems, 32); FREE(val);
62209         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
62210 }
62211
62212 int64_t  CS_LDK_StaticPaymentOutputDescriptor_get_channel_value_satoshis(int64_t this_ptr) {
62213         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62214         this_ptr_conv.inner = untag_ptr(this_ptr);
62215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62217         this_ptr_conv.is_owned = false;
62218         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
62219         return ret_conv;
62220 }
62221
62222 void  CS_LDK_StaticPaymentOutputDescriptor_set_channel_value_satoshis(int64_t this_ptr, int64_t val) {
62223         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62224         this_ptr_conv.inner = untag_ptr(this_ptr);
62225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62227         this_ptr_conv.is_owned = false;
62228         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
62229 }
62230
62231 int64_t  CS_LDK_StaticPaymentOutputDescriptor_get_channel_transaction_parameters(int64_t this_ptr) {
62232         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62233         this_ptr_conv.inner = untag_ptr(this_ptr);
62234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62236         this_ptr_conv.is_owned = false;
62237         LDKChannelTransactionParameters ret_var = StaticPaymentOutputDescriptor_get_channel_transaction_parameters(&this_ptr_conv);
62238         int64_t ret_ref = 0;
62239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62241         return ret_ref;
62242 }
62243
62244 void  CS_LDK_StaticPaymentOutputDescriptor_set_channel_transaction_parameters(int64_t this_ptr, int64_t val) {
62245         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62246         this_ptr_conv.inner = untag_ptr(this_ptr);
62247         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62249         this_ptr_conv.is_owned = false;
62250         LDKChannelTransactionParameters val_conv;
62251         val_conv.inner = untag_ptr(val);
62252         val_conv.is_owned = ptr_is_owned(val);
62253         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62254         val_conv = ChannelTransactionParameters_clone(&val_conv);
62255         StaticPaymentOutputDescriptor_set_channel_transaction_parameters(&this_ptr_conv, val_conv);
62256 }
62257
62258 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) {
62259         LDKOutPoint outpoint_arg_conv;
62260         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
62261         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
62262         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
62263         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
62264         void* output_arg_ptr = untag_ptr(output_arg);
62265         CHECK_ACCESS(output_arg_ptr);
62266         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
62267         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
62268         LDKThirtyTwoBytes channel_keys_id_arg_ref;
62269         CHECK(channel_keys_id_arg->arr_len == 32);
62270         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
62271         LDKChannelTransactionParameters channel_transaction_parameters_arg_conv;
62272         channel_transaction_parameters_arg_conv.inner = untag_ptr(channel_transaction_parameters_arg);
62273         channel_transaction_parameters_arg_conv.is_owned = ptr_is_owned(channel_transaction_parameters_arg);
62274         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_transaction_parameters_arg_conv);
62275         channel_transaction_parameters_arg_conv = ChannelTransactionParameters_clone(&channel_transaction_parameters_arg_conv);
62276         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);
62277         int64_t ret_ref = 0;
62278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62280         return ret_ref;
62281 }
62282
62283 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
62284         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
62285         int64_t ret_ref = 0;
62286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62288         return ret_ref;
62289 }
62290 int64_t  CS_LDK_StaticPaymentOutputDescriptor_clone_ptr(int64_t arg) {
62291         LDKStaticPaymentOutputDescriptor arg_conv;
62292         arg_conv.inner = untag_ptr(arg);
62293         arg_conv.is_owned = ptr_is_owned(arg);
62294         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
62295         arg_conv.is_owned = false;
62296         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
62297         return ret_conv;
62298 }
62299
62300 int64_t  CS_LDK_StaticPaymentOutputDescriptor_clone(int64_t orig) {
62301         LDKStaticPaymentOutputDescriptor orig_conv;
62302         orig_conv.inner = untag_ptr(orig);
62303         orig_conv.is_owned = ptr_is_owned(orig);
62304         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
62305         orig_conv.is_owned = false;
62306         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
62307         int64_t ret_ref = 0;
62308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62309         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62310         return ret_ref;
62311 }
62312
62313 int64_t  CS_LDK_StaticPaymentOutputDescriptor_hash(int64_t o) {
62314         LDKStaticPaymentOutputDescriptor o_conv;
62315         o_conv.inner = untag_ptr(o);
62316         o_conv.is_owned = ptr_is_owned(o);
62317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
62318         o_conv.is_owned = false;
62319         int64_t ret_conv = StaticPaymentOutputDescriptor_hash(&o_conv);
62320         return ret_conv;
62321 }
62322
62323 jboolean  CS_LDK_StaticPaymentOutputDescriptor_eq(int64_t a, int64_t b) {
62324         LDKStaticPaymentOutputDescriptor a_conv;
62325         a_conv.inner = untag_ptr(a);
62326         a_conv.is_owned = ptr_is_owned(a);
62327         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62328         a_conv.is_owned = false;
62329         LDKStaticPaymentOutputDescriptor b_conv;
62330         b_conv.inner = untag_ptr(b);
62331         b_conv.is_owned = ptr_is_owned(b);
62332         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
62333         b_conv.is_owned = false;
62334         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
62335         return ret_conv;
62336 }
62337
62338 int64_t  CS_LDK_StaticPaymentOutputDescriptor_witness_script(int64_t this_arg) {
62339         LDKStaticPaymentOutputDescriptor this_arg_conv;
62340         this_arg_conv.inner = untag_ptr(this_arg);
62341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62343         this_arg_conv.is_owned = false;
62344         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
62345         *ret_copy = StaticPaymentOutputDescriptor_witness_script(&this_arg_conv);
62346         int64_t ret_ref = tag_ptr(ret_copy, true);
62347         return ret_ref;
62348 }
62349
62350 int64_t  CS_LDK_StaticPaymentOutputDescriptor_max_witness_length(int64_t this_arg) {
62351         LDKStaticPaymentOutputDescriptor this_arg_conv;
62352         this_arg_conv.inner = untag_ptr(this_arg);
62353         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62355         this_arg_conv.is_owned = false;
62356         int64_t ret_conv = StaticPaymentOutputDescriptor_max_witness_length(&this_arg_conv);
62357         return ret_conv;
62358 }
62359
62360 int8_tArray  CS_LDK_StaticPaymentOutputDescriptor_write(int64_t obj) {
62361         LDKStaticPaymentOutputDescriptor obj_conv;
62362         obj_conv.inner = untag_ptr(obj);
62363         obj_conv.is_owned = ptr_is_owned(obj);
62364         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
62365         obj_conv.is_owned = false;
62366         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
62367         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62368         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62369         CVec_u8Z_free(ret_var);
62370         return ret_arr;
62371 }
62372
62373 int64_t  CS_LDK_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
62374         LDKu8slice ser_ref;
62375         ser_ref.datalen = ser->arr_len;
62376         ser_ref.data = ser->elems;
62377         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
62378         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
62379         FREE(ser);
62380         return tag_ptr(ret_conv, true);
62381 }
62382
62383 void  CS_LDK_SpendableOutputDescriptor_free(int64_t this_ptr) {
62384         if (!ptr_is_owned(this_ptr)) return;
62385         void* this_ptr_ptr = untag_ptr(this_ptr);
62386         CHECK_ACCESS(this_ptr_ptr);
62387         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
62388         FREE(untag_ptr(this_ptr));
62389         SpendableOutputDescriptor_free(this_ptr_conv);
62390 }
62391
62392 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
62393         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62394         *ret_copy = SpendableOutputDescriptor_clone(arg);
62395         int64_t ret_ref = tag_ptr(ret_copy, true);
62396         return ret_ref;
62397 }
62398 int64_t  CS_LDK_SpendableOutputDescriptor_clone_ptr(int64_t arg) {
62399         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
62400         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
62401         return ret_conv;
62402 }
62403
62404 int64_t  CS_LDK_SpendableOutputDescriptor_clone(int64_t orig) {
62405         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
62406         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62407         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
62408         int64_t ret_ref = tag_ptr(ret_copy, true);
62409         return ret_ref;
62410 }
62411
62412 int64_t  CS_LDK_SpendableOutputDescriptor_static_output(int64_t outpoint, int64_t output) {
62413         LDKOutPoint outpoint_conv;
62414         outpoint_conv.inner = untag_ptr(outpoint);
62415         outpoint_conv.is_owned = ptr_is_owned(outpoint);
62416         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
62417         outpoint_conv = OutPoint_clone(&outpoint_conv);
62418         void* output_ptr = untag_ptr(output);
62419         CHECK_ACCESS(output_ptr);
62420         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
62421         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
62422         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62423         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
62424         int64_t ret_ref = tag_ptr(ret_copy, true);
62425         return ret_ref;
62426 }
62427
62428 int64_t  CS_LDK_SpendableOutputDescriptor_delayed_payment_output(int64_t a) {
62429         LDKDelayedPaymentOutputDescriptor a_conv;
62430         a_conv.inner = untag_ptr(a);
62431         a_conv.is_owned = ptr_is_owned(a);
62432         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62433         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
62434         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62435         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
62436         int64_t ret_ref = tag_ptr(ret_copy, true);
62437         return ret_ref;
62438 }
62439
62440 int64_t  CS_LDK_SpendableOutputDescriptor_static_payment_output(int64_t a) {
62441         LDKStaticPaymentOutputDescriptor a_conv;
62442         a_conv.inner = untag_ptr(a);
62443         a_conv.is_owned = ptr_is_owned(a);
62444         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62445         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
62446         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62447         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
62448         int64_t ret_ref = tag_ptr(ret_copy, true);
62449         return ret_ref;
62450 }
62451
62452 int64_t  CS_LDK_SpendableOutputDescriptor_hash(int64_t o) {
62453         LDKSpendableOutputDescriptor* o_conv = (LDKSpendableOutputDescriptor*)untag_ptr(o);
62454         int64_t ret_conv = SpendableOutputDescriptor_hash(o_conv);
62455         return ret_conv;
62456 }
62457
62458 jboolean  CS_LDK_SpendableOutputDescriptor_eq(int64_t a, int64_t b) {
62459         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
62460         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
62461         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
62462         return ret_conv;
62463 }
62464
62465 int8_tArray  CS_LDK_SpendableOutputDescriptor_write(int64_t obj) {
62466         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
62467         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
62468         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62469         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62470         CVec_u8Z_free(ret_var);
62471         return ret_arr;
62472 }
62473
62474 int64_t  CS_LDK_SpendableOutputDescriptor_read(int8_tArray ser) {
62475         LDKu8slice ser_ref;
62476         ser_ref.datalen = ser->arr_len;
62477         ser_ref.data = ser->elems;
62478         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
62479         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
62480         FREE(ser);
62481         return tag_ptr(ret_conv, true);
62482 }
62483
62484 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) {
62485         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
62486         descriptors_constr.datalen = descriptors->arr_len;
62487         if (descriptors_constr.datalen > 0)
62488                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
62489         else
62490                 descriptors_constr.data = NULL;
62491         int64_t* descriptors_vals = descriptors->elems;
62492         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
62493                 int64_t descriptors_conv_27 = descriptors_vals[b];
62494                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
62495                 CHECK_ACCESS(descriptors_conv_27_ptr);
62496                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
62497                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
62498                 descriptors_constr.data[b] = descriptors_conv_27_conv;
62499         }
62500         FREE(descriptors);
62501         LDKCVec_TxOutZ outputs_constr;
62502         outputs_constr.datalen = outputs->arr_len;
62503         if (outputs_constr.datalen > 0)
62504                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
62505         else
62506                 outputs_constr.data = NULL;
62507         int64_t* outputs_vals = outputs->elems;
62508         for (size_t h = 0; h < outputs_constr.datalen; h++) {
62509                 int64_t outputs_conv_7 = outputs_vals[h];
62510                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
62511                 CHECK_ACCESS(outputs_conv_7_ptr);
62512                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
62513                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
62514                 outputs_constr.data[h] = outputs_conv_7_conv;
62515         }
62516         FREE(outputs);
62517         LDKCVec_u8Z change_destination_script_ref;
62518         change_destination_script_ref.datalen = change_destination_script->arr_len;
62519         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
62520         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
62521         void* locktime_ptr = untag_ptr(locktime);
62522         CHECK_ACCESS(locktime_ptr);
62523         LDKCOption_u32Z locktime_conv = *(LDKCOption_u32Z*)(locktime_ptr);
62524         locktime_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(locktime));
62525         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
62526         *ret_conv = SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight, locktime_conv);
62527         return tag_ptr(ret_conv, true);
62528 }
62529
62530 void  CS_LDK_ChannelDerivationParameters_free(int64_t this_obj) {
62531         LDKChannelDerivationParameters this_obj_conv;
62532         this_obj_conv.inner = untag_ptr(this_obj);
62533         this_obj_conv.is_owned = ptr_is_owned(this_obj);
62534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
62535         ChannelDerivationParameters_free(this_obj_conv);
62536 }
62537
62538 int64_t  CS_LDK_ChannelDerivationParameters_get_value_satoshis(int64_t this_ptr) {
62539         LDKChannelDerivationParameters this_ptr_conv;
62540         this_ptr_conv.inner = untag_ptr(this_ptr);
62541         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62543         this_ptr_conv.is_owned = false;
62544         int64_t ret_conv = ChannelDerivationParameters_get_value_satoshis(&this_ptr_conv);
62545         return ret_conv;
62546 }
62547
62548 void  CS_LDK_ChannelDerivationParameters_set_value_satoshis(int64_t this_ptr, int64_t val) {
62549         LDKChannelDerivationParameters this_ptr_conv;
62550         this_ptr_conv.inner = untag_ptr(this_ptr);
62551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62553         this_ptr_conv.is_owned = false;
62554         ChannelDerivationParameters_set_value_satoshis(&this_ptr_conv, val);
62555 }
62556
62557 int8_tArray  CS_LDK_ChannelDerivationParameters_get_keys_id(int64_t this_ptr) {
62558         LDKChannelDerivationParameters this_ptr_conv;
62559         this_ptr_conv.inner = untag_ptr(this_ptr);
62560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62562         this_ptr_conv.is_owned = false;
62563         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
62564         memcpy(ret_arr->elems, *ChannelDerivationParameters_get_keys_id(&this_ptr_conv), 32);
62565         return ret_arr;
62566 }
62567
62568 void  CS_LDK_ChannelDerivationParameters_set_keys_id(int64_t this_ptr, int8_tArray val) {
62569         LDKChannelDerivationParameters this_ptr_conv;
62570         this_ptr_conv.inner = untag_ptr(this_ptr);
62571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62573         this_ptr_conv.is_owned = false;
62574         LDKThirtyTwoBytes val_ref;
62575         CHECK(val->arr_len == 32);
62576         memcpy(val_ref.data, val->elems, 32); FREE(val);
62577         ChannelDerivationParameters_set_keys_id(&this_ptr_conv, val_ref);
62578 }
62579
62580 int64_t  CS_LDK_ChannelDerivationParameters_get_transaction_parameters(int64_t this_ptr) {
62581         LDKChannelDerivationParameters this_ptr_conv;
62582         this_ptr_conv.inner = untag_ptr(this_ptr);
62583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62585         this_ptr_conv.is_owned = false;
62586         LDKChannelTransactionParameters ret_var = ChannelDerivationParameters_get_transaction_parameters(&this_ptr_conv);
62587         int64_t ret_ref = 0;
62588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62590         return ret_ref;
62591 }
62592
62593 void  CS_LDK_ChannelDerivationParameters_set_transaction_parameters(int64_t this_ptr, int64_t val) {
62594         LDKChannelDerivationParameters this_ptr_conv;
62595         this_ptr_conv.inner = untag_ptr(this_ptr);
62596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62598         this_ptr_conv.is_owned = false;
62599         LDKChannelTransactionParameters val_conv;
62600         val_conv.inner = untag_ptr(val);
62601         val_conv.is_owned = ptr_is_owned(val);
62602         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62603         val_conv = ChannelTransactionParameters_clone(&val_conv);
62604         ChannelDerivationParameters_set_transaction_parameters(&this_ptr_conv, val_conv);
62605 }
62606
62607 int64_t  CS_LDK_ChannelDerivationParameters_new(int64_t value_satoshis_arg, int8_tArray keys_id_arg, int64_t transaction_parameters_arg) {
62608         LDKThirtyTwoBytes keys_id_arg_ref;
62609         CHECK(keys_id_arg->arr_len == 32);
62610         memcpy(keys_id_arg_ref.data, keys_id_arg->elems, 32); FREE(keys_id_arg);
62611         LDKChannelTransactionParameters transaction_parameters_arg_conv;
62612         transaction_parameters_arg_conv.inner = untag_ptr(transaction_parameters_arg);
62613         transaction_parameters_arg_conv.is_owned = ptr_is_owned(transaction_parameters_arg);
62614         CHECK_INNER_FIELD_ACCESS_OR_NULL(transaction_parameters_arg_conv);
62615         transaction_parameters_arg_conv = ChannelTransactionParameters_clone(&transaction_parameters_arg_conv);
62616         LDKChannelDerivationParameters ret_var = ChannelDerivationParameters_new(value_satoshis_arg, keys_id_arg_ref, transaction_parameters_arg_conv);
62617         int64_t ret_ref = 0;
62618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62619         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62620         return ret_ref;
62621 }
62622
62623 static inline uint64_t ChannelDerivationParameters_clone_ptr(LDKChannelDerivationParameters *NONNULL_PTR arg) {
62624         LDKChannelDerivationParameters ret_var = ChannelDerivationParameters_clone(arg);
62625         int64_t ret_ref = 0;
62626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62628         return ret_ref;
62629 }
62630 int64_t  CS_LDK_ChannelDerivationParameters_clone_ptr(int64_t arg) {
62631         LDKChannelDerivationParameters arg_conv;
62632         arg_conv.inner = untag_ptr(arg);
62633         arg_conv.is_owned = ptr_is_owned(arg);
62634         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
62635         arg_conv.is_owned = false;
62636         int64_t ret_conv = ChannelDerivationParameters_clone_ptr(&arg_conv);
62637         return ret_conv;
62638 }
62639
62640 int64_t  CS_LDK_ChannelDerivationParameters_clone(int64_t orig) {
62641         LDKChannelDerivationParameters orig_conv;
62642         orig_conv.inner = untag_ptr(orig);
62643         orig_conv.is_owned = ptr_is_owned(orig);
62644         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
62645         orig_conv.is_owned = false;
62646         LDKChannelDerivationParameters ret_var = ChannelDerivationParameters_clone(&orig_conv);
62647         int64_t ret_ref = 0;
62648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62649         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62650         return ret_ref;
62651 }
62652
62653 jboolean  CS_LDK_ChannelDerivationParameters_eq(int64_t a, int64_t b) {
62654         LDKChannelDerivationParameters a_conv;
62655         a_conv.inner = untag_ptr(a);
62656         a_conv.is_owned = ptr_is_owned(a);
62657         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62658         a_conv.is_owned = false;
62659         LDKChannelDerivationParameters b_conv;
62660         b_conv.inner = untag_ptr(b);
62661         b_conv.is_owned = ptr_is_owned(b);
62662         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
62663         b_conv.is_owned = false;
62664         jboolean ret_conv = ChannelDerivationParameters_eq(&a_conv, &b_conv);
62665         return ret_conv;
62666 }
62667
62668 int8_tArray  CS_LDK_ChannelDerivationParameters_write(int64_t obj) {
62669         LDKChannelDerivationParameters obj_conv;
62670         obj_conv.inner = untag_ptr(obj);
62671         obj_conv.is_owned = ptr_is_owned(obj);
62672         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
62673         obj_conv.is_owned = false;
62674         LDKCVec_u8Z ret_var = ChannelDerivationParameters_write(&obj_conv);
62675         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62676         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62677         CVec_u8Z_free(ret_var);
62678         return ret_arr;
62679 }
62680
62681 int64_t  CS_LDK_ChannelDerivationParameters_read(int8_tArray ser) {
62682         LDKu8slice ser_ref;
62683         ser_ref.datalen = ser->arr_len;
62684         ser_ref.data = ser->elems;
62685         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
62686         *ret_conv = ChannelDerivationParameters_read(ser_ref);
62687         FREE(ser);
62688         return tag_ptr(ret_conv, true);
62689 }
62690
62691 void  CS_LDK_HTLCDescriptor_free(int64_t this_obj) {
62692         LDKHTLCDescriptor this_obj_conv;
62693         this_obj_conv.inner = untag_ptr(this_obj);
62694         this_obj_conv.is_owned = ptr_is_owned(this_obj);
62695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
62696         HTLCDescriptor_free(this_obj_conv);
62697 }
62698
62699 int64_t  CS_LDK_HTLCDescriptor_get_channel_derivation_parameters(int64_t this_ptr) {
62700         LDKHTLCDescriptor this_ptr_conv;
62701         this_ptr_conv.inner = untag_ptr(this_ptr);
62702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62704         this_ptr_conv.is_owned = false;
62705         LDKChannelDerivationParameters ret_var = HTLCDescriptor_get_channel_derivation_parameters(&this_ptr_conv);
62706         int64_t ret_ref = 0;
62707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62708         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62709         return ret_ref;
62710 }
62711
62712 void  CS_LDK_HTLCDescriptor_set_channel_derivation_parameters(int64_t this_ptr, int64_t val) {
62713         LDKHTLCDescriptor this_ptr_conv;
62714         this_ptr_conv.inner = untag_ptr(this_ptr);
62715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62717         this_ptr_conv.is_owned = false;
62718         LDKChannelDerivationParameters val_conv;
62719         val_conv.inner = untag_ptr(val);
62720         val_conv.is_owned = ptr_is_owned(val);
62721         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62722         val_conv = ChannelDerivationParameters_clone(&val_conv);
62723         HTLCDescriptor_set_channel_derivation_parameters(&this_ptr_conv, val_conv);
62724 }
62725
62726 int64_t  CS_LDK_HTLCDescriptor_get_per_commitment_number(int64_t this_ptr) {
62727         LDKHTLCDescriptor this_ptr_conv;
62728         this_ptr_conv.inner = untag_ptr(this_ptr);
62729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62731         this_ptr_conv.is_owned = false;
62732         int64_t ret_conv = HTLCDescriptor_get_per_commitment_number(&this_ptr_conv);
62733         return ret_conv;
62734 }
62735
62736 void  CS_LDK_HTLCDescriptor_set_per_commitment_number(int64_t this_ptr, int64_t val) {
62737         LDKHTLCDescriptor this_ptr_conv;
62738         this_ptr_conv.inner = untag_ptr(this_ptr);
62739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62741         this_ptr_conv.is_owned = false;
62742         HTLCDescriptor_set_per_commitment_number(&this_ptr_conv, val);
62743 }
62744
62745 int8_tArray  CS_LDK_HTLCDescriptor_get_per_commitment_point(int64_t this_ptr) {
62746         LDKHTLCDescriptor this_ptr_conv;
62747         this_ptr_conv.inner = untag_ptr(this_ptr);
62748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62750         this_ptr_conv.is_owned = false;
62751         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
62752         memcpy(ret_arr->elems, HTLCDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
62753         return ret_arr;
62754 }
62755
62756 void  CS_LDK_HTLCDescriptor_set_per_commitment_point(int64_t this_ptr, int8_tArray val) {
62757         LDKHTLCDescriptor this_ptr_conv;
62758         this_ptr_conv.inner = untag_ptr(this_ptr);
62759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62761         this_ptr_conv.is_owned = false;
62762         LDKPublicKey val_ref;
62763         CHECK(val->arr_len == 33);
62764         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
62765         HTLCDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
62766 }
62767
62768 int32_t  CS_LDK_HTLCDescriptor_get_feerate_per_kw(int64_t this_ptr) {
62769         LDKHTLCDescriptor this_ptr_conv;
62770         this_ptr_conv.inner = untag_ptr(this_ptr);
62771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62773         this_ptr_conv.is_owned = false;
62774         int32_t ret_conv = HTLCDescriptor_get_feerate_per_kw(&this_ptr_conv);
62775         return ret_conv;
62776 }
62777
62778 void  CS_LDK_HTLCDescriptor_set_feerate_per_kw(int64_t this_ptr, int32_t val) {
62779         LDKHTLCDescriptor this_ptr_conv;
62780         this_ptr_conv.inner = untag_ptr(this_ptr);
62781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62783         this_ptr_conv.is_owned = false;
62784         HTLCDescriptor_set_feerate_per_kw(&this_ptr_conv, val);
62785 }
62786
62787 int64_t  CS_LDK_HTLCDescriptor_get_htlc(int64_t this_ptr) {
62788         LDKHTLCDescriptor this_ptr_conv;
62789         this_ptr_conv.inner = untag_ptr(this_ptr);
62790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62792         this_ptr_conv.is_owned = false;
62793         LDKHTLCOutputInCommitment ret_var = HTLCDescriptor_get_htlc(&this_ptr_conv);
62794         int64_t ret_ref = 0;
62795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62797         return ret_ref;
62798 }
62799
62800 void  CS_LDK_HTLCDescriptor_set_htlc(int64_t this_ptr, int64_t val) {
62801         LDKHTLCDescriptor this_ptr_conv;
62802         this_ptr_conv.inner = untag_ptr(this_ptr);
62803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62805         this_ptr_conv.is_owned = false;
62806         LDKHTLCOutputInCommitment val_conv;
62807         val_conv.inner = untag_ptr(val);
62808         val_conv.is_owned = ptr_is_owned(val);
62809         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62810         val_conv = HTLCOutputInCommitment_clone(&val_conv);
62811         HTLCDescriptor_set_htlc(&this_ptr_conv, val_conv);
62812 }
62813
62814 int64_t  CS_LDK_HTLCDescriptor_get_preimage(int64_t this_ptr) {
62815         LDKHTLCDescriptor this_ptr_conv;
62816         this_ptr_conv.inner = untag_ptr(this_ptr);
62817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62819         this_ptr_conv.is_owned = false;
62820         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
62821         *ret_copy = HTLCDescriptor_get_preimage(&this_ptr_conv);
62822         int64_t ret_ref = tag_ptr(ret_copy, true);
62823         return ret_ref;
62824 }
62825
62826 void  CS_LDK_HTLCDescriptor_set_preimage(int64_t this_ptr, int64_t val) {
62827         LDKHTLCDescriptor this_ptr_conv;
62828         this_ptr_conv.inner = untag_ptr(this_ptr);
62829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62831         this_ptr_conv.is_owned = false;
62832         void* val_ptr = untag_ptr(val);
62833         CHECK_ACCESS(val_ptr);
62834         LDKCOption_ThirtyTwoBytesZ val_conv = *(LDKCOption_ThirtyTwoBytesZ*)(val_ptr);
62835         val_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(val));
62836         HTLCDescriptor_set_preimage(&this_ptr_conv, val_conv);
62837 }
62838
62839 int8_tArray  CS_LDK_HTLCDescriptor_get_counterparty_sig(int64_t this_ptr) {
62840         LDKHTLCDescriptor this_ptr_conv;
62841         this_ptr_conv.inner = untag_ptr(this_ptr);
62842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62844         this_ptr_conv.is_owned = false;
62845         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
62846         memcpy(ret_arr->elems, HTLCDescriptor_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
62847         return ret_arr;
62848 }
62849
62850 void  CS_LDK_HTLCDescriptor_set_counterparty_sig(int64_t this_ptr, int8_tArray val) {
62851         LDKHTLCDescriptor this_ptr_conv;
62852         this_ptr_conv.inner = untag_ptr(this_ptr);
62853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62855         this_ptr_conv.is_owned = false;
62856         LDKECDSASignature val_ref;
62857         CHECK(val->arr_len == 64);
62858         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
62859         HTLCDescriptor_set_counterparty_sig(&this_ptr_conv, val_ref);
62860 }
62861
62862 static inline uint64_t HTLCDescriptor_clone_ptr(LDKHTLCDescriptor *NONNULL_PTR arg) {
62863         LDKHTLCDescriptor ret_var = HTLCDescriptor_clone(arg);
62864         int64_t ret_ref = 0;
62865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62867         return ret_ref;
62868 }
62869 int64_t  CS_LDK_HTLCDescriptor_clone_ptr(int64_t arg) {
62870         LDKHTLCDescriptor arg_conv;
62871         arg_conv.inner = untag_ptr(arg);
62872         arg_conv.is_owned = ptr_is_owned(arg);
62873         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
62874         arg_conv.is_owned = false;
62875         int64_t ret_conv = HTLCDescriptor_clone_ptr(&arg_conv);
62876         return ret_conv;
62877 }
62878
62879 int64_t  CS_LDK_HTLCDescriptor_clone(int64_t orig) {
62880         LDKHTLCDescriptor orig_conv;
62881         orig_conv.inner = untag_ptr(orig);
62882         orig_conv.is_owned = ptr_is_owned(orig);
62883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
62884         orig_conv.is_owned = false;
62885         LDKHTLCDescriptor ret_var = HTLCDescriptor_clone(&orig_conv);
62886         int64_t ret_ref = 0;
62887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62888         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62889         return ret_ref;
62890 }
62891
62892 jboolean  CS_LDK_HTLCDescriptor_eq(int64_t a, int64_t b) {
62893         LDKHTLCDescriptor a_conv;
62894         a_conv.inner = untag_ptr(a);
62895         a_conv.is_owned = ptr_is_owned(a);
62896         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62897         a_conv.is_owned = false;
62898         LDKHTLCDescriptor b_conv;
62899         b_conv.inner = untag_ptr(b);
62900         b_conv.is_owned = ptr_is_owned(b);
62901         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
62902         b_conv.is_owned = false;
62903         jboolean ret_conv = HTLCDescriptor_eq(&a_conv, &b_conv);
62904         return ret_conv;
62905 }
62906
62907 int8_tArray  CS_LDK_HTLCDescriptor_write(int64_t obj) {
62908         LDKHTLCDescriptor obj_conv;
62909         obj_conv.inner = untag_ptr(obj);
62910         obj_conv.is_owned = ptr_is_owned(obj);
62911         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
62912         obj_conv.is_owned = false;
62913         LDKCVec_u8Z ret_var = HTLCDescriptor_write(&obj_conv);
62914         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62915         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62916         CVec_u8Z_free(ret_var);
62917         return ret_arr;
62918 }
62919
62920 int64_t  CS_LDK_HTLCDescriptor_read(int8_tArray ser) {
62921         LDKu8slice ser_ref;
62922         ser_ref.datalen = ser->arr_len;
62923         ser_ref.data = ser->elems;
62924         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
62925         *ret_conv = HTLCDescriptor_read(ser_ref);
62926         FREE(ser);
62927         return tag_ptr(ret_conv, true);
62928 }
62929
62930 int64_t  CS_LDK_HTLCDescriptor_outpoint(int64_t this_arg) {
62931         LDKHTLCDescriptor this_arg_conv;
62932         this_arg_conv.inner = untag_ptr(this_arg);
62933         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62935         this_arg_conv.is_owned = false;
62936         LDKOutPoint ret_var = HTLCDescriptor_outpoint(&this_arg_conv);
62937         int64_t ret_ref = 0;
62938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62940         return ret_ref;
62941 }
62942
62943 int64_t  CS_LDK_HTLCDescriptor_previous_utxo(int64_t this_arg) {
62944         LDKHTLCDescriptor this_arg_conv;
62945         this_arg_conv.inner = untag_ptr(this_arg);
62946         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62948         this_arg_conv.is_owned = false;
62949         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
62950         *ret_ref = HTLCDescriptor_previous_utxo(&this_arg_conv);
62951         return tag_ptr(ret_ref, true);
62952 }
62953
62954 int64_t  CS_LDK_HTLCDescriptor_unsigned_tx_input(int64_t this_arg) {
62955         LDKHTLCDescriptor this_arg_conv;
62956         this_arg_conv.inner = untag_ptr(this_arg);
62957         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62959         this_arg_conv.is_owned = false;
62960         LDKTxIn* ret_ref = MALLOC(sizeof(LDKTxIn), "LDKTxIn");
62961         *ret_ref = HTLCDescriptor_unsigned_tx_input(&this_arg_conv);
62962         return tag_ptr(ret_ref, true);
62963 }
62964
62965 int64_t  CS_LDK_HTLCDescriptor_tx_output(int64_t this_arg) {
62966         LDKHTLCDescriptor this_arg_conv;
62967         this_arg_conv.inner = untag_ptr(this_arg);
62968         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62970         this_arg_conv.is_owned = false;
62971         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
62972         *ret_ref = HTLCDescriptor_tx_output(&this_arg_conv);
62973         return tag_ptr(ret_ref, true);
62974 }
62975
62976 int8_tArray  CS_LDK_HTLCDescriptor_witness_script(int64_t this_arg) {
62977         LDKHTLCDescriptor this_arg_conv;
62978         this_arg_conv.inner = untag_ptr(this_arg);
62979         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62981         this_arg_conv.is_owned = false;
62982         LDKCVec_u8Z ret_var = HTLCDescriptor_witness_script(&this_arg_conv);
62983         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62984         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62985         CVec_u8Z_free(ret_var);
62986         return ret_arr;
62987 }
62988
62989 int8_tArray  CS_LDK_HTLCDescriptor_tx_input_witness(int64_t this_arg, int8_tArray signature, int8_tArray witness_script) {
62990         LDKHTLCDescriptor this_arg_conv;
62991         this_arg_conv.inner = untag_ptr(this_arg);
62992         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62994         this_arg_conv.is_owned = false;
62995         LDKECDSASignature signature_ref;
62996         CHECK(signature->arr_len == 64);
62997         memcpy(signature_ref.compact_form, signature->elems, 64); FREE(signature);
62998         LDKu8slice witness_script_ref;
62999         witness_script_ref.datalen = witness_script->arr_len;
63000         witness_script_ref.data = witness_script->elems;
63001         LDKWitness ret_var = HTLCDescriptor_tx_input_witness(&this_arg_conv, signature_ref, witness_script_ref);
63002         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
63003         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
63004         Witness_free(ret_var);
63005         FREE(witness_script);
63006         return ret_arr;
63007 }
63008
63009 int64_t  CS_LDK_HTLCDescriptor_derive_channel_signer(int64_t this_arg, int64_t signer_provider) {
63010         LDKHTLCDescriptor this_arg_conv;
63011         this_arg_conv.inner = untag_ptr(this_arg);
63012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63014         this_arg_conv.is_owned = false;
63015         void* signer_provider_ptr = untag_ptr(signer_provider);
63016         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
63017         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
63018         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
63019         *ret_ret = HTLCDescriptor_derive_channel_signer(&this_arg_conv, signer_provider_conv);
63020         return tag_ptr(ret_ret, true);
63021 }
63022
63023 void  CS_LDK_ChannelSigner_free(int64_t this_ptr) {
63024         if (!ptr_is_owned(this_ptr)) return;
63025         void* this_ptr_ptr = untag_ptr(this_ptr);
63026         CHECK_ACCESS(this_ptr_ptr);
63027         LDKChannelSigner this_ptr_conv = *(LDKChannelSigner*)(this_ptr_ptr);
63028         FREE(untag_ptr(this_ptr));
63029         ChannelSigner_free(this_ptr_conv);
63030 }
63031
63032 void  CS_LDK_EcdsaChannelSigner_free(int64_t this_ptr) {
63033         if (!ptr_is_owned(this_ptr)) return;
63034         void* this_ptr_ptr = untag_ptr(this_ptr);
63035         CHECK_ACCESS(this_ptr_ptr);
63036         LDKEcdsaChannelSigner this_ptr_conv = *(LDKEcdsaChannelSigner*)(this_ptr_ptr);
63037         FREE(untag_ptr(this_ptr));
63038         EcdsaChannelSigner_free(this_ptr_conv);
63039 }
63040
63041 static inline uint64_t WriteableEcdsaChannelSigner_clone_ptr(LDKWriteableEcdsaChannelSigner *NONNULL_PTR arg) {
63042         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
63043         *ret_ret = WriteableEcdsaChannelSigner_clone(arg);
63044         return tag_ptr(ret_ret, true);
63045 }
63046 int64_t  CS_LDK_WriteableEcdsaChannelSigner_clone_ptr(int64_t arg) {
63047         void* arg_ptr = untag_ptr(arg);
63048         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
63049         LDKWriteableEcdsaChannelSigner* arg_conv = (LDKWriteableEcdsaChannelSigner*)arg_ptr;
63050         int64_t ret_conv = WriteableEcdsaChannelSigner_clone_ptr(arg_conv);
63051         return ret_conv;
63052 }
63053
63054 int64_t  CS_LDK_WriteableEcdsaChannelSigner_clone(int64_t orig) {
63055         void* orig_ptr = untag_ptr(orig);
63056         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
63057         LDKWriteableEcdsaChannelSigner* orig_conv = (LDKWriteableEcdsaChannelSigner*)orig_ptr;
63058         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
63059         *ret_ret = WriteableEcdsaChannelSigner_clone(orig_conv);
63060         return tag_ptr(ret_ret, true);
63061 }
63062
63063 void  CS_LDK_WriteableEcdsaChannelSigner_free(int64_t this_ptr) {
63064         if (!ptr_is_owned(this_ptr)) return;
63065         void* this_ptr_ptr = untag_ptr(this_ptr);
63066         CHECK_ACCESS(this_ptr_ptr);
63067         LDKWriteableEcdsaChannelSigner this_ptr_conv = *(LDKWriteableEcdsaChannelSigner*)(this_ptr_ptr);
63068         FREE(untag_ptr(this_ptr));
63069         WriteableEcdsaChannelSigner_free(this_ptr_conv);
63070 }
63071
63072 int32_t  CS_LDK_Recipient_clone(int64_t orig) {
63073         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
63074         int32_t ret_conv = LDKRecipient_to_cs(Recipient_clone(orig_conv));
63075         return ret_conv;
63076 }
63077
63078 int32_t  CS_LDK_Recipient_node() {
63079         int32_t ret_conv = LDKRecipient_to_cs(Recipient_node());
63080         return ret_conv;
63081 }
63082
63083 int32_t  CS_LDK_Recipient_phantom_node() {
63084         int32_t ret_conv = LDKRecipient_to_cs(Recipient_phantom_node());
63085         return ret_conv;
63086 }
63087
63088 void  CS_LDK_EntropySource_free(int64_t this_ptr) {
63089         if (!ptr_is_owned(this_ptr)) return;
63090         void* this_ptr_ptr = untag_ptr(this_ptr);
63091         CHECK_ACCESS(this_ptr_ptr);
63092         LDKEntropySource this_ptr_conv = *(LDKEntropySource*)(this_ptr_ptr);
63093         FREE(untag_ptr(this_ptr));
63094         EntropySource_free(this_ptr_conv);
63095 }
63096
63097 void  CS_LDK_NodeSigner_free(int64_t this_ptr) {
63098         if (!ptr_is_owned(this_ptr)) return;
63099         void* this_ptr_ptr = untag_ptr(this_ptr);
63100         CHECK_ACCESS(this_ptr_ptr);
63101         LDKNodeSigner this_ptr_conv = *(LDKNodeSigner*)(this_ptr_ptr);
63102         FREE(untag_ptr(this_ptr));
63103         NodeSigner_free(this_ptr_conv);
63104 }
63105
63106 void  CS_LDK_SignerProvider_free(int64_t this_ptr) {
63107         if (!ptr_is_owned(this_ptr)) return;
63108         void* this_ptr_ptr = untag_ptr(this_ptr);
63109         CHECK_ACCESS(this_ptr_ptr);
63110         LDKSignerProvider this_ptr_conv = *(LDKSignerProvider*)(this_ptr_ptr);
63111         FREE(untag_ptr(this_ptr));
63112         SignerProvider_free(this_ptr_conv);
63113 }
63114
63115 void  CS_LDK_InMemorySigner_free(int64_t this_obj) {
63116         LDKInMemorySigner this_obj_conv;
63117         this_obj_conv.inner = untag_ptr(this_obj);
63118         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63120         InMemorySigner_free(this_obj_conv);
63121 }
63122
63123 int8_tArray  CS_LDK_InMemorySigner_get_funding_key(int64_t this_ptr) {
63124         LDKInMemorySigner this_ptr_conv;
63125         this_ptr_conv.inner = untag_ptr(this_ptr);
63126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63128         this_ptr_conv.is_owned = false;
63129         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63130         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
63131         return ret_arr;
63132 }
63133
63134 void  CS_LDK_InMemorySigner_set_funding_key(int64_t this_ptr, int8_tArray val) {
63135         LDKInMemorySigner this_ptr_conv;
63136         this_ptr_conv.inner = untag_ptr(this_ptr);
63137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63139         this_ptr_conv.is_owned = false;
63140         LDKSecretKey val_ref;
63141         CHECK(val->arr_len == 32);
63142         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63143         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
63144 }
63145
63146 int8_tArray  CS_LDK_InMemorySigner_get_revocation_base_key(int64_t this_ptr) {
63147         LDKInMemorySigner this_ptr_conv;
63148         this_ptr_conv.inner = untag_ptr(this_ptr);
63149         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63151         this_ptr_conv.is_owned = false;
63152         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63153         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
63154         return ret_arr;
63155 }
63156
63157 void  CS_LDK_InMemorySigner_set_revocation_base_key(int64_t this_ptr, int8_tArray val) {
63158         LDKInMemorySigner this_ptr_conv;
63159         this_ptr_conv.inner = untag_ptr(this_ptr);
63160         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63162         this_ptr_conv.is_owned = false;
63163         LDKSecretKey val_ref;
63164         CHECK(val->arr_len == 32);
63165         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63166         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
63167 }
63168
63169 int8_tArray  CS_LDK_InMemorySigner_get_payment_key(int64_t this_ptr) {
63170         LDKInMemorySigner this_ptr_conv;
63171         this_ptr_conv.inner = untag_ptr(this_ptr);
63172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63174         this_ptr_conv.is_owned = false;
63175         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63176         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
63177         return ret_arr;
63178 }
63179
63180 void  CS_LDK_InMemorySigner_set_payment_key(int64_t this_ptr, int8_tArray val) {
63181         LDKInMemorySigner this_ptr_conv;
63182         this_ptr_conv.inner = untag_ptr(this_ptr);
63183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63185         this_ptr_conv.is_owned = false;
63186         LDKSecretKey val_ref;
63187         CHECK(val->arr_len == 32);
63188         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63189         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
63190 }
63191
63192 int8_tArray  CS_LDK_InMemorySigner_get_delayed_payment_base_key(int64_t this_ptr) {
63193         LDKInMemorySigner this_ptr_conv;
63194         this_ptr_conv.inner = untag_ptr(this_ptr);
63195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63197         this_ptr_conv.is_owned = false;
63198         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63199         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
63200         return ret_arr;
63201 }
63202
63203 void  CS_LDK_InMemorySigner_set_delayed_payment_base_key(int64_t this_ptr, int8_tArray val) {
63204         LDKInMemorySigner this_ptr_conv;
63205         this_ptr_conv.inner = untag_ptr(this_ptr);
63206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63208         this_ptr_conv.is_owned = false;
63209         LDKSecretKey val_ref;
63210         CHECK(val->arr_len == 32);
63211         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63212         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
63213 }
63214
63215 int8_tArray  CS_LDK_InMemorySigner_get_htlc_base_key(int64_t this_ptr) {
63216         LDKInMemorySigner this_ptr_conv;
63217         this_ptr_conv.inner = untag_ptr(this_ptr);
63218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63220         this_ptr_conv.is_owned = false;
63221         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63222         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
63223         return ret_arr;
63224 }
63225
63226 void  CS_LDK_InMemorySigner_set_htlc_base_key(int64_t this_ptr, int8_tArray val) {
63227         LDKInMemorySigner this_ptr_conv;
63228         this_ptr_conv.inner = untag_ptr(this_ptr);
63229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63231         this_ptr_conv.is_owned = false;
63232         LDKSecretKey val_ref;
63233         CHECK(val->arr_len == 32);
63234         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63235         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
63236 }
63237
63238 int8_tArray  CS_LDK_InMemorySigner_get_commitment_seed(int64_t this_ptr) {
63239         LDKInMemorySigner this_ptr_conv;
63240         this_ptr_conv.inner = untag_ptr(this_ptr);
63241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63243         this_ptr_conv.is_owned = false;
63244         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63245         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
63246         return ret_arr;
63247 }
63248
63249 void  CS_LDK_InMemorySigner_set_commitment_seed(int64_t this_ptr, int8_tArray val) {
63250         LDKInMemorySigner this_ptr_conv;
63251         this_ptr_conv.inner = untag_ptr(this_ptr);
63252         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63254         this_ptr_conv.is_owned = false;
63255         LDKThirtyTwoBytes val_ref;
63256         CHECK(val->arr_len == 32);
63257         memcpy(val_ref.data, val->elems, 32); FREE(val);
63258         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
63259 }
63260
63261 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
63262         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
63263         int64_t ret_ref = 0;
63264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63266         return ret_ref;
63267 }
63268 int64_t  CS_LDK_InMemorySigner_clone_ptr(int64_t arg) {
63269         LDKInMemorySigner arg_conv;
63270         arg_conv.inner = untag_ptr(arg);
63271         arg_conv.is_owned = ptr_is_owned(arg);
63272         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
63273         arg_conv.is_owned = false;
63274         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
63275         return ret_conv;
63276 }
63277
63278 int64_t  CS_LDK_InMemorySigner_clone(int64_t orig) {
63279         LDKInMemorySigner orig_conv;
63280         orig_conv.inner = untag_ptr(orig);
63281         orig_conv.is_owned = ptr_is_owned(orig);
63282         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
63283         orig_conv.is_owned = false;
63284         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
63285         int64_t ret_ref = 0;
63286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63288         return ret_ref;
63289 }
63290
63291 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) {
63292         LDKSecretKey funding_key_ref;
63293         CHECK(funding_key->arr_len == 32);
63294         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
63295         LDKSecretKey revocation_base_key_ref;
63296         CHECK(revocation_base_key->arr_len == 32);
63297         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
63298         LDKSecretKey payment_key_ref;
63299         CHECK(payment_key->arr_len == 32);
63300         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
63301         LDKSecretKey delayed_payment_base_key_ref;
63302         CHECK(delayed_payment_base_key->arr_len == 32);
63303         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
63304         LDKSecretKey htlc_base_key_ref;
63305         CHECK(htlc_base_key->arr_len == 32);
63306         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
63307         LDKThirtyTwoBytes commitment_seed_ref;
63308         CHECK(commitment_seed->arr_len == 32);
63309         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
63310         LDKThirtyTwoBytes channel_keys_id_ref;
63311         CHECK(channel_keys_id->arr_len == 32);
63312         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
63313         LDKThirtyTwoBytes rand_bytes_unique_start_ref;
63314         CHECK(rand_bytes_unique_start->arr_len == 32);
63315         memcpy(rand_bytes_unique_start_ref.data, rand_bytes_unique_start->elems, 32); FREE(rand_bytes_unique_start);
63316         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);
63317         int64_t ret_ref = 0;
63318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63319         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63320         return ret_ref;
63321 }
63322
63323 int64_t  CS_LDK_InMemorySigner_counterparty_pubkeys(int64_t this_arg) {
63324         LDKInMemorySigner this_arg_conv;
63325         this_arg_conv.inner = untag_ptr(this_arg);
63326         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63328         this_arg_conv.is_owned = false;
63329         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
63330         int64_t ret_ref = 0;
63331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63332         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63333         return ret_ref;
63334 }
63335
63336 int64_t  CS_LDK_InMemorySigner_counterparty_selected_contest_delay(int64_t this_arg) {
63337         LDKInMemorySigner this_arg_conv;
63338         this_arg_conv.inner = untag_ptr(this_arg);
63339         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63341         this_arg_conv.is_owned = false;
63342         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
63343         *ret_copy = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
63344         int64_t ret_ref = tag_ptr(ret_copy, true);
63345         return ret_ref;
63346 }
63347
63348 int64_t  CS_LDK_InMemorySigner_holder_selected_contest_delay(int64_t this_arg) {
63349         LDKInMemorySigner this_arg_conv;
63350         this_arg_conv.inner = untag_ptr(this_arg);
63351         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63353         this_arg_conv.is_owned = false;
63354         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
63355         *ret_copy = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
63356         int64_t ret_ref = tag_ptr(ret_copy, true);
63357         return ret_ref;
63358 }
63359
63360 int64_t  CS_LDK_InMemorySigner_is_outbound(int64_t this_arg) {
63361         LDKInMemorySigner this_arg_conv;
63362         this_arg_conv.inner = untag_ptr(this_arg);
63363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63365         this_arg_conv.is_owned = false;
63366         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
63367         *ret_copy = InMemorySigner_is_outbound(&this_arg_conv);
63368         int64_t ret_ref = tag_ptr(ret_copy, true);
63369         return ret_ref;
63370 }
63371
63372 int64_t  CS_LDK_InMemorySigner_funding_outpoint(int64_t this_arg) {
63373         LDKInMemorySigner this_arg_conv;
63374         this_arg_conv.inner = untag_ptr(this_arg);
63375         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63377         this_arg_conv.is_owned = false;
63378         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
63379         int64_t ret_ref = 0;
63380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63382         return ret_ref;
63383 }
63384
63385 int64_t  CS_LDK_InMemorySigner_get_channel_parameters(int64_t this_arg) {
63386         LDKInMemorySigner this_arg_conv;
63387         this_arg_conv.inner = untag_ptr(this_arg);
63388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63390         this_arg_conv.is_owned = false;
63391         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
63392         int64_t ret_ref = 0;
63393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63394         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63395         return ret_ref;
63396 }
63397
63398 int64_t  CS_LDK_InMemorySigner_channel_type_features(int64_t this_arg) {
63399         LDKInMemorySigner this_arg_conv;
63400         this_arg_conv.inner = untag_ptr(this_arg);
63401         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63403         this_arg_conv.is_owned = false;
63404         LDKChannelTypeFeatures ret_var = InMemorySigner_channel_type_features(&this_arg_conv);
63405         int64_t ret_ref = 0;
63406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63407         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63408         return ret_ref;
63409 }
63410
63411 int64_t  CS_LDK_InMemorySigner_sign_counterparty_payment_input(int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
63412         LDKInMemorySigner this_arg_conv;
63413         this_arg_conv.inner = untag_ptr(this_arg);
63414         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63416         this_arg_conv.is_owned = false;
63417         LDKTransaction spend_tx_ref;
63418         spend_tx_ref.datalen = spend_tx->arr_len;
63419         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
63420         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
63421         spend_tx_ref.data_is_owned = true;
63422         LDKStaticPaymentOutputDescriptor descriptor_conv;
63423         descriptor_conv.inner = untag_ptr(descriptor);
63424         descriptor_conv.is_owned = ptr_is_owned(descriptor);
63425         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
63426         descriptor_conv.is_owned = false;
63427         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
63428         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
63429         return tag_ptr(ret_conv, true);
63430 }
63431
63432 int64_t  CS_LDK_InMemorySigner_sign_dynamic_p2wsh_input(int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
63433         LDKInMemorySigner this_arg_conv;
63434         this_arg_conv.inner = untag_ptr(this_arg);
63435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63437         this_arg_conv.is_owned = false;
63438         LDKTransaction spend_tx_ref;
63439         spend_tx_ref.datalen = spend_tx->arr_len;
63440         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
63441         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
63442         spend_tx_ref.data_is_owned = true;
63443         LDKDelayedPaymentOutputDescriptor descriptor_conv;
63444         descriptor_conv.inner = untag_ptr(descriptor);
63445         descriptor_conv.is_owned = ptr_is_owned(descriptor);
63446         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
63447         descriptor_conv.is_owned = false;
63448         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
63449         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
63450         return tag_ptr(ret_conv, true);
63451 }
63452
63453 int64_t  CS_LDK_InMemorySigner_as_EntropySource(int64_t this_arg) {
63454         LDKInMemorySigner this_arg_conv;
63455         this_arg_conv.inner = untag_ptr(this_arg);
63456         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63458         this_arg_conv.is_owned = false;
63459         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
63460         *ret_ret = InMemorySigner_as_EntropySource(&this_arg_conv);
63461         return tag_ptr(ret_ret, true);
63462 }
63463
63464 int64_t  CS_LDK_InMemorySigner_as_ChannelSigner(int64_t this_arg) {
63465         LDKInMemorySigner this_arg_conv;
63466         this_arg_conv.inner = untag_ptr(this_arg);
63467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63469         this_arg_conv.is_owned = false;
63470         LDKChannelSigner* ret_ret = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
63471         *ret_ret = InMemorySigner_as_ChannelSigner(&this_arg_conv);
63472         return tag_ptr(ret_ret, true);
63473 }
63474
63475 int64_t  CS_LDK_InMemorySigner_as_EcdsaChannelSigner(int64_t this_arg) {
63476         LDKInMemorySigner this_arg_conv;
63477         this_arg_conv.inner = untag_ptr(this_arg);
63478         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63480         this_arg_conv.is_owned = false;
63481         LDKEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
63482         *ret_ret = InMemorySigner_as_EcdsaChannelSigner(&this_arg_conv);
63483         return tag_ptr(ret_ret, true);
63484 }
63485
63486 int64_t  CS_LDK_InMemorySigner_as_WriteableEcdsaChannelSigner(int64_t this_arg) {
63487         LDKInMemorySigner this_arg_conv;
63488         this_arg_conv.inner = untag_ptr(this_arg);
63489         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63491         this_arg_conv.is_owned = false;
63492         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
63493         *ret_ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&this_arg_conv);
63494         return tag_ptr(ret_ret, true);
63495 }
63496
63497 int8_tArray  CS_LDK_InMemorySigner_write(int64_t obj) {
63498         LDKInMemorySigner obj_conv;
63499         obj_conv.inner = untag_ptr(obj);
63500         obj_conv.is_owned = ptr_is_owned(obj);
63501         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
63502         obj_conv.is_owned = false;
63503         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
63504         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
63505         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
63506         CVec_u8Z_free(ret_var);
63507         return ret_arr;
63508 }
63509
63510 int64_t  CS_LDK_InMemorySigner_read(int8_tArray ser, int64_t arg) {
63511         LDKu8slice ser_ref;
63512         ser_ref.datalen = ser->arr_len;
63513         ser_ref.data = ser->elems;
63514         void* arg_ptr = untag_ptr(arg);
63515         CHECK_ACCESS(arg_ptr);
63516         LDKEntropySource arg_conv = *(LDKEntropySource*)(arg_ptr);
63517         if (arg_conv.free == LDKEntropySource_JCalls_free) {
63518                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
63519                 LDKEntropySource_JCalls_cloned(&arg_conv);
63520         }
63521         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
63522         *ret_conv = InMemorySigner_read(ser_ref, arg_conv);
63523         FREE(ser);
63524         return tag_ptr(ret_conv, true);
63525 }
63526
63527 void  CS_LDK_KeysManager_free(int64_t this_obj) {
63528         LDKKeysManager this_obj_conv;
63529         this_obj_conv.inner = untag_ptr(this_obj);
63530         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63532         KeysManager_free(this_obj_conv);
63533 }
63534
63535 int64_t  CS_LDK_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
63536         uint8_t seed_arr[32];
63537         CHECK(seed->arr_len == 32);
63538         memcpy(seed_arr, seed->elems, 32); FREE(seed);
63539         uint8_t (*seed_ref)[32] = &seed_arr;
63540         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
63541         int64_t ret_ref = 0;
63542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63543         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63544         return ret_ref;
63545 }
63546
63547 int8_tArray  CS_LDK_KeysManager_get_node_secret_key(int64_t this_arg) {
63548         LDKKeysManager this_arg_conv;
63549         this_arg_conv.inner = untag_ptr(this_arg);
63550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63552         this_arg_conv.is_owned = false;
63553         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63554         memcpy(ret_arr->elems, KeysManager_get_node_secret_key(&this_arg_conv).bytes, 32);
63555         return ret_arr;
63556 }
63557
63558 int64_t  CS_LDK_KeysManager_derive_channel_keys(int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
63559         LDKKeysManager this_arg_conv;
63560         this_arg_conv.inner = untag_ptr(this_arg);
63561         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63563         this_arg_conv.is_owned = false;
63564         uint8_t params_arr[32];
63565         CHECK(params->arr_len == 32);
63566         memcpy(params_arr, params->elems, 32); FREE(params);
63567         uint8_t (*params_ref)[32] = &params_arr;
63568         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
63569         int64_t ret_ref = 0;
63570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63571         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63572         return ret_ref;
63573 }
63574
63575 int64_t  CS_LDK_KeysManager_sign_spendable_outputs_psbt(int64_t this_arg, int64_tArray descriptors, int8_tArray psbt) {
63576         LDKKeysManager this_arg_conv;
63577         this_arg_conv.inner = untag_ptr(this_arg);
63578         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63580         this_arg_conv.is_owned = false;
63581         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
63582         descriptors_constr.datalen = descriptors->arr_len;
63583         if (descriptors_constr.datalen > 0)
63584                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
63585         else
63586                 descriptors_constr.data = NULL;
63587         int64_t* descriptors_vals = descriptors->elems;
63588         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
63589                 int64_t descriptors_conv_27 = descriptors_vals[b];
63590                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
63591                 CHECK_ACCESS(descriptors_conv_27_ptr);
63592                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
63593                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
63594                 descriptors_constr.data[b] = descriptors_conv_27_conv;
63595         }
63596         FREE(descriptors);
63597         LDKCVec_u8Z psbt_ref;
63598         psbt_ref.datalen = psbt->arr_len;
63599         psbt_ref.data = MALLOC(psbt_ref.datalen, "LDKCVec_u8Z Bytes");
63600         memcpy(psbt_ref.data, psbt->elems, psbt_ref.datalen); FREE(psbt);
63601         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
63602         *ret_conv = KeysManager_sign_spendable_outputs_psbt(&this_arg_conv, descriptors_constr, psbt_ref);
63603         return tag_ptr(ret_conv, true);
63604 }
63605
63606 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) {
63607         LDKKeysManager this_arg_conv;
63608         this_arg_conv.inner = untag_ptr(this_arg);
63609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63611         this_arg_conv.is_owned = false;
63612         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
63613         descriptors_constr.datalen = descriptors->arr_len;
63614         if (descriptors_constr.datalen > 0)
63615                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
63616         else
63617                 descriptors_constr.data = NULL;
63618         int64_t* descriptors_vals = descriptors->elems;
63619         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
63620                 int64_t descriptors_conv_27 = descriptors_vals[b];
63621                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
63622                 CHECK_ACCESS(descriptors_conv_27_ptr);
63623                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
63624                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
63625                 descriptors_constr.data[b] = descriptors_conv_27_conv;
63626         }
63627         FREE(descriptors);
63628         LDKCVec_TxOutZ outputs_constr;
63629         outputs_constr.datalen = outputs->arr_len;
63630         if (outputs_constr.datalen > 0)
63631                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
63632         else
63633                 outputs_constr.data = NULL;
63634         int64_t* outputs_vals = outputs->elems;
63635         for (size_t h = 0; h < outputs_constr.datalen; h++) {
63636                 int64_t outputs_conv_7 = outputs_vals[h];
63637                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
63638                 CHECK_ACCESS(outputs_conv_7_ptr);
63639                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
63640                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
63641                 outputs_constr.data[h] = outputs_conv_7_conv;
63642         }
63643         FREE(outputs);
63644         LDKCVec_u8Z change_destination_script_ref;
63645         change_destination_script_ref.datalen = change_destination_script->arr_len;
63646         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
63647         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
63648         void* locktime_ptr = untag_ptr(locktime);
63649         CHECK_ACCESS(locktime_ptr);
63650         LDKCOption_u32Z locktime_conv = *(LDKCOption_u32Z*)(locktime_ptr);
63651         locktime_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(locktime));
63652         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
63653         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight, locktime_conv);
63654         return tag_ptr(ret_conv, true);
63655 }
63656
63657 int64_t  CS_LDK_KeysManager_as_EntropySource(int64_t this_arg) {
63658         LDKKeysManager this_arg_conv;
63659         this_arg_conv.inner = untag_ptr(this_arg);
63660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63662         this_arg_conv.is_owned = false;
63663         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
63664         *ret_ret = KeysManager_as_EntropySource(&this_arg_conv);
63665         return tag_ptr(ret_ret, true);
63666 }
63667
63668 int64_t  CS_LDK_KeysManager_as_NodeSigner(int64_t this_arg) {
63669         LDKKeysManager this_arg_conv;
63670         this_arg_conv.inner = untag_ptr(this_arg);
63671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63673         this_arg_conv.is_owned = false;
63674         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
63675         *ret_ret = KeysManager_as_NodeSigner(&this_arg_conv);
63676         return tag_ptr(ret_ret, true);
63677 }
63678
63679 int64_t  CS_LDK_KeysManager_as_SignerProvider(int64_t this_arg) {
63680         LDKKeysManager this_arg_conv;
63681         this_arg_conv.inner = untag_ptr(this_arg);
63682         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63684         this_arg_conv.is_owned = false;
63685         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
63686         *ret_ret = KeysManager_as_SignerProvider(&this_arg_conv);
63687         return tag_ptr(ret_ret, true);
63688 }
63689
63690 void  CS_LDK_PhantomKeysManager_free(int64_t this_obj) {
63691         LDKPhantomKeysManager this_obj_conv;
63692         this_obj_conv.inner = untag_ptr(this_obj);
63693         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63695         PhantomKeysManager_free(this_obj_conv);
63696 }
63697
63698 int64_t  CS_LDK_PhantomKeysManager_as_EntropySource(int64_t this_arg) {
63699         LDKPhantomKeysManager this_arg_conv;
63700         this_arg_conv.inner = untag_ptr(this_arg);
63701         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63703         this_arg_conv.is_owned = false;
63704         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
63705         *ret_ret = PhantomKeysManager_as_EntropySource(&this_arg_conv);
63706         return tag_ptr(ret_ret, true);
63707 }
63708
63709 int64_t  CS_LDK_PhantomKeysManager_as_NodeSigner(int64_t this_arg) {
63710         LDKPhantomKeysManager this_arg_conv;
63711         this_arg_conv.inner = untag_ptr(this_arg);
63712         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63714         this_arg_conv.is_owned = false;
63715         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
63716         *ret_ret = PhantomKeysManager_as_NodeSigner(&this_arg_conv);
63717         return tag_ptr(ret_ret, true);
63718 }
63719
63720 int64_t  CS_LDK_PhantomKeysManager_as_SignerProvider(int64_t this_arg) {
63721         LDKPhantomKeysManager this_arg_conv;
63722         this_arg_conv.inner = untag_ptr(this_arg);
63723         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63725         this_arg_conv.is_owned = false;
63726         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
63727         *ret_ret = PhantomKeysManager_as_SignerProvider(&this_arg_conv);
63728         return tag_ptr(ret_ret, true);
63729 }
63730
63731 int64_t  CS_LDK_PhantomKeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos, int8_tArray cross_node_seed) {
63732         uint8_t seed_arr[32];
63733         CHECK(seed->arr_len == 32);
63734         memcpy(seed_arr, seed->elems, 32); FREE(seed);
63735         uint8_t (*seed_ref)[32] = &seed_arr;
63736         uint8_t cross_node_seed_arr[32];
63737         CHECK(cross_node_seed->arr_len == 32);
63738         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
63739         uint8_t (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
63740         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
63741         int64_t ret_ref = 0;
63742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63744         return ret_ref;
63745 }
63746
63747 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) {
63748         LDKPhantomKeysManager this_arg_conv;
63749         this_arg_conv.inner = untag_ptr(this_arg);
63750         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63752         this_arg_conv.is_owned = false;
63753         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
63754         descriptors_constr.datalen = descriptors->arr_len;
63755         if (descriptors_constr.datalen > 0)
63756                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
63757         else
63758                 descriptors_constr.data = NULL;
63759         int64_t* descriptors_vals = descriptors->elems;
63760         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
63761                 int64_t descriptors_conv_27 = descriptors_vals[b];
63762                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
63763                 CHECK_ACCESS(descriptors_conv_27_ptr);
63764                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
63765                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
63766                 descriptors_constr.data[b] = descriptors_conv_27_conv;
63767         }
63768         FREE(descriptors);
63769         LDKCVec_TxOutZ outputs_constr;
63770         outputs_constr.datalen = outputs->arr_len;
63771         if (outputs_constr.datalen > 0)
63772                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
63773         else
63774                 outputs_constr.data = NULL;
63775         int64_t* outputs_vals = outputs->elems;
63776         for (size_t h = 0; h < outputs_constr.datalen; h++) {
63777                 int64_t outputs_conv_7 = outputs_vals[h];
63778                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
63779                 CHECK_ACCESS(outputs_conv_7_ptr);
63780                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
63781                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
63782                 outputs_constr.data[h] = outputs_conv_7_conv;
63783         }
63784         FREE(outputs);
63785         LDKCVec_u8Z change_destination_script_ref;
63786         change_destination_script_ref.datalen = change_destination_script->arr_len;
63787         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
63788         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
63789         void* locktime_ptr = untag_ptr(locktime);
63790         CHECK_ACCESS(locktime_ptr);
63791         LDKCOption_u32Z locktime_conv = *(LDKCOption_u32Z*)(locktime_ptr);
63792         locktime_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(locktime));
63793         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
63794         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight, locktime_conv);
63795         return tag_ptr(ret_conv, true);
63796 }
63797
63798 int64_t  CS_LDK_PhantomKeysManager_derive_channel_keys(int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
63799         LDKPhantomKeysManager this_arg_conv;
63800         this_arg_conv.inner = untag_ptr(this_arg);
63801         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63803         this_arg_conv.is_owned = false;
63804         uint8_t params_arr[32];
63805         CHECK(params->arr_len == 32);
63806         memcpy(params_arr, params->elems, 32); FREE(params);
63807         uint8_t (*params_ref)[32] = &params_arr;
63808         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
63809         int64_t ret_ref = 0;
63810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63812         return ret_ref;
63813 }
63814
63815 int8_tArray  CS_LDK_PhantomKeysManager_get_node_secret_key(int64_t this_arg) {
63816         LDKPhantomKeysManager this_arg_conv;
63817         this_arg_conv.inner = untag_ptr(this_arg);
63818         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63820         this_arg_conv.is_owned = false;
63821         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63822         memcpy(ret_arr->elems, PhantomKeysManager_get_node_secret_key(&this_arg_conv).bytes, 32);
63823         return ret_arr;
63824 }
63825
63826 int8_tArray  CS_LDK_PhantomKeysManager_get_phantom_node_secret_key(int64_t this_arg) {
63827         LDKPhantomKeysManager this_arg_conv;
63828         this_arg_conv.inner = untag_ptr(this_arg);
63829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63831         this_arg_conv.is_owned = false;
63832         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63833         memcpy(ret_arr->elems, PhantomKeysManager_get_phantom_node_secret_key(&this_arg_conv).bytes, 32);
63834         return ret_arr;
63835 }
63836
63837 void  CS_LDK_OnionMessenger_free(int64_t this_obj) {
63838         LDKOnionMessenger this_obj_conv;
63839         this_obj_conv.inner = untag_ptr(this_obj);
63840         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63842         OnionMessenger_free(this_obj_conv);
63843 }
63844
63845 void  CS_LDK_MessageRouter_free(int64_t this_ptr) {
63846         if (!ptr_is_owned(this_ptr)) return;
63847         void* this_ptr_ptr = untag_ptr(this_ptr);
63848         CHECK_ACCESS(this_ptr_ptr);
63849         LDKMessageRouter this_ptr_conv = *(LDKMessageRouter*)(this_ptr_ptr);
63850         FREE(untag_ptr(this_ptr));
63851         MessageRouter_free(this_ptr_conv);
63852 }
63853
63854 void  CS_LDK_DefaultMessageRouter_free(int64_t this_obj) {
63855         LDKDefaultMessageRouter this_obj_conv;
63856         this_obj_conv.inner = untag_ptr(this_obj);
63857         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63859         DefaultMessageRouter_free(this_obj_conv);
63860 }
63861
63862 int64_t  CS_LDK_DefaultMessageRouter_new() {
63863         LDKDefaultMessageRouter ret_var = DefaultMessageRouter_new();
63864         int64_t ret_ref = 0;
63865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63867         return ret_ref;
63868 }
63869
63870 int64_t  CS_LDK_DefaultMessageRouter_as_MessageRouter(int64_t this_arg) {
63871         LDKDefaultMessageRouter this_arg_conv;
63872         this_arg_conv.inner = untag_ptr(this_arg);
63873         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63875         this_arg_conv.is_owned = false;
63876         LDKMessageRouter* ret_ret = MALLOC(sizeof(LDKMessageRouter), "LDKMessageRouter");
63877         *ret_ret = DefaultMessageRouter_as_MessageRouter(&this_arg_conv);
63878         return tag_ptr(ret_ret, true);
63879 }
63880
63881 void  CS_LDK_OnionMessagePath_free(int64_t this_obj) {
63882         LDKOnionMessagePath this_obj_conv;
63883         this_obj_conv.inner = untag_ptr(this_obj);
63884         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63886         OnionMessagePath_free(this_obj_conv);
63887 }
63888
63889 ptrArray  CS_LDK_OnionMessagePath_get_intermediate_nodes(int64_t this_ptr) {
63890         LDKOnionMessagePath this_ptr_conv;
63891         this_ptr_conv.inner = untag_ptr(this_ptr);
63892         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63894         this_ptr_conv.is_owned = false;
63895         LDKCVec_PublicKeyZ ret_var = OnionMessagePath_get_intermediate_nodes(&this_ptr_conv);
63896         ptrArray ret_arr = NULL;
63897         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
63898         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
63899         for (size_t i = 0; i < ret_var.datalen; i++) {
63900                 int8_tArray ret_conv_8_arr = init_int8_tArray(33, __LINE__);
63901                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compressed_form, 33);
63902                 ret_arr_ptr[i] = ret_conv_8_arr;
63903         }
63904         
63905         FREE(ret_var.data);
63906         return ret_arr;
63907 }
63908
63909 void  CS_LDK_OnionMessagePath_set_intermediate_nodes(int64_t this_ptr, ptrArray val) {
63910         LDKOnionMessagePath this_ptr_conv;
63911         this_ptr_conv.inner = untag_ptr(this_ptr);
63912         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63914         this_ptr_conv.is_owned = false;
63915         LDKCVec_PublicKeyZ val_constr;
63916         val_constr.datalen = val->arr_len;
63917         if (val_constr.datalen > 0)
63918                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
63919         else
63920                 val_constr.data = NULL;
63921         int8_tArray* val_vals = (void*) val->elems;
63922         for (size_t i = 0; i < val_constr.datalen; i++) {
63923                 int8_tArray val_conv_8 = val_vals[i];
63924                 LDKPublicKey val_conv_8_ref;
63925                 CHECK(val_conv_8->arr_len == 33);
63926                 memcpy(val_conv_8_ref.compressed_form, val_conv_8->elems, 33); FREE(val_conv_8);
63927                 val_constr.data[i] = val_conv_8_ref;
63928         }
63929         FREE(val);
63930         OnionMessagePath_set_intermediate_nodes(&this_ptr_conv, val_constr);
63931 }
63932
63933 int64_t  CS_LDK_OnionMessagePath_get_destination(int64_t this_ptr) {
63934         LDKOnionMessagePath this_ptr_conv;
63935         this_ptr_conv.inner = untag_ptr(this_ptr);
63936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63938         this_ptr_conv.is_owned = false;
63939         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
63940         *ret_copy = OnionMessagePath_get_destination(&this_ptr_conv);
63941         int64_t ret_ref = tag_ptr(ret_copy, true);
63942         return ret_ref;
63943 }
63944
63945 void  CS_LDK_OnionMessagePath_set_destination(int64_t this_ptr, int64_t val) {
63946         LDKOnionMessagePath this_ptr_conv;
63947         this_ptr_conv.inner = untag_ptr(this_ptr);
63948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63950         this_ptr_conv.is_owned = false;
63951         void* val_ptr = untag_ptr(val);
63952         CHECK_ACCESS(val_ptr);
63953         LDKDestination val_conv = *(LDKDestination*)(val_ptr);
63954         val_conv = Destination_clone((LDKDestination*)untag_ptr(val));
63955         OnionMessagePath_set_destination(&this_ptr_conv, val_conv);
63956 }
63957
63958 int64_t  CS_LDK_OnionMessagePath_new(ptrArray intermediate_nodes_arg, int64_t destination_arg) {
63959         LDKCVec_PublicKeyZ intermediate_nodes_arg_constr;
63960         intermediate_nodes_arg_constr.datalen = intermediate_nodes_arg->arr_len;
63961         if (intermediate_nodes_arg_constr.datalen > 0)
63962                 intermediate_nodes_arg_constr.data = MALLOC(intermediate_nodes_arg_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
63963         else
63964                 intermediate_nodes_arg_constr.data = NULL;
63965         int8_tArray* intermediate_nodes_arg_vals = (void*) intermediate_nodes_arg->elems;
63966         for (size_t i = 0; i < intermediate_nodes_arg_constr.datalen; i++) {
63967                 int8_tArray intermediate_nodes_arg_conv_8 = intermediate_nodes_arg_vals[i];
63968                 LDKPublicKey intermediate_nodes_arg_conv_8_ref;
63969                 CHECK(intermediate_nodes_arg_conv_8->arr_len == 33);
63970                 memcpy(intermediate_nodes_arg_conv_8_ref.compressed_form, intermediate_nodes_arg_conv_8->elems, 33); FREE(intermediate_nodes_arg_conv_8);
63971                 intermediate_nodes_arg_constr.data[i] = intermediate_nodes_arg_conv_8_ref;
63972         }
63973         FREE(intermediate_nodes_arg);
63974         void* destination_arg_ptr = untag_ptr(destination_arg);
63975         CHECK_ACCESS(destination_arg_ptr);
63976         LDKDestination destination_arg_conv = *(LDKDestination*)(destination_arg_ptr);
63977         destination_arg_conv = Destination_clone((LDKDestination*)untag_ptr(destination_arg));
63978         LDKOnionMessagePath ret_var = OnionMessagePath_new(intermediate_nodes_arg_constr, destination_arg_conv);
63979         int64_t ret_ref = 0;
63980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63982         return ret_ref;
63983 }
63984
63985 static inline uint64_t OnionMessagePath_clone_ptr(LDKOnionMessagePath *NONNULL_PTR arg) {
63986         LDKOnionMessagePath ret_var = OnionMessagePath_clone(arg);
63987         int64_t ret_ref = 0;
63988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63989         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63990         return ret_ref;
63991 }
63992 int64_t  CS_LDK_OnionMessagePath_clone_ptr(int64_t arg) {
63993         LDKOnionMessagePath arg_conv;
63994         arg_conv.inner = untag_ptr(arg);
63995         arg_conv.is_owned = ptr_is_owned(arg);
63996         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
63997         arg_conv.is_owned = false;
63998         int64_t ret_conv = OnionMessagePath_clone_ptr(&arg_conv);
63999         return ret_conv;
64000 }
64001
64002 int64_t  CS_LDK_OnionMessagePath_clone(int64_t orig) {
64003         LDKOnionMessagePath orig_conv;
64004         orig_conv.inner = untag_ptr(orig);
64005         orig_conv.is_owned = ptr_is_owned(orig);
64006         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
64007         orig_conv.is_owned = false;
64008         LDKOnionMessagePath ret_var = OnionMessagePath_clone(&orig_conv);
64009         int64_t ret_ref = 0;
64010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64011         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64012         return ret_ref;
64013 }
64014
64015 void  CS_LDK_Destination_free(int64_t this_ptr) {
64016         if (!ptr_is_owned(this_ptr)) return;
64017         void* this_ptr_ptr = untag_ptr(this_ptr);
64018         CHECK_ACCESS(this_ptr_ptr);
64019         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
64020         FREE(untag_ptr(this_ptr));
64021         Destination_free(this_ptr_conv);
64022 }
64023
64024 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
64025         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
64026         *ret_copy = Destination_clone(arg);
64027         int64_t ret_ref = tag_ptr(ret_copy, true);
64028         return ret_ref;
64029 }
64030 int64_t  CS_LDK_Destination_clone_ptr(int64_t arg) {
64031         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
64032         int64_t ret_conv = Destination_clone_ptr(arg_conv);
64033         return ret_conv;
64034 }
64035
64036 int64_t  CS_LDK_Destination_clone(int64_t orig) {
64037         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
64038         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
64039         *ret_copy = Destination_clone(orig_conv);
64040         int64_t ret_ref = tag_ptr(ret_copy, true);
64041         return ret_ref;
64042 }
64043
64044 int64_t  CS_LDK_Destination_node(int8_tArray a) {
64045         LDKPublicKey a_ref;
64046         CHECK(a->arr_len == 33);
64047         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
64048         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
64049         *ret_copy = Destination_node(a_ref);
64050         int64_t ret_ref = tag_ptr(ret_copy, true);
64051         return ret_ref;
64052 }
64053
64054 int64_t  CS_LDK_Destination_blinded_path(int64_t a) {
64055         LDKBlindedPath a_conv;
64056         a_conv.inner = untag_ptr(a);
64057         a_conv.is_owned = ptr_is_owned(a);
64058         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64059         a_conv = BlindedPath_clone(&a_conv);
64060         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
64061         *ret_copy = Destination_blinded_path(a_conv);
64062         int64_t ret_ref = tag_ptr(ret_copy, true);
64063         return ret_ref;
64064 }
64065
64066 void  CS_LDK_SendError_free(int64_t this_ptr) {
64067         if (!ptr_is_owned(this_ptr)) return;
64068         void* this_ptr_ptr = untag_ptr(this_ptr);
64069         CHECK_ACCESS(this_ptr_ptr);
64070         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
64071         FREE(untag_ptr(this_ptr));
64072         SendError_free(this_ptr_conv);
64073 }
64074
64075 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
64076         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64077         *ret_copy = SendError_clone(arg);
64078         int64_t ret_ref = tag_ptr(ret_copy, true);
64079         return ret_ref;
64080 }
64081 int64_t  CS_LDK_SendError_clone_ptr(int64_t arg) {
64082         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
64083         int64_t ret_conv = SendError_clone_ptr(arg_conv);
64084         return ret_conv;
64085 }
64086
64087 int64_t  CS_LDK_SendError_clone(int64_t orig) {
64088         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
64089         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64090         *ret_copy = SendError_clone(orig_conv);
64091         int64_t ret_ref = tag_ptr(ret_copy, true);
64092         return ret_ref;
64093 }
64094
64095 int64_t  CS_LDK_SendError_secp256k1(int32_t a) {
64096         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_cs(a);
64097         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64098         *ret_copy = SendError_secp256k1(a_conv);
64099         int64_t ret_ref = tag_ptr(ret_copy, true);
64100         return ret_ref;
64101 }
64102
64103 int64_t  CS_LDK_SendError_too_big_packet() {
64104         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64105         *ret_copy = SendError_too_big_packet();
64106         int64_t ret_ref = tag_ptr(ret_copy, true);
64107         return ret_ref;
64108 }
64109
64110 int64_t  CS_LDK_SendError_too_few_blinded_hops() {
64111         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64112         *ret_copy = SendError_too_few_blinded_hops();
64113         int64_t ret_ref = tag_ptr(ret_copy, true);
64114         return ret_ref;
64115 }
64116
64117 int64_t  CS_LDK_SendError_invalid_first_hop() {
64118         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64119         *ret_copy = SendError_invalid_first_hop();
64120         int64_t ret_ref = tag_ptr(ret_copy, true);
64121         return ret_ref;
64122 }
64123
64124 int64_t  CS_LDK_SendError_invalid_message() {
64125         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64126         *ret_copy = SendError_invalid_message();
64127         int64_t ret_ref = tag_ptr(ret_copy, true);
64128         return ret_ref;
64129 }
64130
64131 int64_t  CS_LDK_SendError_buffer_full() {
64132         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64133         *ret_copy = SendError_buffer_full();
64134         int64_t ret_ref = tag_ptr(ret_copy, true);
64135         return ret_ref;
64136 }
64137
64138 int64_t  CS_LDK_SendError_get_node_id_failed() {
64139         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64140         *ret_copy = SendError_get_node_id_failed();
64141         int64_t ret_ref = tag_ptr(ret_copy, true);
64142         return ret_ref;
64143 }
64144
64145 int64_t  CS_LDK_SendError_blinded_path_advance_failed() {
64146         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64147         *ret_copy = SendError_blinded_path_advance_failed();
64148         int64_t ret_ref = tag_ptr(ret_copy, true);
64149         return ret_ref;
64150 }
64151
64152 jboolean  CS_LDK_SendError_eq(int64_t a, int64_t b) {
64153         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
64154         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
64155         jboolean ret_conv = SendError_eq(a_conv, b_conv);
64156         return ret_conv;
64157 }
64158
64159 void  CS_LDK_CustomOnionMessageHandler_free(int64_t this_ptr) {
64160         if (!ptr_is_owned(this_ptr)) return;
64161         void* this_ptr_ptr = untag_ptr(this_ptr);
64162         CHECK_ACCESS(this_ptr_ptr);
64163         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
64164         FREE(untag_ptr(this_ptr));
64165         CustomOnionMessageHandler_free(this_ptr_conv);
64166 }
64167
64168 void  CS_LDK_PeeledOnion_free(int64_t this_ptr) {
64169         if (!ptr_is_owned(this_ptr)) return;
64170         void* this_ptr_ptr = untag_ptr(this_ptr);
64171         CHECK_ACCESS(this_ptr_ptr);
64172         LDKPeeledOnion this_ptr_conv = *(LDKPeeledOnion*)(this_ptr_ptr);
64173         FREE(untag_ptr(this_ptr));
64174         PeeledOnion_free(this_ptr_conv);
64175 }
64176
64177 static inline uint64_t PeeledOnion_clone_ptr(LDKPeeledOnion *NONNULL_PTR arg) {
64178         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
64179         *ret_copy = PeeledOnion_clone(arg);
64180         int64_t ret_ref = tag_ptr(ret_copy, true);
64181         return ret_ref;
64182 }
64183 int64_t  CS_LDK_PeeledOnion_clone_ptr(int64_t arg) {
64184         LDKPeeledOnion* arg_conv = (LDKPeeledOnion*)untag_ptr(arg);
64185         int64_t ret_conv = PeeledOnion_clone_ptr(arg_conv);
64186         return ret_conv;
64187 }
64188
64189 int64_t  CS_LDK_PeeledOnion_clone(int64_t orig) {
64190         LDKPeeledOnion* orig_conv = (LDKPeeledOnion*)untag_ptr(orig);
64191         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
64192         *ret_copy = PeeledOnion_clone(orig_conv);
64193         int64_t ret_ref = tag_ptr(ret_copy, true);
64194         return ret_ref;
64195 }
64196
64197 int64_t  CS_LDK_PeeledOnion_forward(int8_tArray a, int64_t b) {
64198         LDKPublicKey a_ref;
64199         CHECK(a->arr_len == 33);
64200         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
64201         LDKOnionMessage b_conv;
64202         b_conv.inner = untag_ptr(b);
64203         b_conv.is_owned = ptr_is_owned(b);
64204         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
64205         b_conv = OnionMessage_clone(&b_conv);
64206         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
64207         *ret_copy = PeeledOnion_forward(a_ref, b_conv);
64208         int64_t ret_ref = tag_ptr(ret_copy, true);
64209         return ret_ref;
64210 }
64211
64212 int64_t  CS_LDK_PeeledOnion_receive(int64_t a, int8_tArray b, int64_t c) {
64213         void* a_ptr = untag_ptr(a);
64214         CHECK_ACCESS(a_ptr);
64215         LDKParsedOnionMessageContents a_conv = *(LDKParsedOnionMessageContents*)(a_ptr);
64216         a_conv = ParsedOnionMessageContents_clone((LDKParsedOnionMessageContents*)untag_ptr(a));
64217         LDKThirtyTwoBytes b_ref;
64218         CHECK(b->arr_len == 32);
64219         memcpy(b_ref.data, b->elems, 32); FREE(b);
64220         LDKBlindedPath c_conv;
64221         c_conv.inner = untag_ptr(c);
64222         c_conv.is_owned = ptr_is_owned(c);
64223         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
64224         c_conv = BlindedPath_clone(&c_conv);
64225         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
64226         *ret_copy = PeeledOnion_receive(a_conv, b_ref, c_conv);
64227         int64_t ret_ref = tag_ptr(ret_copy, true);
64228         return ret_ref;
64229 }
64230
64231 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) {
64232         void* entropy_source_ptr = untag_ptr(entropy_source);
64233         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
64234         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
64235         void* node_signer_ptr = untag_ptr(node_signer);
64236         if (ptr_is_owned(node_signer)) { CHECK_ACCESS(node_signer_ptr); }
64237         LDKNodeSigner* node_signer_conv = (LDKNodeSigner*)node_signer_ptr;
64238         LDKOnionMessagePath path_conv;
64239         path_conv.inner = untag_ptr(path);
64240         path_conv.is_owned = ptr_is_owned(path);
64241         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
64242         path_conv = OnionMessagePath_clone(&path_conv);
64243         void* contents_ptr = untag_ptr(contents);
64244         CHECK_ACCESS(contents_ptr);
64245         LDKOnionMessageContents contents_conv = *(LDKOnionMessageContents*)(contents_ptr);
64246         if (contents_conv.free == LDKOnionMessageContents_JCalls_free) {
64247                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64248                 LDKOnionMessageContents_JCalls_cloned(&contents_conv);
64249         }
64250         LDKBlindedPath reply_path_conv;
64251         reply_path_conv.inner = untag_ptr(reply_path);
64252         reply_path_conv.is_owned = ptr_is_owned(reply_path);
64253         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
64254         reply_path_conv = BlindedPath_clone(&reply_path_conv);
64255         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ), "LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ");
64256         *ret_conv = create_onion_message(entropy_source_conv, node_signer_conv, path_conv, contents_conv, reply_path_conv);
64257         return tag_ptr(ret_conv, true);
64258 }
64259
64260 int64_t  CS_LDK_peel_onion_message(int64_t msg, int64_t node_signer, int64_t logger, int64_t custom_handler) {
64261         LDKOnionMessage msg_conv;
64262         msg_conv.inner = untag_ptr(msg);
64263         msg_conv.is_owned = ptr_is_owned(msg);
64264         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
64265         msg_conv.is_owned = false;
64266         void* node_signer_ptr = untag_ptr(node_signer);
64267         CHECK_ACCESS(node_signer_ptr);
64268         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
64269         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
64270                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64271                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
64272         }
64273         void* logger_ptr = untag_ptr(logger);
64274         CHECK_ACCESS(logger_ptr);
64275         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
64276         if (logger_conv.free == LDKLogger_JCalls_free) {
64277                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64278                 LDKLogger_JCalls_cloned(&logger_conv);
64279         }
64280         void* custom_handler_ptr = untag_ptr(custom_handler);
64281         CHECK_ACCESS(custom_handler_ptr);
64282         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
64283         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
64284                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64285                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
64286         }
64287         LDKCResult_PeeledOnionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PeeledOnionNoneZ), "LDKCResult_PeeledOnionNoneZ");
64288         *ret_conv = peel_onion_message(&msg_conv, node_signer_conv, logger_conv, custom_handler_conv);
64289         return tag_ptr(ret_conv, true);
64290 }
64291
64292 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) {
64293         void* entropy_source_ptr = untag_ptr(entropy_source);
64294         CHECK_ACCESS(entropy_source_ptr);
64295         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
64296         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
64297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64298                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
64299         }
64300         void* node_signer_ptr = untag_ptr(node_signer);
64301         CHECK_ACCESS(node_signer_ptr);
64302         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
64303         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
64304                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64305                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
64306         }
64307         void* logger_ptr = untag_ptr(logger);
64308         CHECK_ACCESS(logger_ptr);
64309         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
64310         if (logger_conv.free == LDKLogger_JCalls_free) {
64311                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64312                 LDKLogger_JCalls_cloned(&logger_conv);
64313         }
64314         void* message_router_ptr = untag_ptr(message_router);
64315         CHECK_ACCESS(message_router_ptr);
64316         LDKMessageRouter message_router_conv = *(LDKMessageRouter*)(message_router_ptr);
64317         if (message_router_conv.free == LDKMessageRouter_JCalls_free) {
64318                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64319                 LDKMessageRouter_JCalls_cloned(&message_router_conv);
64320         }
64321         void* offers_handler_ptr = untag_ptr(offers_handler);
64322         CHECK_ACCESS(offers_handler_ptr);
64323         LDKOffersMessageHandler offers_handler_conv = *(LDKOffersMessageHandler*)(offers_handler_ptr);
64324         if (offers_handler_conv.free == LDKOffersMessageHandler_JCalls_free) {
64325                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64326                 LDKOffersMessageHandler_JCalls_cloned(&offers_handler_conv);
64327         }
64328         void* custom_handler_ptr = untag_ptr(custom_handler);
64329         CHECK_ACCESS(custom_handler_ptr);
64330         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
64331         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
64332                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64333                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
64334         }
64335         LDKOnionMessenger ret_var = OnionMessenger_new(entropy_source_conv, node_signer_conv, logger_conv, message_router_conv, offers_handler_conv, custom_handler_conv);
64336         int64_t ret_ref = 0;
64337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64338         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64339         return ret_ref;
64340 }
64341
64342 int64_t  CS_LDK_OnionMessenger_send_onion_message(int64_t this_arg, int64_t path, int64_t contents, int64_t reply_path) {
64343         LDKOnionMessenger this_arg_conv;
64344         this_arg_conv.inner = untag_ptr(this_arg);
64345         this_arg_conv.is_owned = ptr_is_owned(this_arg);
64346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
64347         this_arg_conv.is_owned = false;
64348         LDKOnionMessagePath path_conv;
64349         path_conv.inner = untag_ptr(path);
64350         path_conv.is_owned = ptr_is_owned(path);
64351         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
64352         path_conv = OnionMessagePath_clone(&path_conv);
64353         void* contents_ptr = untag_ptr(contents);
64354         CHECK_ACCESS(contents_ptr);
64355         LDKOnionMessageContents contents_conv = *(LDKOnionMessageContents*)(contents_ptr);
64356         if (contents_conv.free == LDKOnionMessageContents_JCalls_free) {
64357                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64358                 LDKOnionMessageContents_JCalls_cloned(&contents_conv);
64359         }
64360         LDKBlindedPath reply_path_conv;
64361         reply_path_conv.inner = untag_ptr(reply_path);
64362         reply_path_conv.is_owned = ptr_is_owned(reply_path);
64363         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
64364         reply_path_conv = BlindedPath_clone(&reply_path_conv);
64365         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
64366         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, path_conv, contents_conv, reply_path_conv);
64367         return tag_ptr(ret_conv, true);
64368 }
64369
64370 int64_t  CS_LDK_OnionMessenger_as_OnionMessageHandler(int64_t this_arg) {
64371         LDKOnionMessenger this_arg_conv;
64372         this_arg_conv.inner = untag_ptr(this_arg);
64373         this_arg_conv.is_owned = ptr_is_owned(this_arg);
64374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
64375         this_arg_conv.is_owned = false;
64376         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
64377         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
64378         return tag_ptr(ret_ret, true);
64379 }
64380
64381 void  CS_LDK_OffersMessageHandler_free(int64_t this_ptr) {
64382         if (!ptr_is_owned(this_ptr)) return;
64383         void* this_ptr_ptr = untag_ptr(this_ptr);
64384         CHECK_ACCESS(this_ptr_ptr);
64385         LDKOffersMessageHandler this_ptr_conv = *(LDKOffersMessageHandler*)(this_ptr_ptr);
64386         FREE(untag_ptr(this_ptr));
64387         OffersMessageHandler_free(this_ptr_conv);
64388 }
64389
64390 void  CS_LDK_OffersMessage_free(int64_t this_ptr) {
64391         if (!ptr_is_owned(this_ptr)) return;
64392         void* this_ptr_ptr = untag_ptr(this_ptr);
64393         CHECK_ACCESS(this_ptr_ptr);
64394         LDKOffersMessage this_ptr_conv = *(LDKOffersMessage*)(this_ptr_ptr);
64395         FREE(untag_ptr(this_ptr));
64396         OffersMessage_free(this_ptr_conv);
64397 }
64398
64399 static inline uint64_t OffersMessage_clone_ptr(LDKOffersMessage *NONNULL_PTR arg) {
64400         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64401         *ret_copy = OffersMessage_clone(arg);
64402         int64_t ret_ref = tag_ptr(ret_copy, true);
64403         return ret_ref;
64404 }
64405 int64_t  CS_LDK_OffersMessage_clone_ptr(int64_t arg) {
64406         LDKOffersMessage* arg_conv = (LDKOffersMessage*)untag_ptr(arg);
64407         int64_t ret_conv = OffersMessage_clone_ptr(arg_conv);
64408         return ret_conv;
64409 }
64410
64411 int64_t  CS_LDK_OffersMessage_clone(int64_t orig) {
64412         LDKOffersMessage* orig_conv = (LDKOffersMessage*)untag_ptr(orig);
64413         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64414         *ret_copy = OffersMessage_clone(orig_conv);
64415         int64_t ret_ref = tag_ptr(ret_copy, true);
64416         return ret_ref;
64417 }
64418
64419 int64_t  CS_LDK_OffersMessage_invoice_request(int64_t a) {
64420         LDKInvoiceRequest a_conv;
64421         a_conv.inner = untag_ptr(a);
64422         a_conv.is_owned = ptr_is_owned(a);
64423         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64424         a_conv = InvoiceRequest_clone(&a_conv);
64425         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64426         *ret_copy = OffersMessage_invoice_request(a_conv);
64427         int64_t ret_ref = tag_ptr(ret_copy, true);
64428         return ret_ref;
64429 }
64430
64431 int64_t  CS_LDK_OffersMessage_invoice(int64_t a) {
64432         LDKBolt12Invoice a_conv;
64433         a_conv.inner = untag_ptr(a);
64434         a_conv.is_owned = ptr_is_owned(a);
64435         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64436         a_conv = Bolt12Invoice_clone(&a_conv);
64437         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64438         *ret_copy = OffersMessage_invoice(a_conv);
64439         int64_t ret_ref = tag_ptr(ret_copy, true);
64440         return ret_ref;
64441 }
64442
64443 int64_t  CS_LDK_OffersMessage_invoice_error(int64_t a) {
64444         LDKInvoiceError a_conv;
64445         a_conv.inner = untag_ptr(a);
64446         a_conv.is_owned = ptr_is_owned(a);
64447         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64448         a_conv = InvoiceError_clone(&a_conv);
64449         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64450         *ret_copy = OffersMessage_invoice_error(a_conv);
64451         int64_t ret_ref = tag_ptr(ret_copy, true);
64452         return ret_ref;
64453 }
64454
64455 jboolean  CS_LDK_OffersMessage_is_known_type(int64_t tlv_type) {
64456         jboolean ret_conv = OffersMessage_is_known_type(tlv_type);
64457         return ret_conv;
64458 }
64459
64460 int8_tArray  CS_LDK_OffersMessage_write(int64_t obj) {
64461         LDKOffersMessage* obj_conv = (LDKOffersMessage*)untag_ptr(obj);
64462         LDKCVec_u8Z ret_var = OffersMessage_write(obj_conv);
64463         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64464         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64465         CVec_u8Z_free(ret_var);
64466         return ret_arr;
64467 }
64468
64469 int64_t  CS_LDK_OffersMessage_read(int8_tArray ser, int64_t arg_a, int64_t arg_b) {
64470         LDKu8slice ser_ref;
64471         ser_ref.datalen = ser->arr_len;
64472         ser_ref.data = ser->elems;
64473         void* arg_b_ptr = untag_ptr(arg_b);
64474         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
64475         LDKLogger* arg_b_conv = (LDKLogger*)arg_b_ptr;
64476         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
64477         *ret_conv = OffersMessage_read(ser_ref, arg_a, arg_b_conv);
64478         FREE(ser);
64479         return tag_ptr(ret_conv, true);
64480 }
64481
64482 void  CS_LDK_Packet_free(int64_t this_obj) {
64483         LDKPacket this_obj_conv;
64484         this_obj_conv.inner = untag_ptr(this_obj);
64485         this_obj_conv.is_owned = ptr_is_owned(this_obj);
64486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
64487         Packet_free(this_obj_conv);
64488 }
64489
64490 int8_t  CS_LDK_Packet_get_version(int64_t this_ptr) {
64491         LDKPacket this_ptr_conv;
64492         this_ptr_conv.inner = untag_ptr(this_ptr);
64493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64495         this_ptr_conv.is_owned = false;
64496         int8_t ret_conv = Packet_get_version(&this_ptr_conv);
64497         return ret_conv;
64498 }
64499
64500 void  CS_LDK_Packet_set_version(int64_t this_ptr, int8_t val) {
64501         LDKPacket this_ptr_conv;
64502         this_ptr_conv.inner = untag_ptr(this_ptr);
64503         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64505         this_ptr_conv.is_owned = false;
64506         Packet_set_version(&this_ptr_conv, val);
64507 }
64508
64509 int8_tArray  CS_LDK_Packet_get_public_key(int64_t this_ptr) {
64510         LDKPacket this_ptr_conv;
64511         this_ptr_conv.inner = untag_ptr(this_ptr);
64512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64514         this_ptr_conv.is_owned = false;
64515         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
64516         memcpy(ret_arr->elems, Packet_get_public_key(&this_ptr_conv).compressed_form, 33);
64517         return ret_arr;
64518 }
64519
64520 void  CS_LDK_Packet_set_public_key(int64_t this_ptr, int8_tArray val) {
64521         LDKPacket this_ptr_conv;
64522         this_ptr_conv.inner = untag_ptr(this_ptr);
64523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64525         this_ptr_conv.is_owned = false;
64526         LDKPublicKey val_ref;
64527         CHECK(val->arr_len == 33);
64528         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
64529         Packet_set_public_key(&this_ptr_conv, val_ref);
64530 }
64531
64532 int8_tArray  CS_LDK_Packet_get_hop_data(int64_t this_ptr) {
64533         LDKPacket this_ptr_conv;
64534         this_ptr_conv.inner = untag_ptr(this_ptr);
64535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64537         this_ptr_conv.is_owned = false;
64538         LDKCVec_u8Z ret_var = Packet_get_hop_data(&this_ptr_conv);
64539         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64540         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64541         CVec_u8Z_free(ret_var);
64542         return ret_arr;
64543 }
64544
64545 void  CS_LDK_Packet_set_hop_data(int64_t this_ptr, int8_tArray val) {
64546         LDKPacket this_ptr_conv;
64547         this_ptr_conv.inner = untag_ptr(this_ptr);
64548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64550         this_ptr_conv.is_owned = false;
64551         LDKCVec_u8Z val_ref;
64552         val_ref.datalen = val->arr_len;
64553         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
64554         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
64555         Packet_set_hop_data(&this_ptr_conv, val_ref);
64556 }
64557
64558 int8_tArray  CS_LDK_Packet_get_hmac(int64_t this_ptr) {
64559         LDKPacket this_ptr_conv;
64560         this_ptr_conv.inner = untag_ptr(this_ptr);
64561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64563         this_ptr_conv.is_owned = false;
64564         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
64565         memcpy(ret_arr->elems, *Packet_get_hmac(&this_ptr_conv), 32);
64566         return ret_arr;
64567 }
64568
64569 void  CS_LDK_Packet_set_hmac(int64_t this_ptr, int8_tArray val) {
64570         LDKPacket this_ptr_conv;
64571         this_ptr_conv.inner = untag_ptr(this_ptr);
64572         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64574         this_ptr_conv.is_owned = false;
64575         LDKThirtyTwoBytes val_ref;
64576         CHECK(val->arr_len == 32);
64577         memcpy(val_ref.data, val->elems, 32); FREE(val);
64578         Packet_set_hmac(&this_ptr_conv, val_ref);
64579 }
64580
64581 int64_t  CS_LDK_Packet_new(int8_t version_arg, int8_tArray public_key_arg, int8_tArray hop_data_arg, int8_tArray hmac_arg) {
64582         LDKPublicKey public_key_arg_ref;
64583         CHECK(public_key_arg->arr_len == 33);
64584         memcpy(public_key_arg_ref.compressed_form, public_key_arg->elems, 33); FREE(public_key_arg);
64585         LDKCVec_u8Z hop_data_arg_ref;
64586         hop_data_arg_ref.datalen = hop_data_arg->arr_len;
64587         hop_data_arg_ref.data = MALLOC(hop_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
64588         memcpy(hop_data_arg_ref.data, hop_data_arg->elems, hop_data_arg_ref.datalen); FREE(hop_data_arg);
64589         LDKThirtyTwoBytes hmac_arg_ref;
64590         CHECK(hmac_arg->arr_len == 32);
64591         memcpy(hmac_arg_ref.data, hmac_arg->elems, 32); FREE(hmac_arg);
64592         LDKPacket ret_var = Packet_new(version_arg, public_key_arg_ref, hop_data_arg_ref, hmac_arg_ref);
64593         int64_t ret_ref = 0;
64594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64596         return ret_ref;
64597 }
64598
64599 static inline uint64_t Packet_clone_ptr(LDKPacket *NONNULL_PTR arg) {
64600         LDKPacket ret_var = Packet_clone(arg);
64601         int64_t ret_ref = 0;
64602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64604         return ret_ref;
64605 }
64606 int64_t  CS_LDK_Packet_clone_ptr(int64_t arg) {
64607         LDKPacket arg_conv;
64608         arg_conv.inner = untag_ptr(arg);
64609         arg_conv.is_owned = ptr_is_owned(arg);
64610         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
64611         arg_conv.is_owned = false;
64612         int64_t ret_conv = Packet_clone_ptr(&arg_conv);
64613         return ret_conv;
64614 }
64615
64616 int64_t  CS_LDK_Packet_clone(int64_t orig) {
64617         LDKPacket orig_conv;
64618         orig_conv.inner = untag_ptr(orig);
64619         orig_conv.is_owned = ptr_is_owned(orig);
64620         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
64621         orig_conv.is_owned = false;
64622         LDKPacket ret_var = Packet_clone(&orig_conv);
64623         int64_t ret_ref = 0;
64624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64626         return ret_ref;
64627 }
64628
64629 jboolean  CS_LDK_Packet_eq(int64_t a, int64_t b) {
64630         LDKPacket a_conv;
64631         a_conv.inner = untag_ptr(a);
64632         a_conv.is_owned = ptr_is_owned(a);
64633         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64634         a_conv.is_owned = false;
64635         LDKPacket b_conv;
64636         b_conv.inner = untag_ptr(b);
64637         b_conv.is_owned = ptr_is_owned(b);
64638         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
64639         b_conv.is_owned = false;
64640         jboolean ret_conv = Packet_eq(&a_conv, &b_conv);
64641         return ret_conv;
64642 }
64643
64644 int8_tArray  CS_LDK_Packet_write(int64_t obj) {
64645         LDKPacket obj_conv;
64646         obj_conv.inner = untag_ptr(obj);
64647         obj_conv.is_owned = ptr_is_owned(obj);
64648         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
64649         obj_conv.is_owned = false;
64650         LDKCVec_u8Z ret_var = Packet_write(&obj_conv);
64651         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64652         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64653         CVec_u8Z_free(ret_var);
64654         return ret_arr;
64655 }
64656
64657 void  CS_LDK_ParsedOnionMessageContents_free(int64_t this_ptr) {
64658         if (!ptr_is_owned(this_ptr)) return;
64659         void* this_ptr_ptr = untag_ptr(this_ptr);
64660         CHECK_ACCESS(this_ptr_ptr);
64661         LDKParsedOnionMessageContents this_ptr_conv = *(LDKParsedOnionMessageContents*)(this_ptr_ptr);
64662         FREE(untag_ptr(this_ptr));
64663         ParsedOnionMessageContents_free(this_ptr_conv);
64664 }
64665
64666 static inline uint64_t ParsedOnionMessageContents_clone_ptr(LDKParsedOnionMessageContents *NONNULL_PTR arg) {
64667         LDKParsedOnionMessageContents *ret_copy = MALLOC(sizeof(LDKParsedOnionMessageContents), "LDKParsedOnionMessageContents");
64668         *ret_copy = ParsedOnionMessageContents_clone(arg);
64669         int64_t ret_ref = tag_ptr(ret_copy, true);
64670         return ret_ref;
64671 }
64672 int64_t  CS_LDK_ParsedOnionMessageContents_clone_ptr(int64_t arg) {
64673         LDKParsedOnionMessageContents* arg_conv = (LDKParsedOnionMessageContents*)untag_ptr(arg);
64674         int64_t ret_conv = ParsedOnionMessageContents_clone_ptr(arg_conv);
64675         return ret_conv;
64676 }
64677
64678 int64_t  CS_LDK_ParsedOnionMessageContents_clone(int64_t orig) {
64679         LDKParsedOnionMessageContents* orig_conv = (LDKParsedOnionMessageContents*)untag_ptr(orig);
64680         LDKParsedOnionMessageContents *ret_copy = MALLOC(sizeof(LDKParsedOnionMessageContents), "LDKParsedOnionMessageContents");
64681         *ret_copy = ParsedOnionMessageContents_clone(orig_conv);
64682         int64_t ret_ref = tag_ptr(ret_copy, true);
64683         return ret_ref;
64684 }
64685
64686 int64_t  CS_LDK_ParsedOnionMessageContents_offers(int64_t a) {
64687         void* a_ptr = untag_ptr(a);
64688         CHECK_ACCESS(a_ptr);
64689         LDKOffersMessage a_conv = *(LDKOffersMessage*)(a_ptr);
64690         a_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(a));
64691         LDKParsedOnionMessageContents *ret_copy = MALLOC(sizeof(LDKParsedOnionMessageContents), "LDKParsedOnionMessageContents");
64692         *ret_copy = ParsedOnionMessageContents_offers(a_conv);
64693         int64_t ret_ref = tag_ptr(ret_copy, true);
64694         return ret_ref;
64695 }
64696
64697 int64_t  CS_LDK_ParsedOnionMessageContents_custom(int64_t a) {
64698         void* a_ptr = untag_ptr(a);
64699         CHECK_ACCESS(a_ptr);
64700         LDKOnionMessageContents a_conv = *(LDKOnionMessageContents*)(a_ptr);
64701         if (a_conv.free == LDKOnionMessageContents_JCalls_free) {
64702                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64703                 LDKOnionMessageContents_JCalls_cloned(&a_conv);
64704         }
64705         LDKParsedOnionMessageContents *ret_copy = MALLOC(sizeof(LDKParsedOnionMessageContents), "LDKParsedOnionMessageContents");
64706         *ret_copy = ParsedOnionMessageContents_custom(a_conv);
64707         int64_t ret_ref = tag_ptr(ret_copy, true);
64708         return ret_ref;
64709 }
64710
64711 int64_t  CS_LDK_ParsedOnionMessageContents_as_OnionMessageContents(int64_t this_arg) {
64712         LDKParsedOnionMessageContents* this_arg_conv = (LDKParsedOnionMessageContents*)untag_ptr(this_arg);
64713         LDKOnionMessageContents* ret_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
64714         *ret_ret = ParsedOnionMessageContents_as_OnionMessageContents(this_arg_conv);
64715         return tag_ptr(ret_ret, true);
64716 }
64717
64718 int8_tArray  CS_LDK_ParsedOnionMessageContents_write(int64_t obj) {
64719         LDKParsedOnionMessageContents* obj_conv = (LDKParsedOnionMessageContents*)untag_ptr(obj);
64720         LDKCVec_u8Z ret_var = ParsedOnionMessageContents_write(obj_conv);
64721         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64722         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64723         CVec_u8Z_free(ret_var);
64724         return ret_arr;
64725 }
64726
64727 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
64728         LDKOnionMessageContents* ret_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
64729         *ret_ret = OnionMessageContents_clone(arg);
64730         return tag_ptr(ret_ret, true);
64731 }
64732 int64_t  CS_LDK_OnionMessageContents_clone_ptr(int64_t arg) {
64733         void* arg_ptr = untag_ptr(arg);
64734         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
64735         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)arg_ptr;
64736         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
64737         return ret_conv;
64738 }
64739
64740 int64_t  CS_LDK_OnionMessageContents_clone(int64_t orig) {
64741         void* orig_ptr = untag_ptr(orig);
64742         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
64743         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)orig_ptr;
64744         LDKOnionMessageContents* ret_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
64745         *ret_ret = OnionMessageContents_clone(orig_conv);
64746         return tag_ptr(ret_ret, true);
64747 }
64748
64749 void  CS_LDK_OnionMessageContents_free(int64_t this_ptr) {
64750         if (!ptr_is_owned(this_ptr)) return;
64751         void* this_ptr_ptr = untag_ptr(this_ptr);
64752         CHECK_ACCESS(this_ptr_ptr);
64753         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
64754         FREE(untag_ptr(this_ptr));
64755         OnionMessageContents_free(this_ptr_conv);
64756 }
64757
64758 void  CS_LDK_BlindedPath_free(int64_t this_obj) {
64759         LDKBlindedPath this_obj_conv;
64760         this_obj_conv.inner = untag_ptr(this_obj);
64761         this_obj_conv.is_owned = ptr_is_owned(this_obj);
64762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
64763         BlindedPath_free(this_obj_conv);
64764 }
64765
64766 int8_tArray  CS_LDK_BlindedPath_get_introduction_node_id(int64_t this_ptr) {
64767         LDKBlindedPath this_ptr_conv;
64768         this_ptr_conv.inner = untag_ptr(this_ptr);
64769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64771         this_ptr_conv.is_owned = false;
64772         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
64773         memcpy(ret_arr->elems, BlindedPath_get_introduction_node_id(&this_ptr_conv).compressed_form, 33);
64774         return ret_arr;
64775 }
64776
64777 void  CS_LDK_BlindedPath_set_introduction_node_id(int64_t this_ptr, int8_tArray val) {
64778         LDKBlindedPath this_ptr_conv;
64779         this_ptr_conv.inner = untag_ptr(this_ptr);
64780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64782         this_ptr_conv.is_owned = false;
64783         LDKPublicKey val_ref;
64784         CHECK(val->arr_len == 33);
64785         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
64786         BlindedPath_set_introduction_node_id(&this_ptr_conv, val_ref);
64787 }
64788
64789 int8_tArray  CS_LDK_BlindedPath_get_blinding_point(int64_t this_ptr) {
64790         LDKBlindedPath this_ptr_conv;
64791         this_ptr_conv.inner = untag_ptr(this_ptr);
64792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64794         this_ptr_conv.is_owned = false;
64795         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
64796         memcpy(ret_arr->elems, BlindedPath_get_blinding_point(&this_ptr_conv).compressed_form, 33);
64797         return ret_arr;
64798 }
64799
64800 void  CS_LDK_BlindedPath_set_blinding_point(int64_t this_ptr, int8_tArray val) {
64801         LDKBlindedPath this_ptr_conv;
64802         this_ptr_conv.inner = untag_ptr(this_ptr);
64803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64805         this_ptr_conv.is_owned = false;
64806         LDKPublicKey val_ref;
64807         CHECK(val->arr_len == 33);
64808         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
64809         BlindedPath_set_blinding_point(&this_ptr_conv, val_ref);
64810 }
64811
64812 int64_tArray  CS_LDK_BlindedPath_get_blinded_hops(int64_t this_ptr) {
64813         LDKBlindedPath this_ptr_conv;
64814         this_ptr_conv.inner = untag_ptr(this_ptr);
64815         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64817         this_ptr_conv.is_owned = false;
64818         LDKCVec_BlindedHopZ ret_var = BlindedPath_get_blinded_hops(&this_ptr_conv);
64819         int64_tArray ret_arr = NULL;
64820         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
64821         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
64822         for (size_t m = 0; m < ret_var.datalen; m++) {
64823                 LDKBlindedHop ret_conv_12_var = ret_var.data[m];
64824                 int64_t ret_conv_12_ref = 0;
64825                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_var);
64826                 ret_conv_12_ref = tag_ptr(ret_conv_12_var.inner, ret_conv_12_var.is_owned);
64827                 ret_arr_ptr[m] = ret_conv_12_ref;
64828         }
64829         
64830         FREE(ret_var.data);
64831         return ret_arr;
64832 }
64833
64834 void  CS_LDK_BlindedPath_set_blinded_hops(int64_t this_ptr, int64_tArray val) {
64835         LDKBlindedPath this_ptr_conv;
64836         this_ptr_conv.inner = untag_ptr(this_ptr);
64837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64839         this_ptr_conv.is_owned = false;
64840         LDKCVec_BlindedHopZ val_constr;
64841         val_constr.datalen = val->arr_len;
64842         if (val_constr.datalen > 0)
64843                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
64844         else
64845                 val_constr.data = NULL;
64846         int64_t* val_vals = val->elems;
64847         for (size_t m = 0; m < val_constr.datalen; m++) {
64848                 int64_t val_conv_12 = val_vals[m];
64849                 LDKBlindedHop val_conv_12_conv;
64850                 val_conv_12_conv.inner = untag_ptr(val_conv_12);
64851                 val_conv_12_conv.is_owned = ptr_is_owned(val_conv_12);
64852                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv);
64853                 val_conv_12_conv = BlindedHop_clone(&val_conv_12_conv);
64854                 val_constr.data[m] = val_conv_12_conv;
64855         }
64856         FREE(val);
64857         BlindedPath_set_blinded_hops(&this_ptr_conv, val_constr);
64858 }
64859
64860 int64_t  CS_LDK_BlindedPath_new(int8_tArray introduction_node_id_arg, int8_tArray blinding_point_arg, int64_tArray blinded_hops_arg) {
64861         LDKPublicKey introduction_node_id_arg_ref;
64862         CHECK(introduction_node_id_arg->arr_len == 33);
64863         memcpy(introduction_node_id_arg_ref.compressed_form, introduction_node_id_arg->elems, 33); FREE(introduction_node_id_arg);
64864         LDKPublicKey blinding_point_arg_ref;
64865         CHECK(blinding_point_arg->arr_len == 33);
64866         memcpy(blinding_point_arg_ref.compressed_form, blinding_point_arg->elems, 33); FREE(blinding_point_arg);
64867         LDKCVec_BlindedHopZ blinded_hops_arg_constr;
64868         blinded_hops_arg_constr.datalen = blinded_hops_arg->arr_len;
64869         if (blinded_hops_arg_constr.datalen > 0)
64870                 blinded_hops_arg_constr.data = MALLOC(blinded_hops_arg_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
64871         else
64872                 blinded_hops_arg_constr.data = NULL;
64873         int64_t* blinded_hops_arg_vals = blinded_hops_arg->elems;
64874         for (size_t m = 0; m < blinded_hops_arg_constr.datalen; m++) {
64875                 int64_t blinded_hops_arg_conv_12 = blinded_hops_arg_vals[m];
64876                 LDKBlindedHop blinded_hops_arg_conv_12_conv;
64877                 blinded_hops_arg_conv_12_conv.inner = untag_ptr(blinded_hops_arg_conv_12);
64878                 blinded_hops_arg_conv_12_conv.is_owned = ptr_is_owned(blinded_hops_arg_conv_12);
64879                 CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_hops_arg_conv_12_conv);
64880                 blinded_hops_arg_conv_12_conv = BlindedHop_clone(&blinded_hops_arg_conv_12_conv);
64881                 blinded_hops_arg_constr.data[m] = blinded_hops_arg_conv_12_conv;
64882         }
64883         FREE(blinded_hops_arg);
64884         LDKBlindedPath ret_var = BlindedPath_new(introduction_node_id_arg_ref, blinding_point_arg_ref, blinded_hops_arg_constr);
64885         int64_t ret_ref = 0;
64886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64888         return ret_ref;
64889 }
64890
64891 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
64892         LDKBlindedPath ret_var = BlindedPath_clone(arg);
64893         int64_t ret_ref = 0;
64894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64896         return ret_ref;
64897 }
64898 int64_t  CS_LDK_BlindedPath_clone_ptr(int64_t arg) {
64899         LDKBlindedPath arg_conv;
64900         arg_conv.inner = untag_ptr(arg);
64901         arg_conv.is_owned = ptr_is_owned(arg);
64902         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
64903         arg_conv.is_owned = false;
64904         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
64905         return ret_conv;
64906 }
64907
64908 int64_t  CS_LDK_BlindedPath_clone(int64_t orig) {
64909         LDKBlindedPath orig_conv;
64910         orig_conv.inner = untag_ptr(orig);
64911         orig_conv.is_owned = ptr_is_owned(orig);
64912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
64913         orig_conv.is_owned = false;
64914         LDKBlindedPath ret_var = BlindedPath_clone(&orig_conv);
64915         int64_t ret_ref = 0;
64916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64918         return ret_ref;
64919 }
64920
64921 int64_t  CS_LDK_BlindedPath_hash(int64_t o) {
64922         LDKBlindedPath o_conv;
64923         o_conv.inner = untag_ptr(o);
64924         o_conv.is_owned = ptr_is_owned(o);
64925         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
64926         o_conv.is_owned = false;
64927         int64_t ret_conv = BlindedPath_hash(&o_conv);
64928         return ret_conv;
64929 }
64930
64931 jboolean  CS_LDK_BlindedPath_eq(int64_t a, int64_t b) {
64932         LDKBlindedPath a_conv;
64933         a_conv.inner = untag_ptr(a);
64934         a_conv.is_owned = ptr_is_owned(a);
64935         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64936         a_conv.is_owned = false;
64937         LDKBlindedPath b_conv;
64938         b_conv.inner = untag_ptr(b);
64939         b_conv.is_owned = ptr_is_owned(b);
64940         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
64941         b_conv.is_owned = false;
64942         jboolean ret_conv = BlindedPath_eq(&a_conv, &b_conv);
64943         return ret_conv;
64944 }
64945
64946 void  CS_LDK_BlindedHop_free(int64_t this_obj) {
64947         LDKBlindedHop this_obj_conv;
64948         this_obj_conv.inner = untag_ptr(this_obj);
64949         this_obj_conv.is_owned = ptr_is_owned(this_obj);
64950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
64951         BlindedHop_free(this_obj_conv);
64952 }
64953
64954 int8_tArray  CS_LDK_BlindedHop_get_blinded_node_id(int64_t this_ptr) {
64955         LDKBlindedHop this_ptr_conv;
64956         this_ptr_conv.inner = untag_ptr(this_ptr);
64957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64959         this_ptr_conv.is_owned = false;
64960         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
64961         memcpy(ret_arr->elems, BlindedHop_get_blinded_node_id(&this_ptr_conv).compressed_form, 33);
64962         return ret_arr;
64963 }
64964
64965 void  CS_LDK_BlindedHop_set_blinded_node_id(int64_t this_ptr, int8_tArray val) {
64966         LDKBlindedHop this_ptr_conv;
64967         this_ptr_conv.inner = untag_ptr(this_ptr);
64968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64970         this_ptr_conv.is_owned = false;
64971         LDKPublicKey val_ref;
64972         CHECK(val->arr_len == 33);
64973         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
64974         BlindedHop_set_blinded_node_id(&this_ptr_conv, val_ref);
64975 }
64976
64977 int8_tArray  CS_LDK_BlindedHop_get_encrypted_payload(int64_t this_ptr) {
64978         LDKBlindedHop this_ptr_conv;
64979         this_ptr_conv.inner = untag_ptr(this_ptr);
64980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64982         this_ptr_conv.is_owned = false;
64983         LDKCVec_u8Z ret_var = BlindedHop_get_encrypted_payload(&this_ptr_conv);
64984         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64985         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64986         CVec_u8Z_free(ret_var);
64987         return ret_arr;
64988 }
64989
64990 void  CS_LDK_BlindedHop_set_encrypted_payload(int64_t this_ptr, int8_tArray val) {
64991         LDKBlindedHop this_ptr_conv;
64992         this_ptr_conv.inner = untag_ptr(this_ptr);
64993         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64995         this_ptr_conv.is_owned = false;
64996         LDKCVec_u8Z val_ref;
64997         val_ref.datalen = val->arr_len;
64998         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
64999         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
65000         BlindedHop_set_encrypted_payload(&this_ptr_conv, val_ref);
65001 }
65002
65003 int64_t  CS_LDK_BlindedHop_new(int8_tArray blinded_node_id_arg, int8_tArray encrypted_payload_arg) {
65004         LDKPublicKey blinded_node_id_arg_ref;
65005         CHECK(blinded_node_id_arg->arr_len == 33);
65006         memcpy(blinded_node_id_arg_ref.compressed_form, blinded_node_id_arg->elems, 33); FREE(blinded_node_id_arg);
65007         LDKCVec_u8Z encrypted_payload_arg_ref;
65008         encrypted_payload_arg_ref.datalen = encrypted_payload_arg->arr_len;
65009         encrypted_payload_arg_ref.data = MALLOC(encrypted_payload_arg_ref.datalen, "LDKCVec_u8Z Bytes");
65010         memcpy(encrypted_payload_arg_ref.data, encrypted_payload_arg->elems, encrypted_payload_arg_ref.datalen); FREE(encrypted_payload_arg);
65011         LDKBlindedHop ret_var = BlindedHop_new(blinded_node_id_arg_ref, encrypted_payload_arg_ref);
65012         int64_t ret_ref = 0;
65013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65015         return ret_ref;
65016 }
65017
65018 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
65019         LDKBlindedHop ret_var = BlindedHop_clone(arg);
65020         int64_t ret_ref = 0;
65021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65022         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65023         return ret_ref;
65024 }
65025 int64_t  CS_LDK_BlindedHop_clone_ptr(int64_t arg) {
65026         LDKBlindedHop arg_conv;
65027         arg_conv.inner = untag_ptr(arg);
65028         arg_conv.is_owned = ptr_is_owned(arg);
65029         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65030         arg_conv.is_owned = false;
65031         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
65032         return ret_conv;
65033 }
65034
65035 int64_t  CS_LDK_BlindedHop_clone(int64_t orig) {
65036         LDKBlindedHop orig_conv;
65037         orig_conv.inner = untag_ptr(orig);
65038         orig_conv.is_owned = ptr_is_owned(orig);
65039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65040         orig_conv.is_owned = false;
65041         LDKBlindedHop ret_var = BlindedHop_clone(&orig_conv);
65042         int64_t ret_ref = 0;
65043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65045         return ret_ref;
65046 }
65047
65048 int64_t  CS_LDK_BlindedHop_hash(int64_t o) {
65049         LDKBlindedHop o_conv;
65050         o_conv.inner = untag_ptr(o);
65051         o_conv.is_owned = ptr_is_owned(o);
65052         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
65053         o_conv.is_owned = false;
65054         int64_t ret_conv = BlindedHop_hash(&o_conv);
65055         return ret_conv;
65056 }
65057
65058 jboolean  CS_LDK_BlindedHop_eq(int64_t a, int64_t b) {
65059         LDKBlindedHop a_conv;
65060         a_conv.inner = untag_ptr(a);
65061         a_conv.is_owned = ptr_is_owned(a);
65062         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
65063         a_conv.is_owned = false;
65064         LDKBlindedHop b_conv;
65065         b_conv.inner = untag_ptr(b);
65066         b_conv.is_owned = ptr_is_owned(b);
65067         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
65068         b_conv.is_owned = false;
65069         jboolean ret_conv = BlindedHop_eq(&a_conv, &b_conv);
65070         return ret_conv;
65071 }
65072
65073 int64_t  CS_LDK_BlindedPath_one_hop_for_message(int8_tArray recipient_node_id, int64_t entropy_source) {
65074         LDKPublicKey recipient_node_id_ref;
65075         CHECK(recipient_node_id->arr_len == 33);
65076         memcpy(recipient_node_id_ref.compressed_form, recipient_node_id->elems, 33); FREE(recipient_node_id);
65077         void* entropy_source_ptr = untag_ptr(entropy_source);
65078         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
65079         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
65080         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
65081         *ret_conv = BlindedPath_one_hop_for_message(recipient_node_id_ref, entropy_source_conv);
65082         return tag_ptr(ret_conv, true);
65083 }
65084
65085 int64_t  CS_LDK_BlindedPath_new_for_message(ptrArray node_pks, int64_t entropy_source) {
65086         LDKCVec_PublicKeyZ node_pks_constr;
65087         node_pks_constr.datalen = node_pks->arr_len;
65088         if (node_pks_constr.datalen > 0)
65089                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
65090         else
65091                 node_pks_constr.data = NULL;
65092         int8_tArray* node_pks_vals = (void*) node_pks->elems;
65093         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
65094                 int8_tArray node_pks_conv_8 = node_pks_vals[i];
65095                 LDKPublicKey node_pks_conv_8_ref;
65096                 CHECK(node_pks_conv_8->arr_len == 33);
65097                 memcpy(node_pks_conv_8_ref.compressed_form, node_pks_conv_8->elems, 33); FREE(node_pks_conv_8);
65098                 node_pks_constr.data[i] = node_pks_conv_8_ref;
65099         }
65100         FREE(node_pks);
65101         void* entropy_source_ptr = untag_ptr(entropy_source);
65102         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
65103         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
65104         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
65105         *ret_conv = BlindedPath_new_for_message(node_pks_constr, entropy_source_conv);
65106         return tag_ptr(ret_conv, true);
65107 }
65108
65109 int64_t  CS_LDK_BlindedPath_one_hop_for_payment(int8_tArray payee_node_id, int64_t payee_tlvs, int64_t entropy_source) {
65110         LDKPublicKey payee_node_id_ref;
65111         CHECK(payee_node_id->arr_len == 33);
65112         memcpy(payee_node_id_ref.compressed_form, payee_node_id->elems, 33); FREE(payee_node_id);
65113         LDKReceiveTlvs payee_tlvs_conv;
65114         payee_tlvs_conv.inner = untag_ptr(payee_tlvs);
65115         payee_tlvs_conv.is_owned = ptr_is_owned(payee_tlvs);
65116         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_tlvs_conv);
65117         payee_tlvs_conv = ReceiveTlvs_clone(&payee_tlvs_conv);
65118         void* entropy_source_ptr = untag_ptr(entropy_source);
65119         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
65120         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
65121         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
65122         *ret_conv = BlindedPath_one_hop_for_payment(payee_node_id_ref, payee_tlvs_conv, entropy_source_conv);
65123         return tag_ptr(ret_conv, true);
65124 }
65125
65126 int8_tArray  CS_LDK_BlindedPath_write(int64_t obj) {
65127         LDKBlindedPath obj_conv;
65128         obj_conv.inner = untag_ptr(obj);
65129         obj_conv.is_owned = ptr_is_owned(obj);
65130         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65131         obj_conv.is_owned = false;
65132         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
65133         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65134         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65135         CVec_u8Z_free(ret_var);
65136         return ret_arr;
65137 }
65138
65139 int64_t  CS_LDK_BlindedPath_read(int8_tArray ser) {
65140         LDKu8slice ser_ref;
65141         ser_ref.datalen = ser->arr_len;
65142         ser_ref.data = ser->elems;
65143         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
65144         *ret_conv = BlindedPath_read(ser_ref);
65145         FREE(ser);
65146         return tag_ptr(ret_conv, true);
65147 }
65148
65149 int8_tArray  CS_LDK_BlindedHop_write(int64_t obj) {
65150         LDKBlindedHop obj_conv;
65151         obj_conv.inner = untag_ptr(obj);
65152         obj_conv.is_owned = ptr_is_owned(obj);
65153         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65154         obj_conv.is_owned = false;
65155         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
65156         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65157         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65158         CVec_u8Z_free(ret_var);
65159         return ret_arr;
65160 }
65161
65162 int64_t  CS_LDK_BlindedHop_read(int8_tArray ser) {
65163         LDKu8slice ser_ref;
65164         ser_ref.datalen = ser->arr_len;
65165         ser_ref.data = ser->elems;
65166         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
65167         *ret_conv = BlindedHop_read(ser_ref);
65168         FREE(ser);
65169         return tag_ptr(ret_conv, true);
65170 }
65171
65172 void  CS_LDK_ForwardNode_free(int64_t this_obj) {
65173         LDKForwardNode this_obj_conv;
65174         this_obj_conv.inner = untag_ptr(this_obj);
65175         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65177         ForwardNode_free(this_obj_conv);
65178 }
65179
65180 int64_t  CS_LDK_ForwardNode_get_tlvs(int64_t this_ptr) {
65181         LDKForwardNode this_ptr_conv;
65182         this_ptr_conv.inner = untag_ptr(this_ptr);
65183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65185         this_ptr_conv.is_owned = false;
65186         LDKForwardTlvs ret_var = ForwardNode_get_tlvs(&this_ptr_conv);
65187         int64_t ret_ref = 0;
65188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65190         return ret_ref;
65191 }
65192
65193 void  CS_LDK_ForwardNode_set_tlvs(int64_t this_ptr, int64_t val) {
65194         LDKForwardNode this_ptr_conv;
65195         this_ptr_conv.inner = untag_ptr(this_ptr);
65196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65198         this_ptr_conv.is_owned = false;
65199         LDKForwardTlvs val_conv;
65200         val_conv.inner = untag_ptr(val);
65201         val_conv.is_owned = ptr_is_owned(val);
65202         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65203         val_conv = ForwardTlvs_clone(&val_conv);
65204         ForwardNode_set_tlvs(&this_ptr_conv, val_conv);
65205 }
65206
65207 int8_tArray  CS_LDK_ForwardNode_get_node_id(int64_t this_ptr) {
65208         LDKForwardNode this_ptr_conv;
65209         this_ptr_conv.inner = untag_ptr(this_ptr);
65210         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65212         this_ptr_conv.is_owned = false;
65213         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
65214         memcpy(ret_arr->elems, ForwardNode_get_node_id(&this_ptr_conv).compressed_form, 33);
65215         return ret_arr;
65216 }
65217
65218 void  CS_LDK_ForwardNode_set_node_id(int64_t this_ptr, int8_tArray val) {
65219         LDKForwardNode this_ptr_conv;
65220         this_ptr_conv.inner = untag_ptr(this_ptr);
65221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65223         this_ptr_conv.is_owned = false;
65224         LDKPublicKey val_ref;
65225         CHECK(val->arr_len == 33);
65226         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
65227         ForwardNode_set_node_id(&this_ptr_conv, val_ref);
65228 }
65229
65230 int64_t  CS_LDK_ForwardNode_get_htlc_maximum_msat(int64_t this_ptr) {
65231         LDKForwardNode this_ptr_conv;
65232         this_ptr_conv.inner = untag_ptr(this_ptr);
65233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65235         this_ptr_conv.is_owned = false;
65236         int64_t ret_conv = ForwardNode_get_htlc_maximum_msat(&this_ptr_conv);
65237         return ret_conv;
65238 }
65239
65240 void  CS_LDK_ForwardNode_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
65241         LDKForwardNode this_ptr_conv;
65242         this_ptr_conv.inner = untag_ptr(this_ptr);
65243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65245         this_ptr_conv.is_owned = false;
65246         ForwardNode_set_htlc_maximum_msat(&this_ptr_conv, val);
65247 }
65248
65249 int64_t  CS_LDK_ForwardNode_new(int64_t tlvs_arg, int8_tArray node_id_arg, int64_t htlc_maximum_msat_arg) {
65250         LDKForwardTlvs tlvs_arg_conv;
65251         tlvs_arg_conv.inner = untag_ptr(tlvs_arg);
65252         tlvs_arg_conv.is_owned = ptr_is_owned(tlvs_arg);
65253         CHECK_INNER_FIELD_ACCESS_OR_NULL(tlvs_arg_conv);
65254         tlvs_arg_conv = ForwardTlvs_clone(&tlvs_arg_conv);
65255         LDKPublicKey node_id_arg_ref;
65256         CHECK(node_id_arg->arr_len == 33);
65257         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
65258         LDKForwardNode ret_var = ForwardNode_new(tlvs_arg_conv, node_id_arg_ref, htlc_maximum_msat_arg);
65259         int64_t ret_ref = 0;
65260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65262         return ret_ref;
65263 }
65264
65265 static inline uint64_t ForwardNode_clone_ptr(LDKForwardNode *NONNULL_PTR arg) {
65266         LDKForwardNode ret_var = ForwardNode_clone(arg);
65267         int64_t ret_ref = 0;
65268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65269         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65270         return ret_ref;
65271 }
65272 int64_t  CS_LDK_ForwardNode_clone_ptr(int64_t arg) {
65273         LDKForwardNode arg_conv;
65274         arg_conv.inner = untag_ptr(arg);
65275         arg_conv.is_owned = ptr_is_owned(arg);
65276         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65277         arg_conv.is_owned = false;
65278         int64_t ret_conv = ForwardNode_clone_ptr(&arg_conv);
65279         return ret_conv;
65280 }
65281
65282 int64_t  CS_LDK_ForwardNode_clone(int64_t orig) {
65283         LDKForwardNode orig_conv;
65284         orig_conv.inner = untag_ptr(orig);
65285         orig_conv.is_owned = ptr_is_owned(orig);
65286         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65287         orig_conv.is_owned = false;
65288         LDKForwardNode ret_var = ForwardNode_clone(&orig_conv);
65289         int64_t ret_ref = 0;
65290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65292         return ret_ref;
65293 }
65294
65295 void  CS_LDK_ForwardTlvs_free(int64_t this_obj) {
65296         LDKForwardTlvs this_obj_conv;
65297         this_obj_conv.inner = untag_ptr(this_obj);
65298         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65300         ForwardTlvs_free(this_obj_conv);
65301 }
65302
65303 int64_t  CS_LDK_ForwardTlvs_get_short_channel_id(int64_t this_ptr) {
65304         LDKForwardTlvs this_ptr_conv;
65305         this_ptr_conv.inner = untag_ptr(this_ptr);
65306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65308         this_ptr_conv.is_owned = false;
65309         int64_t ret_conv = ForwardTlvs_get_short_channel_id(&this_ptr_conv);
65310         return ret_conv;
65311 }
65312
65313 void  CS_LDK_ForwardTlvs_set_short_channel_id(int64_t this_ptr, int64_t val) {
65314         LDKForwardTlvs this_ptr_conv;
65315         this_ptr_conv.inner = untag_ptr(this_ptr);
65316         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65318         this_ptr_conv.is_owned = false;
65319         ForwardTlvs_set_short_channel_id(&this_ptr_conv, val);
65320 }
65321
65322 int64_t  CS_LDK_ForwardTlvs_get_payment_relay(int64_t this_ptr) {
65323         LDKForwardTlvs this_ptr_conv;
65324         this_ptr_conv.inner = untag_ptr(this_ptr);
65325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65327         this_ptr_conv.is_owned = false;
65328         LDKPaymentRelay ret_var = ForwardTlvs_get_payment_relay(&this_ptr_conv);
65329         int64_t ret_ref = 0;
65330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65332         return ret_ref;
65333 }
65334
65335 void  CS_LDK_ForwardTlvs_set_payment_relay(int64_t this_ptr, int64_t val) {
65336         LDKForwardTlvs this_ptr_conv;
65337         this_ptr_conv.inner = untag_ptr(this_ptr);
65338         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65340         this_ptr_conv.is_owned = false;
65341         LDKPaymentRelay val_conv;
65342         val_conv.inner = untag_ptr(val);
65343         val_conv.is_owned = ptr_is_owned(val);
65344         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65345         val_conv = PaymentRelay_clone(&val_conv);
65346         ForwardTlvs_set_payment_relay(&this_ptr_conv, val_conv);
65347 }
65348
65349 int64_t  CS_LDK_ForwardTlvs_get_payment_constraints(int64_t this_ptr) {
65350         LDKForwardTlvs this_ptr_conv;
65351         this_ptr_conv.inner = untag_ptr(this_ptr);
65352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65354         this_ptr_conv.is_owned = false;
65355         LDKPaymentConstraints ret_var = ForwardTlvs_get_payment_constraints(&this_ptr_conv);
65356         int64_t ret_ref = 0;
65357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65359         return ret_ref;
65360 }
65361
65362 void  CS_LDK_ForwardTlvs_set_payment_constraints(int64_t this_ptr, int64_t val) {
65363         LDKForwardTlvs this_ptr_conv;
65364         this_ptr_conv.inner = untag_ptr(this_ptr);
65365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65367         this_ptr_conv.is_owned = false;
65368         LDKPaymentConstraints val_conv;
65369         val_conv.inner = untag_ptr(val);
65370         val_conv.is_owned = ptr_is_owned(val);
65371         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65372         val_conv = PaymentConstraints_clone(&val_conv);
65373         ForwardTlvs_set_payment_constraints(&this_ptr_conv, val_conv);
65374 }
65375
65376 int64_t  CS_LDK_ForwardTlvs_get_features(int64_t this_ptr) {
65377         LDKForwardTlvs this_ptr_conv;
65378         this_ptr_conv.inner = untag_ptr(this_ptr);
65379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65381         this_ptr_conv.is_owned = false;
65382         LDKBlindedHopFeatures ret_var = ForwardTlvs_get_features(&this_ptr_conv);
65383         int64_t ret_ref = 0;
65384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65386         return ret_ref;
65387 }
65388
65389 void  CS_LDK_ForwardTlvs_set_features(int64_t this_ptr, int64_t val) {
65390         LDKForwardTlvs this_ptr_conv;
65391         this_ptr_conv.inner = untag_ptr(this_ptr);
65392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65394         this_ptr_conv.is_owned = false;
65395         LDKBlindedHopFeatures val_conv;
65396         val_conv.inner = untag_ptr(val);
65397         val_conv.is_owned = ptr_is_owned(val);
65398         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65399         val_conv = BlindedHopFeatures_clone(&val_conv);
65400         ForwardTlvs_set_features(&this_ptr_conv, val_conv);
65401 }
65402
65403 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) {
65404         LDKPaymentRelay payment_relay_arg_conv;
65405         payment_relay_arg_conv.inner = untag_ptr(payment_relay_arg);
65406         payment_relay_arg_conv.is_owned = ptr_is_owned(payment_relay_arg);
65407         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_relay_arg_conv);
65408         payment_relay_arg_conv = PaymentRelay_clone(&payment_relay_arg_conv);
65409         LDKPaymentConstraints payment_constraints_arg_conv;
65410         payment_constraints_arg_conv.inner = untag_ptr(payment_constraints_arg);
65411         payment_constraints_arg_conv.is_owned = ptr_is_owned(payment_constraints_arg);
65412         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_constraints_arg_conv);
65413         payment_constraints_arg_conv = PaymentConstraints_clone(&payment_constraints_arg_conv);
65414         LDKBlindedHopFeatures features_arg_conv;
65415         features_arg_conv.inner = untag_ptr(features_arg);
65416         features_arg_conv.is_owned = ptr_is_owned(features_arg);
65417         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
65418         features_arg_conv = BlindedHopFeatures_clone(&features_arg_conv);
65419         LDKForwardTlvs ret_var = ForwardTlvs_new(short_channel_id_arg, payment_relay_arg_conv, payment_constraints_arg_conv, features_arg_conv);
65420         int64_t ret_ref = 0;
65421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65423         return ret_ref;
65424 }
65425
65426 static inline uint64_t ForwardTlvs_clone_ptr(LDKForwardTlvs *NONNULL_PTR arg) {
65427         LDKForwardTlvs ret_var = ForwardTlvs_clone(arg);
65428         int64_t ret_ref = 0;
65429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65431         return ret_ref;
65432 }
65433 int64_t  CS_LDK_ForwardTlvs_clone_ptr(int64_t arg) {
65434         LDKForwardTlvs arg_conv;
65435         arg_conv.inner = untag_ptr(arg);
65436         arg_conv.is_owned = ptr_is_owned(arg);
65437         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65438         arg_conv.is_owned = false;
65439         int64_t ret_conv = ForwardTlvs_clone_ptr(&arg_conv);
65440         return ret_conv;
65441 }
65442
65443 int64_t  CS_LDK_ForwardTlvs_clone(int64_t orig) {
65444         LDKForwardTlvs orig_conv;
65445         orig_conv.inner = untag_ptr(orig);
65446         orig_conv.is_owned = ptr_is_owned(orig);
65447         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65448         orig_conv.is_owned = false;
65449         LDKForwardTlvs ret_var = ForwardTlvs_clone(&orig_conv);
65450         int64_t ret_ref = 0;
65451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65452         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65453         return ret_ref;
65454 }
65455
65456 void  CS_LDK_ReceiveTlvs_free(int64_t this_obj) {
65457         LDKReceiveTlvs this_obj_conv;
65458         this_obj_conv.inner = untag_ptr(this_obj);
65459         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65461         ReceiveTlvs_free(this_obj_conv);
65462 }
65463
65464 int8_tArray  CS_LDK_ReceiveTlvs_get_payment_secret(int64_t this_ptr) {
65465         LDKReceiveTlvs this_ptr_conv;
65466         this_ptr_conv.inner = untag_ptr(this_ptr);
65467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65469         this_ptr_conv.is_owned = false;
65470         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
65471         memcpy(ret_arr->elems, *ReceiveTlvs_get_payment_secret(&this_ptr_conv), 32);
65472         return ret_arr;
65473 }
65474
65475 void  CS_LDK_ReceiveTlvs_set_payment_secret(int64_t this_ptr, int8_tArray val) {
65476         LDKReceiveTlvs this_ptr_conv;
65477         this_ptr_conv.inner = untag_ptr(this_ptr);
65478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65480         this_ptr_conv.is_owned = false;
65481         LDKThirtyTwoBytes val_ref;
65482         CHECK(val->arr_len == 32);
65483         memcpy(val_ref.data, val->elems, 32); FREE(val);
65484         ReceiveTlvs_set_payment_secret(&this_ptr_conv, val_ref);
65485 }
65486
65487 int64_t  CS_LDK_ReceiveTlvs_get_payment_constraints(int64_t this_ptr) {
65488         LDKReceiveTlvs this_ptr_conv;
65489         this_ptr_conv.inner = untag_ptr(this_ptr);
65490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65492         this_ptr_conv.is_owned = false;
65493         LDKPaymentConstraints ret_var = ReceiveTlvs_get_payment_constraints(&this_ptr_conv);
65494         int64_t ret_ref = 0;
65495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65497         return ret_ref;
65498 }
65499
65500 void  CS_LDK_ReceiveTlvs_set_payment_constraints(int64_t this_ptr, int64_t val) {
65501         LDKReceiveTlvs this_ptr_conv;
65502         this_ptr_conv.inner = untag_ptr(this_ptr);
65503         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65505         this_ptr_conv.is_owned = false;
65506         LDKPaymentConstraints val_conv;
65507         val_conv.inner = untag_ptr(val);
65508         val_conv.is_owned = ptr_is_owned(val);
65509         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65510         val_conv = PaymentConstraints_clone(&val_conv);
65511         ReceiveTlvs_set_payment_constraints(&this_ptr_conv, val_conv);
65512 }
65513
65514 int64_t  CS_LDK_ReceiveTlvs_new(int8_tArray payment_secret_arg, int64_t payment_constraints_arg) {
65515         LDKThirtyTwoBytes payment_secret_arg_ref;
65516         CHECK(payment_secret_arg->arr_len == 32);
65517         memcpy(payment_secret_arg_ref.data, payment_secret_arg->elems, 32); FREE(payment_secret_arg);
65518         LDKPaymentConstraints payment_constraints_arg_conv;
65519         payment_constraints_arg_conv.inner = untag_ptr(payment_constraints_arg);
65520         payment_constraints_arg_conv.is_owned = ptr_is_owned(payment_constraints_arg);
65521         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_constraints_arg_conv);
65522         payment_constraints_arg_conv = PaymentConstraints_clone(&payment_constraints_arg_conv);
65523         LDKReceiveTlvs ret_var = ReceiveTlvs_new(payment_secret_arg_ref, payment_constraints_arg_conv);
65524         int64_t ret_ref = 0;
65525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65526         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65527         return ret_ref;
65528 }
65529
65530 static inline uint64_t ReceiveTlvs_clone_ptr(LDKReceiveTlvs *NONNULL_PTR arg) {
65531         LDKReceiveTlvs ret_var = ReceiveTlvs_clone(arg);
65532         int64_t ret_ref = 0;
65533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65535         return ret_ref;
65536 }
65537 int64_t  CS_LDK_ReceiveTlvs_clone_ptr(int64_t arg) {
65538         LDKReceiveTlvs arg_conv;
65539         arg_conv.inner = untag_ptr(arg);
65540         arg_conv.is_owned = ptr_is_owned(arg);
65541         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65542         arg_conv.is_owned = false;
65543         int64_t ret_conv = ReceiveTlvs_clone_ptr(&arg_conv);
65544         return ret_conv;
65545 }
65546
65547 int64_t  CS_LDK_ReceiveTlvs_clone(int64_t orig) {
65548         LDKReceiveTlvs orig_conv;
65549         orig_conv.inner = untag_ptr(orig);
65550         orig_conv.is_owned = ptr_is_owned(orig);
65551         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65552         orig_conv.is_owned = false;
65553         LDKReceiveTlvs ret_var = ReceiveTlvs_clone(&orig_conv);
65554         int64_t ret_ref = 0;
65555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65557         return ret_ref;
65558 }
65559
65560 void  CS_LDK_PaymentRelay_free(int64_t this_obj) {
65561         LDKPaymentRelay this_obj_conv;
65562         this_obj_conv.inner = untag_ptr(this_obj);
65563         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65565         PaymentRelay_free(this_obj_conv);
65566 }
65567
65568 int16_t  CS_LDK_PaymentRelay_get_cltv_expiry_delta(int64_t this_ptr) {
65569         LDKPaymentRelay this_ptr_conv;
65570         this_ptr_conv.inner = untag_ptr(this_ptr);
65571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65573         this_ptr_conv.is_owned = false;
65574         int16_t ret_conv = PaymentRelay_get_cltv_expiry_delta(&this_ptr_conv);
65575         return ret_conv;
65576 }
65577
65578 void  CS_LDK_PaymentRelay_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
65579         LDKPaymentRelay this_ptr_conv;
65580         this_ptr_conv.inner = untag_ptr(this_ptr);
65581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65583         this_ptr_conv.is_owned = false;
65584         PaymentRelay_set_cltv_expiry_delta(&this_ptr_conv, val);
65585 }
65586
65587 int32_t  CS_LDK_PaymentRelay_get_fee_proportional_millionths(int64_t this_ptr) {
65588         LDKPaymentRelay this_ptr_conv;
65589         this_ptr_conv.inner = untag_ptr(this_ptr);
65590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65592         this_ptr_conv.is_owned = false;
65593         int32_t ret_conv = PaymentRelay_get_fee_proportional_millionths(&this_ptr_conv);
65594         return ret_conv;
65595 }
65596
65597 void  CS_LDK_PaymentRelay_set_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
65598         LDKPaymentRelay this_ptr_conv;
65599         this_ptr_conv.inner = untag_ptr(this_ptr);
65600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65602         this_ptr_conv.is_owned = false;
65603         PaymentRelay_set_fee_proportional_millionths(&this_ptr_conv, val);
65604 }
65605
65606 int32_t  CS_LDK_PaymentRelay_get_fee_base_msat(int64_t this_ptr) {
65607         LDKPaymentRelay this_ptr_conv;
65608         this_ptr_conv.inner = untag_ptr(this_ptr);
65609         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65611         this_ptr_conv.is_owned = false;
65612         int32_t ret_conv = PaymentRelay_get_fee_base_msat(&this_ptr_conv);
65613         return ret_conv;
65614 }
65615
65616 void  CS_LDK_PaymentRelay_set_fee_base_msat(int64_t this_ptr, int32_t val) {
65617         LDKPaymentRelay this_ptr_conv;
65618         this_ptr_conv.inner = untag_ptr(this_ptr);
65619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65621         this_ptr_conv.is_owned = false;
65622         PaymentRelay_set_fee_base_msat(&this_ptr_conv, val);
65623 }
65624
65625 int64_t  CS_LDK_PaymentRelay_new(int16_t cltv_expiry_delta_arg, int32_t fee_proportional_millionths_arg, int32_t fee_base_msat_arg) {
65626         LDKPaymentRelay ret_var = PaymentRelay_new(cltv_expiry_delta_arg, fee_proportional_millionths_arg, fee_base_msat_arg);
65627         int64_t ret_ref = 0;
65628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65629         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65630         return ret_ref;
65631 }
65632
65633 static inline uint64_t PaymentRelay_clone_ptr(LDKPaymentRelay *NONNULL_PTR arg) {
65634         LDKPaymentRelay ret_var = PaymentRelay_clone(arg);
65635         int64_t ret_ref = 0;
65636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65638         return ret_ref;
65639 }
65640 int64_t  CS_LDK_PaymentRelay_clone_ptr(int64_t arg) {
65641         LDKPaymentRelay arg_conv;
65642         arg_conv.inner = untag_ptr(arg);
65643         arg_conv.is_owned = ptr_is_owned(arg);
65644         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65645         arg_conv.is_owned = false;
65646         int64_t ret_conv = PaymentRelay_clone_ptr(&arg_conv);
65647         return ret_conv;
65648 }
65649
65650 int64_t  CS_LDK_PaymentRelay_clone(int64_t orig) {
65651         LDKPaymentRelay orig_conv;
65652         orig_conv.inner = untag_ptr(orig);
65653         orig_conv.is_owned = ptr_is_owned(orig);
65654         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65655         orig_conv.is_owned = false;
65656         LDKPaymentRelay ret_var = PaymentRelay_clone(&orig_conv);
65657         int64_t ret_ref = 0;
65658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65659         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65660         return ret_ref;
65661 }
65662
65663 void  CS_LDK_PaymentConstraints_free(int64_t this_obj) {
65664         LDKPaymentConstraints this_obj_conv;
65665         this_obj_conv.inner = untag_ptr(this_obj);
65666         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65668         PaymentConstraints_free(this_obj_conv);
65669 }
65670
65671 int32_t  CS_LDK_PaymentConstraints_get_max_cltv_expiry(int64_t this_ptr) {
65672         LDKPaymentConstraints this_ptr_conv;
65673         this_ptr_conv.inner = untag_ptr(this_ptr);
65674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65676         this_ptr_conv.is_owned = false;
65677         int32_t ret_conv = PaymentConstraints_get_max_cltv_expiry(&this_ptr_conv);
65678         return ret_conv;
65679 }
65680
65681 void  CS_LDK_PaymentConstraints_set_max_cltv_expiry(int64_t this_ptr, int32_t val) {
65682         LDKPaymentConstraints this_ptr_conv;
65683         this_ptr_conv.inner = untag_ptr(this_ptr);
65684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65686         this_ptr_conv.is_owned = false;
65687         PaymentConstraints_set_max_cltv_expiry(&this_ptr_conv, val);
65688 }
65689
65690 int64_t  CS_LDK_PaymentConstraints_get_htlc_minimum_msat(int64_t this_ptr) {
65691         LDKPaymentConstraints this_ptr_conv;
65692         this_ptr_conv.inner = untag_ptr(this_ptr);
65693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65695         this_ptr_conv.is_owned = false;
65696         int64_t ret_conv = PaymentConstraints_get_htlc_minimum_msat(&this_ptr_conv);
65697         return ret_conv;
65698 }
65699
65700 void  CS_LDK_PaymentConstraints_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
65701         LDKPaymentConstraints this_ptr_conv;
65702         this_ptr_conv.inner = untag_ptr(this_ptr);
65703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65705         this_ptr_conv.is_owned = false;
65706         PaymentConstraints_set_htlc_minimum_msat(&this_ptr_conv, val);
65707 }
65708
65709 int64_t  CS_LDK_PaymentConstraints_new(int32_t max_cltv_expiry_arg, int64_t htlc_minimum_msat_arg) {
65710         LDKPaymentConstraints ret_var = PaymentConstraints_new(max_cltv_expiry_arg, htlc_minimum_msat_arg);
65711         int64_t ret_ref = 0;
65712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65714         return ret_ref;
65715 }
65716
65717 static inline uint64_t PaymentConstraints_clone_ptr(LDKPaymentConstraints *NONNULL_PTR arg) {
65718         LDKPaymentConstraints ret_var = PaymentConstraints_clone(arg);
65719         int64_t ret_ref = 0;
65720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65722         return ret_ref;
65723 }
65724 int64_t  CS_LDK_PaymentConstraints_clone_ptr(int64_t arg) {
65725         LDKPaymentConstraints arg_conv;
65726         arg_conv.inner = untag_ptr(arg);
65727         arg_conv.is_owned = ptr_is_owned(arg);
65728         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65729         arg_conv.is_owned = false;
65730         int64_t ret_conv = PaymentConstraints_clone_ptr(&arg_conv);
65731         return ret_conv;
65732 }
65733
65734 int64_t  CS_LDK_PaymentConstraints_clone(int64_t orig) {
65735         LDKPaymentConstraints orig_conv;
65736         orig_conv.inner = untag_ptr(orig);
65737         orig_conv.is_owned = ptr_is_owned(orig);
65738         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65739         orig_conv.is_owned = false;
65740         LDKPaymentConstraints ret_var = PaymentConstraints_clone(&orig_conv);
65741         int64_t ret_ref = 0;
65742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65744         return ret_ref;
65745 }
65746
65747 int8_tArray  CS_LDK_ForwardTlvs_write(int64_t obj) {
65748         LDKForwardTlvs obj_conv;
65749         obj_conv.inner = untag_ptr(obj);
65750         obj_conv.is_owned = ptr_is_owned(obj);
65751         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65752         obj_conv.is_owned = false;
65753         LDKCVec_u8Z ret_var = ForwardTlvs_write(&obj_conv);
65754         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65755         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65756         CVec_u8Z_free(ret_var);
65757         return ret_arr;
65758 }
65759
65760 int8_tArray  CS_LDK_ReceiveTlvs_write(int64_t obj) {
65761         LDKReceiveTlvs obj_conv;
65762         obj_conv.inner = untag_ptr(obj);
65763         obj_conv.is_owned = ptr_is_owned(obj);
65764         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65765         obj_conv.is_owned = false;
65766         LDKCVec_u8Z ret_var = ReceiveTlvs_write(&obj_conv);
65767         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65768         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65769         CVec_u8Z_free(ret_var);
65770         return ret_arr;
65771 }
65772
65773 int64_t  CS_LDK_ReceiveTlvs_read(int8_tArray ser) {
65774         LDKu8slice ser_ref;
65775         ser_ref.datalen = ser->arr_len;
65776         ser_ref.data = ser->elems;
65777         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
65778         *ret_conv = ReceiveTlvs_read(ser_ref);
65779         FREE(ser);
65780         return tag_ptr(ret_conv, true);
65781 }
65782
65783 int8_tArray  CS_LDK_PaymentRelay_write(int64_t obj) {
65784         LDKPaymentRelay obj_conv;
65785         obj_conv.inner = untag_ptr(obj);
65786         obj_conv.is_owned = ptr_is_owned(obj);
65787         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65788         obj_conv.is_owned = false;
65789         LDKCVec_u8Z ret_var = PaymentRelay_write(&obj_conv);
65790         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65791         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65792         CVec_u8Z_free(ret_var);
65793         return ret_arr;
65794 }
65795
65796 int64_t  CS_LDK_PaymentRelay_read(int8_tArray ser) {
65797         LDKu8slice ser_ref;
65798         ser_ref.datalen = ser->arr_len;
65799         ser_ref.data = ser->elems;
65800         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
65801         *ret_conv = PaymentRelay_read(ser_ref);
65802         FREE(ser);
65803         return tag_ptr(ret_conv, true);
65804 }
65805
65806 int8_tArray  CS_LDK_PaymentConstraints_write(int64_t obj) {
65807         LDKPaymentConstraints obj_conv;
65808         obj_conv.inner = untag_ptr(obj);
65809         obj_conv.is_owned = ptr_is_owned(obj);
65810         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65811         obj_conv.is_owned = false;
65812         LDKCVec_u8Z ret_var = PaymentConstraints_write(&obj_conv);
65813         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65814         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65815         CVec_u8Z_free(ret_var);
65816         return ret_arr;
65817 }
65818
65819 int64_t  CS_LDK_PaymentConstraints_read(int8_tArray ser) {
65820         LDKu8slice ser_ref;
65821         ser_ref.datalen = ser->arr_len;
65822         ser_ref.data = ser->elems;
65823         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
65824         *ret_conv = PaymentConstraints_read(ser_ref);
65825         FREE(ser);
65826         return tag_ptr(ret_conv, true);
65827 }
65828
65829 void  CS_LDK_PaymentPurpose_free(int64_t this_ptr) {
65830         if (!ptr_is_owned(this_ptr)) return;
65831         void* this_ptr_ptr = untag_ptr(this_ptr);
65832         CHECK_ACCESS(this_ptr_ptr);
65833         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
65834         FREE(untag_ptr(this_ptr));
65835         PaymentPurpose_free(this_ptr_conv);
65836 }
65837
65838 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
65839         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
65840         *ret_copy = PaymentPurpose_clone(arg);
65841         int64_t ret_ref = tag_ptr(ret_copy, true);
65842         return ret_ref;
65843 }
65844 int64_t  CS_LDK_PaymentPurpose_clone_ptr(int64_t arg) {
65845         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
65846         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
65847         return ret_conv;
65848 }
65849
65850 int64_t  CS_LDK_PaymentPurpose_clone(int64_t orig) {
65851         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
65852         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
65853         *ret_copy = PaymentPurpose_clone(orig_conv);
65854         int64_t ret_ref = tag_ptr(ret_copy, true);
65855         return ret_ref;
65856 }
65857
65858 int64_t  CS_LDK_PaymentPurpose_invoice_payment(int64_t payment_preimage, int8_tArray payment_secret) {
65859         void* payment_preimage_ptr = untag_ptr(payment_preimage);
65860         CHECK_ACCESS(payment_preimage_ptr);
65861         LDKCOption_ThirtyTwoBytesZ payment_preimage_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_preimage_ptr);
65862         payment_preimage_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_preimage));
65863         LDKThirtyTwoBytes payment_secret_ref;
65864         CHECK(payment_secret->arr_len == 32);
65865         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
65866         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
65867         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_conv, payment_secret_ref);
65868         int64_t ret_ref = tag_ptr(ret_copy, true);
65869         return ret_ref;
65870 }
65871
65872 int64_t  CS_LDK_PaymentPurpose_spontaneous_payment(int8_tArray a) {
65873         LDKThirtyTwoBytes a_ref;
65874         CHECK(a->arr_len == 32);
65875         memcpy(a_ref.data, a->elems, 32); FREE(a);
65876         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
65877         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
65878         int64_t ret_ref = tag_ptr(ret_copy, true);
65879         return ret_ref;
65880 }
65881
65882 jboolean  CS_LDK_PaymentPurpose_eq(int64_t a, int64_t b) {
65883         LDKPaymentPurpose* a_conv = (LDKPaymentPurpose*)untag_ptr(a);
65884         LDKPaymentPurpose* b_conv = (LDKPaymentPurpose*)untag_ptr(b);
65885         jboolean ret_conv = PaymentPurpose_eq(a_conv, b_conv);
65886         return ret_conv;
65887 }
65888
65889 int8_tArray  CS_LDK_PaymentPurpose_write(int64_t obj) {
65890         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
65891         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
65892         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65893         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65894         CVec_u8Z_free(ret_var);
65895         return ret_arr;
65896 }
65897
65898 int64_t  CS_LDK_PaymentPurpose_read(int8_tArray ser) {
65899         LDKu8slice ser_ref;
65900         ser_ref.datalen = ser->arr_len;
65901         ser_ref.data = ser->elems;
65902         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
65903         *ret_conv = PaymentPurpose_read(ser_ref);
65904         FREE(ser);
65905         return tag_ptr(ret_conv, true);
65906 }
65907
65908 void  CS_LDK_ClaimedHTLC_free(int64_t this_obj) {
65909         LDKClaimedHTLC this_obj_conv;
65910         this_obj_conv.inner = untag_ptr(this_obj);
65911         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65913         ClaimedHTLC_free(this_obj_conv);
65914 }
65915
65916 int8_tArray  CS_LDK_ClaimedHTLC_get_channel_id(int64_t this_ptr) {
65917         LDKClaimedHTLC this_ptr_conv;
65918         this_ptr_conv.inner = untag_ptr(this_ptr);
65919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65921         this_ptr_conv.is_owned = false;
65922         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
65923         memcpy(ret_arr->elems, *ClaimedHTLC_get_channel_id(&this_ptr_conv), 32);
65924         return ret_arr;
65925 }
65926
65927 void  CS_LDK_ClaimedHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
65928         LDKClaimedHTLC this_ptr_conv;
65929         this_ptr_conv.inner = untag_ptr(this_ptr);
65930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65932         this_ptr_conv.is_owned = false;
65933         LDKThirtyTwoBytes val_ref;
65934         CHECK(val->arr_len == 32);
65935         memcpy(val_ref.data, val->elems, 32); FREE(val);
65936         ClaimedHTLC_set_channel_id(&this_ptr_conv, val_ref);
65937 }
65938
65939 int8_tArray  CS_LDK_ClaimedHTLC_get_user_channel_id(int64_t this_ptr) {
65940         LDKClaimedHTLC this_ptr_conv;
65941         this_ptr_conv.inner = untag_ptr(this_ptr);
65942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65944         this_ptr_conv.is_owned = false;
65945         int8_tArray ret_arr = init_int8_tArray(16, __LINE__);
65946         memcpy(ret_arr->elems, ClaimedHTLC_get_user_channel_id(&this_ptr_conv).le_bytes, 16);
65947         return ret_arr;
65948 }
65949
65950 void  CS_LDK_ClaimedHTLC_set_user_channel_id(int64_t this_ptr, int8_tArray val) {
65951         LDKClaimedHTLC this_ptr_conv;
65952         this_ptr_conv.inner = untag_ptr(this_ptr);
65953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65955         this_ptr_conv.is_owned = false;
65956         LDKU128 val_ref;
65957         CHECK(val->arr_len == 16);
65958         memcpy(val_ref.le_bytes, val->elems, 16); FREE(val);
65959         ClaimedHTLC_set_user_channel_id(&this_ptr_conv, val_ref);
65960 }
65961
65962 int32_t  CS_LDK_ClaimedHTLC_get_cltv_expiry(int64_t this_ptr) {
65963         LDKClaimedHTLC this_ptr_conv;
65964         this_ptr_conv.inner = untag_ptr(this_ptr);
65965         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65967         this_ptr_conv.is_owned = false;
65968         int32_t ret_conv = ClaimedHTLC_get_cltv_expiry(&this_ptr_conv);
65969         return ret_conv;
65970 }
65971
65972 void  CS_LDK_ClaimedHTLC_set_cltv_expiry(int64_t this_ptr, int32_t val) {
65973         LDKClaimedHTLC this_ptr_conv;
65974         this_ptr_conv.inner = untag_ptr(this_ptr);
65975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65977         this_ptr_conv.is_owned = false;
65978         ClaimedHTLC_set_cltv_expiry(&this_ptr_conv, val);
65979 }
65980
65981 int64_t  CS_LDK_ClaimedHTLC_get_value_msat(int64_t this_ptr) {
65982         LDKClaimedHTLC this_ptr_conv;
65983         this_ptr_conv.inner = untag_ptr(this_ptr);
65984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65986         this_ptr_conv.is_owned = false;
65987         int64_t ret_conv = ClaimedHTLC_get_value_msat(&this_ptr_conv);
65988         return ret_conv;
65989 }
65990
65991 void  CS_LDK_ClaimedHTLC_set_value_msat(int64_t this_ptr, int64_t val) {
65992         LDKClaimedHTLC this_ptr_conv;
65993         this_ptr_conv.inner = untag_ptr(this_ptr);
65994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65996         this_ptr_conv.is_owned = false;
65997         ClaimedHTLC_set_value_msat(&this_ptr_conv, val);
65998 }
65999
66000 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) {
66001         LDKThirtyTwoBytes channel_id_arg_ref;
66002         CHECK(channel_id_arg->arr_len == 32);
66003         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
66004         LDKU128 user_channel_id_arg_ref;
66005         CHECK(user_channel_id_arg->arr_len == 16);
66006         memcpy(user_channel_id_arg_ref.le_bytes, user_channel_id_arg->elems, 16); FREE(user_channel_id_arg);
66007         LDKClaimedHTLC ret_var = ClaimedHTLC_new(channel_id_arg_ref, user_channel_id_arg_ref, cltv_expiry_arg, value_msat_arg);
66008         int64_t ret_ref = 0;
66009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
66010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
66011         return ret_ref;
66012 }
66013
66014 static inline uint64_t ClaimedHTLC_clone_ptr(LDKClaimedHTLC *NONNULL_PTR arg) {
66015         LDKClaimedHTLC ret_var = ClaimedHTLC_clone(arg);
66016         int64_t ret_ref = 0;
66017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
66018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
66019         return ret_ref;
66020 }
66021 int64_t  CS_LDK_ClaimedHTLC_clone_ptr(int64_t arg) {
66022         LDKClaimedHTLC arg_conv;
66023         arg_conv.inner = untag_ptr(arg);
66024         arg_conv.is_owned = ptr_is_owned(arg);
66025         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
66026         arg_conv.is_owned = false;
66027         int64_t ret_conv = ClaimedHTLC_clone_ptr(&arg_conv);
66028         return ret_conv;
66029 }
66030
66031 int64_t  CS_LDK_ClaimedHTLC_clone(int64_t orig) {
66032         LDKClaimedHTLC orig_conv;
66033         orig_conv.inner = untag_ptr(orig);
66034         orig_conv.is_owned = ptr_is_owned(orig);
66035         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
66036         orig_conv.is_owned = false;
66037         LDKClaimedHTLC ret_var = ClaimedHTLC_clone(&orig_conv);
66038         int64_t ret_ref = 0;
66039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
66040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
66041         return ret_ref;
66042 }
66043
66044 jboolean  CS_LDK_ClaimedHTLC_eq(int64_t a, int64_t b) {
66045         LDKClaimedHTLC a_conv;
66046         a_conv.inner = untag_ptr(a);
66047         a_conv.is_owned = ptr_is_owned(a);
66048         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
66049         a_conv.is_owned = false;
66050         LDKClaimedHTLC b_conv;
66051         b_conv.inner = untag_ptr(b);
66052         b_conv.is_owned = ptr_is_owned(b);
66053         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
66054         b_conv.is_owned = false;
66055         jboolean ret_conv = ClaimedHTLC_eq(&a_conv, &b_conv);
66056         return ret_conv;
66057 }
66058
66059 int8_tArray  CS_LDK_ClaimedHTLC_write(int64_t obj) {
66060         LDKClaimedHTLC obj_conv;
66061         obj_conv.inner = untag_ptr(obj);
66062         obj_conv.is_owned = ptr_is_owned(obj);
66063         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
66064         obj_conv.is_owned = false;
66065         LDKCVec_u8Z ret_var = ClaimedHTLC_write(&obj_conv);
66066         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66067         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66068         CVec_u8Z_free(ret_var);
66069         return ret_arr;
66070 }
66071
66072 int64_t  CS_LDK_ClaimedHTLC_read(int8_tArray ser) {
66073         LDKu8slice ser_ref;
66074         ser_ref.datalen = ser->arr_len;
66075         ser_ref.data = ser->elems;
66076         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
66077         *ret_conv = ClaimedHTLC_read(ser_ref);
66078         FREE(ser);
66079         return tag_ptr(ret_conv, true);
66080 }
66081
66082 void  CS_LDK_PathFailure_free(int64_t this_ptr) {
66083         if (!ptr_is_owned(this_ptr)) return;
66084         void* this_ptr_ptr = untag_ptr(this_ptr);
66085         CHECK_ACCESS(this_ptr_ptr);
66086         LDKPathFailure this_ptr_conv = *(LDKPathFailure*)(this_ptr_ptr);
66087         FREE(untag_ptr(this_ptr));
66088         PathFailure_free(this_ptr_conv);
66089 }
66090
66091 static inline uint64_t PathFailure_clone_ptr(LDKPathFailure *NONNULL_PTR arg) {
66092         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
66093         *ret_copy = PathFailure_clone(arg);
66094         int64_t ret_ref = tag_ptr(ret_copy, true);
66095         return ret_ref;
66096 }
66097 int64_t  CS_LDK_PathFailure_clone_ptr(int64_t arg) {
66098         LDKPathFailure* arg_conv = (LDKPathFailure*)untag_ptr(arg);
66099         int64_t ret_conv = PathFailure_clone_ptr(arg_conv);
66100         return ret_conv;
66101 }
66102
66103 int64_t  CS_LDK_PathFailure_clone(int64_t orig) {
66104         LDKPathFailure* orig_conv = (LDKPathFailure*)untag_ptr(orig);
66105         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
66106         *ret_copy = PathFailure_clone(orig_conv);
66107         int64_t ret_ref = tag_ptr(ret_copy, true);
66108         return ret_ref;
66109 }
66110
66111 int64_t  CS_LDK_PathFailure_initial_send(int64_t err) {
66112         void* err_ptr = untag_ptr(err);
66113         CHECK_ACCESS(err_ptr);
66114         LDKAPIError err_conv = *(LDKAPIError*)(err_ptr);
66115         err_conv = APIError_clone((LDKAPIError*)untag_ptr(err));
66116         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
66117         *ret_copy = PathFailure_initial_send(err_conv);
66118         int64_t ret_ref = tag_ptr(ret_copy, true);
66119         return ret_ref;
66120 }
66121
66122 int64_t  CS_LDK_PathFailure_on_path(int64_t network_update) {
66123         void* network_update_ptr = untag_ptr(network_update);
66124         CHECK_ACCESS(network_update_ptr);
66125         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
66126         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
66127         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
66128         *ret_copy = PathFailure_on_path(network_update_conv);
66129         int64_t ret_ref = tag_ptr(ret_copy, true);
66130         return ret_ref;
66131 }
66132
66133 jboolean  CS_LDK_PathFailure_eq(int64_t a, int64_t b) {
66134         LDKPathFailure* a_conv = (LDKPathFailure*)untag_ptr(a);
66135         LDKPathFailure* b_conv = (LDKPathFailure*)untag_ptr(b);
66136         jboolean ret_conv = PathFailure_eq(a_conv, b_conv);
66137         return ret_conv;
66138 }
66139
66140 int8_tArray  CS_LDK_PathFailure_write(int64_t obj) {
66141         LDKPathFailure* obj_conv = (LDKPathFailure*)untag_ptr(obj);
66142         LDKCVec_u8Z ret_var = PathFailure_write(obj_conv);
66143         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66144         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66145         CVec_u8Z_free(ret_var);
66146         return ret_arr;
66147 }
66148
66149 int64_t  CS_LDK_PathFailure_read(int8_tArray ser) {
66150         LDKu8slice ser_ref;
66151         ser_ref.datalen = ser->arr_len;
66152         ser_ref.data = ser->elems;
66153         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
66154         *ret_conv = PathFailure_read(ser_ref);
66155         FREE(ser);
66156         return tag_ptr(ret_conv, true);
66157 }
66158
66159 void  CS_LDK_ClosureReason_free(int64_t this_ptr) {
66160         if (!ptr_is_owned(this_ptr)) return;
66161         void* this_ptr_ptr = untag_ptr(this_ptr);
66162         CHECK_ACCESS(this_ptr_ptr);
66163         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
66164         FREE(untag_ptr(this_ptr));
66165         ClosureReason_free(this_ptr_conv);
66166 }
66167
66168 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
66169         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66170         *ret_copy = ClosureReason_clone(arg);
66171         int64_t ret_ref = tag_ptr(ret_copy, true);
66172         return ret_ref;
66173 }
66174 int64_t  CS_LDK_ClosureReason_clone_ptr(int64_t arg) {
66175         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
66176         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
66177         return ret_conv;
66178 }
66179
66180 int64_t  CS_LDK_ClosureReason_clone(int64_t orig) {
66181         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
66182         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66183         *ret_copy = ClosureReason_clone(orig_conv);
66184         int64_t ret_ref = tag_ptr(ret_copy, true);
66185         return ret_ref;
66186 }
66187
66188 int64_t  CS_LDK_ClosureReason_counterparty_force_closed(int64_t peer_msg) {
66189         LDKUntrustedString peer_msg_conv;
66190         peer_msg_conv.inner = untag_ptr(peer_msg);
66191         peer_msg_conv.is_owned = ptr_is_owned(peer_msg);
66192         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_conv);
66193         peer_msg_conv = UntrustedString_clone(&peer_msg_conv);
66194         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66195         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
66196         int64_t ret_ref = tag_ptr(ret_copy, true);
66197         return ret_ref;
66198 }
66199
66200 int64_t  CS_LDK_ClosureReason_holder_force_closed() {
66201         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66202         *ret_copy = ClosureReason_holder_force_closed();
66203         int64_t ret_ref = tag_ptr(ret_copy, true);
66204         return ret_ref;
66205 }
66206
66207 int64_t  CS_LDK_ClosureReason_cooperative_closure() {
66208         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66209         *ret_copy = ClosureReason_cooperative_closure();
66210         int64_t ret_ref = tag_ptr(ret_copy, true);
66211         return ret_ref;
66212 }
66213
66214 int64_t  CS_LDK_ClosureReason_commitment_tx_confirmed() {
66215         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66216         *ret_copy = ClosureReason_commitment_tx_confirmed();
66217         int64_t ret_ref = tag_ptr(ret_copy, true);
66218         return ret_ref;
66219 }
66220
66221 int64_t  CS_LDK_ClosureReason_funding_timed_out() {
66222         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66223         *ret_copy = ClosureReason_funding_timed_out();
66224         int64_t ret_ref = tag_ptr(ret_copy, true);
66225         return ret_ref;
66226 }
66227
66228 int64_t  CS_LDK_ClosureReason_processing_error(jstring err) {
66229         LDKStr err_conv = str_ref_to_owned_c(err);
66230         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66231         *ret_copy = ClosureReason_processing_error(err_conv);
66232         int64_t ret_ref = tag_ptr(ret_copy, true);
66233         return ret_ref;
66234 }
66235
66236 int64_t  CS_LDK_ClosureReason_disconnected_peer() {
66237         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66238         *ret_copy = ClosureReason_disconnected_peer();
66239         int64_t ret_ref = tag_ptr(ret_copy, true);
66240         return ret_ref;
66241 }
66242
66243 int64_t  CS_LDK_ClosureReason_outdated_channel_manager() {
66244         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66245         *ret_copy = ClosureReason_outdated_channel_manager();
66246         int64_t ret_ref = tag_ptr(ret_copy, true);
66247         return ret_ref;
66248 }
66249
66250 int64_t  CS_LDK_ClosureReason_counterparty_coop_closed_unfunded_channel() {
66251         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66252         *ret_copy = ClosureReason_counterparty_coop_closed_unfunded_channel();
66253         int64_t ret_ref = tag_ptr(ret_copy, true);
66254         return ret_ref;
66255 }
66256
66257 int64_t  CS_LDK_ClosureReason_funding_batch_closure() {
66258         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66259         *ret_copy = ClosureReason_funding_batch_closure();
66260         int64_t ret_ref = tag_ptr(ret_copy, true);
66261         return ret_ref;
66262 }
66263
66264 jboolean  CS_LDK_ClosureReason_eq(int64_t a, int64_t b) {
66265         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
66266         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
66267         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
66268         return ret_conv;
66269 }
66270
66271 int8_tArray  CS_LDK_ClosureReason_write(int64_t obj) {
66272         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
66273         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
66274         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66275         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66276         CVec_u8Z_free(ret_var);
66277         return ret_arr;
66278 }
66279
66280 int64_t  CS_LDK_ClosureReason_read(int8_tArray ser) {
66281         LDKu8slice ser_ref;
66282         ser_ref.datalen = ser->arr_len;
66283         ser_ref.data = ser->elems;
66284         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
66285         *ret_conv = ClosureReason_read(ser_ref);
66286         FREE(ser);
66287         return tag_ptr(ret_conv, true);
66288 }
66289
66290 void  CS_LDK_HTLCDestination_free(int64_t this_ptr) {
66291         if (!ptr_is_owned(this_ptr)) return;
66292         void* this_ptr_ptr = untag_ptr(this_ptr);
66293         CHECK_ACCESS(this_ptr_ptr);
66294         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
66295         FREE(untag_ptr(this_ptr));
66296         HTLCDestination_free(this_ptr_conv);
66297 }
66298
66299 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
66300         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66301         *ret_copy = HTLCDestination_clone(arg);
66302         int64_t ret_ref = tag_ptr(ret_copy, true);
66303         return ret_ref;
66304 }
66305 int64_t  CS_LDK_HTLCDestination_clone_ptr(int64_t arg) {
66306         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
66307         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
66308         return ret_conv;
66309 }
66310
66311 int64_t  CS_LDK_HTLCDestination_clone(int64_t orig) {
66312         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
66313         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66314         *ret_copy = HTLCDestination_clone(orig_conv);
66315         int64_t ret_ref = tag_ptr(ret_copy, true);
66316         return ret_ref;
66317 }
66318
66319 int64_t  CS_LDK_HTLCDestination_next_hop_channel(int8_tArray node_id, int8_tArray channel_id) {
66320         LDKPublicKey node_id_ref;
66321         CHECK(node_id->arr_len == 33);
66322         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66323         LDKThirtyTwoBytes channel_id_ref;
66324         CHECK(channel_id->arr_len == 32);
66325         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66326         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66327         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
66328         int64_t ret_ref = tag_ptr(ret_copy, true);
66329         return ret_ref;
66330 }
66331
66332 int64_t  CS_LDK_HTLCDestination_unknown_next_hop(int64_t requested_forward_scid) {
66333         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66334         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
66335         int64_t ret_ref = tag_ptr(ret_copy, true);
66336         return ret_ref;
66337 }
66338
66339 int64_t  CS_LDK_HTLCDestination_invalid_forward(int64_t requested_forward_scid) {
66340         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66341         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
66342         int64_t ret_ref = tag_ptr(ret_copy, true);
66343         return ret_ref;
66344 }
66345
66346 int64_t  CS_LDK_HTLCDestination_failed_payment(int8_tArray payment_hash) {
66347         LDKThirtyTwoBytes payment_hash_ref;
66348         CHECK(payment_hash->arr_len == 32);
66349         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66350         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66351         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
66352         int64_t ret_ref = tag_ptr(ret_copy, true);
66353         return ret_ref;
66354 }
66355
66356 jboolean  CS_LDK_HTLCDestination_eq(int64_t a, int64_t b) {
66357         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
66358         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
66359         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
66360         return ret_conv;
66361 }
66362
66363 int8_tArray  CS_LDK_HTLCDestination_write(int64_t obj) {
66364         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
66365         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
66366         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66367         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66368         CVec_u8Z_free(ret_var);
66369         return ret_arr;
66370 }
66371
66372 int64_t  CS_LDK_HTLCDestination_read(int8_tArray ser) {
66373         LDKu8slice ser_ref;
66374         ser_ref.datalen = ser->arr_len;
66375         ser_ref.data = ser->elems;
66376         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
66377         *ret_conv = HTLCDestination_read(ser_ref);
66378         FREE(ser);
66379         return tag_ptr(ret_conv, true);
66380 }
66381
66382 int32_t  CS_LDK_PaymentFailureReason_clone(int64_t orig) {
66383         LDKPaymentFailureReason* orig_conv = (LDKPaymentFailureReason*)untag_ptr(orig);
66384         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_clone(orig_conv));
66385         return ret_conv;
66386 }
66387
66388 int32_t  CS_LDK_PaymentFailureReason_recipient_rejected() {
66389         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_recipient_rejected());
66390         return ret_conv;
66391 }
66392
66393 int32_t  CS_LDK_PaymentFailureReason_user_abandoned() {
66394         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_user_abandoned());
66395         return ret_conv;
66396 }
66397
66398 int32_t  CS_LDK_PaymentFailureReason_retries_exhausted() {
66399         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_retries_exhausted());
66400         return ret_conv;
66401 }
66402
66403 int32_t  CS_LDK_PaymentFailureReason_payment_expired() {
66404         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_payment_expired());
66405         return ret_conv;
66406 }
66407
66408 int32_t  CS_LDK_PaymentFailureReason_route_not_found() {
66409         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_route_not_found());
66410         return ret_conv;
66411 }
66412
66413 int32_t  CS_LDK_PaymentFailureReason_unexpected_error() {
66414         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_unexpected_error());
66415         return ret_conv;
66416 }
66417
66418 jboolean  CS_LDK_PaymentFailureReason_eq(int64_t a, int64_t b) {
66419         LDKPaymentFailureReason* a_conv = (LDKPaymentFailureReason*)untag_ptr(a);
66420         LDKPaymentFailureReason* b_conv = (LDKPaymentFailureReason*)untag_ptr(b);
66421         jboolean ret_conv = PaymentFailureReason_eq(a_conv, b_conv);
66422         return ret_conv;
66423 }
66424
66425 int8_tArray  CS_LDK_PaymentFailureReason_write(int64_t obj) {
66426         LDKPaymentFailureReason* obj_conv = (LDKPaymentFailureReason*)untag_ptr(obj);
66427         LDKCVec_u8Z ret_var = PaymentFailureReason_write(obj_conv);
66428         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66429         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66430         CVec_u8Z_free(ret_var);
66431         return ret_arr;
66432 }
66433
66434 int64_t  CS_LDK_PaymentFailureReason_read(int8_tArray ser) {
66435         LDKu8slice ser_ref;
66436         ser_ref.datalen = ser->arr_len;
66437         ser_ref.data = ser->elems;
66438         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
66439         *ret_conv = PaymentFailureReason_read(ser_ref);
66440         FREE(ser);
66441         return tag_ptr(ret_conv, true);
66442 }
66443
66444 void  CS_LDK_Event_free(int64_t this_ptr) {
66445         if (!ptr_is_owned(this_ptr)) return;
66446         void* this_ptr_ptr = untag_ptr(this_ptr);
66447         CHECK_ACCESS(this_ptr_ptr);
66448         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
66449         FREE(untag_ptr(this_ptr));
66450         Event_free(this_ptr_conv);
66451 }
66452
66453 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
66454         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66455         *ret_copy = Event_clone(arg);
66456         int64_t ret_ref = tag_ptr(ret_copy, true);
66457         return ret_ref;
66458 }
66459 int64_t  CS_LDK_Event_clone_ptr(int64_t arg) {
66460         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
66461         int64_t ret_conv = Event_clone_ptr(arg_conv);
66462         return ret_conv;
66463 }
66464
66465 int64_t  CS_LDK_Event_clone(int64_t orig) {
66466         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
66467         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66468         *ret_copy = Event_clone(orig_conv);
66469         int64_t ret_ref = tag_ptr(ret_copy, true);
66470         return ret_ref;
66471 }
66472
66473 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) {
66474         LDKThirtyTwoBytes temporary_channel_id_ref;
66475         CHECK(temporary_channel_id->arr_len == 32);
66476         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
66477         LDKPublicKey counterparty_node_id_ref;
66478         CHECK(counterparty_node_id->arr_len == 33);
66479         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66480         LDKCVec_u8Z output_script_ref;
66481         output_script_ref.datalen = output_script->arr_len;
66482         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
66483         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
66484         LDKU128 user_channel_id_ref;
66485         CHECK(user_channel_id->arr_len == 16);
66486         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
66487         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66488         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
66489         int64_t ret_ref = tag_ptr(ret_copy, true);
66490         return ret_ref;
66491 }
66492
66493 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) {
66494         LDKPublicKey receiver_node_id_ref;
66495         CHECK(receiver_node_id->arr_len == 33);
66496         memcpy(receiver_node_id_ref.compressed_form, receiver_node_id->elems, 33); FREE(receiver_node_id);
66497         LDKThirtyTwoBytes payment_hash_ref;
66498         CHECK(payment_hash->arr_len == 32);
66499         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66500         LDKRecipientOnionFields onion_fields_conv;
66501         onion_fields_conv.inner = untag_ptr(onion_fields);
66502         onion_fields_conv.is_owned = ptr_is_owned(onion_fields);
66503         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_conv);
66504         onion_fields_conv = RecipientOnionFields_clone(&onion_fields_conv);
66505         void* purpose_ptr = untag_ptr(purpose);
66506         CHECK_ACCESS(purpose_ptr);
66507         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
66508         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
66509         void* via_channel_id_ptr = untag_ptr(via_channel_id);
66510         CHECK_ACCESS(via_channel_id_ptr);
66511         LDKCOption_ThirtyTwoBytesZ via_channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(via_channel_id_ptr);
66512         via_channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(via_channel_id));
66513         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
66514         CHECK_ACCESS(via_user_channel_id_ptr);
66515         LDKCOption_U128Z via_user_channel_id_conv = *(LDKCOption_U128Z*)(via_user_channel_id_ptr);
66516         via_user_channel_id_conv = COption_U128Z_clone((LDKCOption_U128Z*)untag_ptr(via_user_channel_id));
66517         void* claim_deadline_ptr = untag_ptr(claim_deadline);
66518         CHECK_ACCESS(claim_deadline_ptr);
66519         LDKCOption_u32Z claim_deadline_conv = *(LDKCOption_u32Z*)(claim_deadline_ptr);
66520         claim_deadline_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(claim_deadline));
66521         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66522         *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);
66523         int64_t ret_ref = tag_ptr(ret_copy, true);
66524         return ret_ref;
66525 }
66526
66527 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) {
66528         LDKPublicKey receiver_node_id_ref;
66529         CHECK(receiver_node_id->arr_len == 33);
66530         memcpy(receiver_node_id_ref.compressed_form, receiver_node_id->elems, 33); FREE(receiver_node_id);
66531         LDKThirtyTwoBytes payment_hash_ref;
66532         CHECK(payment_hash->arr_len == 32);
66533         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66534         void* purpose_ptr = untag_ptr(purpose);
66535         CHECK_ACCESS(purpose_ptr);
66536         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
66537         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
66538         LDKCVec_ClaimedHTLCZ htlcs_constr;
66539         htlcs_constr.datalen = htlcs->arr_len;
66540         if (htlcs_constr.datalen > 0)
66541                 htlcs_constr.data = MALLOC(htlcs_constr.datalen * sizeof(LDKClaimedHTLC), "LDKCVec_ClaimedHTLCZ Elements");
66542         else
66543                 htlcs_constr.data = NULL;
66544         int64_t* htlcs_vals = htlcs->elems;
66545         for (size_t n = 0; n < htlcs_constr.datalen; n++) {
66546                 int64_t htlcs_conv_13 = htlcs_vals[n];
66547                 LDKClaimedHTLC htlcs_conv_13_conv;
66548                 htlcs_conv_13_conv.inner = untag_ptr(htlcs_conv_13);
66549                 htlcs_conv_13_conv.is_owned = ptr_is_owned(htlcs_conv_13);
66550                 CHECK_INNER_FIELD_ACCESS_OR_NULL(htlcs_conv_13_conv);
66551                 htlcs_conv_13_conv = ClaimedHTLC_clone(&htlcs_conv_13_conv);
66552                 htlcs_constr.data[n] = htlcs_conv_13_conv;
66553         }
66554         FREE(htlcs);
66555         void* sender_intended_total_msat_ptr = untag_ptr(sender_intended_total_msat);
66556         CHECK_ACCESS(sender_intended_total_msat_ptr);
66557         LDKCOption_u64Z sender_intended_total_msat_conv = *(LDKCOption_u64Z*)(sender_intended_total_msat_ptr);
66558         sender_intended_total_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(sender_intended_total_msat));
66559         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66560         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv, htlcs_constr, sender_intended_total_msat_conv);
66561         int64_t ret_ref = tag_ptr(ret_copy, true);
66562         return ret_ref;
66563 }
66564
66565 int64_t  CS_LDK_Event_invoice_request_failed(int8_tArray payment_id) {
66566         LDKThirtyTwoBytes payment_id_ref;
66567         CHECK(payment_id->arr_len == 32);
66568         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66569         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66570         *ret_copy = Event_invoice_request_failed(payment_id_ref);
66571         int64_t ret_ref = tag_ptr(ret_copy, true);
66572         return ret_ref;
66573 }
66574
66575 int64_t  CS_LDK_Event_payment_sent(int64_t payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, int64_t fee_paid_msat) {
66576         void* payment_id_ptr = untag_ptr(payment_id);
66577         CHECK_ACCESS(payment_id_ptr);
66578         LDKCOption_ThirtyTwoBytesZ payment_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_id_ptr);
66579         payment_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_id));
66580         LDKThirtyTwoBytes payment_preimage_ref;
66581         CHECK(payment_preimage->arr_len == 32);
66582         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
66583         LDKThirtyTwoBytes payment_hash_ref;
66584         CHECK(payment_hash->arr_len == 32);
66585         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66586         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
66587         CHECK_ACCESS(fee_paid_msat_ptr);
66588         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
66589         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
66590         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66591         *ret_copy = Event_payment_sent(payment_id_conv, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
66592         int64_t ret_ref = tag_ptr(ret_copy, true);
66593         return ret_ref;
66594 }
66595
66596 int64_t  CS_LDK_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash, int64_t reason) {
66597         LDKThirtyTwoBytes payment_id_ref;
66598         CHECK(payment_id->arr_len == 32);
66599         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66600         LDKThirtyTwoBytes payment_hash_ref;
66601         CHECK(payment_hash->arr_len == 32);
66602         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66603         void* reason_ptr = untag_ptr(reason);
66604         CHECK_ACCESS(reason_ptr);
66605         LDKCOption_PaymentFailureReasonZ reason_conv = *(LDKCOption_PaymentFailureReasonZ*)(reason_ptr);
66606         reason_conv = COption_PaymentFailureReasonZ_clone((LDKCOption_PaymentFailureReasonZ*)untag_ptr(reason));
66607         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66608         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref, reason_conv);
66609         int64_t ret_ref = tag_ptr(ret_copy, true);
66610         return ret_ref;
66611 }
66612
66613 int64_t  CS_LDK_Event_payment_path_successful(int8_tArray payment_id, int64_t payment_hash, int64_t path) {
66614         LDKThirtyTwoBytes payment_id_ref;
66615         CHECK(payment_id->arr_len == 32);
66616         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66617         void* payment_hash_ptr = untag_ptr(payment_hash);
66618         CHECK_ACCESS(payment_hash_ptr);
66619         LDKCOption_ThirtyTwoBytesZ payment_hash_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_hash_ptr);
66620         payment_hash_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_hash));
66621         LDKPath path_conv;
66622         path_conv.inner = untag_ptr(path);
66623         path_conv.is_owned = ptr_is_owned(path);
66624         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
66625         path_conv = Path_clone(&path_conv);
66626         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66627         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_conv, path_conv);
66628         int64_t ret_ref = tag_ptr(ret_copy, true);
66629         return ret_ref;
66630 }
66631
66632 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) {
66633         void* payment_id_ptr = untag_ptr(payment_id);
66634         CHECK_ACCESS(payment_id_ptr);
66635         LDKCOption_ThirtyTwoBytesZ payment_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_id_ptr);
66636         payment_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_id));
66637         LDKThirtyTwoBytes payment_hash_ref;
66638         CHECK(payment_hash->arr_len == 32);
66639         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66640         void* failure_ptr = untag_ptr(failure);
66641         CHECK_ACCESS(failure_ptr);
66642         LDKPathFailure failure_conv = *(LDKPathFailure*)(failure_ptr);
66643         failure_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(failure));
66644         LDKPath path_conv;
66645         path_conv.inner = untag_ptr(path);
66646         path_conv.is_owned = ptr_is_owned(path);
66647         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
66648         path_conv = Path_clone(&path_conv);
66649         void* short_channel_id_ptr = untag_ptr(short_channel_id);
66650         CHECK_ACCESS(short_channel_id_ptr);
66651         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
66652         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
66653         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66654         *ret_copy = Event_payment_path_failed(payment_id_conv, payment_hash_ref, payment_failed_permanently, failure_conv, path_conv, short_channel_id_conv);
66655         int64_t ret_ref = tag_ptr(ret_copy, true);
66656         return ret_ref;
66657 }
66658
66659 int64_t  CS_LDK_Event_probe_successful(int8_tArray payment_id, int8_tArray payment_hash, int64_t path) {
66660         LDKThirtyTwoBytes payment_id_ref;
66661         CHECK(payment_id->arr_len == 32);
66662         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66663         LDKThirtyTwoBytes payment_hash_ref;
66664         CHECK(payment_hash->arr_len == 32);
66665         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66666         LDKPath path_conv;
66667         path_conv.inner = untag_ptr(path);
66668         path_conv.is_owned = ptr_is_owned(path);
66669         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
66670         path_conv = Path_clone(&path_conv);
66671         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66672         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_conv);
66673         int64_t ret_ref = tag_ptr(ret_copy, true);
66674         return ret_ref;
66675 }
66676
66677 int64_t  CS_LDK_Event_probe_failed(int8_tArray payment_id, int8_tArray payment_hash, int64_t path, int64_t short_channel_id) {
66678         LDKThirtyTwoBytes payment_id_ref;
66679         CHECK(payment_id->arr_len == 32);
66680         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66681         LDKThirtyTwoBytes payment_hash_ref;
66682         CHECK(payment_hash->arr_len == 32);
66683         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66684         LDKPath path_conv;
66685         path_conv.inner = untag_ptr(path);
66686         path_conv.is_owned = ptr_is_owned(path);
66687         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
66688         path_conv = Path_clone(&path_conv);
66689         void* short_channel_id_ptr = untag_ptr(short_channel_id);
66690         CHECK_ACCESS(short_channel_id_ptr);
66691         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
66692         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
66693         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66694         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_conv, short_channel_id_conv);
66695         int64_t ret_ref = tag_ptr(ret_copy, true);
66696         return ret_ref;
66697 }
66698
66699 int64_t  CS_LDK_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
66700         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66701         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
66702         int64_t ret_ref = tag_ptr(ret_copy, true);
66703         return ret_ref;
66704 }
66705
66706 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) {
66707         LDKThirtyTwoBytes intercept_id_ref;
66708         CHECK(intercept_id->arr_len == 32);
66709         memcpy(intercept_id_ref.data, intercept_id->elems, 32); FREE(intercept_id);
66710         LDKThirtyTwoBytes payment_hash_ref;
66711         CHECK(payment_hash->arr_len == 32);
66712         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66713         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66714         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
66715         int64_t ret_ref = tag_ptr(ret_copy, true);
66716         return ret_ref;
66717 }
66718
66719 int64_t  CS_LDK_Event_spendable_outputs(int64_tArray outputs, int64_t channel_id) {
66720         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
66721         outputs_constr.datalen = outputs->arr_len;
66722         if (outputs_constr.datalen > 0)
66723                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
66724         else
66725                 outputs_constr.data = NULL;
66726         int64_t* outputs_vals = outputs->elems;
66727         for (size_t b = 0; b < outputs_constr.datalen; b++) {
66728                 int64_t outputs_conv_27 = outputs_vals[b];
66729                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
66730                 CHECK_ACCESS(outputs_conv_27_ptr);
66731                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
66732                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
66733                 outputs_constr.data[b] = outputs_conv_27_conv;
66734         }
66735         FREE(outputs);
66736         void* channel_id_ptr = untag_ptr(channel_id);
66737         CHECK_ACCESS(channel_id_ptr);
66738         LDKCOption_ThirtyTwoBytesZ channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(channel_id_ptr);
66739         channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(channel_id));
66740         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66741         *ret_copy = Event_spendable_outputs(outputs_constr, channel_id_conv);
66742         int64_t ret_ref = tag_ptr(ret_copy, true);
66743         return ret_ref;
66744 }
66745
66746 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) {
66747         void* prev_channel_id_ptr = untag_ptr(prev_channel_id);
66748         CHECK_ACCESS(prev_channel_id_ptr);
66749         LDKCOption_ThirtyTwoBytesZ prev_channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(prev_channel_id_ptr);
66750         prev_channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(prev_channel_id));
66751         void* next_channel_id_ptr = untag_ptr(next_channel_id);
66752         CHECK_ACCESS(next_channel_id_ptr);
66753         LDKCOption_ThirtyTwoBytesZ next_channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(next_channel_id_ptr);
66754         next_channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(next_channel_id));
66755         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
66756         CHECK_ACCESS(fee_earned_msat_ptr);
66757         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
66758         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
66759         void* outbound_amount_forwarded_msat_ptr = untag_ptr(outbound_amount_forwarded_msat);
66760         CHECK_ACCESS(outbound_amount_forwarded_msat_ptr);
66761         LDKCOption_u64Z outbound_amount_forwarded_msat_conv = *(LDKCOption_u64Z*)(outbound_amount_forwarded_msat_ptr);
66762         outbound_amount_forwarded_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_amount_forwarded_msat));
66763         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66764         *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);
66765         int64_t ret_ref = tag_ptr(ret_copy, true);
66766         return ret_ref;
66767 }
66768
66769 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) {
66770         LDKThirtyTwoBytes channel_id_ref;
66771         CHECK(channel_id->arr_len == 32);
66772         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66773         LDKU128 user_channel_id_ref;
66774         CHECK(user_channel_id->arr_len == 16);
66775         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
66776         void* former_temporary_channel_id_ptr = untag_ptr(former_temporary_channel_id);
66777         CHECK_ACCESS(former_temporary_channel_id_ptr);
66778         LDKCOption_ThirtyTwoBytesZ former_temporary_channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(former_temporary_channel_id_ptr);
66779         former_temporary_channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(former_temporary_channel_id));
66780         LDKPublicKey counterparty_node_id_ref;
66781         CHECK(counterparty_node_id->arr_len == 33);
66782         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66783         LDKOutPoint funding_txo_conv;
66784         funding_txo_conv.inner = untag_ptr(funding_txo);
66785         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
66786         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
66787         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
66788         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66789         *ret_copy = Event_channel_pending(channel_id_ref, user_channel_id_ref, former_temporary_channel_id_conv, counterparty_node_id_ref, funding_txo_conv);
66790         int64_t ret_ref = tag_ptr(ret_copy, true);
66791         return ret_ref;
66792 }
66793
66794 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) {
66795         LDKThirtyTwoBytes channel_id_ref;
66796         CHECK(channel_id->arr_len == 32);
66797         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66798         LDKU128 user_channel_id_ref;
66799         CHECK(user_channel_id->arr_len == 16);
66800         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
66801         LDKPublicKey counterparty_node_id_ref;
66802         CHECK(counterparty_node_id->arr_len == 33);
66803         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66804         LDKChannelTypeFeatures channel_type_conv;
66805         channel_type_conv.inner = untag_ptr(channel_type);
66806         channel_type_conv.is_owned = ptr_is_owned(channel_type);
66807         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
66808         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
66809         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66810         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
66811         int64_t ret_ref = tag_ptr(ret_copy, true);
66812         return ret_ref;
66813 }
66814
66815 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) {
66816         LDKThirtyTwoBytes channel_id_ref;
66817         CHECK(channel_id->arr_len == 32);
66818         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66819         LDKU128 user_channel_id_ref;
66820         CHECK(user_channel_id->arr_len == 16);
66821         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
66822         void* reason_ptr = untag_ptr(reason);
66823         CHECK_ACCESS(reason_ptr);
66824         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
66825         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
66826         LDKPublicKey counterparty_node_id_ref;
66827         CHECK(counterparty_node_id->arr_len == 33);
66828         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66829         void* channel_capacity_sats_ptr = untag_ptr(channel_capacity_sats);
66830         CHECK_ACCESS(channel_capacity_sats_ptr);
66831         LDKCOption_u64Z channel_capacity_sats_conv = *(LDKCOption_u64Z*)(channel_capacity_sats_ptr);
66832         channel_capacity_sats_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(channel_capacity_sats));
66833         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66834         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv, counterparty_node_id_ref, channel_capacity_sats_conv);
66835         int64_t ret_ref = tag_ptr(ret_copy, true);
66836         return ret_ref;
66837 }
66838
66839 int64_t  CS_LDK_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
66840         LDKThirtyTwoBytes channel_id_ref;
66841         CHECK(channel_id->arr_len == 32);
66842         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66843         LDKTransaction transaction_ref;
66844         transaction_ref.datalen = transaction->arr_len;
66845         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
66846         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
66847         transaction_ref.data_is_owned = true;
66848         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66849         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
66850         int64_t ret_ref = tag_ptr(ret_copy, true);
66851         return ret_ref;
66852 }
66853
66854 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) {
66855         LDKThirtyTwoBytes temporary_channel_id_ref;
66856         CHECK(temporary_channel_id->arr_len == 32);
66857         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
66858         LDKPublicKey counterparty_node_id_ref;
66859         CHECK(counterparty_node_id->arr_len == 33);
66860         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66861         LDKChannelTypeFeatures channel_type_conv;
66862         channel_type_conv.inner = untag_ptr(channel_type);
66863         channel_type_conv.is_owned = ptr_is_owned(channel_type);
66864         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
66865         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
66866         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66867         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
66868         int64_t ret_ref = tag_ptr(ret_copy, true);
66869         return ret_ref;
66870 }
66871
66872 int64_t  CS_LDK_Event_htlchandling_failed(int8_tArray prev_channel_id, int64_t failed_next_destination) {
66873         LDKThirtyTwoBytes prev_channel_id_ref;
66874         CHECK(prev_channel_id->arr_len == 32);
66875         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
66876         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
66877         CHECK_ACCESS(failed_next_destination_ptr);
66878         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
66879         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
66880         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66881         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
66882         int64_t ret_ref = tag_ptr(ret_copy, true);
66883         return ret_ref;
66884 }
66885
66886 int64_t  CS_LDK_Event_bump_transaction(int64_t a) {
66887         void* a_ptr = untag_ptr(a);
66888         CHECK_ACCESS(a_ptr);
66889         LDKBumpTransactionEvent a_conv = *(LDKBumpTransactionEvent*)(a_ptr);
66890         a_conv = BumpTransactionEvent_clone((LDKBumpTransactionEvent*)untag_ptr(a));
66891         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66892         *ret_copy = Event_bump_transaction(a_conv);
66893         int64_t ret_ref = tag_ptr(ret_copy, true);
66894         return ret_ref;
66895 }
66896
66897 jboolean  CS_LDK_Event_eq(int64_t a, int64_t b) {
66898         LDKEvent* a_conv = (LDKEvent*)untag_ptr(a);
66899         LDKEvent* b_conv = (LDKEvent*)untag_ptr(b);
66900         jboolean ret_conv = Event_eq(a_conv, b_conv);
66901         return ret_conv;
66902 }
66903
66904 int8_tArray  CS_LDK_Event_write(int64_t obj) {
66905         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
66906         LDKCVec_u8Z ret_var = Event_write(obj_conv);
66907         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66908         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66909         CVec_u8Z_free(ret_var);
66910         return ret_arr;
66911 }
66912
66913 int64_t  CS_LDK_Event_read(int8_tArray ser) {
66914         LDKu8slice ser_ref;
66915         ser_ref.datalen = ser->arr_len;
66916         ser_ref.data = ser->elems;
66917         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
66918         *ret_conv = Event_read(ser_ref);
66919         FREE(ser);
66920         return tag_ptr(ret_conv, true);
66921 }
66922
66923 void  CS_LDK_MessageSendEvent_free(int64_t this_ptr) {
66924         if (!ptr_is_owned(this_ptr)) return;
66925         void* this_ptr_ptr = untag_ptr(this_ptr);
66926         CHECK_ACCESS(this_ptr_ptr);
66927         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
66928         FREE(untag_ptr(this_ptr));
66929         MessageSendEvent_free(this_ptr_conv);
66930 }
66931
66932 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
66933         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66934         *ret_copy = MessageSendEvent_clone(arg);
66935         int64_t ret_ref = tag_ptr(ret_copy, true);
66936         return ret_ref;
66937 }
66938 int64_t  CS_LDK_MessageSendEvent_clone_ptr(int64_t arg) {
66939         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
66940         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
66941         return ret_conv;
66942 }
66943
66944 int64_t  CS_LDK_MessageSendEvent_clone(int64_t orig) {
66945         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
66946         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66947         *ret_copy = MessageSendEvent_clone(orig_conv);
66948         int64_t ret_ref = tag_ptr(ret_copy, true);
66949         return ret_ref;
66950 }
66951
66952 int64_t  CS_LDK_MessageSendEvent_send_accept_channel(int8_tArray node_id, int64_t msg) {
66953         LDKPublicKey node_id_ref;
66954         CHECK(node_id->arr_len == 33);
66955         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66956         LDKAcceptChannel msg_conv;
66957         msg_conv.inner = untag_ptr(msg);
66958         msg_conv.is_owned = ptr_is_owned(msg);
66959         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
66960         msg_conv = AcceptChannel_clone(&msg_conv);
66961         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66962         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
66963         int64_t ret_ref = tag_ptr(ret_copy, true);
66964         return ret_ref;
66965 }
66966
66967 int64_t  CS_LDK_MessageSendEvent_send_accept_channel_v2(int8_tArray node_id, int64_t msg) {
66968         LDKPublicKey node_id_ref;
66969         CHECK(node_id->arr_len == 33);
66970         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66971         LDKAcceptChannelV2 msg_conv;
66972         msg_conv.inner = untag_ptr(msg);
66973         msg_conv.is_owned = ptr_is_owned(msg);
66974         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
66975         msg_conv = AcceptChannelV2_clone(&msg_conv);
66976         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66977         *ret_copy = MessageSendEvent_send_accept_channel_v2(node_id_ref, msg_conv);
66978         int64_t ret_ref = tag_ptr(ret_copy, true);
66979         return ret_ref;
66980 }
66981
66982 int64_t  CS_LDK_MessageSendEvent_send_open_channel(int8_tArray node_id, int64_t msg) {
66983         LDKPublicKey node_id_ref;
66984         CHECK(node_id->arr_len == 33);
66985         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66986         LDKOpenChannel msg_conv;
66987         msg_conv.inner = untag_ptr(msg);
66988         msg_conv.is_owned = ptr_is_owned(msg);
66989         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
66990         msg_conv = OpenChannel_clone(&msg_conv);
66991         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66992         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
66993         int64_t ret_ref = tag_ptr(ret_copy, true);
66994         return ret_ref;
66995 }
66996
66997 int64_t  CS_LDK_MessageSendEvent_send_open_channel_v2(int8_tArray node_id, int64_t msg) {
66998         LDKPublicKey node_id_ref;
66999         CHECK(node_id->arr_len == 33);
67000         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67001         LDKOpenChannelV2 msg_conv;
67002         msg_conv.inner = untag_ptr(msg);
67003         msg_conv.is_owned = ptr_is_owned(msg);
67004         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67005         msg_conv = OpenChannelV2_clone(&msg_conv);
67006         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67007         *ret_copy = MessageSendEvent_send_open_channel_v2(node_id_ref, msg_conv);
67008         int64_t ret_ref = tag_ptr(ret_copy, true);
67009         return ret_ref;
67010 }
67011
67012 int64_t  CS_LDK_MessageSendEvent_send_funding_created(int8_tArray node_id, int64_t msg) {
67013         LDKPublicKey node_id_ref;
67014         CHECK(node_id->arr_len == 33);
67015         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67016         LDKFundingCreated msg_conv;
67017         msg_conv.inner = untag_ptr(msg);
67018         msg_conv.is_owned = ptr_is_owned(msg);
67019         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67020         msg_conv = FundingCreated_clone(&msg_conv);
67021         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67022         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
67023         int64_t ret_ref = tag_ptr(ret_copy, true);
67024         return ret_ref;
67025 }
67026
67027 int64_t  CS_LDK_MessageSendEvent_send_funding_signed(int8_tArray node_id, int64_t msg) {
67028         LDKPublicKey node_id_ref;
67029         CHECK(node_id->arr_len == 33);
67030         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67031         LDKFundingSigned msg_conv;
67032         msg_conv.inner = untag_ptr(msg);
67033         msg_conv.is_owned = ptr_is_owned(msg);
67034         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67035         msg_conv = FundingSigned_clone(&msg_conv);
67036         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67037         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
67038         int64_t ret_ref = tag_ptr(ret_copy, true);
67039         return ret_ref;
67040 }
67041
67042 int64_t  CS_LDK_MessageSendEvent_send_tx_add_input(int8_tArray node_id, int64_t msg) {
67043         LDKPublicKey node_id_ref;
67044         CHECK(node_id->arr_len == 33);
67045         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67046         LDKTxAddInput msg_conv;
67047         msg_conv.inner = untag_ptr(msg);
67048         msg_conv.is_owned = ptr_is_owned(msg);
67049         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67050         msg_conv = TxAddInput_clone(&msg_conv);
67051         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67052         *ret_copy = MessageSendEvent_send_tx_add_input(node_id_ref, msg_conv);
67053         int64_t ret_ref = tag_ptr(ret_copy, true);
67054         return ret_ref;
67055 }
67056
67057 int64_t  CS_LDK_MessageSendEvent_send_tx_add_output(int8_tArray node_id, int64_t msg) {
67058         LDKPublicKey node_id_ref;
67059         CHECK(node_id->arr_len == 33);
67060         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67061         LDKTxAddOutput msg_conv;
67062         msg_conv.inner = untag_ptr(msg);
67063         msg_conv.is_owned = ptr_is_owned(msg);
67064         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67065         msg_conv = TxAddOutput_clone(&msg_conv);
67066         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67067         *ret_copy = MessageSendEvent_send_tx_add_output(node_id_ref, msg_conv);
67068         int64_t ret_ref = tag_ptr(ret_copy, true);
67069         return ret_ref;
67070 }
67071
67072 int64_t  CS_LDK_MessageSendEvent_send_tx_remove_input(int8_tArray node_id, int64_t msg) {
67073         LDKPublicKey node_id_ref;
67074         CHECK(node_id->arr_len == 33);
67075         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67076         LDKTxRemoveInput msg_conv;
67077         msg_conv.inner = untag_ptr(msg);
67078         msg_conv.is_owned = ptr_is_owned(msg);
67079         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67080         msg_conv = TxRemoveInput_clone(&msg_conv);
67081         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67082         *ret_copy = MessageSendEvent_send_tx_remove_input(node_id_ref, msg_conv);
67083         int64_t ret_ref = tag_ptr(ret_copy, true);
67084         return ret_ref;
67085 }
67086
67087 int64_t  CS_LDK_MessageSendEvent_send_tx_remove_output(int8_tArray node_id, int64_t msg) {
67088         LDKPublicKey node_id_ref;
67089         CHECK(node_id->arr_len == 33);
67090         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67091         LDKTxRemoveOutput msg_conv;
67092         msg_conv.inner = untag_ptr(msg);
67093         msg_conv.is_owned = ptr_is_owned(msg);
67094         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67095         msg_conv = TxRemoveOutput_clone(&msg_conv);
67096         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67097         *ret_copy = MessageSendEvent_send_tx_remove_output(node_id_ref, msg_conv);
67098         int64_t ret_ref = tag_ptr(ret_copy, true);
67099         return ret_ref;
67100 }
67101
67102 int64_t  CS_LDK_MessageSendEvent_send_tx_complete(int8_tArray node_id, int64_t msg) {
67103         LDKPublicKey node_id_ref;
67104         CHECK(node_id->arr_len == 33);
67105         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67106         LDKTxComplete msg_conv;
67107         msg_conv.inner = untag_ptr(msg);
67108         msg_conv.is_owned = ptr_is_owned(msg);
67109         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67110         msg_conv = TxComplete_clone(&msg_conv);
67111         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67112         *ret_copy = MessageSendEvent_send_tx_complete(node_id_ref, msg_conv);
67113         int64_t ret_ref = tag_ptr(ret_copy, true);
67114         return ret_ref;
67115 }
67116
67117 int64_t  CS_LDK_MessageSendEvent_send_tx_signatures(int8_tArray node_id, int64_t msg) {
67118         LDKPublicKey node_id_ref;
67119         CHECK(node_id->arr_len == 33);
67120         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67121         LDKTxSignatures msg_conv;
67122         msg_conv.inner = untag_ptr(msg);
67123         msg_conv.is_owned = ptr_is_owned(msg);
67124         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67125         msg_conv = TxSignatures_clone(&msg_conv);
67126         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67127         *ret_copy = MessageSendEvent_send_tx_signatures(node_id_ref, msg_conv);
67128         int64_t ret_ref = tag_ptr(ret_copy, true);
67129         return ret_ref;
67130 }
67131
67132 int64_t  CS_LDK_MessageSendEvent_send_tx_init_rbf(int8_tArray node_id, int64_t msg) {
67133         LDKPublicKey node_id_ref;
67134         CHECK(node_id->arr_len == 33);
67135         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67136         LDKTxInitRbf msg_conv;
67137         msg_conv.inner = untag_ptr(msg);
67138         msg_conv.is_owned = ptr_is_owned(msg);
67139         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67140         msg_conv = TxInitRbf_clone(&msg_conv);
67141         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67142         *ret_copy = MessageSendEvent_send_tx_init_rbf(node_id_ref, msg_conv);
67143         int64_t ret_ref = tag_ptr(ret_copy, true);
67144         return ret_ref;
67145 }
67146
67147 int64_t  CS_LDK_MessageSendEvent_send_tx_ack_rbf(int8_tArray node_id, int64_t msg) {
67148         LDKPublicKey node_id_ref;
67149         CHECK(node_id->arr_len == 33);
67150         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67151         LDKTxAckRbf msg_conv;
67152         msg_conv.inner = untag_ptr(msg);
67153         msg_conv.is_owned = ptr_is_owned(msg);
67154         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67155         msg_conv = TxAckRbf_clone(&msg_conv);
67156         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67157         *ret_copy = MessageSendEvent_send_tx_ack_rbf(node_id_ref, msg_conv);
67158         int64_t ret_ref = tag_ptr(ret_copy, true);
67159         return ret_ref;
67160 }
67161
67162 int64_t  CS_LDK_MessageSendEvent_send_tx_abort(int8_tArray node_id, int64_t msg) {
67163         LDKPublicKey node_id_ref;
67164         CHECK(node_id->arr_len == 33);
67165         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67166         LDKTxAbort msg_conv;
67167         msg_conv.inner = untag_ptr(msg);
67168         msg_conv.is_owned = ptr_is_owned(msg);
67169         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67170         msg_conv = TxAbort_clone(&msg_conv);
67171         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67172         *ret_copy = MessageSendEvent_send_tx_abort(node_id_ref, msg_conv);
67173         int64_t ret_ref = tag_ptr(ret_copy, true);
67174         return ret_ref;
67175 }
67176
67177 int64_t  CS_LDK_MessageSendEvent_send_channel_ready(int8_tArray node_id, int64_t msg) {
67178         LDKPublicKey node_id_ref;
67179         CHECK(node_id->arr_len == 33);
67180         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67181         LDKChannelReady msg_conv;
67182         msg_conv.inner = untag_ptr(msg);
67183         msg_conv.is_owned = ptr_is_owned(msg);
67184         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67185         msg_conv = ChannelReady_clone(&msg_conv);
67186         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67187         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
67188         int64_t ret_ref = tag_ptr(ret_copy, true);
67189         return ret_ref;
67190 }
67191
67192 int64_t  CS_LDK_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, int64_t msg) {
67193         LDKPublicKey node_id_ref;
67194         CHECK(node_id->arr_len == 33);
67195         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67196         LDKAnnouncementSignatures msg_conv;
67197         msg_conv.inner = untag_ptr(msg);
67198         msg_conv.is_owned = ptr_is_owned(msg);
67199         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67200         msg_conv = AnnouncementSignatures_clone(&msg_conv);
67201         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67202         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
67203         int64_t ret_ref = tag_ptr(ret_copy, true);
67204         return ret_ref;
67205 }
67206
67207 int64_t  CS_LDK_MessageSendEvent_update_htlcs(int8_tArray node_id, int64_t updates) {
67208         LDKPublicKey node_id_ref;
67209         CHECK(node_id->arr_len == 33);
67210         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67211         LDKCommitmentUpdate updates_conv;
67212         updates_conv.inner = untag_ptr(updates);
67213         updates_conv.is_owned = ptr_is_owned(updates);
67214         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
67215         updates_conv = CommitmentUpdate_clone(&updates_conv);
67216         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67217         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
67218         int64_t ret_ref = tag_ptr(ret_copy, true);
67219         return ret_ref;
67220 }
67221
67222 int64_t  CS_LDK_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, int64_t msg) {
67223         LDKPublicKey node_id_ref;
67224         CHECK(node_id->arr_len == 33);
67225         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67226         LDKRevokeAndACK msg_conv;
67227         msg_conv.inner = untag_ptr(msg);
67228         msg_conv.is_owned = ptr_is_owned(msg);
67229         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67230         msg_conv = RevokeAndACK_clone(&msg_conv);
67231         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67232         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
67233         int64_t ret_ref = tag_ptr(ret_copy, true);
67234         return ret_ref;
67235 }
67236
67237 int64_t  CS_LDK_MessageSendEvent_send_closing_signed(int8_tArray node_id, int64_t msg) {
67238         LDKPublicKey node_id_ref;
67239         CHECK(node_id->arr_len == 33);
67240         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67241         LDKClosingSigned msg_conv;
67242         msg_conv.inner = untag_ptr(msg);
67243         msg_conv.is_owned = ptr_is_owned(msg);
67244         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67245         msg_conv = ClosingSigned_clone(&msg_conv);
67246         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67247         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
67248         int64_t ret_ref = tag_ptr(ret_copy, true);
67249         return ret_ref;
67250 }
67251
67252 int64_t  CS_LDK_MessageSendEvent_send_shutdown(int8_tArray node_id, int64_t msg) {
67253         LDKPublicKey node_id_ref;
67254         CHECK(node_id->arr_len == 33);
67255         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67256         LDKShutdown msg_conv;
67257         msg_conv.inner = untag_ptr(msg);
67258         msg_conv.is_owned = ptr_is_owned(msg);
67259         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67260         msg_conv = Shutdown_clone(&msg_conv);
67261         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67262         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
67263         int64_t ret_ref = tag_ptr(ret_copy, true);
67264         return ret_ref;
67265 }
67266
67267 int64_t  CS_LDK_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, int64_t msg) {
67268         LDKPublicKey node_id_ref;
67269         CHECK(node_id->arr_len == 33);
67270         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67271         LDKChannelReestablish msg_conv;
67272         msg_conv.inner = untag_ptr(msg);
67273         msg_conv.is_owned = ptr_is_owned(msg);
67274         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67275         msg_conv = ChannelReestablish_clone(&msg_conv);
67276         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67277         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
67278         int64_t ret_ref = tag_ptr(ret_copy, true);
67279         return ret_ref;
67280 }
67281
67282 int64_t  CS_LDK_MessageSendEvent_send_channel_announcement(int8_tArray node_id, int64_t msg, int64_t update_msg) {
67283         LDKPublicKey node_id_ref;
67284         CHECK(node_id->arr_len == 33);
67285         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67286         LDKChannelAnnouncement msg_conv;
67287         msg_conv.inner = untag_ptr(msg);
67288         msg_conv.is_owned = ptr_is_owned(msg);
67289         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67290         msg_conv = ChannelAnnouncement_clone(&msg_conv);
67291         LDKChannelUpdate update_msg_conv;
67292         update_msg_conv.inner = untag_ptr(update_msg);
67293         update_msg_conv.is_owned = ptr_is_owned(update_msg);
67294         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
67295         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
67296         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67297         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
67298         int64_t ret_ref = tag_ptr(ret_copy, true);
67299         return ret_ref;
67300 }
67301
67302 int64_t  CS_LDK_MessageSendEvent_broadcast_channel_announcement(int64_t msg, int64_t update_msg) {
67303         LDKChannelAnnouncement msg_conv;
67304         msg_conv.inner = untag_ptr(msg);
67305         msg_conv.is_owned = ptr_is_owned(msg);
67306         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67307         msg_conv = ChannelAnnouncement_clone(&msg_conv);
67308         LDKChannelUpdate update_msg_conv;
67309         update_msg_conv.inner = untag_ptr(update_msg);
67310         update_msg_conv.is_owned = ptr_is_owned(update_msg);
67311         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
67312         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
67313         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67314         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
67315         int64_t ret_ref = tag_ptr(ret_copy, true);
67316         return ret_ref;
67317 }
67318
67319 int64_t  CS_LDK_MessageSendEvent_broadcast_channel_update(int64_t msg) {
67320         LDKChannelUpdate msg_conv;
67321         msg_conv.inner = untag_ptr(msg);
67322         msg_conv.is_owned = ptr_is_owned(msg);
67323         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67324         msg_conv = ChannelUpdate_clone(&msg_conv);
67325         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67326         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
67327         int64_t ret_ref = tag_ptr(ret_copy, true);
67328         return ret_ref;
67329 }
67330
67331 int64_t  CS_LDK_MessageSendEvent_broadcast_node_announcement(int64_t msg) {
67332         LDKNodeAnnouncement msg_conv;
67333         msg_conv.inner = untag_ptr(msg);
67334         msg_conv.is_owned = ptr_is_owned(msg);
67335         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67336         msg_conv = NodeAnnouncement_clone(&msg_conv);
67337         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67338         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
67339         int64_t ret_ref = tag_ptr(ret_copy, true);
67340         return ret_ref;
67341 }
67342
67343 int64_t  CS_LDK_MessageSendEvent_send_channel_update(int8_tArray node_id, int64_t msg) {
67344         LDKPublicKey node_id_ref;
67345         CHECK(node_id->arr_len == 33);
67346         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67347         LDKChannelUpdate msg_conv;
67348         msg_conv.inner = untag_ptr(msg);
67349         msg_conv.is_owned = ptr_is_owned(msg);
67350         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67351         msg_conv = ChannelUpdate_clone(&msg_conv);
67352         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67353         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
67354         int64_t ret_ref = tag_ptr(ret_copy, true);
67355         return ret_ref;
67356 }
67357
67358 int64_t  CS_LDK_MessageSendEvent_handle_error(int8_tArray node_id, int64_t action) {
67359         LDKPublicKey node_id_ref;
67360         CHECK(node_id->arr_len == 33);
67361         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67362         void* action_ptr = untag_ptr(action);
67363         CHECK_ACCESS(action_ptr);
67364         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
67365         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
67366         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67367         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
67368         int64_t ret_ref = tag_ptr(ret_copy, true);
67369         return ret_ref;
67370 }
67371
67372 int64_t  CS_LDK_MessageSendEvent_send_channel_range_query(int8_tArray node_id, int64_t msg) {
67373         LDKPublicKey node_id_ref;
67374         CHECK(node_id->arr_len == 33);
67375         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67376         LDKQueryChannelRange msg_conv;
67377         msg_conv.inner = untag_ptr(msg);
67378         msg_conv.is_owned = ptr_is_owned(msg);
67379         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67380         msg_conv = QueryChannelRange_clone(&msg_conv);
67381         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67382         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
67383         int64_t ret_ref = tag_ptr(ret_copy, true);
67384         return ret_ref;
67385 }
67386
67387 int64_t  CS_LDK_MessageSendEvent_send_short_ids_query(int8_tArray node_id, int64_t msg) {
67388         LDKPublicKey node_id_ref;
67389         CHECK(node_id->arr_len == 33);
67390         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67391         LDKQueryShortChannelIds msg_conv;
67392         msg_conv.inner = untag_ptr(msg);
67393         msg_conv.is_owned = ptr_is_owned(msg);
67394         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67395         msg_conv = QueryShortChannelIds_clone(&msg_conv);
67396         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67397         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
67398         int64_t ret_ref = tag_ptr(ret_copy, true);
67399         return ret_ref;
67400 }
67401
67402 int64_t  CS_LDK_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, int64_t msg) {
67403         LDKPublicKey node_id_ref;
67404         CHECK(node_id->arr_len == 33);
67405         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67406         LDKReplyChannelRange msg_conv;
67407         msg_conv.inner = untag_ptr(msg);
67408         msg_conv.is_owned = ptr_is_owned(msg);
67409         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67410         msg_conv = ReplyChannelRange_clone(&msg_conv);
67411         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67412         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
67413         int64_t ret_ref = tag_ptr(ret_copy, true);
67414         return ret_ref;
67415 }
67416
67417 int64_t  CS_LDK_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, int64_t msg) {
67418         LDKPublicKey node_id_ref;
67419         CHECK(node_id->arr_len == 33);
67420         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67421         LDKGossipTimestampFilter msg_conv;
67422         msg_conv.inner = untag_ptr(msg);
67423         msg_conv.is_owned = ptr_is_owned(msg);
67424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67425         msg_conv = GossipTimestampFilter_clone(&msg_conv);
67426         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67427         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
67428         int64_t ret_ref = tag_ptr(ret_copy, true);
67429         return ret_ref;
67430 }
67431
67432 void  CS_LDK_MessageSendEventsProvider_free(int64_t this_ptr) {
67433         if (!ptr_is_owned(this_ptr)) return;
67434         void* this_ptr_ptr = untag_ptr(this_ptr);
67435         CHECK_ACCESS(this_ptr_ptr);
67436         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
67437         FREE(untag_ptr(this_ptr));
67438         MessageSendEventsProvider_free(this_ptr_conv);
67439 }
67440
67441 void  CS_LDK_EventsProvider_free(int64_t this_ptr) {
67442         if (!ptr_is_owned(this_ptr)) return;
67443         void* this_ptr_ptr = untag_ptr(this_ptr);
67444         CHECK_ACCESS(this_ptr_ptr);
67445         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
67446         FREE(untag_ptr(this_ptr));
67447         EventsProvider_free(this_ptr_conv);
67448 }
67449
67450 void  CS_LDK_EventHandler_free(int64_t this_ptr) {
67451         if (!ptr_is_owned(this_ptr)) return;
67452         void* this_ptr_ptr = untag_ptr(this_ptr);
67453         CHECK_ACCESS(this_ptr_ptr);
67454         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
67455         FREE(untag_ptr(this_ptr));
67456         EventHandler_free(this_ptr_conv);
67457 }
67458
67459 void  CS_LDK_AnchorDescriptor_free(int64_t this_obj) {
67460         LDKAnchorDescriptor this_obj_conv;
67461         this_obj_conv.inner = untag_ptr(this_obj);
67462         this_obj_conv.is_owned = ptr_is_owned(this_obj);
67463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
67464         AnchorDescriptor_free(this_obj_conv);
67465 }
67466
67467 int64_t  CS_LDK_AnchorDescriptor_get_channel_derivation_parameters(int64_t this_ptr) {
67468         LDKAnchorDescriptor this_ptr_conv;
67469         this_ptr_conv.inner = untag_ptr(this_ptr);
67470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67472         this_ptr_conv.is_owned = false;
67473         LDKChannelDerivationParameters ret_var = AnchorDescriptor_get_channel_derivation_parameters(&this_ptr_conv);
67474         int64_t ret_ref = 0;
67475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67477         return ret_ref;
67478 }
67479
67480 void  CS_LDK_AnchorDescriptor_set_channel_derivation_parameters(int64_t this_ptr, int64_t val) {
67481         LDKAnchorDescriptor this_ptr_conv;
67482         this_ptr_conv.inner = untag_ptr(this_ptr);
67483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67485         this_ptr_conv.is_owned = false;
67486         LDKChannelDerivationParameters val_conv;
67487         val_conv.inner = untag_ptr(val);
67488         val_conv.is_owned = ptr_is_owned(val);
67489         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
67490         val_conv = ChannelDerivationParameters_clone(&val_conv);
67491         AnchorDescriptor_set_channel_derivation_parameters(&this_ptr_conv, val_conv);
67492 }
67493
67494 int64_t  CS_LDK_AnchorDescriptor_get_outpoint(int64_t this_ptr) {
67495         LDKAnchorDescriptor this_ptr_conv;
67496         this_ptr_conv.inner = untag_ptr(this_ptr);
67497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67499         this_ptr_conv.is_owned = false;
67500         LDKOutPoint ret_var = AnchorDescriptor_get_outpoint(&this_ptr_conv);
67501         int64_t ret_ref = 0;
67502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67503         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67504         return ret_ref;
67505 }
67506
67507 void  CS_LDK_AnchorDescriptor_set_outpoint(int64_t this_ptr, int64_t val) {
67508         LDKAnchorDescriptor this_ptr_conv;
67509         this_ptr_conv.inner = untag_ptr(this_ptr);
67510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67512         this_ptr_conv.is_owned = false;
67513         LDKOutPoint val_conv;
67514         val_conv.inner = untag_ptr(val);
67515         val_conv.is_owned = ptr_is_owned(val);
67516         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
67517         val_conv = OutPoint_clone(&val_conv);
67518         AnchorDescriptor_set_outpoint(&this_ptr_conv, val_conv);
67519 }
67520
67521 int64_t  CS_LDK_AnchorDescriptor_new(int64_t channel_derivation_parameters_arg, int64_t outpoint_arg) {
67522         LDKChannelDerivationParameters channel_derivation_parameters_arg_conv;
67523         channel_derivation_parameters_arg_conv.inner = untag_ptr(channel_derivation_parameters_arg);
67524         channel_derivation_parameters_arg_conv.is_owned = ptr_is_owned(channel_derivation_parameters_arg);
67525         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_derivation_parameters_arg_conv);
67526         channel_derivation_parameters_arg_conv = ChannelDerivationParameters_clone(&channel_derivation_parameters_arg_conv);
67527         LDKOutPoint outpoint_arg_conv;
67528         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
67529         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
67530         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
67531         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
67532         LDKAnchorDescriptor ret_var = AnchorDescriptor_new(channel_derivation_parameters_arg_conv, outpoint_arg_conv);
67533         int64_t ret_ref = 0;
67534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67536         return ret_ref;
67537 }
67538
67539 static inline uint64_t AnchorDescriptor_clone_ptr(LDKAnchorDescriptor *NONNULL_PTR arg) {
67540         LDKAnchorDescriptor ret_var = AnchorDescriptor_clone(arg);
67541         int64_t ret_ref = 0;
67542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67543         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67544         return ret_ref;
67545 }
67546 int64_t  CS_LDK_AnchorDescriptor_clone_ptr(int64_t arg) {
67547         LDKAnchorDescriptor arg_conv;
67548         arg_conv.inner = untag_ptr(arg);
67549         arg_conv.is_owned = ptr_is_owned(arg);
67550         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
67551         arg_conv.is_owned = false;
67552         int64_t ret_conv = AnchorDescriptor_clone_ptr(&arg_conv);
67553         return ret_conv;
67554 }
67555
67556 int64_t  CS_LDK_AnchorDescriptor_clone(int64_t orig) {
67557         LDKAnchorDescriptor orig_conv;
67558         orig_conv.inner = untag_ptr(orig);
67559         orig_conv.is_owned = ptr_is_owned(orig);
67560         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
67561         orig_conv.is_owned = false;
67562         LDKAnchorDescriptor ret_var = AnchorDescriptor_clone(&orig_conv);
67563         int64_t ret_ref = 0;
67564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67565         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67566         return ret_ref;
67567 }
67568
67569 jboolean  CS_LDK_AnchorDescriptor_eq(int64_t a, int64_t b) {
67570         LDKAnchorDescriptor a_conv;
67571         a_conv.inner = untag_ptr(a);
67572         a_conv.is_owned = ptr_is_owned(a);
67573         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
67574         a_conv.is_owned = false;
67575         LDKAnchorDescriptor b_conv;
67576         b_conv.inner = untag_ptr(b);
67577         b_conv.is_owned = ptr_is_owned(b);
67578         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
67579         b_conv.is_owned = false;
67580         jboolean ret_conv = AnchorDescriptor_eq(&a_conv, &b_conv);
67581         return ret_conv;
67582 }
67583
67584 int64_t  CS_LDK_AnchorDescriptor_previous_utxo(int64_t this_arg) {
67585         LDKAnchorDescriptor this_arg_conv;
67586         this_arg_conv.inner = untag_ptr(this_arg);
67587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67589         this_arg_conv.is_owned = false;
67590         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
67591         *ret_ref = AnchorDescriptor_previous_utxo(&this_arg_conv);
67592         return tag_ptr(ret_ref, true);
67593 }
67594
67595 int64_t  CS_LDK_AnchorDescriptor_unsigned_tx_input(int64_t this_arg) {
67596         LDKAnchorDescriptor this_arg_conv;
67597         this_arg_conv.inner = untag_ptr(this_arg);
67598         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67600         this_arg_conv.is_owned = false;
67601         LDKTxIn* ret_ref = MALLOC(sizeof(LDKTxIn), "LDKTxIn");
67602         *ret_ref = AnchorDescriptor_unsigned_tx_input(&this_arg_conv);
67603         return tag_ptr(ret_ref, true);
67604 }
67605
67606 int8_tArray  CS_LDK_AnchorDescriptor_witness_script(int64_t this_arg) {
67607         LDKAnchorDescriptor this_arg_conv;
67608         this_arg_conv.inner = untag_ptr(this_arg);
67609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67611         this_arg_conv.is_owned = false;
67612         LDKCVec_u8Z ret_var = AnchorDescriptor_witness_script(&this_arg_conv);
67613         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
67614         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
67615         CVec_u8Z_free(ret_var);
67616         return ret_arr;
67617 }
67618
67619 int8_tArray  CS_LDK_AnchorDescriptor_tx_input_witness(int64_t this_arg, int8_tArray signature) {
67620         LDKAnchorDescriptor this_arg_conv;
67621         this_arg_conv.inner = untag_ptr(this_arg);
67622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67624         this_arg_conv.is_owned = false;
67625         LDKECDSASignature signature_ref;
67626         CHECK(signature->arr_len == 64);
67627         memcpy(signature_ref.compact_form, signature->elems, 64); FREE(signature);
67628         LDKWitness ret_var = AnchorDescriptor_tx_input_witness(&this_arg_conv, signature_ref);
67629         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
67630         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
67631         Witness_free(ret_var);
67632         return ret_arr;
67633 }
67634
67635 int64_t  CS_LDK_AnchorDescriptor_derive_channel_signer(int64_t this_arg, int64_t signer_provider) {
67636         LDKAnchorDescriptor this_arg_conv;
67637         this_arg_conv.inner = untag_ptr(this_arg);
67638         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67640         this_arg_conv.is_owned = false;
67641         void* signer_provider_ptr = untag_ptr(signer_provider);
67642         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
67643         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
67644         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
67645         *ret_ret = AnchorDescriptor_derive_channel_signer(&this_arg_conv, signer_provider_conv);
67646         return tag_ptr(ret_ret, true);
67647 }
67648
67649 void  CS_LDK_BumpTransactionEvent_free(int64_t this_ptr) {
67650         if (!ptr_is_owned(this_ptr)) return;
67651         void* this_ptr_ptr = untag_ptr(this_ptr);
67652         CHECK_ACCESS(this_ptr_ptr);
67653         LDKBumpTransactionEvent this_ptr_conv = *(LDKBumpTransactionEvent*)(this_ptr_ptr);
67654         FREE(untag_ptr(this_ptr));
67655         BumpTransactionEvent_free(this_ptr_conv);
67656 }
67657
67658 static inline uint64_t BumpTransactionEvent_clone_ptr(LDKBumpTransactionEvent *NONNULL_PTR arg) {
67659         LDKBumpTransactionEvent *ret_copy = MALLOC(sizeof(LDKBumpTransactionEvent), "LDKBumpTransactionEvent");
67660         *ret_copy = BumpTransactionEvent_clone(arg);
67661         int64_t ret_ref = tag_ptr(ret_copy, true);
67662         return ret_ref;
67663 }
67664 int64_t  CS_LDK_BumpTransactionEvent_clone_ptr(int64_t arg) {
67665         LDKBumpTransactionEvent* arg_conv = (LDKBumpTransactionEvent*)untag_ptr(arg);
67666         int64_t ret_conv = BumpTransactionEvent_clone_ptr(arg_conv);
67667         return ret_conv;
67668 }
67669
67670 int64_t  CS_LDK_BumpTransactionEvent_clone(int64_t orig) {
67671         LDKBumpTransactionEvent* orig_conv = (LDKBumpTransactionEvent*)untag_ptr(orig);
67672         LDKBumpTransactionEvent *ret_copy = MALLOC(sizeof(LDKBumpTransactionEvent), "LDKBumpTransactionEvent");
67673         *ret_copy = BumpTransactionEvent_clone(orig_conv);
67674         int64_t ret_ref = tag_ptr(ret_copy, true);
67675         return ret_ref;
67676 }
67677
67678 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) {
67679         LDKThirtyTwoBytes claim_id_ref;
67680         CHECK(claim_id->arr_len == 32);
67681         memcpy(claim_id_ref.data, claim_id->elems, 32); FREE(claim_id);
67682         LDKTransaction commitment_tx_ref;
67683         commitment_tx_ref.datalen = commitment_tx->arr_len;
67684         commitment_tx_ref.data = MALLOC(commitment_tx_ref.datalen, "LDKTransaction Bytes");
67685         memcpy(commitment_tx_ref.data, commitment_tx->elems, commitment_tx_ref.datalen); FREE(commitment_tx);
67686         commitment_tx_ref.data_is_owned = true;
67687         LDKAnchorDescriptor anchor_descriptor_conv;
67688         anchor_descriptor_conv.inner = untag_ptr(anchor_descriptor);
67689         anchor_descriptor_conv.is_owned = ptr_is_owned(anchor_descriptor);
67690         CHECK_INNER_FIELD_ACCESS_OR_NULL(anchor_descriptor_conv);
67691         anchor_descriptor_conv = AnchorDescriptor_clone(&anchor_descriptor_conv);
67692         LDKCVec_HTLCOutputInCommitmentZ pending_htlcs_constr;
67693         pending_htlcs_constr.datalen = pending_htlcs->arr_len;
67694         if (pending_htlcs_constr.datalen > 0)
67695                 pending_htlcs_constr.data = MALLOC(pending_htlcs_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
67696         else
67697                 pending_htlcs_constr.data = NULL;
67698         int64_t* pending_htlcs_vals = pending_htlcs->elems;
67699         for (size_t y = 0; y < pending_htlcs_constr.datalen; y++) {
67700                 int64_t pending_htlcs_conv_24 = pending_htlcs_vals[y];
67701                 LDKHTLCOutputInCommitment pending_htlcs_conv_24_conv;
67702                 pending_htlcs_conv_24_conv.inner = untag_ptr(pending_htlcs_conv_24);
67703                 pending_htlcs_conv_24_conv.is_owned = ptr_is_owned(pending_htlcs_conv_24);
67704                 CHECK_INNER_FIELD_ACCESS_OR_NULL(pending_htlcs_conv_24_conv);
67705                 pending_htlcs_conv_24_conv = HTLCOutputInCommitment_clone(&pending_htlcs_conv_24_conv);
67706                 pending_htlcs_constr.data[y] = pending_htlcs_conv_24_conv;
67707         }
67708         FREE(pending_htlcs);
67709         LDKBumpTransactionEvent *ret_copy = MALLOC(sizeof(LDKBumpTransactionEvent), "LDKBumpTransactionEvent");
67710         *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);
67711         int64_t ret_ref = tag_ptr(ret_copy, true);
67712         return ret_ref;
67713 }
67714
67715 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) {
67716         LDKThirtyTwoBytes claim_id_ref;
67717         CHECK(claim_id->arr_len == 32);
67718         memcpy(claim_id_ref.data, claim_id->elems, 32); FREE(claim_id);
67719         LDKCVec_HTLCDescriptorZ htlc_descriptors_constr;
67720         htlc_descriptors_constr.datalen = htlc_descriptors->arr_len;
67721         if (htlc_descriptors_constr.datalen > 0)
67722                 htlc_descriptors_constr.data = MALLOC(htlc_descriptors_constr.datalen * sizeof(LDKHTLCDescriptor), "LDKCVec_HTLCDescriptorZ Elements");
67723         else
67724                 htlc_descriptors_constr.data = NULL;
67725         int64_t* htlc_descriptors_vals = htlc_descriptors->elems;
67726         for (size_t q = 0; q < htlc_descriptors_constr.datalen; q++) {
67727                 int64_t htlc_descriptors_conv_16 = htlc_descriptors_vals[q];
67728                 LDKHTLCDescriptor htlc_descriptors_conv_16_conv;
67729                 htlc_descriptors_conv_16_conv.inner = untag_ptr(htlc_descriptors_conv_16);
67730                 htlc_descriptors_conv_16_conv.is_owned = ptr_is_owned(htlc_descriptors_conv_16);
67731                 CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_descriptors_conv_16_conv);
67732                 htlc_descriptors_conv_16_conv = HTLCDescriptor_clone(&htlc_descriptors_conv_16_conv);
67733                 htlc_descriptors_constr.data[q] = htlc_descriptors_conv_16_conv;
67734         }
67735         FREE(htlc_descriptors);
67736         LDKBumpTransactionEvent *ret_copy = MALLOC(sizeof(LDKBumpTransactionEvent), "LDKBumpTransactionEvent");
67737         *ret_copy = BumpTransactionEvent_htlcresolution(claim_id_ref, target_feerate_sat_per_1000_weight, htlc_descriptors_constr, tx_lock_time);
67738         int64_t ret_ref = tag_ptr(ret_copy, true);
67739         return ret_ref;
67740 }
67741
67742 jboolean  CS_LDK_BumpTransactionEvent_eq(int64_t a, int64_t b) {
67743         LDKBumpTransactionEvent* a_conv = (LDKBumpTransactionEvent*)untag_ptr(a);
67744         LDKBumpTransactionEvent* b_conv = (LDKBumpTransactionEvent*)untag_ptr(b);
67745         jboolean ret_conv = BumpTransactionEvent_eq(a_conv, b_conv);
67746         return ret_conv;
67747 }
67748
67749 void  CS_LDK_Input_free(int64_t this_obj) {
67750         LDKInput this_obj_conv;
67751         this_obj_conv.inner = untag_ptr(this_obj);
67752         this_obj_conv.is_owned = ptr_is_owned(this_obj);
67753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
67754         Input_free(this_obj_conv);
67755 }
67756
67757 int64_t  CS_LDK_Input_get_outpoint(int64_t this_ptr) {
67758         LDKInput this_ptr_conv;
67759         this_ptr_conv.inner = untag_ptr(this_ptr);
67760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67762         this_ptr_conv.is_owned = false;
67763         LDKOutPoint ret_var = Input_get_outpoint(&this_ptr_conv);
67764         int64_t ret_ref = 0;
67765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67767         return ret_ref;
67768 }
67769
67770 void  CS_LDK_Input_set_outpoint(int64_t this_ptr, int64_t val) {
67771         LDKInput this_ptr_conv;
67772         this_ptr_conv.inner = untag_ptr(this_ptr);
67773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67775         this_ptr_conv.is_owned = false;
67776         LDKOutPoint val_conv;
67777         val_conv.inner = untag_ptr(val);
67778         val_conv.is_owned = ptr_is_owned(val);
67779         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
67780         val_conv = OutPoint_clone(&val_conv);
67781         Input_set_outpoint(&this_ptr_conv, val_conv);
67782 }
67783
67784 int64_t  CS_LDK_Input_get_previous_utxo(int64_t this_ptr) {
67785         LDKInput this_ptr_conv;
67786         this_ptr_conv.inner = untag_ptr(this_ptr);
67787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67789         this_ptr_conv.is_owned = false;
67790         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
67791         *ret_ref = Input_get_previous_utxo(&this_ptr_conv);
67792         return tag_ptr(ret_ref, true);
67793 }
67794
67795 void  CS_LDK_Input_set_previous_utxo(int64_t this_ptr, int64_t val) {
67796         LDKInput this_ptr_conv;
67797         this_ptr_conv.inner = untag_ptr(this_ptr);
67798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67800         this_ptr_conv.is_owned = false;
67801         void* val_ptr = untag_ptr(val);
67802         CHECK_ACCESS(val_ptr);
67803         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
67804         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
67805         Input_set_previous_utxo(&this_ptr_conv, val_conv);
67806 }
67807
67808 int64_t  CS_LDK_Input_get_satisfaction_weight(int64_t this_ptr) {
67809         LDKInput this_ptr_conv;
67810         this_ptr_conv.inner = untag_ptr(this_ptr);
67811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67813         this_ptr_conv.is_owned = false;
67814         int64_t ret_conv = Input_get_satisfaction_weight(&this_ptr_conv);
67815         return ret_conv;
67816 }
67817
67818 void  CS_LDK_Input_set_satisfaction_weight(int64_t this_ptr, int64_t val) {
67819         LDKInput this_ptr_conv;
67820         this_ptr_conv.inner = untag_ptr(this_ptr);
67821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67823         this_ptr_conv.is_owned = false;
67824         Input_set_satisfaction_weight(&this_ptr_conv, val);
67825 }
67826
67827 int64_t  CS_LDK_Input_new(int64_t outpoint_arg, int64_t previous_utxo_arg, int64_t satisfaction_weight_arg) {
67828         LDKOutPoint outpoint_arg_conv;
67829         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
67830         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
67831         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
67832         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
67833         void* previous_utxo_arg_ptr = untag_ptr(previous_utxo_arg);
67834         CHECK_ACCESS(previous_utxo_arg_ptr);
67835         LDKTxOut previous_utxo_arg_conv = *(LDKTxOut*)(previous_utxo_arg_ptr);
67836         previous_utxo_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(previous_utxo_arg));
67837         LDKInput ret_var = Input_new(outpoint_arg_conv, previous_utxo_arg_conv, satisfaction_weight_arg);
67838         int64_t ret_ref = 0;
67839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67840         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67841         return ret_ref;
67842 }
67843
67844 static inline uint64_t Input_clone_ptr(LDKInput *NONNULL_PTR arg) {
67845         LDKInput ret_var = Input_clone(arg);
67846         int64_t ret_ref = 0;
67847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67848         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67849         return ret_ref;
67850 }
67851 int64_t  CS_LDK_Input_clone_ptr(int64_t arg) {
67852         LDKInput arg_conv;
67853         arg_conv.inner = untag_ptr(arg);
67854         arg_conv.is_owned = ptr_is_owned(arg);
67855         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
67856         arg_conv.is_owned = false;
67857         int64_t ret_conv = Input_clone_ptr(&arg_conv);
67858         return ret_conv;
67859 }
67860
67861 int64_t  CS_LDK_Input_clone(int64_t orig) {
67862         LDKInput orig_conv;
67863         orig_conv.inner = untag_ptr(orig);
67864         orig_conv.is_owned = ptr_is_owned(orig);
67865         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
67866         orig_conv.is_owned = false;
67867         LDKInput ret_var = Input_clone(&orig_conv);
67868         int64_t ret_ref = 0;
67869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67870         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67871         return ret_ref;
67872 }
67873
67874 int64_t  CS_LDK_Input_hash(int64_t o) {
67875         LDKInput o_conv;
67876         o_conv.inner = untag_ptr(o);
67877         o_conv.is_owned = ptr_is_owned(o);
67878         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
67879         o_conv.is_owned = false;
67880         int64_t ret_conv = Input_hash(&o_conv);
67881         return ret_conv;
67882 }
67883
67884 jboolean  CS_LDK_Input_eq(int64_t a, int64_t b) {
67885         LDKInput a_conv;
67886         a_conv.inner = untag_ptr(a);
67887         a_conv.is_owned = ptr_is_owned(a);
67888         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
67889         a_conv.is_owned = false;
67890         LDKInput b_conv;
67891         b_conv.inner = untag_ptr(b);
67892         b_conv.is_owned = ptr_is_owned(b);
67893         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
67894         b_conv.is_owned = false;
67895         jboolean ret_conv = Input_eq(&a_conv, &b_conv);
67896         return ret_conv;
67897 }
67898
67899 void  CS_LDK_Utxo_free(int64_t this_obj) {
67900         LDKUtxo this_obj_conv;
67901         this_obj_conv.inner = untag_ptr(this_obj);
67902         this_obj_conv.is_owned = ptr_is_owned(this_obj);
67903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
67904         Utxo_free(this_obj_conv);
67905 }
67906
67907 int64_t  CS_LDK_Utxo_get_outpoint(int64_t this_ptr) {
67908         LDKUtxo this_ptr_conv;
67909         this_ptr_conv.inner = untag_ptr(this_ptr);
67910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67912         this_ptr_conv.is_owned = false;
67913         LDKOutPoint ret_var = Utxo_get_outpoint(&this_ptr_conv);
67914         int64_t ret_ref = 0;
67915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67916         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67917         return ret_ref;
67918 }
67919
67920 void  CS_LDK_Utxo_set_outpoint(int64_t this_ptr, int64_t val) {
67921         LDKUtxo this_ptr_conv;
67922         this_ptr_conv.inner = untag_ptr(this_ptr);
67923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67925         this_ptr_conv.is_owned = false;
67926         LDKOutPoint val_conv;
67927         val_conv.inner = untag_ptr(val);
67928         val_conv.is_owned = ptr_is_owned(val);
67929         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
67930         val_conv = OutPoint_clone(&val_conv);
67931         Utxo_set_outpoint(&this_ptr_conv, val_conv);
67932 }
67933
67934 int64_t  CS_LDK_Utxo_get_output(int64_t this_ptr) {
67935         LDKUtxo this_ptr_conv;
67936         this_ptr_conv.inner = untag_ptr(this_ptr);
67937         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67939         this_ptr_conv.is_owned = false;
67940         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
67941         *ret_ref = Utxo_get_output(&this_ptr_conv);
67942         return tag_ptr(ret_ref, true);
67943 }
67944
67945 void  CS_LDK_Utxo_set_output(int64_t this_ptr, int64_t val) {
67946         LDKUtxo this_ptr_conv;
67947         this_ptr_conv.inner = untag_ptr(this_ptr);
67948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67950         this_ptr_conv.is_owned = false;
67951         void* val_ptr = untag_ptr(val);
67952         CHECK_ACCESS(val_ptr);
67953         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
67954         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
67955         Utxo_set_output(&this_ptr_conv, val_conv);
67956 }
67957
67958 int64_t  CS_LDK_Utxo_get_satisfaction_weight(int64_t this_ptr) {
67959         LDKUtxo this_ptr_conv;
67960         this_ptr_conv.inner = untag_ptr(this_ptr);
67961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67963         this_ptr_conv.is_owned = false;
67964         int64_t ret_conv = Utxo_get_satisfaction_weight(&this_ptr_conv);
67965         return ret_conv;
67966 }
67967
67968 void  CS_LDK_Utxo_set_satisfaction_weight(int64_t this_ptr, int64_t val) {
67969         LDKUtxo this_ptr_conv;
67970         this_ptr_conv.inner = untag_ptr(this_ptr);
67971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67973         this_ptr_conv.is_owned = false;
67974         Utxo_set_satisfaction_weight(&this_ptr_conv, val);
67975 }
67976
67977 int64_t  CS_LDK_Utxo_new(int64_t outpoint_arg, int64_t output_arg, int64_t satisfaction_weight_arg) {
67978         LDKOutPoint outpoint_arg_conv;
67979         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
67980         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
67981         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
67982         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
67983         void* output_arg_ptr = untag_ptr(output_arg);
67984         CHECK_ACCESS(output_arg_ptr);
67985         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
67986         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
67987         LDKUtxo ret_var = Utxo_new(outpoint_arg_conv, output_arg_conv, satisfaction_weight_arg);
67988         int64_t ret_ref = 0;
67989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67991         return ret_ref;
67992 }
67993
67994 static inline uint64_t Utxo_clone_ptr(LDKUtxo *NONNULL_PTR arg) {
67995         LDKUtxo ret_var = Utxo_clone(arg);
67996         int64_t ret_ref = 0;
67997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67998         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67999         return ret_ref;
68000 }
68001 int64_t  CS_LDK_Utxo_clone_ptr(int64_t arg) {
68002         LDKUtxo arg_conv;
68003         arg_conv.inner = untag_ptr(arg);
68004         arg_conv.is_owned = ptr_is_owned(arg);
68005         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68006         arg_conv.is_owned = false;
68007         int64_t ret_conv = Utxo_clone_ptr(&arg_conv);
68008         return ret_conv;
68009 }
68010
68011 int64_t  CS_LDK_Utxo_clone(int64_t orig) {
68012         LDKUtxo orig_conv;
68013         orig_conv.inner = untag_ptr(orig);
68014         orig_conv.is_owned = ptr_is_owned(orig);
68015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68016         orig_conv.is_owned = false;
68017         LDKUtxo ret_var = Utxo_clone(&orig_conv);
68018         int64_t ret_ref = 0;
68019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68021         return ret_ref;
68022 }
68023
68024 int64_t  CS_LDK_Utxo_hash(int64_t o) {
68025         LDKUtxo o_conv;
68026         o_conv.inner = untag_ptr(o);
68027         o_conv.is_owned = ptr_is_owned(o);
68028         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
68029         o_conv.is_owned = false;
68030         int64_t ret_conv = Utxo_hash(&o_conv);
68031         return ret_conv;
68032 }
68033
68034 jboolean  CS_LDK_Utxo_eq(int64_t a, int64_t b) {
68035         LDKUtxo a_conv;
68036         a_conv.inner = untag_ptr(a);
68037         a_conv.is_owned = ptr_is_owned(a);
68038         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68039         a_conv.is_owned = false;
68040         LDKUtxo b_conv;
68041         b_conv.inner = untag_ptr(b);
68042         b_conv.is_owned = ptr_is_owned(b);
68043         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68044         b_conv.is_owned = false;
68045         jboolean ret_conv = Utxo_eq(&a_conv, &b_conv);
68046         return ret_conv;
68047 }
68048
68049 int64_t  CS_LDK_Utxo_new_p2pkh(int64_t outpoint, int64_t value, int8_tArray pubkey_hash) {
68050         LDKOutPoint outpoint_conv;
68051         outpoint_conv.inner = untag_ptr(outpoint);
68052         outpoint_conv.is_owned = ptr_is_owned(outpoint);
68053         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
68054         outpoint_conv = OutPoint_clone(&outpoint_conv);
68055         uint8_t pubkey_hash_arr[20];
68056         CHECK(pubkey_hash->arr_len == 20);
68057         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
68058         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
68059         LDKUtxo ret_var = Utxo_new_p2pkh(outpoint_conv, value, pubkey_hash_ref);
68060         int64_t ret_ref = 0;
68061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68062         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68063         return ret_ref;
68064 }
68065
68066 void  CS_LDK_CoinSelection_free(int64_t this_obj) {
68067         LDKCoinSelection this_obj_conv;
68068         this_obj_conv.inner = untag_ptr(this_obj);
68069         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68071         CoinSelection_free(this_obj_conv);
68072 }
68073
68074 int64_tArray  CS_LDK_CoinSelection_get_confirmed_utxos(int64_t this_ptr) {
68075         LDKCoinSelection this_ptr_conv;
68076         this_ptr_conv.inner = untag_ptr(this_ptr);
68077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68079         this_ptr_conv.is_owned = false;
68080         LDKCVec_UtxoZ ret_var = CoinSelection_get_confirmed_utxos(&this_ptr_conv);
68081         int64_tArray ret_arr = NULL;
68082         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
68083         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
68084         for (size_t g = 0; g < ret_var.datalen; g++) {
68085                 LDKUtxo ret_conv_6_var = ret_var.data[g];
68086                 int64_t ret_conv_6_ref = 0;
68087                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
68088                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
68089                 ret_arr_ptr[g] = ret_conv_6_ref;
68090         }
68091         
68092         FREE(ret_var.data);
68093         return ret_arr;
68094 }
68095
68096 void  CS_LDK_CoinSelection_set_confirmed_utxos(int64_t this_ptr, int64_tArray val) {
68097         LDKCoinSelection this_ptr_conv;
68098         this_ptr_conv.inner = untag_ptr(this_ptr);
68099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68101         this_ptr_conv.is_owned = false;
68102         LDKCVec_UtxoZ val_constr;
68103         val_constr.datalen = val->arr_len;
68104         if (val_constr.datalen > 0)
68105                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUtxo), "LDKCVec_UtxoZ Elements");
68106         else
68107                 val_constr.data = NULL;
68108         int64_t* val_vals = val->elems;
68109         for (size_t g = 0; g < val_constr.datalen; g++) {
68110                 int64_t val_conv_6 = val_vals[g];
68111                 LDKUtxo val_conv_6_conv;
68112                 val_conv_6_conv.inner = untag_ptr(val_conv_6);
68113                 val_conv_6_conv.is_owned = ptr_is_owned(val_conv_6);
68114                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_6_conv);
68115                 val_conv_6_conv = Utxo_clone(&val_conv_6_conv);
68116                 val_constr.data[g] = val_conv_6_conv;
68117         }
68118         FREE(val);
68119         CoinSelection_set_confirmed_utxos(&this_ptr_conv, val_constr);
68120 }
68121
68122 int64_t  CS_LDK_CoinSelection_get_change_output(int64_t this_ptr) {
68123         LDKCoinSelection this_ptr_conv;
68124         this_ptr_conv.inner = untag_ptr(this_ptr);
68125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68127         this_ptr_conv.is_owned = false;
68128         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
68129         *ret_copy = CoinSelection_get_change_output(&this_ptr_conv);
68130         int64_t ret_ref = tag_ptr(ret_copy, true);
68131         return ret_ref;
68132 }
68133
68134 void  CS_LDK_CoinSelection_set_change_output(int64_t this_ptr, int64_t val) {
68135         LDKCoinSelection this_ptr_conv;
68136         this_ptr_conv.inner = untag_ptr(this_ptr);
68137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68139         this_ptr_conv.is_owned = false;
68140         void* val_ptr = untag_ptr(val);
68141         CHECK_ACCESS(val_ptr);
68142         LDKCOption_TxOutZ val_conv = *(LDKCOption_TxOutZ*)(val_ptr);
68143         val_conv = COption_TxOutZ_clone((LDKCOption_TxOutZ*)untag_ptr(val));
68144         CoinSelection_set_change_output(&this_ptr_conv, val_conv);
68145 }
68146
68147 int64_t  CS_LDK_CoinSelection_new(int64_tArray confirmed_utxos_arg, int64_t change_output_arg) {
68148         LDKCVec_UtxoZ confirmed_utxos_arg_constr;
68149         confirmed_utxos_arg_constr.datalen = confirmed_utxos_arg->arr_len;
68150         if (confirmed_utxos_arg_constr.datalen > 0)
68151                 confirmed_utxos_arg_constr.data = MALLOC(confirmed_utxos_arg_constr.datalen * sizeof(LDKUtxo), "LDKCVec_UtxoZ Elements");
68152         else
68153                 confirmed_utxos_arg_constr.data = NULL;
68154         int64_t* confirmed_utxos_arg_vals = confirmed_utxos_arg->elems;
68155         for (size_t g = 0; g < confirmed_utxos_arg_constr.datalen; g++) {
68156                 int64_t confirmed_utxos_arg_conv_6 = confirmed_utxos_arg_vals[g];
68157                 LDKUtxo confirmed_utxos_arg_conv_6_conv;
68158                 confirmed_utxos_arg_conv_6_conv.inner = untag_ptr(confirmed_utxos_arg_conv_6);
68159                 confirmed_utxos_arg_conv_6_conv.is_owned = ptr_is_owned(confirmed_utxos_arg_conv_6);
68160                 CHECK_INNER_FIELD_ACCESS_OR_NULL(confirmed_utxos_arg_conv_6_conv);
68161                 confirmed_utxos_arg_conv_6_conv = Utxo_clone(&confirmed_utxos_arg_conv_6_conv);
68162                 confirmed_utxos_arg_constr.data[g] = confirmed_utxos_arg_conv_6_conv;
68163         }
68164         FREE(confirmed_utxos_arg);
68165         void* change_output_arg_ptr = untag_ptr(change_output_arg);
68166         CHECK_ACCESS(change_output_arg_ptr);
68167         LDKCOption_TxOutZ change_output_arg_conv = *(LDKCOption_TxOutZ*)(change_output_arg_ptr);
68168         change_output_arg_conv = COption_TxOutZ_clone((LDKCOption_TxOutZ*)untag_ptr(change_output_arg));
68169         LDKCoinSelection ret_var = CoinSelection_new(confirmed_utxos_arg_constr, change_output_arg_conv);
68170         int64_t ret_ref = 0;
68171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68173         return ret_ref;
68174 }
68175
68176 static inline uint64_t CoinSelection_clone_ptr(LDKCoinSelection *NONNULL_PTR arg) {
68177         LDKCoinSelection ret_var = CoinSelection_clone(arg);
68178         int64_t ret_ref = 0;
68179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68180         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68181         return ret_ref;
68182 }
68183 int64_t  CS_LDK_CoinSelection_clone_ptr(int64_t arg) {
68184         LDKCoinSelection arg_conv;
68185         arg_conv.inner = untag_ptr(arg);
68186         arg_conv.is_owned = ptr_is_owned(arg);
68187         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68188         arg_conv.is_owned = false;
68189         int64_t ret_conv = CoinSelection_clone_ptr(&arg_conv);
68190         return ret_conv;
68191 }
68192
68193 int64_t  CS_LDK_CoinSelection_clone(int64_t orig) {
68194         LDKCoinSelection orig_conv;
68195         orig_conv.inner = untag_ptr(orig);
68196         orig_conv.is_owned = ptr_is_owned(orig);
68197         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68198         orig_conv.is_owned = false;
68199         LDKCoinSelection ret_var = CoinSelection_clone(&orig_conv);
68200         int64_t ret_ref = 0;
68201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68203         return ret_ref;
68204 }
68205
68206 void  CS_LDK_CoinSelectionSource_free(int64_t this_ptr) {
68207         if (!ptr_is_owned(this_ptr)) return;
68208         void* this_ptr_ptr = untag_ptr(this_ptr);
68209         CHECK_ACCESS(this_ptr_ptr);
68210         LDKCoinSelectionSource this_ptr_conv = *(LDKCoinSelectionSource*)(this_ptr_ptr);
68211         FREE(untag_ptr(this_ptr));
68212         CoinSelectionSource_free(this_ptr_conv);
68213 }
68214
68215 void  CS_LDK_WalletSource_free(int64_t this_ptr) {
68216         if (!ptr_is_owned(this_ptr)) return;
68217         void* this_ptr_ptr = untag_ptr(this_ptr);
68218         CHECK_ACCESS(this_ptr_ptr);
68219         LDKWalletSource this_ptr_conv = *(LDKWalletSource*)(this_ptr_ptr);
68220         FREE(untag_ptr(this_ptr));
68221         WalletSource_free(this_ptr_conv);
68222 }
68223
68224 void  CS_LDK_Wallet_free(int64_t this_obj) {
68225         LDKWallet this_obj_conv;
68226         this_obj_conv.inner = untag_ptr(this_obj);
68227         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68229         Wallet_free(this_obj_conv);
68230 }
68231
68232 int64_t  CS_LDK_Wallet_new(int64_t source, int64_t logger) {
68233         void* source_ptr = untag_ptr(source);
68234         CHECK_ACCESS(source_ptr);
68235         LDKWalletSource source_conv = *(LDKWalletSource*)(source_ptr);
68236         if (source_conv.free == LDKWalletSource_JCalls_free) {
68237                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68238                 LDKWalletSource_JCalls_cloned(&source_conv);
68239         }
68240         void* logger_ptr = untag_ptr(logger);
68241         CHECK_ACCESS(logger_ptr);
68242         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
68243         if (logger_conv.free == LDKLogger_JCalls_free) {
68244                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68245                 LDKLogger_JCalls_cloned(&logger_conv);
68246         }
68247         LDKWallet ret_var = Wallet_new(source_conv, logger_conv);
68248         int64_t ret_ref = 0;
68249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68251         return ret_ref;
68252 }
68253
68254 int64_t  CS_LDK_Wallet_as_CoinSelectionSource(int64_t this_arg) {
68255         LDKWallet this_arg_conv;
68256         this_arg_conv.inner = untag_ptr(this_arg);
68257         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68259         this_arg_conv.is_owned = false;
68260         LDKCoinSelectionSource* ret_ret = MALLOC(sizeof(LDKCoinSelectionSource), "LDKCoinSelectionSource");
68261         *ret_ret = Wallet_as_CoinSelectionSource(&this_arg_conv);
68262         return tag_ptr(ret_ret, true);
68263 }
68264
68265 void  CS_LDK_BumpTransactionEventHandler_free(int64_t this_obj) {
68266         LDKBumpTransactionEventHandler this_obj_conv;
68267         this_obj_conv.inner = untag_ptr(this_obj);
68268         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68270         BumpTransactionEventHandler_free(this_obj_conv);
68271 }
68272
68273 int64_t  CS_LDK_BumpTransactionEventHandler_new(int64_t broadcaster, int64_t utxo_source, int64_t signer_provider, int64_t logger) {
68274         void* broadcaster_ptr = untag_ptr(broadcaster);
68275         CHECK_ACCESS(broadcaster_ptr);
68276         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
68277         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
68278                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68279                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
68280         }
68281         void* utxo_source_ptr = untag_ptr(utxo_source);
68282         CHECK_ACCESS(utxo_source_ptr);
68283         LDKCoinSelectionSource utxo_source_conv = *(LDKCoinSelectionSource*)(utxo_source_ptr);
68284         if (utxo_source_conv.free == LDKCoinSelectionSource_JCalls_free) {
68285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68286                 LDKCoinSelectionSource_JCalls_cloned(&utxo_source_conv);
68287         }
68288         void* signer_provider_ptr = untag_ptr(signer_provider);
68289         CHECK_ACCESS(signer_provider_ptr);
68290         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
68291         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
68292                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68293                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
68294         }
68295         void* logger_ptr = untag_ptr(logger);
68296         CHECK_ACCESS(logger_ptr);
68297         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
68298         if (logger_conv.free == LDKLogger_JCalls_free) {
68299                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68300                 LDKLogger_JCalls_cloned(&logger_conv);
68301         }
68302         LDKBumpTransactionEventHandler ret_var = BumpTransactionEventHandler_new(broadcaster_conv, utxo_source_conv, signer_provider_conv, logger_conv);
68303         int64_t ret_ref = 0;
68304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68305         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68306         return ret_ref;
68307 }
68308
68309 void  CS_LDK_BumpTransactionEventHandler_handle_event(int64_t this_arg, int64_t event) {
68310         LDKBumpTransactionEventHandler this_arg_conv;
68311         this_arg_conv.inner = untag_ptr(this_arg);
68312         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68314         this_arg_conv.is_owned = false;
68315         LDKBumpTransactionEvent* event_conv = (LDKBumpTransactionEvent*)untag_ptr(event);
68316         BumpTransactionEventHandler_handle_event(&this_arg_conv, event_conv);
68317 }
68318
68319 void  CS_LDK_FilesystemStore_free(int64_t this_obj) {
68320         LDKFilesystemStore this_obj_conv;
68321         this_obj_conv.inner = untag_ptr(this_obj);
68322         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68324         FilesystemStore_free(this_obj_conv);
68325 }
68326
68327 int64_t  CS_LDK_FilesystemStore_new(jstring data_dir) {
68328         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
68329         LDKFilesystemStore ret_var = FilesystemStore_new(data_dir_conv);
68330         int64_t ret_ref = 0;
68331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68332         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68333         return ret_ref;
68334 }
68335
68336 jstring  CS_LDK_FilesystemStore_get_data_dir(int64_t this_arg) {
68337         LDKFilesystemStore this_arg_conv;
68338         this_arg_conv.inner = untag_ptr(this_arg);
68339         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68341         this_arg_conv.is_owned = false;
68342         LDKStr ret_str = FilesystemStore_get_data_dir(&this_arg_conv);
68343         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
68344         Str_free(ret_str);
68345         return ret_conv;
68346 }
68347
68348 int64_t  CS_LDK_FilesystemStore_as_KVStore(int64_t this_arg) {
68349         LDKFilesystemStore this_arg_conv;
68350         this_arg_conv.inner = untag_ptr(this_arg);
68351         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68353         this_arg_conv.is_owned = false;
68354         LDKKVStore* ret_ret = MALLOC(sizeof(LDKKVStore), "LDKKVStore");
68355         *ret_ret = FilesystemStore_as_KVStore(&this_arg_conv);
68356         return tag_ptr(ret_ret, true);
68357 }
68358
68359 void  CS_LDK_BackgroundProcessor_free(int64_t this_obj) {
68360         LDKBackgroundProcessor this_obj_conv;
68361         this_obj_conv.inner = untag_ptr(this_obj);
68362         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68364         BackgroundProcessor_free(this_obj_conv);
68365 }
68366
68367 void  CS_LDK_GossipSync_free(int64_t this_ptr) {
68368         if (!ptr_is_owned(this_ptr)) return;
68369         void* this_ptr_ptr = untag_ptr(this_ptr);
68370         CHECK_ACCESS(this_ptr_ptr);
68371         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
68372         FREE(untag_ptr(this_ptr));
68373         GossipSync_free(this_ptr_conv);
68374 }
68375
68376 int64_t  CS_LDK_GossipSync_p2_p(int64_t a) {
68377         LDKP2PGossipSync a_conv;
68378         a_conv.inner = untag_ptr(a);
68379         a_conv.is_owned = ptr_is_owned(a);
68380         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68381         a_conv.is_owned = false;
68382         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
68383         *ret_copy = GossipSync_p2_p(&a_conv);
68384         int64_t ret_ref = tag_ptr(ret_copy, true);
68385         return ret_ref;
68386 }
68387
68388 int64_t  CS_LDK_GossipSync_rapid(int64_t a) {
68389         LDKRapidGossipSync a_conv;
68390         a_conv.inner = untag_ptr(a);
68391         a_conv.is_owned = ptr_is_owned(a);
68392         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68393         a_conv.is_owned = false;
68394         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
68395         *ret_copy = GossipSync_rapid(&a_conv);
68396         int64_t ret_ref = tag_ptr(ret_copy, true);
68397         return ret_ref;
68398 }
68399
68400 int64_t  CS_LDK_GossipSync_none() {
68401         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
68402         *ret_copy = GossipSync_none();
68403         int64_t ret_ref = tag_ptr(ret_copy, true);
68404         return ret_ref;
68405 }
68406
68407 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) {
68408         void* persister_ptr = untag_ptr(persister);
68409         CHECK_ACCESS(persister_ptr);
68410         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
68411         if (persister_conv.free == LDKPersister_JCalls_free) {
68412                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68413                 LDKPersister_JCalls_cloned(&persister_conv);
68414         }
68415         void* event_handler_ptr = untag_ptr(event_handler);
68416         CHECK_ACCESS(event_handler_ptr);
68417         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
68418         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
68419                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68420                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
68421         }
68422         LDKChainMonitor chain_monitor_conv;
68423         chain_monitor_conv.inner = untag_ptr(chain_monitor);
68424         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
68425         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
68426         chain_monitor_conv.is_owned = false;
68427         LDKChannelManager channel_manager_conv;
68428         channel_manager_conv.inner = untag_ptr(channel_manager);
68429         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
68430         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
68431         channel_manager_conv.is_owned = false;
68432         void* gossip_sync_ptr = untag_ptr(gossip_sync);
68433         CHECK_ACCESS(gossip_sync_ptr);
68434         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
68435         // WARNING: we may need a move here but no clone is available for LDKGossipSync
68436         LDKPeerManager peer_manager_conv;
68437         peer_manager_conv.inner = untag_ptr(peer_manager);
68438         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
68439         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
68440         peer_manager_conv.is_owned = false;
68441         void* logger_ptr = untag_ptr(logger);
68442         CHECK_ACCESS(logger_ptr);
68443         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
68444         if (logger_conv.free == LDKLogger_JCalls_free) {
68445                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68446                 LDKLogger_JCalls_cloned(&logger_conv);
68447         }
68448         void* scorer_ptr = untag_ptr(scorer);
68449         CHECK_ACCESS(scorer_ptr);
68450         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
68451         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
68452         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
68453                 // Manually implement clone for Java trait instances
68454                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
68455                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68456                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
68457                 }
68458         }
68459         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);
68460         int64_t ret_ref = 0;
68461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68463         return ret_ref;
68464 }
68465
68466 int64_t  CS_LDK_BackgroundProcessor_join(int64_t this_arg) {
68467         LDKBackgroundProcessor this_arg_conv;
68468         this_arg_conv.inner = untag_ptr(this_arg);
68469         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68471         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
68472         
68473         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
68474         *ret_conv = BackgroundProcessor_join(this_arg_conv);
68475         return tag_ptr(ret_conv, true);
68476 }
68477
68478 int64_t  CS_LDK_BackgroundProcessor_stop(int64_t this_arg) {
68479         LDKBackgroundProcessor this_arg_conv;
68480         this_arg_conv.inner = untag_ptr(this_arg);
68481         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68483         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
68484         
68485         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
68486         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
68487         return tag_ptr(ret_conv, true);
68488 }
68489
68490 void  CS_LDK_Bolt11ParseError_free(int64_t this_ptr) {
68491         if (!ptr_is_owned(this_ptr)) return;
68492         void* this_ptr_ptr = untag_ptr(this_ptr);
68493         CHECK_ACCESS(this_ptr_ptr);
68494         LDKBolt11ParseError this_ptr_conv = *(LDKBolt11ParseError*)(this_ptr_ptr);
68495         FREE(untag_ptr(this_ptr));
68496         Bolt11ParseError_free(this_ptr_conv);
68497 }
68498
68499 static inline uint64_t Bolt11ParseError_clone_ptr(LDKBolt11ParseError *NONNULL_PTR arg) {
68500         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68501         *ret_copy = Bolt11ParseError_clone(arg);
68502         int64_t ret_ref = tag_ptr(ret_copy, true);
68503         return ret_ref;
68504 }
68505 int64_t  CS_LDK_Bolt11ParseError_clone_ptr(int64_t arg) {
68506         LDKBolt11ParseError* arg_conv = (LDKBolt11ParseError*)untag_ptr(arg);
68507         int64_t ret_conv = Bolt11ParseError_clone_ptr(arg_conv);
68508         return ret_conv;
68509 }
68510
68511 int64_t  CS_LDK_Bolt11ParseError_clone(int64_t orig) {
68512         LDKBolt11ParseError* orig_conv = (LDKBolt11ParseError*)untag_ptr(orig);
68513         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68514         *ret_copy = Bolt11ParseError_clone(orig_conv);
68515         int64_t ret_ref = tag_ptr(ret_copy, true);
68516         return ret_ref;
68517 }
68518
68519 int64_t  CS_LDK_Bolt11ParseError_bech32_error(int64_t a) {
68520         void* a_ptr = untag_ptr(a);
68521         CHECK_ACCESS(a_ptr);
68522         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
68523         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
68524         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68525         *ret_copy = Bolt11ParseError_bech32_error(a_conv);
68526         int64_t ret_ref = tag_ptr(ret_copy, true);
68527         return ret_ref;
68528 }
68529
68530 int64_t  CS_LDK_Bolt11ParseError_parse_amount_error(int32_t a) {
68531         
68532         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68533         *ret_copy = Bolt11ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
68534         int64_t ret_ref = tag_ptr(ret_copy, true);
68535         return ret_ref;
68536 }
68537
68538 int64_t  CS_LDK_Bolt11ParseError_malformed_signature(int32_t a) {
68539         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_cs(a);
68540         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68541         *ret_copy = Bolt11ParseError_malformed_signature(a_conv);
68542         int64_t ret_ref = tag_ptr(ret_copy, true);
68543         return ret_ref;
68544 }
68545
68546 int64_t  CS_LDK_Bolt11ParseError_bad_prefix() {
68547         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68548         *ret_copy = Bolt11ParseError_bad_prefix();
68549         int64_t ret_ref = tag_ptr(ret_copy, true);
68550         return ret_ref;
68551 }
68552
68553 int64_t  CS_LDK_Bolt11ParseError_unknown_currency() {
68554         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68555         *ret_copy = Bolt11ParseError_unknown_currency();
68556         int64_t ret_ref = tag_ptr(ret_copy, true);
68557         return ret_ref;
68558 }
68559
68560 int64_t  CS_LDK_Bolt11ParseError_unknown_si_prefix() {
68561         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68562         *ret_copy = Bolt11ParseError_unknown_si_prefix();
68563         int64_t ret_ref = tag_ptr(ret_copy, true);
68564         return ret_ref;
68565 }
68566
68567 int64_t  CS_LDK_Bolt11ParseError_malformed_hrp() {
68568         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68569         *ret_copy = Bolt11ParseError_malformed_hrp();
68570         int64_t ret_ref = tag_ptr(ret_copy, true);
68571         return ret_ref;
68572 }
68573
68574 int64_t  CS_LDK_Bolt11ParseError_too_short_data_part() {
68575         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68576         *ret_copy = Bolt11ParseError_too_short_data_part();
68577         int64_t ret_ref = tag_ptr(ret_copy, true);
68578         return ret_ref;
68579 }
68580
68581 int64_t  CS_LDK_Bolt11ParseError_unexpected_end_of_tagged_fields() {
68582         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68583         *ret_copy = Bolt11ParseError_unexpected_end_of_tagged_fields();
68584         int64_t ret_ref = tag_ptr(ret_copy, true);
68585         return ret_ref;
68586 }
68587
68588 int64_t  CS_LDK_Bolt11ParseError_description_decode_error(int32_t a) {
68589         
68590         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68591         *ret_copy = Bolt11ParseError_description_decode_error((LDKError){ ._dummy = 0 });
68592         int64_t ret_ref = tag_ptr(ret_copy, true);
68593         return ret_ref;
68594 }
68595
68596 int64_t  CS_LDK_Bolt11ParseError_padding_error() {
68597         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68598         *ret_copy = Bolt11ParseError_padding_error();
68599         int64_t ret_ref = tag_ptr(ret_copy, true);
68600         return ret_ref;
68601 }
68602
68603 int64_t  CS_LDK_Bolt11ParseError_integer_overflow_error() {
68604         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68605         *ret_copy = Bolt11ParseError_integer_overflow_error();
68606         int64_t ret_ref = tag_ptr(ret_copy, true);
68607         return ret_ref;
68608 }
68609
68610 int64_t  CS_LDK_Bolt11ParseError_invalid_seg_wit_program_length() {
68611         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68612         *ret_copy = Bolt11ParseError_invalid_seg_wit_program_length();
68613         int64_t ret_ref = tag_ptr(ret_copy, true);
68614         return ret_ref;
68615 }
68616
68617 int64_t  CS_LDK_Bolt11ParseError_invalid_pub_key_hash_length() {
68618         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68619         *ret_copy = Bolt11ParseError_invalid_pub_key_hash_length();
68620         int64_t ret_ref = tag_ptr(ret_copy, true);
68621         return ret_ref;
68622 }
68623
68624 int64_t  CS_LDK_Bolt11ParseError_invalid_script_hash_length() {
68625         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68626         *ret_copy = Bolt11ParseError_invalid_script_hash_length();
68627         int64_t ret_ref = tag_ptr(ret_copy, true);
68628         return ret_ref;
68629 }
68630
68631 int64_t  CS_LDK_Bolt11ParseError_invalid_recovery_id() {
68632         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68633         *ret_copy = Bolt11ParseError_invalid_recovery_id();
68634         int64_t ret_ref = tag_ptr(ret_copy, true);
68635         return ret_ref;
68636 }
68637
68638 int64_t  CS_LDK_Bolt11ParseError_invalid_slice_length(jstring a) {
68639         LDKStr a_conv = str_ref_to_owned_c(a);
68640         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68641         *ret_copy = Bolt11ParseError_invalid_slice_length(a_conv);
68642         int64_t ret_ref = tag_ptr(ret_copy, true);
68643         return ret_ref;
68644 }
68645
68646 int64_t  CS_LDK_Bolt11ParseError_skip() {
68647         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68648         *ret_copy = Bolt11ParseError_skip();
68649         int64_t ret_ref = tag_ptr(ret_copy, true);
68650         return ret_ref;
68651 }
68652
68653 jboolean  CS_LDK_Bolt11ParseError_eq(int64_t a, int64_t b) {
68654         LDKBolt11ParseError* a_conv = (LDKBolt11ParseError*)untag_ptr(a);
68655         LDKBolt11ParseError* b_conv = (LDKBolt11ParseError*)untag_ptr(b);
68656         jboolean ret_conv = Bolt11ParseError_eq(a_conv, b_conv);
68657         return ret_conv;
68658 }
68659
68660 void  CS_LDK_ParseOrSemanticError_free(int64_t this_ptr) {
68661         if (!ptr_is_owned(this_ptr)) return;
68662         void* this_ptr_ptr = untag_ptr(this_ptr);
68663         CHECK_ACCESS(this_ptr_ptr);
68664         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
68665         FREE(untag_ptr(this_ptr));
68666         ParseOrSemanticError_free(this_ptr_conv);
68667 }
68668
68669 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
68670         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
68671         *ret_copy = ParseOrSemanticError_clone(arg);
68672         int64_t ret_ref = tag_ptr(ret_copy, true);
68673         return ret_ref;
68674 }
68675 int64_t  CS_LDK_ParseOrSemanticError_clone_ptr(int64_t arg) {
68676         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
68677         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
68678         return ret_conv;
68679 }
68680
68681 int64_t  CS_LDK_ParseOrSemanticError_clone(int64_t orig) {
68682         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
68683         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
68684         *ret_copy = ParseOrSemanticError_clone(orig_conv);
68685         int64_t ret_ref = tag_ptr(ret_copy, true);
68686         return ret_ref;
68687 }
68688
68689 int64_t  CS_LDK_ParseOrSemanticError_parse_error(int64_t a) {
68690         void* a_ptr = untag_ptr(a);
68691         CHECK_ACCESS(a_ptr);
68692         LDKBolt11ParseError a_conv = *(LDKBolt11ParseError*)(a_ptr);
68693         a_conv = Bolt11ParseError_clone((LDKBolt11ParseError*)untag_ptr(a));
68694         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
68695         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
68696         int64_t ret_ref = tag_ptr(ret_copy, true);
68697         return ret_ref;
68698 }
68699
68700 int64_t  CS_LDK_ParseOrSemanticError_semantic_error(int32_t a) {
68701         LDKBolt11SemanticError a_conv = LDKBolt11SemanticError_from_cs(a);
68702         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
68703         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
68704         int64_t ret_ref = tag_ptr(ret_copy, true);
68705         return ret_ref;
68706 }
68707
68708 jboolean  CS_LDK_ParseOrSemanticError_eq(int64_t a, int64_t b) {
68709         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
68710         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
68711         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
68712         return ret_conv;
68713 }
68714
68715 void  CS_LDK_Bolt11Invoice_free(int64_t this_obj) {
68716         LDKBolt11Invoice this_obj_conv;
68717         this_obj_conv.inner = untag_ptr(this_obj);
68718         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68720         Bolt11Invoice_free(this_obj_conv);
68721 }
68722
68723 jboolean  CS_LDK_Bolt11Invoice_eq(int64_t a, int64_t b) {
68724         LDKBolt11Invoice a_conv;
68725         a_conv.inner = untag_ptr(a);
68726         a_conv.is_owned = ptr_is_owned(a);
68727         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68728         a_conv.is_owned = false;
68729         LDKBolt11Invoice b_conv;
68730         b_conv.inner = untag_ptr(b);
68731         b_conv.is_owned = ptr_is_owned(b);
68732         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68733         b_conv.is_owned = false;
68734         jboolean ret_conv = Bolt11Invoice_eq(&a_conv, &b_conv);
68735         return ret_conv;
68736 }
68737
68738 static inline uint64_t Bolt11Invoice_clone_ptr(LDKBolt11Invoice *NONNULL_PTR arg) {
68739         LDKBolt11Invoice ret_var = Bolt11Invoice_clone(arg);
68740         int64_t ret_ref = 0;
68741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68742         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68743         return ret_ref;
68744 }
68745 int64_t  CS_LDK_Bolt11Invoice_clone_ptr(int64_t arg) {
68746         LDKBolt11Invoice arg_conv;
68747         arg_conv.inner = untag_ptr(arg);
68748         arg_conv.is_owned = ptr_is_owned(arg);
68749         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68750         arg_conv.is_owned = false;
68751         int64_t ret_conv = Bolt11Invoice_clone_ptr(&arg_conv);
68752         return ret_conv;
68753 }
68754
68755 int64_t  CS_LDK_Bolt11Invoice_clone(int64_t orig) {
68756         LDKBolt11Invoice orig_conv;
68757         orig_conv.inner = untag_ptr(orig);
68758         orig_conv.is_owned = ptr_is_owned(orig);
68759         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68760         orig_conv.is_owned = false;
68761         LDKBolt11Invoice ret_var = Bolt11Invoice_clone(&orig_conv);
68762         int64_t ret_ref = 0;
68763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68765         return ret_ref;
68766 }
68767
68768 int64_t  CS_LDK_Bolt11Invoice_hash(int64_t o) {
68769         LDKBolt11Invoice o_conv;
68770         o_conv.inner = untag_ptr(o);
68771         o_conv.is_owned = ptr_is_owned(o);
68772         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
68773         o_conv.is_owned = false;
68774         int64_t ret_conv = Bolt11Invoice_hash(&o_conv);
68775         return ret_conv;
68776 }
68777
68778 void  CS_LDK_SignedRawBolt11Invoice_free(int64_t this_obj) {
68779         LDKSignedRawBolt11Invoice this_obj_conv;
68780         this_obj_conv.inner = untag_ptr(this_obj);
68781         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68783         SignedRawBolt11Invoice_free(this_obj_conv);
68784 }
68785
68786 jboolean  CS_LDK_SignedRawBolt11Invoice_eq(int64_t a, int64_t b) {
68787         LDKSignedRawBolt11Invoice a_conv;
68788         a_conv.inner = untag_ptr(a);
68789         a_conv.is_owned = ptr_is_owned(a);
68790         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68791         a_conv.is_owned = false;
68792         LDKSignedRawBolt11Invoice b_conv;
68793         b_conv.inner = untag_ptr(b);
68794         b_conv.is_owned = ptr_is_owned(b);
68795         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68796         b_conv.is_owned = false;
68797         jboolean ret_conv = SignedRawBolt11Invoice_eq(&a_conv, &b_conv);
68798         return ret_conv;
68799 }
68800
68801 static inline uint64_t SignedRawBolt11Invoice_clone_ptr(LDKSignedRawBolt11Invoice *NONNULL_PTR arg) {
68802         LDKSignedRawBolt11Invoice ret_var = SignedRawBolt11Invoice_clone(arg);
68803         int64_t ret_ref = 0;
68804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68806         return ret_ref;
68807 }
68808 int64_t  CS_LDK_SignedRawBolt11Invoice_clone_ptr(int64_t arg) {
68809         LDKSignedRawBolt11Invoice arg_conv;
68810         arg_conv.inner = untag_ptr(arg);
68811         arg_conv.is_owned = ptr_is_owned(arg);
68812         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68813         arg_conv.is_owned = false;
68814         int64_t ret_conv = SignedRawBolt11Invoice_clone_ptr(&arg_conv);
68815         return ret_conv;
68816 }
68817
68818 int64_t  CS_LDK_SignedRawBolt11Invoice_clone(int64_t orig) {
68819         LDKSignedRawBolt11Invoice orig_conv;
68820         orig_conv.inner = untag_ptr(orig);
68821         orig_conv.is_owned = ptr_is_owned(orig);
68822         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68823         orig_conv.is_owned = false;
68824         LDKSignedRawBolt11Invoice ret_var = SignedRawBolt11Invoice_clone(&orig_conv);
68825         int64_t ret_ref = 0;
68826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68828         return ret_ref;
68829 }
68830
68831 int64_t  CS_LDK_SignedRawBolt11Invoice_hash(int64_t o) {
68832         LDKSignedRawBolt11Invoice o_conv;
68833         o_conv.inner = untag_ptr(o);
68834         o_conv.is_owned = ptr_is_owned(o);
68835         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
68836         o_conv.is_owned = false;
68837         int64_t ret_conv = SignedRawBolt11Invoice_hash(&o_conv);
68838         return ret_conv;
68839 }
68840
68841 void  CS_LDK_RawBolt11Invoice_free(int64_t this_obj) {
68842         LDKRawBolt11Invoice this_obj_conv;
68843         this_obj_conv.inner = untag_ptr(this_obj);
68844         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68846         RawBolt11Invoice_free(this_obj_conv);
68847 }
68848
68849 int64_t  CS_LDK_RawBolt11Invoice_get_data(int64_t this_ptr) {
68850         LDKRawBolt11Invoice this_ptr_conv;
68851         this_ptr_conv.inner = untag_ptr(this_ptr);
68852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68854         this_ptr_conv.is_owned = false;
68855         LDKRawDataPart ret_var = RawBolt11Invoice_get_data(&this_ptr_conv);
68856         int64_t ret_ref = 0;
68857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68859         return ret_ref;
68860 }
68861
68862 void  CS_LDK_RawBolt11Invoice_set_data(int64_t this_ptr, int64_t val) {
68863         LDKRawBolt11Invoice this_ptr_conv;
68864         this_ptr_conv.inner = untag_ptr(this_ptr);
68865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68867         this_ptr_conv.is_owned = false;
68868         LDKRawDataPart val_conv;
68869         val_conv.inner = untag_ptr(val);
68870         val_conv.is_owned = ptr_is_owned(val);
68871         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
68872         val_conv = RawDataPart_clone(&val_conv);
68873         RawBolt11Invoice_set_data(&this_ptr_conv, val_conv);
68874 }
68875
68876 jboolean  CS_LDK_RawBolt11Invoice_eq(int64_t a, int64_t b) {
68877         LDKRawBolt11Invoice a_conv;
68878         a_conv.inner = untag_ptr(a);
68879         a_conv.is_owned = ptr_is_owned(a);
68880         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68881         a_conv.is_owned = false;
68882         LDKRawBolt11Invoice b_conv;
68883         b_conv.inner = untag_ptr(b);
68884         b_conv.is_owned = ptr_is_owned(b);
68885         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68886         b_conv.is_owned = false;
68887         jboolean ret_conv = RawBolt11Invoice_eq(&a_conv, &b_conv);
68888         return ret_conv;
68889 }
68890
68891 static inline uint64_t RawBolt11Invoice_clone_ptr(LDKRawBolt11Invoice *NONNULL_PTR arg) {
68892         LDKRawBolt11Invoice ret_var = RawBolt11Invoice_clone(arg);
68893         int64_t ret_ref = 0;
68894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68896         return ret_ref;
68897 }
68898 int64_t  CS_LDK_RawBolt11Invoice_clone_ptr(int64_t arg) {
68899         LDKRawBolt11Invoice arg_conv;
68900         arg_conv.inner = untag_ptr(arg);
68901         arg_conv.is_owned = ptr_is_owned(arg);
68902         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68903         arg_conv.is_owned = false;
68904         int64_t ret_conv = RawBolt11Invoice_clone_ptr(&arg_conv);
68905         return ret_conv;
68906 }
68907
68908 int64_t  CS_LDK_RawBolt11Invoice_clone(int64_t orig) {
68909         LDKRawBolt11Invoice orig_conv;
68910         orig_conv.inner = untag_ptr(orig);
68911         orig_conv.is_owned = ptr_is_owned(orig);
68912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68913         orig_conv.is_owned = false;
68914         LDKRawBolt11Invoice ret_var = RawBolt11Invoice_clone(&orig_conv);
68915         int64_t ret_ref = 0;
68916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68918         return ret_ref;
68919 }
68920
68921 int64_t  CS_LDK_RawBolt11Invoice_hash(int64_t o) {
68922         LDKRawBolt11Invoice o_conv;
68923         o_conv.inner = untag_ptr(o);
68924         o_conv.is_owned = ptr_is_owned(o);
68925         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
68926         o_conv.is_owned = false;
68927         int64_t ret_conv = RawBolt11Invoice_hash(&o_conv);
68928         return ret_conv;
68929 }
68930
68931 void  CS_LDK_RawDataPart_free(int64_t this_obj) {
68932         LDKRawDataPart this_obj_conv;
68933         this_obj_conv.inner = untag_ptr(this_obj);
68934         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68936         RawDataPart_free(this_obj_conv);
68937 }
68938
68939 int64_t  CS_LDK_RawDataPart_get_timestamp(int64_t this_ptr) {
68940         LDKRawDataPart this_ptr_conv;
68941         this_ptr_conv.inner = untag_ptr(this_ptr);
68942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68944         this_ptr_conv.is_owned = false;
68945         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
68946         int64_t ret_ref = 0;
68947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68948         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68949         return ret_ref;
68950 }
68951
68952 void  CS_LDK_RawDataPart_set_timestamp(int64_t this_ptr, int64_t val) {
68953         LDKRawDataPart this_ptr_conv;
68954         this_ptr_conv.inner = untag_ptr(this_ptr);
68955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68957         this_ptr_conv.is_owned = false;
68958         LDKPositiveTimestamp val_conv;
68959         val_conv.inner = untag_ptr(val);
68960         val_conv.is_owned = ptr_is_owned(val);
68961         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
68962         val_conv = PositiveTimestamp_clone(&val_conv);
68963         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
68964 }
68965
68966 jboolean  CS_LDK_RawDataPart_eq(int64_t a, int64_t b) {
68967         LDKRawDataPart a_conv;
68968         a_conv.inner = untag_ptr(a);
68969         a_conv.is_owned = ptr_is_owned(a);
68970         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68971         a_conv.is_owned = false;
68972         LDKRawDataPart b_conv;
68973         b_conv.inner = untag_ptr(b);
68974         b_conv.is_owned = ptr_is_owned(b);
68975         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68976         b_conv.is_owned = false;
68977         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
68978         return ret_conv;
68979 }
68980
68981 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
68982         LDKRawDataPart ret_var = RawDataPart_clone(arg);
68983         int64_t ret_ref = 0;
68984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68986         return ret_ref;
68987 }
68988 int64_t  CS_LDK_RawDataPart_clone_ptr(int64_t arg) {
68989         LDKRawDataPart arg_conv;
68990         arg_conv.inner = untag_ptr(arg);
68991         arg_conv.is_owned = ptr_is_owned(arg);
68992         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68993         arg_conv.is_owned = false;
68994         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
68995         return ret_conv;
68996 }
68997
68998 int64_t  CS_LDK_RawDataPart_clone(int64_t orig) {
68999         LDKRawDataPart orig_conv;
69000         orig_conv.inner = untag_ptr(orig);
69001         orig_conv.is_owned = ptr_is_owned(orig);
69002         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69003         orig_conv.is_owned = false;
69004         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
69005         int64_t ret_ref = 0;
69006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69008         return ret_ref;
69009 }
69010
69011 int64_t  CS_LDK_RawDataPart_hash(int64_t o) {
69012         LDKRawDataPart o_conv;
69013         o_conv.inner = untag_ptr(o);
69014         o_conv.is_owned = ptr_is_owned(o);
69015         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69016         o_conv.is_owned = false;
69017         int64_t ret_conv = RawDataPart_hash(&o_conv);
69018         return ret_conv;
69019 }
69020
69021 void  CS_LDK_PositiveTimestamp_free(int64_t this_obj) {
69022         LDKPositiveTimestamp this_obj_conv;
69023         this_obj_conv.inner = untag_ptr(this_obj);
69024         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69026         PositiveTimestamp_free(this_obj_conv);
69027 }
69028
69029 jboolean  CS_LDK_PositiveTimestamp_eq(int64_t a, int64_t b) {
69030         LDKPositiveTimestamp a_conv;
69031         a_conv.inner = untag_ptr(a);
69032         a_conv.is_owned = ptr_is_owned(a);
69033         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69034         a_conv.is_owned = false;
69035         LDKPositiveTimestamp b_conv;
69036         b_conv.inner = untag_ptr(b);
69037         b_conv.is_owned = ptr_is_owned(b);
69038         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69039         b_conv.is_owned = false;
69040         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
69041         return ret_conv;
69042 }
69043
69044 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
69045         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
69046         int64_t ret_ref = 0;
69047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69049         return ret_ref;
69050 }
69051 int64_t  CS_LDK_PositiveTimestamp_clone_ptr(int64_t arg) {
69052         LDKPositiveTimestamp arg_conv;
69053         arg_conv.inner = untag_ptr(arg);
69054         arg_conv.is_owned = ptr_is_owned(arg);
69055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69056         arg_conv.is_owned = false;
69057         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
69058         return ret_conv;
69059 }
69060
69061 int64_t  CS_LDK_PositiveTimestamp_clone(int64_t orig) {
69062         LDKPositiveTimestamp orig_conv;
69063         orig_conv.inner = untag_ptr(orig);
69064         orig_conv.is_owned = ptr_is_owned(orig);
69065         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69066         orig_conv.is_owned = false;
69067         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
69068         int64_t ret_ref = 0;
69069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69070         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69071         return ret_ref;
69072 }
69073
69074 int64_t  CS_LDK_PositiveTimestamp_hash(int64_t o) {
69075         LDKPositiveTimestamp o_conv;
69076         o_conv.inner = untag_ptr(o);
69077         o_conv.is_owned = ptr_is_owned(o);
69078         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69079         o_conv.is_owned = false;
69080         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
69081         return ret_conv;
69082 }
69083
69084 int32_t  CS_LDK_SiPrefix_clone(int64_t orig) {
69085         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
69086         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_clone(orig_conv));
69087         return ret_conv;
69088 }
69089
69090 int32_t  CS_LDK_SiPrefix_milli() {
69091         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_milli());
69092         return ret_conv;
69093 }
69094
69095 int32_t  CS_LDK_SiPrefix_micro() {
69096         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_micro());
69097         return ret_conv;
69098 }
69099
69100 int32_t  CS_LDK_SiPrefix_nano() {
69101         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_nano());
69102         return ret_conv;
69103 }
69104
69105 int32_t  CS_LDK_SiPrefix_pico() {
69106         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_pico());
69107         return ret_conv;
69108 }
69109
69110 jboolean  CS_LDK_SiPrefix_eq(int64_t a, int64_t b) {
69111         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
69112         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
69113         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
69114         return ret_conv;
69115 }
69116
69117 int64_t  CS_LDK_SiPrefix_hash(int64_t o) {
69118         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
69119         int64_t ret_conv = SiPrefix_hash(o_conv);
69120         return ret_conv;
69121 }
69122
69123 int64_t  CS_LDK_SiPrefix_multiplier(int64_t this_arg) {
69124         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
69125         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
69126         return ret_conv;
69127 }
69128
69129 int32_t  CS_LDK_Currency_clone(int64_t orig) {
69130         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
69131         int32_t ret_conv = LDKCurrency_to_cs(Currency_clone(orig_conv));
69132         return ret_conv;
69133 }
69134
69135 int32_t  CS_LDK_Currency_bitcoin() {
69136         int32_t ret_conv = LDKCurrency_to_cs(Currency_bitcoin());
69137         return ret_conv;
69138 }
69139
69140 int32_t  CS_LDK_Currency_bitcoin_testnet() {
69141         int32_t ret_conv = LDKCurrency_to_cs(Currency_bitcoin_testnet());
69142         return ret_conv;
69143 }
69144
69145 int32_t  CS_LDK_Currency_regtest() {
69146         int32_t ret_conv = LDKCurrency_to_cs(Currency_regtest());
69147         return ret_conv;
69148 }
69149
69150 int32_t  CS_LDK_Currency_simnet() {
69151         int32_t ret_conv = LDKCurrency_to_cs(Currency_simnet());
69152         return ret_conv;
69153 }
69154
69155 int32_t  CS_LDK_Currency_signet() {
69156         int32_t ret_conv = LDKCurrency_to_cs(Currency_signet());
69157         return ret_conv;
69158 }
69159
69160 int64_t  CS_LDK_Currency_hash(int64_t o) {
69161         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
69162         int64_t ret_conv = Currency_hash(o_conv);
69163         return ret_conv;
69164 }
69165
69166 jboolean  CS_LDK_Currency_eq(int64_t a, int64_t b) {
69167         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
69168         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
69169         jboolean ret_conv = Currency_eq(a_conv, b_conv);
69170         return ret_conv;
69171 }
69172
69173 void  CS_LDK_Sha256_free(int64_t this_obj) {
69174         LDKSha256 this_obj_conv;
69175         this_obj_conv.inner = untag_ptr(this_obj);
69176         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69178         Sha256_free(this_obj_conv);
69179 }
69180
69181 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
69182         LDKSha256 ret_var = Sha256_clone(arg);
69183         int64_t ret_ref = 0;
69184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69185         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69186         return ret_ref;
69187 }
69188 int64_t  CS_LDK_Sha256_clone_ptr(int64_t arg) {
69189         LDKSha256 arg_conv;
69190         arg_conv.inner = untag_ptr(arg);
69191         arg_conv.is_owned = ptr_is_owned(arg);
69192         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69193         arg_conv.is_owned = false;
69194         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
69195         return ret_conv;
69196 }
69197
69198 int64_t  CS_LDK_Sha256_clone(int64_t orig) {
69199         LDKSha256 orig_conv;
69200         orig_conv.inner = untag_ptr(orig);
69201         orig_conv.is_owned = ptr_is_owned(orig);
69202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69203         orig_conv.is_owned = false;
69204         LDKSha256 ret_var = Sha256_clone(&orig_conv);
69205         int64_t ret_ref = 0;
69206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69207         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69208         return ret_ref;
69209 }
69210
69211 int64_t  CS_LDK_Sha256_hash(int64_t o) {
69212         LDKSha256 o_conv;
69213         o_conv.inner = untag_ptr(o);
69214         o_conv.is_owned = ptr_is_owned(o);
69215         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69216         o_conv.is_owned = false;
69217         int64_t ret_conv = Sha256_hash(&o_conv);
69218         return ret_conv;
69219 }
69220
69221 jboolean  CS_LDK_Sha256_eq(int64_t a, int64_t b) {
69222         LDKSha256 a_conv;
69223         a_conv.inner = untag_ptr(a);
69224         a_conv.is_owned = ptr_is_owned(a);
69225         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69226         a_conv.is_owned = false;
69227         LDKSha256 b_conv;
69228         b_conv.inner = untag_ptr(b);
69229         b_conv.is_owned = ptr_is_owned(b);
69230         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69231         b_conv.is_owned = false;
69232         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
69233         return ret_conv;
69234 }
69235
69236 int64_t  CS_LDK_Sha256_from_bytes(int8_tArray bytes) {
69237         uint8_t bytes_arr[32];
69238         CHECK(bytes->arr_len == 32);
69239         memcpy(bytes_arr, bytes->elems, 32); FREE(bytes);
69240         uint8_t (*bytes_ref)[32] = &bytes_arr;
69241         LDKSha256 ret_var = Sha256_from_bytes(bytes_ref);
69242         int64_t ret_ref = 0;
69243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69245         return ret_ref;
69246 }
69247
69248 void  CS_LDK_Description_free(int64_t this_obj) {
69249         LDKDescription this_obj_conv;
69250         this_obj_conv.inner = untag_ptr(this_obj);
69251         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69253         Description_free(this_obj_conv);
69254 }
69255
69256 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
69257         LDKDescription ret_var = Description_clone(arg);
69258         int64_t ret_ref = 0;
69259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69260         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69261         return ret_ref;
69262 }
69263 int64_t  CS_LDK_Description_clone_ptr(int64_t arg) {
69264         LDKDescription arg_conv;
69265         arg_conv.inner = untag_ptr(arg);
69266         arg_conv.is_owned = ptr_is_owned(arg);
69267         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69268         arg_conv.is_owned = false;
69269         int64_t ret_conv = Description_clone_ptr(&arg_conv);
69270         return ret_conv;
69271 }
69272
69273 int64_t  CS_LDK_Description_clone(int64_t orig) {
69274         LDKDescription orig_conv;
69275         orig_conv.inner = untag_ptr(orig);
69276         orig_conv.is_owned = ptr_is_owned(orig);
69277         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69278         orig_conv.is_owned = false;
69279         LDKDescription ret_var = Description_clone(&orig_conv);
69280         int64_t ret_ref = 0;
69281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69282         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69283         return ret_ref;
69284 }
69285
69286 int64_t  CS_LDK_Description_hash(int64_t o) {
69287         LDKDescription o_conv;
69288         o_conv.inner = untag_ptr(o);
69289         o_conv.is_owned = ptr_is_owned(o);
69290         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69291         o_conv.is_owned = false;
69292         int64_t ret_conv = Description_hash(&o_conv);
69293         return ret_conv;
69294 }
69295
69296 jboolean  CS_LDK_Description_eq(int64_t a, int64_t b) {
69297         LDKDescription a_conv;
69298         a_conv.inner = untag_ptr(a);
69299         a_conv.is_owned = ptr_is_owned(a);
69300         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69301         a_conv.is_owned = false;
69302         LDKDescription b_conv;
69303         b_conv.inner = untag_ptr(b);
69304         b_conv.is_owned = ptr_is_owned(b);
69305         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69306         b_conv.is_owned = false;
69307         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
69308         return ret_conv;
69309 }
69310
69311 void  CS_LDK_PayeePubKey_free(int64_t this_obj) {
69312         LDKPayeePubKey this_obj_conv;
69313         this_obj_conv.inner = untag_ptr(this_obj);
69314         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69316         PayeePubKey_free(this_obj_conv);
69317 }
69318
69319 int8_tArray  CS_LDK_PayeePubKey_get_a(int64_t this_ptr) {
69320         LDKPayeePubKey this_ptr_conv;
69321         this_ptr_conv.inner = untag_ptr(this_ptr);
69322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
69323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
69324         this_ptr_conv.is_owned = false;
69325         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
69326         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
69327         return ret_arr;
69328 }
69329
69330 void  CS_LDK_PayeePubKey_set_a(int64_t this_ptr, int8_tArray val) {
69331         LDKPayeePubKey this_ptr_conv;
69332         this_ptr_conv.inner = untag_ptr(this_ptr);
69333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
69334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
69335         this_ptr_conv.is_owned = false;
69336         LDKPublicKey val_ref;
69337         CHECK(val->arr_len == 33);
69338         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
69339         PayeePubKey_set_a(&this_ptr_conv, val_ref);
69340 }
69341
69342 int64_t  CS_LDK_PayeePubKey_new(int8_tArray a_arg) {
69343         LDKPublicKey a_arg_ref;
69344         CHECK(a_arg->arr_len == 33);
69345         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
69346         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
69347         int64_t ret_ref = 0;
69348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69350         return ret_ref;
69351 }
69352
69353 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
69354         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
69355         int64_t ret_ref = 0;
69356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69358         return ret_ref;
69359 }
69360 int64_t  CS_LDK_PayeePubKey_clone_ptr(int64_t arg) {
69361         LDKPayeePubKey arg_conv;
69362         arg_conv.inner = untag_ptr(arg);
69363         arg_conv.is_owned = ptr_is_owned(arg);
69364         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69365         arg_conv.is_owned = false;
69366         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
69367         return ret_conv;
69368 }
69369
69370 int64_t  CS_LDK_PayeePubKey_clone(int64_t orig) {
69371         LDKPayeePubKey orig_conv;
69372         orig_conv.inner = untag_ptr(orig);
69373         orig_conv.is_owned = ptr_is_owned(orig);
69374         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69375         orig_conv.is_owned = false;
69376         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
69377         int64_t ret_ref = 0;
69378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69380         return ret_ref;
69381 }
69382
69383 int64_t  CS_LDK_PayeePubKey_hash(int64_t o) {
69384         LDKPayeePubKey o_conv;
69385         o_conv.inner = untag_ptr(o);
69386         o_conv.is_owned = ptr_is_owned(o);
69387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69388         o_conv.is_owned = false;
69389         int64_t ret_conv = PayeePubKey_hash(&o_conv);
69390         return ret_conv;
69391 }
69392
69393 jboolean  CS_LDK_PayeePubKey_eq(int64_t a, int64_t b) {
69394         LDKPayeePubKey a_conv;
69395         a_conv.inner = untag_ptr(a);
69396         a_conv.is_owned = ptr_is_owned(a);
69397         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69398         a_conv.is_owned = false;
69399         LDKPayeePubKey b_conv;
69400         b_conv.inner = untag_ptr(b);
69401         b_conv.is_owned = ptr_is_owned(b);
69402         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69403         b_conv.is_owned = false;
69404         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
69405         return ret_conv;
69406 }
69407
69408 void  CS_LDK_ExpiryTime_free(int64_t this_obj) {
69409         LDKExpiryTime this_obj_conv;
69410         this_obj_conv.inner = untag_ptr(this_obj);
69411         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69413         ExpiryTime_free(this_obj_conv);
69414 }
69415
69416 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
69417         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
69418         int64_t ret_ref = 0;
69419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69420         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69421         return ret_ref;
69422 }
69423 int64_t  CS_LDK_ExpiryTime_clone_ptr(int64_t arg) {
69424         LDKExpiryTime arg_conv;
69425         arg_conv.inner = untag_ptr(arg);
69426         arg_conv.is_owned = ptr_is_owned(arg);
69427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69428         arg_conv.is_owned = false;
69429         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
69430         return ret_conv;
69431 }
69432
69433 int64_t  CS_LDK_ExpiryTime_clone(int64_t orig) {
69434         LDKExpiryTime orig_conv;
69435         orig_conv.inner = untag_ptr(orig);
69436         orig_conv.is_owned = ptr_is_owned(orig);
69437         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69438         orig_conv.is_owned = false;
69439         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
69440         int64_t ret_ref = 0;
69441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69442         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69443         return ret_ref;
69444 }
69445
69446 int64_t  CS_LDK_ExpiryTime_hash(int64_t o) {
69447         LDKExpiryTime o_conv;
69448         o_conv.inner = untag_ptr(o);
69449         o_conv.is_owned = ptr_is_owned(o);
69450         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69451         o_conv.is_owned = false;
69452         int64_t ret_conv = ExpiryTime_hash(&o_conv);
69453         return ret_conv;
69454 }
69455
69456 jboolean  CS_LDK_ExpiryTime_eq(int64_t a, int64_t b) {
69457         LDKExpiryTime a_conv;
69458         a_conv.inner = untag_ptr(a);
69459         a_conv.is_owned = ptr_is_owned(a);
69460         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69461         a_conv.is_owned = false;
69462         LDKExpiryTime b_conv;
69463         b_conv.inner = untag_ptr(b);
69464         b_conv.is_owned = ptr_is_owned(b);
69465         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69466         b_conv.is_owned = false;
69467         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
69468         return ret_conv;
69469 }
69470
69471 void  CS_LDK_MinFinalCltvExpiryDelta_free(int64_t this_obj) {
69472         LDKMinFinalCltvExpiryDelta this_obj_conv;
69473         this_obj_conv.inner = untag_ptr(this_obj);
69474         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69476         MinFinalCltvExpiryDelta_free(this_obj_conv);
69477 }
69478
69479 int64_t  CS_LDK_MinFinalCltvExpiryDelta_get_a(int64_t this_ptr) {
69480         LDKMinFinalCltvExpiryDelta this_ptr_conv;
69481         this_ptr_conv.inner = untag_ptr(this_ptr);
69482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
69483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
69484         this_ptr_conv.is_owned = false;
69485         int64_t ret_conv = MinFinalCltvExpiryDelta_get_a(&this_ptr_conv);
69486         return ret_conv;
69487 }
69488
69489 void  CS_LDK_MinFinalCltvExpiryDelta_set_a(int64_t this_ptr, int64_t val) {
69490         LDKMinFinalCltvExpiryDelta this_ptr_conv;
69491         this_ptr_conv.inner = untag_ptr(this_ptr);
69492         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
69493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
69494         this_ptr_conv.is_owned = false;
69495         MinFinalCltvExpiryDelta_set_a(&this_ptr_conv, val);
69496 }
69497
69498 int64_t  CS_LDK_MinFinalCltvExpiryDelta_new(int64_t a_arg) {
69499         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_new(a_arg);
69500         int64_t ret_ref = 0;
69501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69503         return ret_ref;
69504 }
69505
69506 static inline uint64_t MinFinalCltvExpiryDelta_clone_ptr(LDKMinFinalCltvExpiryDelta *NONNULL_PTR arg) {
69507         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(arg);
69508         int64_t ret_ref = 0;
69509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69511         return ret_ref;
69512 }
69513 int64_t  CS_LDK_MinFinalCltvExpiryDelta_clone_ptr(int64_t arg) {
69514         LDKMinFinalCltvExpiryDelta arg_conv;
69515         arg_conv.inner = untag_ptr(arg);
69516         arg_conv.is_owned = ptr_is_owned(arg);
69517         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69518         arg_conv.is_owned = false;
69519         int64_t ret_conv = MinFinalCltvExpiryDelta_clone_ptr(&arg_conv);
69520         return ret_conv;
69521 }
69522
69523 int64_t  CS_LDK_MinFinalCltvExpiryDelta_clone(int64_t orig) {
69524         LDKMinFinalCltvExpiryDelta orig_conv;
69525         orig_conv.inner = untag_ptr(orig);
69526         orig_conv.is_owned = ptr_is_owned(orig);
69527         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69528         orig_conv.is_owned = false;
69529         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(&orig_conv);
69530         int64_t ret_ref = 0;
69531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69532         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69533         return ret_ref;
69534 }
69535
69536 int64_t  CS_LDK_MinFinalCltvExpiryDelta_hash(int64_t o) {
69537         LDKMinFinalCltvExpiryDelta o_conv;
69538         o_conv.inner = untag_ptr(o);
69539         o_conv.is_owned = ptr_is_owned(o);
69540         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69541         o_conv.is_owned = false;
69542         int64_t ret_conv = MinFinalCltvExpiryDelta_hash(&o_conv);
69543         return ret_conv;
69544 }
69545
69546 jboolean  CS_LDK_MinFinalCltvExpiryDelta_eq(int64_t a, int64_t b) {
69547         LDKMinFinalCltvExpiryDelta a_conv;
69548         a_conv.inner = untag_ptr(a);
69549         a_conv.is_owned = ptr_is_owned(a);
69550         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69551         a_conv.is_owned = false;
69552         LDKMinFinalCltvExpiryDelta b_conv;
69553         b_conv.inner = untag_ptr(b);
69554         b_conv.is_owned = ptr_is_owned(b);
69555         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69556         b_conv.is_owned = false;
69557         jboolean ret_conv = MinFinalCltvExpiryDelta_eq(&a_conv, &b_conv);
69558         return ret_conv;
69559 }
69560
69561 void  CS_LDK_Fallback_free(int64_t this_ptr) {
69562         if (!ptr_is_owned(this_ptr)) return;
69563         void* this_ptr_ptr = untag_ptr(this_ptr);
69564         CHECK_ACCESS(this_ptr_ptr);
69565         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
69566         FREE(untag_ptr(this_ptr));
69567         Fallback_free(this_ptr_conv);
69568 }
69569
69570 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
69571         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69572         *ret_copy = Fallback_clone(arg);
69573         int64_t ret_ref = tag_ptr(ret_copy, true);
69574         return ret_ref;
69575 }
69576 int64_t  CS_LDK_Fallback_clone_ptr(int64_t arg) {
69577         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
69578         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
69579         return ret_conv;
69580 }
69581
69582 int64_t  CS_LDK_Fallback_clone(int64_t orig) {
69583         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
69584         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69585         *ret_copy = Fallback_clone(orig_conv);
69586         int64_t ret_ref = tag_ptr(ret_copy, true);
69587         return ret_ref;
69588 }
69589
69590 int64_t  CS_LDK_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
69591         
69592         LDKCVec_u8Z program_ref;
69593         program_ref.datalen = program->arr_len;
69594         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
69595         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
69596         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69597         *ret_copy = Fallback_seg_wit_program((LDKWitnessVersion){ ._0 = version }, program_ref);
69598         int64_t ret_ref = tag_ptr(ret_copy, true);
69599         return ret_ref;
69600 }
69601
69602 int64_t  CS_LDK_Fallback_pub_key_hash(int8_tArray a) {
69603         LDKTwentyBytes a_ref;
69604         CHECK(a->arr_len == 20);
69605         memcpy(a_ref.data, a->elems, 20); FREE(a);
69606         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69607         *ret_copy = Fallback_pub_key_hash(a_ref);
69608         int64_t ret_ref = tag_ptr(ret_copy, true);
69609         return ret_ref;
69610 }
69611
69612 int64_t  CS_LDK_Fallback_script_hash(int8_tArray a) {
69613         LDKTwentyBytes a_ref;
69614         CHECK(a->arr_len == 20);
69615         memcpy(a_ref.data, a->elems, 20); FREE(a);
69616         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69617         *ret_copy = Fallback_script_hash(a_ref);
69618         int64_t ret_ref = tag_ptr(ret_copy, true);
69619         return ret_ref;
69620 }
69621
69622 int64_t  CS_LDK_Fallback_hash(int64_t o) {
69623         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
69624         int64_t ret_conv = Fallback_hash(o_conv);
69625         return ret_conv;
69626 }
69627
69628 jboolean  CS_LDK_Fallback_eq(int64_t a, int64_t b) {
69629         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
69630         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
69631         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
69632         return ret_conv;
69633 }
69634
69635 void  CS_LDK_Bolt11InvoiceSignature_free(int64_t this_obj) {
69636         LDKBolt11InvoiceSignature this_obj_conv;
69637         this_obj_conv.inner = untag_ptr(this_obj);
69638         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69640         Bolt11InvoiceSignature_free(this_obj_conv);
69641 }
69642
69643 static inline uint64_t Bolt11InvoiceSignature_clone_ptr(LDKBolt11InvoiceSignature *NONNULL_PTR arg) {
69644         LDKBolt11InvoiceSignature ret_var = Bolt11InvoiceSignature_clone(arg);
69645         int64_t ret_ref = 0;
69646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69647         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69648         return ret_ref;
69649 }
69650 int64_t  CS_LDK_Bolt11InvoiceSignature_clone_ptr(int64_t arg) {
69651         LDKBolt11InvoiceSignature arg_conv;
69652         arg_conv.inner = untag_ptr(arg);
69653         arg_conv.is_owned = ptr_is_owned(arg);
69654         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69655         arg_conv.is_owned = false;
69656         int64_t ret_conv = Bolt11InvoiceSignature_clone_ptr(&arg_conv);
69657         return ret_conv;
69658 }
69659
69660 int64_t  CS_LDK_Bolt11InvoiceSignature_clone(int64_t orig) {
69661         LDKBolt11InvoiceSignature orig_conv;
69662         orig_conv.inner = untag_ptr(orig);
69663         orig_conv.is_owned = ptr_is_owned(orig);
69664         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69665         orig_conv.is_owned = false;
69666         LDKBolt11InvoiceSignature ret_var = Bolt11InvoiceSignature_clone(&orig_conv);
69667         int64_t ret_ref = 0;
69668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69670         return ret_ref;
69671 }
69672
69673 int64_t  CS_LDK_Bolt11InvoiceSignature_hash(int64_t o) {
69674         LDKBolt11InvoiceSignature o_conv;
69675         o_conv.inner = untag_ptr(o);
69676         o_conv.is_owned = ptr_is_owned(o);
69677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69678         o_conv.is_owned = false;
69679         int64_t ret_conv = Bolt11InvoiceSignature_hash(&o_conv);
69680         return ret_conv;
69681 }
69682
69683 jboolean  CS_LDK_Bolt11InvoiceSignature_eq(int64_t a, int64_t b) {
69684         LDKBolt11InvoiceSignature a_conv;
69685         a_conv.inner = untag_ptr(a);
69686         a_conv.is_owned = ptr_is_owned(a);
69687         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69688         a_conv.is_owned = false;
69689         LDKBolt11InvoiceSignature b_conv;
69690         b_conv.inner = untag_ptr(b);
69691         b_conv.is_owned = ptr_is_owned(b);
69692         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69693         b_conv.is_owned = false;
69694         jboolean ret_conv = Bolt11InvoiceSignature_eq(&a_conv, &b_conv);
69695         return ret_conv;
69696 }
69697
69698 void  CS_LDK_PrivateRoute_free(int64_t this_obj) {
69699         LDKPrivateRoute this_obj_conv;
69700         this_obj_conv.inner = untag_ptr(this_obj);
69701         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69703         PrivateRoute_free(this_obj_conv);
69704 }
69705
69706 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
69707         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
69708         int64_t ret_ref = 0;
69709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69710         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69711         return ret_ref;
69712 }
69713 int64_t  CS_LDK_PrivateRoute_clone_ptr(int64_t arg) {
69714         LDKPrivateRoute arg_conv;
69715         arg_conv.inner = untag_ptr(arg);
69716         arg_conv.is_owned = ptr_is_owned(arg);
69717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69718         arg_conv.is_owned = false;
69719         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
69720         return ret_conv;
69721 }
69722
69723 int64_t  CS_LDK_PrivateRoute_clone(int64_t orig) {
69724         LDKPrivateRoute orig_conv;
69725         orig_conv.inner = untag_ptr(orig);
69726         orig_conv.is_owned = ptr_is_owned(orig);
69727         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69728         orig_conv.is_owned = false;
69729         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
69730         int64_t ret_ref = 0;
69731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69733         return ret_ref;
69734 }
69735
69736 int64_t  CS_LDK_PrivateRoute_hash(int64_t o) {
69737         LDKPrivateRoute o_conv;
69738         o_conv.inner = untag_ptr(o);
69739         o_conv.is_owned = ptr_is_owned(o);
69740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69741         o_conv.is_owned = false;
69742         int64_t ret_conv = PrivateRoute_hash(&o_conv);
69743         return ret_conv;
69744 }
69745
69746 jboolean  CS_LDK_PrivateRoute_eq(int64_t a, int64_t b) {
69747         LDKPrivateRoute a_conv;
69748         a_conv.inner = untag_ptr(a);
69749         a_conv.is_owned = ptr_is_owned(a);
69750         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69751         a_conv.is_owned = false;
69752         LDKPrivateRoute b_conv;
69753         b_conv.inner = untag_ptr(b);
69754         b_conv.is_owned = ptr_is_owned(b);
69755         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69756         b_conv.is_owned = false;
69757         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
69758         return ret_conv;
69759 }
69760
69761 int64_t  CS_LDK_SignedRawBolt11Invoice_into_parts(int64_t this_arg) {
69762         LDKSignedRawBolt11Invoice this_arg_conv;
69763         this_arg_conv.inner = untag_ptr(this_arg);
69764         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69766         this_arg_conv = SignedRawBolt11Invoice_clone(&this_arg_conv);
69767         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ), "LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ");
69768         *ret_conv = SignedRawBolt11Invoice_into_parts(this_arg_conv);
69769         return tag_ptr(ret_conv, true);
69770 }
69771
69772 int64_t  CS_LDK_SignedRawBolt11Invoice_raw_invoice(int64_t this_arg) {
69773         LDKSignedRawBolt11Invoice this_arg_conv;
69774         this_arg_conv.inner = untag_ptr(this_arg);
69775         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69777         this_arg_conv.is_owned = false;
69778         LDKRawBolt11Invoice ret_var = SignedRawBolt11Invoice_raw_invoice(&this_arg_conv);
69779         int64_t ret_ref = 0;
69780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69782         return ret_ref;
69783 }
69784
69785 int8_tArray  CS_LDK_SignedRawBolt11Invoice_signable_hash(int64_t this_arg) {
69786         LDKSignedRawBolt11Invoice this_arg_conv;
69787         this_arg_conv.inner = untag_ptr(this_arg);
69788         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69790         this_arg_conv.is_owned = false;
69791         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
69792         memcpy(ret_arr->elems, *SignedRawBolt11Invoice_signable_hash(&this_arg_conv), 32);
69793         return ret_arr;
69794 }
69795
69796 int64_t  CS_LDK_SignedRawBolt11Invoice_signature(int64_t this_arg) {
69797         LDKSignedRawBolt11Invoice this_arg_conv;
69798         this_arg_conv.inner = untag_ptr(this_arg);
69799         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69801         this_arg_conv.is_owned = false;
69802         LDKBolt11InvoiceSignature ret_var = SignedRawBolt11Invoice_signature(&this_arg_conv);
69803         int64_t ret_ref = 0;
69804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69806         return ret_ref;
69807 }
69808
69809 int64_t  CS_LDK_SignedRawBolt11Invoice_recover_payee_pub_key(int64_t this_arg) {
69810         LDKSignedRawBolt11Invoice this_arg_conv;
69811         this_arg_conv.inner = untag_ptr(this_arg);
69812         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69814         this_arg_conv.is_owned = false;
69815         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
69816         *ret_conv = SignedRawBolt11Invoice_recover_payee_pub_key(&this_arg_conv);
69817         return tag_ptr(ret_conv, true);
69818 }
69819
69820 jboolean  CS_LDK_SignedRawBolt11Invoice_check_signature(int64_t this_arg) {
69821         LDKSignedRawBolt11Invoice this_arg_conv;
69822         this_arg_conv.inner = untag_ptr(this_arg);
69823         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69825         this_arg_conv.is_owned = false;
69826         jboolean ret_conv = SignedRawBolt11Invoice_check_signature(&this_arg_conv);
69827         return ret_conv;
69828 }
69829
69830 int8_tArray  CS_LDK_RawBolt11Invoice_signable_hash(int64_t this_arg) {
69831         LDKRawBolt11Invoice this_arg_conv;
69832         this_arg_conv.inner = untag_ptr(this_arg);
69833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69835         this_arg_conv.is_owned = false;
69836         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
69837         memcpy(ret_arr->elems, RawBolt11Invoice_signable_hash(&this_arg_conv).data, 32);
69838         return ret_arr;
69839 }
69840
69841 int64_t  CS_LDK_RawBolt11Invoice_payment_hash(int64_t this_arg) {
69842         LDKRawBolt11Invoice this_arg_conv;
69843         this_arg_conv.inner = untag_ptr(this_arg);
69844         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69846         this_arg_conv.is_owned = false;
69847         LDKSha256 ret_var = RawBolt11Invoice_payment_hash(&this_arg_conv);
69848         int64_t ret_ref = 0;
69849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69850         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69851         return ret_ref;
69852 }
69853
69854 int64_t  CS_LDK_RawBolt11Invoice_description(int64_t this_arg) {
69855         LDKRawBolt11Invoice this_arg_conv;
69856         this_arg_conv.inner = untag_ptr(this_arg);
69857         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69859         this_arg_conv.is_owned = false;
69860         LDKDescription ret_var = RawBolt11Invoice_description(&this_arg_conv);
69861         int64_t ret_ref = 0;
69862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69864         return ret_ref;
69865 }
69866
69867 int64_t  CS_LDK_RawBolt11Invoice_payee_pub_key(int64_t this_arg) {
69868         LDKRawBolt11Invoice this_arg_conv;
69869         this_arg_conv.inner = untag_ptr(this_arg);
69870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69872         this_arg_conv.is_owned = false;
69873         LDKPayeePubKey ret_var = RawBolt11Invoice_payee_pub_key(&this_arg_conv);
69874         int64_t ret_ref = 0;
69875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69877         return ret_ref;
69878 }
69879
69880 int64_t  CS_LDK_RawBolt11Invoice_description_hash(int64_t this_arg) {
69881         LDKRawBolt11Invoice this_arg_conv;
69882         this_arg_conv.inner = untag_ptr(this_arg);
69883         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69885         this_arg_conv.is_owned = false;
69886         LDKSha256 ret_var = RawBolt11Invoice_description_hash(&this_arg_conv);
69887         int64_t ret_ref = 0;
69888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69890         return ret_ref;
69891 }
69892
69893 int64_t  CS_LDK_RawBolt11Invoice_expiry_time(int64_t this_arg) {
69894         LDKRawBolt11Invoice this_arg_conv;
69895         this_arg_conv.inner = untag_ptr(this_arg);
69896         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69898         this_arg_conv.is_owned = false;
69899         LDKExpiryTime ret_var = RawBolt11Invoice_expiry_time(&this_arg_conv);
69900         int64_t ret_ref = 0;
69901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69902         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69903         return ret_ref;
69904 }
69905
69906 int64_t  CS_LDK_RawBolt11Invoice_min_final_cltv_expiry_delta(int64_t this_arg) {
69907         LDKRawBolt11Invoice this_arg_conv;
69908         this_arg_conv.inner = untag_ptr(this_arg);
69909         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69911         this_arg_conv.is_owned = false;
69912         LDKMinFinalCltvExpiryDelta ret_var = RawBolt11Invoice_min_final_cltv_expiry_delta(&this_arg_conv);
69913         int64_t ret_ref = 0;
69914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69916         return ret_ref;
69917 }
69918
69919 int64_t  CS_LDK_RawBolt11Invoice_payment_secret(int64_t this_arg) {
69920         LDKRawBolt11Invoice this_arg_conv;
69921         this_arg_conv.inner = untag_ptr(this_arg);
69922         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69924         this_arg_conv.is_owned = false;
69925         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
69926         *ret_copy = RawBolt11Invoice_payment_secret(&this_arg_conv);
69927         int64_t ret_ref = tag_ptr(ret_copy, true);
69928         return ret_ref;
69929 }
69930
69931 int64_t  CS_LDK_RawBolt11Invoice_payment_metadata(int64_t this_arg) {
69932         LDKRawBolt11Invoice this_arg_conv;
69933         this_arg_conv.inner = untag_ptr(this_arg);
69934         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69936         this_arg_conv.is_owned = false;
69937         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
69938         *ret_copy = RawBolt11Invoice_payment_metadata(&this_arg_conv);
69939         int64_t ret_ref = tag_ptr(ret_copy, true);
69940         return ret_ref;
69941 }
69942
69943 int64_t  CS_LDK_RawBolt11Invoice_features(int64_t this_arg) {
69944         LDKRawBolt11Invoice this_arg_conv;
69945         this_arg_conv.inner = untag_ptr(this_arg);
69946         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69948         this_arg_conv.is_owned = false;
69949         LDKBolt11InvoiceFeatures ret_var = RawBolt11Invoice_features(&this_arg_conv);
69950         int64_t ret_ref = 0;
69951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69953         return ret_ref;
69954 }
69955
69956 int64_tArray  CS_LDK_RawBolt11Invoice_private_routes(int64_t this_arg) {
69957         LDKRawBolt11Invoice this_arg_conv;
69958         this_arg_conv.inner = untag_ptr(this_arg);
69959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69961         this_arg_conv.is_owned = false;
69962         LDKCVec_PrivateRouteZ ret_var = RawBolt11Invoice_private_routes(&this_arg_conv);
69963         int64_tArray ret_arr = NULL;
69964         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
69965         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
69966         for (size_t o = 0; o < ret_var.datalen; o++) {
69967                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
69968                 int64_t ret_conv_14_ref = 0;
69969                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
69970                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
69971                 ret_arr_ptr[o] = ret_conv_14_ref;
69972         }
69973         
69974         FREE(ret_var.data);
69975         return ret_arr;
69976 }
69977
69978 int64_t  CS_LDK_RawBolt11Invoice_amount_pico_btc(int64_t this_arg) {
69979         LDKRawBolt11Invoice this_arg_conv;
69980         this_arg_conv.inner = untag_ptr(this_arg);
69981         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69983         this_arg_conv.is_owned = false;
69984         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
69985         *ret_copy = RawBolt11Invoice_amount_pico_btc(&this_arg_conv);
69986         int64_t ret_ref = tag_ptr(ret_copy, true);
69987         return ret_ref;
69988 }
69989
69990 int32_t  CS_LDK_RawBolt11Invoice_currency(int64_t this_arg) {
69991         LDKRawBolt11Invoice this_arg_conv;
69992         this_arg_conv.inner = untag_ptr(this_arg);
69993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69995         this_arg_conv.is_owned = false;
69996         int32_t ret_conv = LDKCurrency_to_cs(RawBolt11Invoice_currency(&this_arg_conv));
69997         return ret_conv;
69998 }
69999
70000 int64_t  CS_LDK_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
70001         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
70002         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
70003         return tag_ptr(ret_conv, true);
70004 }
70005
70006 int64_t  CS_LDK_PositiveTimestamp_from_system_time(int64_t time) {
70007         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
70008         *ret_conv = PositiveTimestamp_from_system_time(time);
70009         return tag_ptr(ret_conv, true);
70010 }
70011
70012 int64_t  CS_LDK_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
70013         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
70014         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
70015         return tag_ptr(ret_conv, true);
70016 }
70017
70018 int64_t  CS_LDK_PositiveTimestamp_as_unix_timestamp(int64_t this_arg) {
70019         LDKPositiveTimestamp this_arg_conv;
70020         this_arg_conv.inner = untag_ptr(this_arg);
70021         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70023         this_arg_conv.is_owned = false;
70024         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
70025         return ret_conv;
70026 }
70027
70028 int64_t  CS_LDK_PositiveTimestamp_as_duration_since_epoch(int64_t this_arg) {
70029         LDKPositiveTimestamp this_arg_conv;
70030         this_arg_conv.inner = untag_ptr(this_arg);
70031         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70033         this_arg_conv.is_owned = false;
70034         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
70035         return ret_conv;
70036 }
70037
70038 int64_t  CS_LDK_PositiveTimestamp_as_time(int64_t this_arg) {
70039         LDKPositiveTimestamp this_arg_conv;
70040         this_arg_conv.inner = untag_ptr(this_arg);
70041         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70043         this_arg_conv.is_owned = false;
70044         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
70045         return ret_conv;
70046 }
70047
70048 int8_tArray  CS_LDK_Bolt11Invoice_signable_hash(int64_t this_arg) {
70049         LDKBolt11Invoice this_arg_conv;
70050         this_arg_conv.inner = untag_ptr(this_arg);
70051         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70053         this_arg_conv.is_owned = false;
70054         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
70055         memcpy(ret_arr->elems, Bolt11Invoice_signable_hash(&this_arg_conv).data, 32);
70056         return ret_arr;
70057 }
70058
70059 int64_t  CS_LDK_Bolt11Invoice_into_signed_raw(int64_t this_arg) {
70060         LDKBolt11Invoice this_arg_conv;
70061         this_arg_conv.inner = untag_ptr(this_arg);
70062         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70064         this_arg_conv = Bolt11Invoice_clone(&this_arg_conv);
70065         LDKSignedRawBolt11Invoice ret_var = Bolt11Invoice_into_signed_raw(this_arg_conv);
70066         int64_t ret_ref = 0;
70067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70069         return ret_ref;
70070 }
70071
70072 int64_t  CS_LDK_Bolt11Invoice_check_signature(int64_t this_arg) {
70073         LDKBolt11Invoice this_arg_conv;
70074         this_arg_conv.inner = untag_ptr(this_arg);
70075         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70077         this_arg_conv.is_owned = false;
70078         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
70079         *ret_conv = Bolt11Invoice_check_signature(&this_arg_conv);
70080         return tag_ptr(ret_conv, true);
70081 }
70082
70083 int64_t  CS_LDK_Bolt11Invoice_from_signed(int64_t signed_invoice) {
70084         LDKSignedRawBolt11Invoice signed_invoice_conv;
70085         signed_invoice_conv.inner = untag_ptr(signed_invoice);
70086         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
70087         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
70088         signed_invoice_conv = SignedRawBolt11Invoice_clone(&signed_invoice_conv);
70089         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
70090         *ret_conv = Bolt11Invoice_from_signed(signed_invoice_conv);
70091         return tag_ptr(ret_conv, true);
70092 }
70093
70094 int64_t  CS_LDK_Bolt11Invoice_timestamp(int64_t this_arg) {
70095         LDKBolt11Invoice this_arg_conv;
70096         this_arg_conv.inner = untag_ptr(this_arg);
70097         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70099         this_arg_conv.is_owned = false;
70100         int64_t ret_conv = Bolt11Invoice_timestamp(&this_arg_conv);
70101         return ret_conv;
70102 }
70103
70104 int64_t  CS_LDK_Bolt11Invoice_duration_since_epoch(int64_t this_arg) {
70105         LDKBolt11Invoice this_arg_conv;
70106         this_arg_conv.inner = untag_ptr(this_arg);
70107         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70109         this_arg_conv.is_owned = false;
70110         int64_t ret_conv = Bolt11Invoice_duration_since_epoch(&this_arg_conv);
70111         return ret_conv;
70112 }
70113
70114 int8_tArray  CS_LDK_Bolt11Invoice_payment_hash(int64_t this_arg) {
70115         LDKBolt11Invoice this_arg_conv;
70116         this_arg_conv.inner = untag_ptr(this_arg);
70117         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70119         this_arg_conv.is_owned = false;
70120         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
70121         memcpy(ret_arr->elems, *Bolt11Invoice_payment_hash(&this_arg_conv), 32);
70122         return ret_arr;
70123 }
70124
70125 int8_tArray  CS_LDK_Bolt11Invoice_payee_pub_key(int64_t this_arg) {
70126         LDKBolt11Invoice this_arg_conv;
70127         this_arg_conv.inner = untag_ptr(this_arg);
70128         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70130         this_arg_conv.is_owned = false;
70131         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
70132         memcpy(ret_arr->elems, Bolt11Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
70133         return ret_arr;
70134 }
70135
70136 int8_tArray  CS_LDK_Bolt11Invoice_payment_secret(int64_t this_arg) {
70137         LDKBolt11Invoice this_arg_conv;
70138         this_arg_conv.inner = untag_ptr(this_arg);
70139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70141         this_arg_conv.is_owned = false;
70142         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
70143         memcpy(ret_arr->elems, *Bolt11Invoice_payment_secret(&this_arg_conv), 32);
70144         return ret_arr;
70145 }
70146
70147 int64_t  CS_LDK_Bolt11Invoice_payment_metadata(int64_t this_arg) {
70148         LDKBolt11Invoice this_arg_conv;
70149         this_arg_conv.inner = untag_ptr(this_arg);
70150         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70152         this_arg_conv.is_owned = false;
70153         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
70154         *ret_copy = Bolt11Invoice_payment_metadata(&this_arg_conv);
70155         int64_t ret_ref = tag_ptr(ret_copy, true);
70156         return ret_ref;
70157 }
70158
70159 int64_t  CS_LDK_Bolt11Invoice_features(int64_t this_arg) {
70160         LDKBolt11Invoice this_arg_conv;
70161         this_arg_conv.inner = untag_ptr(this_arg);
70162         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70164         this_arg_conv.is_owned = false;
70165         LDKBolt11InvoiceFeatures ret_var = Bolt11Invoice_features(&this_arg_conv);
70166         int64_t ret_ref = 0;
70167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70169         return ret_ref;
70170 }
70171
70172 int8_tArray  CS_LDK_Bolt11Invoice_recover_payee_pub_key(int64_t this_arg) {
70173         LDKBolt11Invoice this_arg_conv;
70174         this_arg_conv.inner = untag_ptr(this_arg);
70175         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70177         this_arg_conv.is_owned = false;
70178         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
70179         memcpy(ret_arr->elems, Bolt11Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
70180         return ret_arr;
70181 }
70182
70183 int64_t  CS_LDK_Bolt11Invoice_expires_at(int64_t this_arg) {
70184         LDKBolt11Invoice this_arg_conv;
70185         this_arg_conv.inner = untag_ptr(this_arg);
70186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70188         this_arg_conv.is_owned = false;
70189         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
70190         *ret_copy = Bolt11Invoice_expires_at(&this_arg_conv);
70191         int64_t ret_ref = tag_ptr(ret_copy, true);
70192         return ret_ref;
70193 }
70194
70195 int64_t  CS_LDK_Bolt11Invoice_expiry_time(int64_t this_arg) {
70196         LDKBolt11Invoice this_arg_conv;
70197         this_arg_conv.inner = untag_ptr(this_arg);
70198         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70200         this_arg_conv.is_owned = false;
70201         int64_t ret_conv = Bolt11Invoice_expiry_time(&this_arg_conv);
70202         return ret_conv;
70203 }
70204
70205 jboolean  CS_LDK_Bolt11Invoice_is_expired(int64_t this_arg) {
70206         LDKBolt11Invoice this_arg_conv;
70207         this_arg_conv.inner = untag_ptr(this_arg);
70208         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70210         this_arg_conv.is_owned = false;
70211         jboolean ret_conv = Bolt11Invoice_is_expired(&this_arg_conv);
70212         return ret_conv;
70213 }
70214
70215 int64_t  CS_LDK_Bolt11Invoice_duration_until_expiry(int64_t this_arg) {
70216         LDKBolt11Invoice this_arg_conv;
70217         this_arg_conv.inner = untag_ptr(this_arg);
70218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70220         this_arg_conv.is_owned = false;
70221         int64_t ret_conv = Bolt11Invoice_duration_until_expiry(&this_arg_conv);
70222         return ret_conv;
70223 }
70224
70225 int64_t  CS_LDK_Bolt11Invoice_expiration_remaining_from_epoch(int64_t this_arg, int64_t time) {
70226         LDKBolt11Invoice this_arg_conv;
70227         this_arg_conv.inner = untag_ptr(this_arg);
70228         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70230         this_arg_conv.is_owned = false;
70231         int64_t ret_conv = Bolt11Invoice_expiration_remaining_from_epoch(&this_arg_conv, time);
70232         return ret_conv;
70233 }
70234
70235 jboolean  CS_LDK_Bolt11Invoice_would_expire(int64_t this_arg, int64_t at_time) {
70236         LDKBolt11Invoice this_arg_conv;
70237         this_arg_conv.inner = untag_ptr(this_arg);
70238         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70240         this_arg_conv.is_owned = false;
70241         jboolean ret_conv = Bolt11Invoice_would_expire(&this_arg_conv, at_time);
70242         return ret_conv;
70243 }
70244
70245 int64_t  CS_LDK_Bolt11Invoice_min_final_cltv_expiry_delta(int64_t this_arg) {
70246         LDKBolt11Invoice this_arg_conv;
70247         this_arg_conv.inner = untag_ptr(this_arg);
70248         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70250         this_arg_conv.is_owned = false;
70251         int64_t ret_conv = Bolt11Invoice_min_final_cltv_expiry_delta(&this_arg_conv);
70252         return ret_conv;
70253 }
70254
70255 ptrArray  CS_LDK_Bolt11Invoice_fallback_addresses(int64_t this_arg) {
70256         LDKBolt11Invoice this_arg_conv;
70257         this_arg_conv.inner = untag_ptr(this_arg);
70258         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70260         this_arg_conv.is_owned = false;
70261         LDKCVec_StrZ ret_var = Bolt11Invoice_fallback_addresses(&this_arg_conv);
70262         ptrArray ret_arr = NULL;
70263         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
70264         jstring *ret_arr_ptr = (jstring*)(((uint8_t*)ret_arr) + 8);
70265         for (size_t i = 0; i < ret_var.datalen; i++) {
70266                 LDKStr ret_conv_8_str = ret_var.data[i];
70267                 jstring ret_conv_8_conv = str_ref_to_cs(ret_conv_8_str.chars, ret_conv_8_str.len);
70268                 Str_free(ret_conv_8_str);
70269                 ret_arr_ptr[i] = ret_conv_8_conv;
70270         }
70271         
70272         FREE(ret_var.data);
70273         return ret_arr;
70274 }
70275
70276 int64_tArray  CS_LDK_Bolt11Invoice_private_routes(int64_t this_arg) {
70277         LDKBolt11Invoice this_arg_conv;
70278         this_arg_conv.inner = untag_ptr(this_arg);
70279         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70281         this_arg_conv.is_owned = false;
70282         LDKCVec_PrivateRouteZ ret_var = Bolt11Invoice_private_routes(&this_arg_conv);
70283         int64_tArray ret_arr = NULL;
70284         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
70285         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
70286         for (size_t o = 0; o < ret_var.datalen; o++) {
70287                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
70288                 int64_t ret_conv_14_ref = 0;
70289                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
70290                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
70291                 ret_arr_ptr[o] = ret_conv_14_ref;
70292         }
70293         
70294         FREE(ret_var.data);
70295         return ret_arr;
70296 }
70297
70298 int64_tArray  CS_LDK_Bolt11Invoice_route_hints(int64_t this_arg) {
70299         LDKBolt11Invoice this_arg_conv;
70300         this_arg_conv.inner = untag_ptr(this_arg);
70301         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70303         this_arg_conv.is_owned = false;
70304         LDKCVec_RouteHintZ ret_var = Bolt11Invoice_route_hints(&this_arg_conv);
70305         int64_tArray ret_arr = NULL;
70306         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
70307         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
70308         for (size_t l = 0; l < ret_var.datalen; l++) {
70309                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
70310                 int64_t ret_conv_11_ref = 0;
70311                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
70312                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
70313                 ret_arr_ptr[l] = ret_conv_11_ref;
70314         }
70315         
70316         FREE(ret_var.data);
70317         return ret_arr;
70318 }
70319
70320 int32_t  CS_LDK_Bolt11Invoice_currency(int64_t this_arg) {
70321         LDKBolt11Invoice this_arg_conv;
70322         this_arg_conv.inner = untag_ptr(this_arg);
70323         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70325         this_arg_conv.is_owned = false;
70326         int32_t ret_conv = LDKCurrency_to_cs(Bolt11Invoice_currency(&this_arg_conv));
70327         return ret_conv;
70328 }
70329
70330 int64_t  CS_LDK_Bolt11Invoice_amount_milli_satoshis(int64_t this_arg) {
70331         LDKBolt11Invoice this_arg_conv;
70332         this_arg_conv.inner = untag_ptr(this_arg);
70333         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70335         this_arg_conv.is_owned = false;
70336         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
70337         *ret_copy = Bolt11Invoice_amount_milli_satoshis(&this_arg_conv);
70338         int64_t ret_ref = tag_ptr(ret_copy, true);
70339         return ret_ref;
70340 }
70341
70342 int64_t  CS_LDK_Description_new(jstring description) {
70343         LDKStr description_conv = str_ref_to_owned_c(description);
70344         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
70345         *ret_conv = Description_new(description_conv);
70346         return tag_ptr(ret_conv, true);
70347 }
70348
70349 jstring  CS_LDK_Description_into_inner(int64_t this_arg) {
70350         LDKDescription this_arg_conv;
70351         this_arg_conv.inner = untag_ptr(this_arg);
70352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70354         this_arg_conv = Description_clone(&this_arg_conv);
70355         LDKStr ret_str = Description_into_inner(this_arg_conv);
70356         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
70357         Str_free(ret_str);
70358         return ret_conv;
70359 }
70360
70361 int64_t  CS_LDK_ExpiryTime_from_seconds(int64_t seconds) {
70362         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
70363         int64_t ret_ref = 0;
70364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70366         return ret_ref;
70367 }
70368
70369 int64_t  CS_LDK_ExpiryTime_from_duration(int64_t duration) {
70370         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
70371         int64_t ret_ref = 0;
70372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70374         return ret_ref;
70375 }
70376
70377 int64_t  CS_LDK_ExpiryTime_as_seconds(int64_t this_arg) {
70378         LDKExpiryTime this_arg_conv;
70379         this_arg_conv.inner = untag_ptr(this_arg);
70380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70382         this_arg_conv.is_owned = false;
70383         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
70384         return ret_conv;
70385 }
70386
70387 int64_t  CS_LDK_ExpiryTime_as_duration(int64_t this_arg) {
70388         LDKExpiryTime this_arg_conv;
70389         this_arg_conv.inner = untag_ptr(this_arg);
70390         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70392         this_arg_conv.is_owned = false;
70393         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
70394         return ret_conv;
70395 }
70396
70397 int64_t  CS_LDK_PrivateRoute_new(int64_t hops) {
70398         LDKRouteHint hops_conv;
70399         hops_conv.inner = untag_ptr(hops);
70400         hops_conv.is_owned = ptr_is_owned(hops);
70401         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
70402         hops_conv = RouteHint_clone(&hops_conv);
70403         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
70404         *ret_conv = PrivateRoute_new(hops_conv);
70405         return tag_ptr(ret_conv, true);
70406 }
70407
70408 int64_t  CS_LDK_PrivateRoute_into_inner(int64_t this_arg) {
70409         LDKPrivateRoute this_arg_conv;
70410         this_arg_conv.inner = untag_ptr(this_arg);
70411         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70413         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
70414         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
70415         int64_t ret_ref = 0;
70416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70418         return ret_ref;
70419 }
70420
70421 int32_t  CS_LDK_CreationError_clone(int64_t orig) {
70422         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
70423         int32_t ret_conv = LDKCreationError_to_cs(CreationError_clone(orig_conv));
70424         return ret_conv;
70425 }
70426
70427 int32_t  CS_LDK_CreationError_description_too_long() {
70428         int32_t ret_conv = LDKCreationError_to_cs(CreationError_description_too_long());
70429         return ret_conv;
70430 }
70431
70432 int32_t  CS_LDK_CreationError_route_too_long() {
70433         int32_t ret_conv = LDKCreationError_to_cs(CreationError_route_too_long());
70434         return ret_conv;
70435 }
70436
70437 int32_t  CS_LDK_CreationError_timestamp_out_of_bounds() {
70438         int32_t ret_conv = LDKCreationError_to_cs(CreationError_timestamp_out_of_bounds());
70439         return ret_conv;
70440 }
70441
70442 int32_t  CS_LDK_CreationError_invalid_amount() {
70443         int32_t ret_conv = LDKCreationError_to_cs(CreationError_invalid_amount());
70444         return ret_conv;
70445 }
70446
70447 int32_t  CS_LDK_CreationError_missing_route_hints() {
70448         int32_t ret_conv = LDKCreationError_to_cs(CreationError_missing_route_hints());
70449         return ret_conv;
70450 }
70451
70452 int32_t  CS_LDK_CreationError_min_final_cltv_expiry_delta_too_short() {
70453         int32_t ret_conv = LDKCreationError_to_cs(CreationError_min_final_cltv_expiry_delta_too_short());
70454         return ret_conv;
70455 }
70456
70457 jboolean  CS_LDK_CreationError_eq(int64_t a, int64_t b) {
70458         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
70459         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
70460         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
70461         return ret_conv;
70462 }
70463
70464 jstring  CS_LDK_CreationError_to_str(int64_t o) {
70465         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
70466         LDKStr ret_str = CreationError_to_str(o_conv);
70467         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
70468         Str_free(ret_str);
70469         return ret_conv;
70470 }
70471
70472 int32_t  CS_LDK_Bolt11SemanticError_clone(int64_t orig) {
70473         LDKBolt11SemanticError* orig_conv = (LDKBolt11SemanticError*)untag_ptr(orig);
70474         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_clone(orig_conv));
70475         return ret_conv;
70476 }
70477
70478 int32_t  CS_LDK_Bolt11SemanticError_no_payment_hash() {
70479         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_no_payment_hash());
70480         return ret_conv;
70481 }
70482
70483 int32_t  CS_LDK_Bolt11SemanticError_multiple_payment_hashes() {
70484         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_multiple_payment_hashes());
70485         return ret_conv;
70486 }
70487
70488 int32_t  CS_LDK_Bolt11SemanticError_no_description() {
70489         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_no_description());
70490         return ret_conv;
70491 }
70492
70493 int32_t  CS_LDK_Bolt11SemanticError_multiple_descriptions() {
70494         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_multiple_descriptions());
70495         return ret_conv;
70496 }
70497
70498 int32_t  CS_LDK_Bolt11SemanticError_no_payment_secret() {
70499         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_no_payment_secret());
70500         return ret_conv;
70501 }
70502
70503 int32_t  CS_LDK_Bolt11SemanticError_multiple_payment_secrets() {
70504         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_multiple_payment_secrets());
70505         return ret_conv;
70506 }
70507
70508 int32_t  CS_LDK_Bolt11SemanticError_invalid_features() {
70509         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_invalid_features());
70510         return ret_conv;
70511 }
70512
70513 int32_t  CS_LDK_Bolt11SemanticError_invalid_recovery_id() {
70514         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_invalid_recovery_id());
70515         return ret_conv;
70516 }
70517
70518 int32_t  CS_LDK_Bolt11SemanticError_invalid_signature() {
70519         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_invalid_signature());
70520         return ret_conv;
70521 }
70522
70523 int32_t  CS_LDK_Bolt11SemanticError_imprecise_amount() {
70524         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_imprecise_amount());
70525         return ret_conv;
70526 }
70527
70528 jboolean  CS_LDK_Bolt11SemanticError_eq(int64_t a, int64_t b) {
70529         LDKBolt11SemanticError* a_conv = (LDKBolt11SemanticError*)untag_ptr(a);
70530         LDKBolt11SemanticError* b_conv = (LDKBolt11SemanticError*)untag_ptr(b);
70531         jboolean ret_conv = Bolt11SemanticError_eq(a_conv, b_conv);
70532         return ret_conv;
70533 }
70534
70535 jstring  CS_LDK_Bolt11SemanticError_to_str(int64_t o) {
70536         LDKBolt11SemanticError* o_conv = (LDKBolt11SemanticError*)untag_ptr(o);
70537         LDKStr ret_str = Bolt11SemanticError_to_str(o_conv);
70538         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
70539         Str_free(ret_str);
70540         return ret_conv;
70541 }
70542
70543 void  CS_LDK_SignOrCreationError_free(int64_t this_ptr) {
70544         if (!ptr_is_owned(this_ptr)) return;
70545         void* this_ptr_ptr = untag_ptr(this_ptr);
70546         CHECK_ACCESS(this_ptr_ptr);
70547         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
70548         FREE(untag_ptr(this_ptr));
70549         SignOrCreationError_free(this_ptr_conv);
70550 }
70551
70552 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
70553         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
70554         *ret_copy = SignOrCreationError_clone(arg);
70555         int64_t ret_ref = tag_ptr(ret_copy, true);
70556         return ret_ref;
70557 }
70558 int64_t  CS_LDK_SignOrCreationError_clone_ptr(int64_t arg) {
70559         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
70560         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
70561         return ret_conv;
70562 }
70563
70564 int64_t  CS_LDK_SignOrCreationError_clone(int64_t orig) {
70565         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
70566         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
70567         *ret_copy = SignOrCreationError_clone(orig_conv);
70568         int64_t ret_ref = tag_ptr(ret_copy, true);
70569         return ret_ref;
70570 }
70571
70572 int64_t  CS_LDK_SignOrCreationError_sign_error() {
70573         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
70574         *ret_copy = SignOrCreationError_sign_error();
70575         int64_t ret_ref = tag_ptr(ret_copy, true);
70576         return ret_ref;
70577 }
70578
70579 int64_t  CS_LDK_SignOrCreationError_creation_error(int32_t a) {
70580         LDKCreationError a_conv = LDKCreationError_from_cs(a);
70581         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
70582         *ret_copy = SignOrCreationError_creation_error(a_conv);
70583         int64_t ret_ref = tag_ptr(ret_copy, true);
70584         return ret_ref;
70585 }
70586
70587 jboolean  CS_LDK_SignOrCreationError_eq(int64_t a, int64_t b) {
70588         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
70589         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
70590         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
70591         return ret_conv;
70592 }
70593
70594 jstring  CS_LDK_SignOrCreationError_to_str(int64_t o) {
70595         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
70596         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
70597         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
70598         Str_free(ret_str);
70599         return ret_conv;
70600 }
70601
70602 int64_t  CS_LDK_pay_invoice(int64_t invoice, int64_t retry_strategy, int64_t channelmanager) {
70603         LDKBolt11Invoice invoice_conv;
70604         invoice_conv.inner = untag_ptr(invoice);
70605         invoice_conv.is_owned = ptr_is_owned(invoice);
70606         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70607         invoice_conv.is_owned = false;
70608         void* retry_strategy_ptr = untag_ptr(retry_strategy);
70609         CHECK_ACCESS(retry_strategy_ptr);
70610         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
70611         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
70612         LDKChannelManager channelmanager_conv;
70613         channelmanager_conv.inner = untag_ptr(channelmanager);
70614         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70615         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70616         channelmanager_conv.is_owned = false;
70617         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
70618         *ret_conv = pay_invoice(&invoice_conv, retry_strategy_conv, &channelmanager_conv);
70619         return tag_ptr(ret_conv, true);
70620 }
70621
70622 int64_t  CS_LDK_pay_invoice_with_id(int64_t invoice, int8_tArray payment_id, int64_t retry_strategy, int64_t channelmanager) {
70623         LDKBolt11Invoice invoice_conv;
70624         invoice_conv.inner = untag_ptr(invoice);
70625         invoice_conv.is_owned = ptr_is_owned(invoice);
70626         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70627         invoice_conv.is_owned = false;
70628         LDKThirtyTwoBytes payment_id_ref;
70629         CHECK(payment_id->arr_len == 32);
70630         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
70631         void* retry_strategy_ptr = untag_ptr(retry_strategy);
70632         CHECK_ACCESS(retry_strategy_ptr);
70633         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
70634         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
70635         LDKChannelManager channelmanager_conv;
70636         channelmanager_conv.inner = untag_ptr(channelmanager);
70637         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70638         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70639         channelmanager_conv.is_owned = false;
70640         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
70641         *ret_conv = pay_invoice_with_id(&invoice_conv, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
70642         return tag_ptr(ret_conv, true);
70643 }
70644
70645 int64_t  CS_LDK_pay_zero_value_invoice(int64_t invoice, int64_t amount_msats, int64_t retry_strategy, int64_t channelmanager) {
70646         LDKBolt11Invoice invoice_conv;
70647         invoice_conv.inner = untag_ptr(invoice);
70648         invoice_conv.is_owned = ptr_is_owned(invoice);
70649         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70650         invoice_conv.is_owned = false;
70651         void* retry_strategy_ptr = untag_ptr(retry_strategy);
70652         CHECK_ACCESS(retry_strategy_ptr);
70653         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
70654         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
70655         LDKChannelManager channelmanager_conv;
70656         channelmanager_conv.inner = untag_ptr(channelmanager);
70657         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70658         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70659         channelmanager_conv.is_owned = false;
70660         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
70661         *ret_conv = pay_zero_value_invoice(&invoice_conv, amount_msats, retry_strategy_conv, &channelmanager_conv);
70662         return tag_ptr(ret_conv, true);
70663 }
70664
70665 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) {
70666         LDKBolt11Invoice invoice_conv;
70667         invoice_conv.inner = untag_ptr(invoice);
70668         invoice_conv.is_owned = ptr_is_owned(invoice);
70669         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70670         invoice_conv.is_owned = false;
70671         LDKThirtyTwoBytes payment_id_ref;
70672         CHECK(payment_id->arr_len == 32);
70673         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
70674         void* retry_strategy_ptr = untag_ptr(retry_strategy);
70675         CHECK_ACCESS(retry_strategy_ptr);
70676         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
70677         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
70678         LDKChannelManager channelmanager_conv;
70679         channelmanager_conv.inner = untag_ptr(channelmanager);
70680         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70681         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70682         channelmanager_conv.is_owned = false;
70683         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
70684         *ret_conv = pay_zero_value_invoice_with_id(&invoice_conv, amount_msats, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
70685         return tag_ptr(ret_conv, true);
70686 }
70687
70688 int64_t  CS_LDK_preflight_probe_invoice(int64_t invoice, int64_t channelmanager, int64_t liquidity_limit_multiplier) {
70689         LDKBolt11Invoice invoice_conv;
70690         invoice_conv.inner = untag_ptr(invoice);
70691         invoice_conv.is_owned = ptr_is_owned(invoice);
70692         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70693         invoice_conv.is_owned = false;
70694         LDKChannelManager channelmanager_conv;
70695         channelmanager_conv.inner = untag_ptr(channelmanager);
70696         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70697         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70698         channelmanager_conv.is_owned = false;
70699         void* liquidity_limit_multiplier_ptr = untag_ptr(liquidity_limit_multiplier);
70700         CHECK_ACCESS(liquidity_limit_multiplier_ptr);
70701         LDKCOption_u64Z liquidity_limit_multiplier_conv = *(LDKCOption_u64Z*)(liquidity_limit_multiplier_ptr);
70702         liquidity_limit_multiplier_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(liquidity_limit_multiplier));
70703         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
70704         *ret_conv = preflight_probe_invoice(&invoice_conv, &channelmanager_conv, liquidity_limit_multiplier_conv);
70705         return tag_ptr(ret_conv, true);
70706 }
70707
70708 int64_t  CS_LDK_preflight_probe_zero_value_invoice(int64_t invoice, int64_t amount_msat, int64_t channelmanager, int64_t liquidity_limit_multiplier) {
70709         LDKBolt11Invoice invoice_conv;
70710         invoice_conv.inner = untag_ptr(invoice);
70711         invoice_conv.is_owned = ptr_is_owned(invoice);
70712         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70713         invoice_conv.is_owned = false;
70714         LDKChannelManager channelmanager_conv;
70715         channelmanager_conv.inner = untag_ptr(channelmanager);
70716         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70717         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70718         channelmanager_conv.is_owned = false;
70719         void* liquidity_limit_multiplier_ptr = untag_ptr(liquidity_limit_multiplier);
70720         CHECK_ACCESS(liquidity_limit_multiplier_ptr);
70721         LDKCOption_u64Z liquidity_limit_multiplier_conv = *(LDKCOption_u64Z*)(liquidity_limit_multiplier_ptr);
70722         liquidity_limit_multiplier_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(liquidity_limit_multiplier));
70723         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
70724         *ret_conv = preflight_probe_zero_value_invoice(&invoice_conv, amount_msat, &channelmanager_conv, liquidity_limit_multiplier_conv);
70725         return tag_ptr(ret_conv, true);
70726 }
70727
70728 void  CS_LDK_PaymentError_free(int64_t this_ptr) {
70729         if (!ptr_is_owned(this_ptr)) return;
70730         void* this_ptr_ptr = untag_ptr(this_ptr);
70731         CHECK_ACCESS(this_ptr_ptr);
70732         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
70733         FREE(untag_ptr(this_ptr));
70734         PaymentError_free(this_ptr_conv);
70735 }
70736
70737 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
70738         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
70739         *ret_copy = PaymentError_clone(arg);
70740         int64_t ret_ref = tag_ptr(ret_copy, true);
70741         return ret_ref;
70742 }
70743 int64_t  CS_LDK_PaymentError_clone_ptr(int64_t arg) {
70744         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
70745         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
70746         return ret_conv;
70747 }
70748
70749 int64_t  CS_LDK_PaymentError_clone(int64_t orig) {
70750         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
70751         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
70752         *ret_copy = PaymentError_clone(orig_conv);
70753         int64_t ret_ref = tag_ptr(ret_copy, true);
70754         return ret_ref;
70755 }
70756
70757 int64_t  CS_LDK_PaymentError_invoice(jstring a) {
70758         LDKStr a_conv = str_ref_to_owned_c(a);
70759         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
70760         *ret_copy = PaymentError_invoice(a_conv);
70761         int64_t ret_ref = tag_ptr(ret_copy, true);
70762         return ret_ref;
70763 }
70764
70765 int64_t  CS_LDK_PaymentError_sending(int32_t a) {
70766         LDKRetryableSendFailure a_conv = LDKRetryableSendFailure_from_cs(a);
70767         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
70768         *ret_copy = PaymentError_sending(a_conv);
70769         int64_t ret_ref = tag_ptr(ret_copy, true);
70770         return ret_ref;
70771 }
70772
70773 jboolean  CS_LDK_PaymentError_eq(int64_t a, int64_t b) {
70774         LDKPaymentError* a_conv = (LDKPaymentError*)untag_ptr(a);
70775         LDKPaymentError* b_conv = (LDKPaymentError*)untag_ptr(b);
70776         jboolean ret_conv = PaymentError_eq(a_conv, b_conv);
70777         return ret_conv;
70778 }
70779
70780 void  CS_LDK_ProbingError_free(int64_t this_ptr) {
70781         if (!ptr_is_owned(this_ptr)) return;
70782         void* this_ptr_ptr = untag_ptr(this_ptr);
70783         CHECK_ACCESS(this_ptr_ptr);
70784         LDKProbingError this_ptr_conv = *(LDKProbingError*)(this_ptr_ptr);
70785         FREE(untag_ptr(this_ptr));
70786         ProbingError_free(this_ptr_conv);
70787 }
70788
70789 static inline uint64_t ProbingError_clone_ptr(LDKProbingError *NONNULL_PTR arg) {
70790         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
70791         *ret_copy = ProbingError_clone(arg);
70792         int64_t ret_ref = tag_ptr(ret_copy, true);
70793         return ret_ref;
70794 }
70795 int64_t  CS_LDK_ProbingError_clone_ptr(int64_t arg) {
70796         LDKProbingError* arg_conv = (LDKProbingError*)untag_ptr(arg);
70797         int64_t ret_conv = ProbingError_clone_ptr(arg_conv);
70798         return ret_conv;
70799 }
70800
70801 int64_t  CS_LDK_ProbingError_clone(int64_t orig) {
70802         LDKProbingError* orig_conv = (LDKProbingError*)untag_ptr(orig);
70803         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
70804         *ret_copy = ProbingError_clone(orig_conv);
70805         int64_t ret_ref = tag_ptr(ret_copy, true);
70806         return ret_ref;
70807 }
70808
70809 int64_t  CS_LDK_ProbingError_invoice(jstring a) {
70810         LDKStr a_conv = str_ref_to_owned_c(a);
70811         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
70812         *ret_copy = ProbingError_invoice(a_conv);
70813         int64_t ret_ref = tag_ptr(ret_copy, true);
70814         return ret_ref;
70815 }
70816
70817 int64_t  CS_LDK_ProbingError_sending(int64_t a) {
70818         void* a_ptr = untag_ptr(a);
70819         CHECK_ACCESS(a_ptr);
70820         LDKProbeSendFailure a_conv = *(LDKProbeSendFailure*)(a_ptr);
70821         a_conv = ProbeSendFailure_clone((LDKProbeSendFailure*)untag_ptr(a));
70822         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
70823         *ret_copy = ProbingError_sending(a_conv);
70824         int64_t ret_ref = tag_ptr(ret_copy, true);
70825         return ret_ref;
70826 }
70827
70828 jboolean  CS_LDK_ProbingError_eq(int64_t a, int64_t b) {
70829         LDKProbingError* a_conv = (LDKProbingError*)untag_ptr(a);
70830         LDKProbingError* b_conv = (LDKProbingError*)untag_ptr(b);
70831         jboolean ret_conv = ProbingError_eq(a_conv, b_conv);
70832         return ret_conv;
70833 }
70834
70835 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) {
70836         void* amt_msat_ptr = untag_ptr(amt_msat);
70837         CHECK_ACCESS(amt_msat_ptr);
70838         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
70839         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
70840         void* payment_hash_ptr = untag_ptr(payment_hash);
70841         CHECK_ACCESS(payment_hash_ptr);
70842         LDKCOption_ThirtyTwoBytesZ payment_hash_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_hash_ptr);
70843         payment_hash_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_hash));
70844         LDKStr description_conv = str_ref_to_owned_c(description);
70845         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
70846         phantom_route_hints_constr.datalen = phantom_route_hints->arr_len;
70847         if (phantom_route_hints_constr.datalen > 0)
70848                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
70849         else
70850                 phantom_route_hints_constr.data = NULL;
70851         int64_t* phantom_route_hints_vals = phantom_route_hints->elems;
70852         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
70853                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
70854                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
70855                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
70856                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
70857                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
70858                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
70859                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
70860         }
70861         FREE(phantom_route_hints);
70862         void* entropy_source_ptr = untag_ptr(entropy_source);
70863         CHECK_ACCESS(entropy_source_ptr);
70864         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
70865         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
70866                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70867                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
70868         }
70869         void* node_signer_ptr = untag_ptr(node_signer);
70870         CHECK_ACCESS(node_signer_ptr);
70871         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
70872         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
70873                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70874                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
70875         }
70876         void* logger_ptr = untag_ptr(logger);
70877         CHECK_ACCESS(logger_ptr);
70878         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
70879         if (logger_conv.free == LDKLogger_JCalls_free) {
70880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70881                 LDKLogger_JCalls_cloned(&logger_conv);
70882         }
70883         LDKCurrency network_conv = LDKCurrency_from_cs(network);
70884         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
70885         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
70886         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
70887         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
70888         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
70889         *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);
70890         return tag_ptr(ret_conv, true);
70891 }
70892
70893 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) {
70894         void* amt_msat_ptr = untag_ptr(amt_msat);
70895         CHECK_ACCESS(amt_msat_ptr);
70896         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
70897         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
70898         void* payment_hash_ptr = untag_ptr(payment_hash);
70899         CHECK_ACCESS(payment_hash_ptr);
70900         LDKCOption_ThirtyTwoBytesZ payment_hash_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_hash_ptr);
70901         payment_hash_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_hash));
70902         LDKSha256 description_hash_conv;
70903         description_hash_conv.inner = untag_ptr(description_hash);
70904         description_hash_conv.is_owned = ptr_is_owned(description_hash);
70905         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
70906         description_hash_conv = Sha256_clone(&description_hash_conv);
70907         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
70908         phantom_route_hints_constr.datalen = phantom_route_hints->arr_len;
70909         if (phantom_route_hints_constr.datalen > 0)
70910                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
70911         else
70912                 phantom_route_hints_constr.data = NULL;
70913         int64_t* phantom_route_hints_vals = phantom_route_hints->elems;
70914         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
70915                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
70916                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
70917                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
70918                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
70919                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
70920                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
70921                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
70922         }
70923         FREE(phantom_route_hints);
70924         void* entropy_source_ptr = untag_ptr(entropy_source);
70925         CHECK_ACCESS(entropy_source_ptr);
70926         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
70927         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
70928                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70929                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
70930         }
70931         void* node_signer_ptr = untag_ptr(node_signer);
70932         CHECK_ACCESS(node_signer_ptr);
70933         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
70934         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
70935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70936                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
70937         }
70938         void* logger_ptr = untag_ptr(logger);
70939         CHECK_ACCESS(logger_ptr);
70940         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
70941         if (logger_conv.free == LDKLogger_JCalls_free) {
70942                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70943                 LDKLogger_JCalls_cloned(&logger_conv);
70944         }
70945         LDKCurrency network_conv = LDKCurrency_from_cs(network);
70946         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
70947         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
70948         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
70949         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
70950         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
70951         *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);
70952         return tag_ptr(ret_conv, true);
70953 }
70954
70955 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) {
70956         LDKChannelManager channelmanager_conv;
70957         channelmanager_conv.inner = untag_ptr(channelmanager);
70958         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70959         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70960         channelmanager_conv.is_owned = false;
70961         void* node_signer_ptr = untag_ptr(node_signer);
70962         CHECK_ACCESS(node_signer_ptr);
70963         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
70964         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
70965                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70966                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
70967         }
70968         void* logger_ptr = untag_ptr(logger);
70969         CHECK_ACCESS(logger_ptr);
70970         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
70971         if (logger_conv.free == LDKLogger_JCalls_free) {
70972                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70973                 LDKLogger_JCalls_cloned(&logger_conv);
70974         }
70975         LDKCurrency network_conv = LDKCurrency_from_cs(network);
70976         void* amt_msat_ptr = untag_ptr(amt_msat);
70977         CHECK_ACCESS(amt_msat_ptr);
70978         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
70979         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
70980         LDKStr description_conv = str_ref_to_owned_c(description);
70981         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
70982         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
70983         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
70984         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
70985         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
70986         *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);
70987         return tag_ptr(ret_conv, true);
70988 }
70989
70990 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) {
70991         LDKChannelManager channelmanager_conv;
70992         channelmanager_conv.inner = untag_ptr(channelmanager);
70993         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70994         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70995         channelmanager_conv.is_owned = false;
70996         void* node_signer_ptr = untag_ptr(node_signer);
70997         CHECK_ACCESS(node_signer_ptr);
70998         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
70999         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
71000                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71001                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
71002         }
71003         void* logger_ptr = untag_ptr(logger);
71004         CHECK_ACCESS(logger_ptr);
71005         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71006         if (logger_conv.free == LDKLogger_JCalls_free) {
71007                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71008                 LDKLogger_JCalls_cloned(&logger_conv);
71009         }
71010         LDKCurrency network_conv = LDKCurrency_from_cs(network);
71011         void* amt_msat_ptr = untag_ptr(amt_msat);
71012         CHECK_ACCESS(amt_msat_ptr);
71013         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
71014         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
71015         LDKSha256 description_hash_conv;
71016         description_hash_conv.inner = untag_ptr(description_hash);
71017         description_hash_conv.is_owned = ptr_is_owned(description_hash);
71018         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
71019         description_hash_conv = Sha256_clone(&description_hash_conv);
71020         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
71021         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
71022         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
71023         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
71024         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
71025         *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);
71026         return tag_ptr(ret_conv, true);
71027 }
71028
71029 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) {
71030         LDKChannelManager channelmanager_conv;
71031         channelmanager_conv.inner = untag_ptr(channelmanager);
71032         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
71033         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
71034         channelmanager_conv.is_owned = false;
71035         void* node_signer_ptr = untag_ptr(node_signer);
71036         CHECK_ACCESS(node_signer_ptr);
71037         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
71038         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
71039                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71040                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
71041         }
71042         void* logger_ptr = untag_ptr(logger);
71043         CHECK_ACCESS(logger_ptr);
71044         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71045         if (logger_conv.free == LDKLogger_JCalls_free) {
71046                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71047                 LDKLogger_JCalls_cloned(&logger_conv);
71048         }
71049         LDKCurrency network_conv = LDKCurrency_from_cs(network);
71050         void* amt_msat_ptr = untag_ptr(amt_msat);
71051         CHECK_ACCESS(amt_msat_ptr);
71052         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
71053         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
71054         LDKSha256 description_hash_conv;
71055         description_hash_conv.inner = untag_ptr(description_hash);
71056         description_hash_conv.is_owned = ptr_is_owned(description_hash);
71057         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
71058         description_hash_conv = Sha256_clone(&description_hash_conv);
71059         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
71060         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
71061         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
71062         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
71063         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
71064         *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);
71065         return tag_ptr(ret_conv, true);
71066 }
71067
71068 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) {
71069         LDKChannelManager channelmanager_conv;
71070         channelmanager_conv.inner = untag_ptr(channelmanager);
71071         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
71072         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
71073         channelmanager_conv.is_owned = false;
71074         void* node_signer_ptr = untag_ptr(node_signer);
71075         CHECK_ACCESS(node_signer_ptr);
71076         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
71077         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
71078                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71079                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
71080         }
71081         void* logger_ptr = untag_ptr(logger);
71082         CHECK_ACCESS(logger_ptr);
71083         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71084         if (logger_conv.free == LDKLogger_JCalls_free) {
71085                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71086                 LDKLogger_JCalls_cloned(&logger_conv);
71087         }
71088         LDKCurrency network_conv = LDKCurrency_from_cs(network);
71089         void* amt_msat_ptr = untag_ptr(amt_msat);
71090         CHECK_ACCESS(amt_msat_ptr);
71091         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
71092         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
71093         LDKStr description_conv = str_ref_to_owned_c(description);
71094         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
71095         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
71096         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
71097         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
71098         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
71099         *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);
71100         return tag_ptr(ret_conv, true);
71101 }
71102
71103 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) {
71104         LDKChannelManager channelmanager_conv;
71105         channelmanager_conv.inner = untag_ptr(channelmanager);
71106         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
71107         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
71108         channelmanager_conv.is_owned = false;
71109         void* node_signer_ptr = untag_ptr(node_signer);
71110         CHECK_ACCESS(node_signer_ptr);
71111         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
71112         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
71113                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71114                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
71115         }
71116         void* logger_ptr = untag_ptr(logger);
71117         CHECK_ACCESS(logger_ptr);
71118         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71119         if (logger_conv.free == LDKLogger_JCalls_free) {
71120                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71121                 LDKLogger_JCalls_cloned(&logger_conv);
71122         }
71123         LDKCurrency network_conv = LDKCurrency_from_cs(network);
71124         void* amt_msat_ptr = untag_ptr(amt_msat);
71125         CHECK_ACCESS(amt_msat_ptr);
71126         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
71127         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
71128         LDKStr description_conv = str_ref_to_owned_c(description);
71129         LDKThirtyTwoBytes payment_hash_ref;
71130         CHECK(payment_hash->arr_len == 32);
71131         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
71132         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
71133         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
71134         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
71135         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
71136         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
71137         *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);
71138         return tag_ptr(ret_conv, true);
71139 }
71140
71141 int64_t  CS_LDK_SiPrefix_from_str(jstring s) {
71142         LDKStr s_conv = str_ref_to_owned_c(s);
71143         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
71144         *ret_conv = SiPrefix_from_str(s_conv);
71145         return tag_ptr(ret_conv, true);
71146 }
71147
71148 int64_t  CS_LDK_Bolt11Invoice_from_str(jstring s) {
71149         LDKStr s_conv = str_ref_to_owned_c(s);
71150         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
71151         *ret_conv = Bolt11Invoice_from_str(s_conv);
71152         return tag_ptr(ret_conv, true);
71153 }
71154
71155 int64_t  CS_LDK_SignedRawBolt11Invoice_from_str(jstring s) {
71156         LDKStr s_conv = str_ref_to_owned_c(s);
71157         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
71158         *ret_conv = SignedRawBolt11Invoice_from_str(s_conv);
71159         return tag_ptr(ret_conv, true);
71160 }
71161
71162 jstring  CS_LDK_Bolt11ParseError_to_str(int64_t o) {
71163         LDKBolt11ParseError* o_conv = (LDKBolt11ParseError*)untag_ptr(o);
71164         LDKStr ret_str = Bolt11ParseError_to_str(o_conv);
71165         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71166         Str_free(ret_str);
71167         return ret_conv;
71168 }
71169
71170 jstring  CS_LDK_ParseOrSemanticError_to_str(int64_t o) {
71171         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
71172         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
71173         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71174         Str_free(ret_str);
71175         return ret_conv;
71176 }
71177
71178 jstring  CS_LDK_Bolt11Invoice_to_str(int64_t o) {
71179         LDKBolt11Invoice o_conv;
71180         o_conv.inner = untag_ptr(o);
71181         o_conv.is_owned = ptr_is_owned(o);
71182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
71183         o_conv.is_owned = false;
71184         LDKStr ret_str = Bolt11Invoice_to_str(&o_conv);
71185         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71186         Str_free(ret_str);
71187         return ret_conv;
71188 }
71189
71190 jstring  CS_LDK_SignedRawBolt11Invoice_to_str(int64_t o) {
71191         LDKSignedRawBolt11Invoice o_conv;
71192         o_conv.inner = untag_ptr(o);
71193         o_conv.is_owned = ptr_is_owned(o);
71194         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
71195         o_conv.is_owned = false;
71196         LDKStr ret_str = SignedRawBolt11Invoice_to_str(&o_conv);
71197         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71198         Str_free(ret_str);
71199         return ret_conv;
71200 }
71201
71202 jstring  CS_LDK_Currency_to_str(int64_t o) {
71203         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
71204         LDKStr ret_str = Currency_to_str(o_conv);
71205         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71206         Str_free(ret_str);
71207         return ret_conv;
71208 }
71209
71210 jstring  CS_LDK_SiPrefix_to_str(int64_t o) {
71211         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
71212         LDKStr ret_str = SiPrefix_to_str(o_conv);
71213         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71214         Str_free(ret_str);
71215         return ret_conv;
71216 }
71217
71218 void  CS_LDK_RapidGossipSync_free(int64_t this_obj) {
71219         LDKRapidGossipSync this_obj_conv;
71220         this_obj_conv.inner = untag_ptr(this_obj);
71221         this_obj_conv.is_owned = ptr_is_owned(this_obj);
71222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
71223         RapidGossipSync_free(this_obj_conv);
71224 }
71225
71226 int64_t  CS_LDK_RapidGossipSync_new(int64_t network_graph, int64_t logger) {
71227         LDKNetworkGraph network_graph_conv;
71228         network_graph_conv.inner = untag_ptr(network_graph);
71229         network_graph_conv.is_owned = ptr_is_owned(network_graph);
71230         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
71231         network_graph_conv.is_owned = false;
71232         void* logger_ptr = untag_ptr(logger);
71233         CHECK_ACCESS(logger_ptr);
71234         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71235         if (logger_conv.free == LDKLogger_JCalls_free) {
71236                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71237                 LDKLogger_JCalls_cloned(&logger_conv);
71238         }
71239         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv, logger_conv);
71240         int64_t ret_ref = 0;
71241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
71242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
71243         return ret_ref;
71244 }
71245
71246 int64_t  CS_LDK_RapidGossipSync_sync_network_graph_with_file_path(int64_t this_arg, jstring sync_path) {
71247         LDKRapidGossipSync this_arg_conv;
71248         this_arg_conv.inner = untag_ptr(this_arg);
71249         this_arg_conv.is_owned = ptr_is_owned(this_arg);
71250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
71251         this_arg_conv.is_owned = false;
71252         LDKStr sync_path_conv = str_ref_to_owned_c(sync_path);
71253         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
71254         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
71255         return tag_ptr(ret_conv, true);
71256 }
71257
71258 int64_t  CS_LDK_RapidGossipSync_update_network_graph(int64_t this_arg, int8_tArray update_data) {
71259         LDKRapidGossipSync this_arg_conv;
71260         this_arg_conv.inner = untag_ptr(this_arg);
71261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
71262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
71263         this_arg_conv.is_owned = false;
71264         LDKu8slice update_data_ref;
71265         update_data_ref.datalen = update_data->arr_len;
71266         update_data_ref.data = update_data->elems;
71267         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
71268         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
71269         FREE(update_data);
71270         return tag_ptr(ret_conv, true);
71271 }
71272
71273 int64_t  CS_LDK_RapidGossipSync_update_network_graph_no_std(int64_t this_arg, int8_tArray update_data, int64_t current_time_unix) {
71274         LDKRapidGossipSync this_arg_conv;
71275         this_arg_conv.inner = untag_ptr(this_arg);
71276         this_arg_conv.is_owned = ptr_is_owned(this_arg);
71277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
71278         this_arg_conv.is_owned = false;
71279         LDKu8slice update_data_ref;
71280         update_data_ref.datalen = update_data->arr_len;
71281         update_data_ref.data = update_data->elems;
71282         void* current_time_unix_ptr = untag_ptr(current_time_unix);
71283         CHECK_ACCESS(current_time_unix_ptr);
71284         LDKCOption_u64Z current_time_unix_conv = *(LDKCOption_u64Z*)(current_time_unix_ptr);
71285         current_time_unix_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(current_time_unix));
71286         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
71287         *ret_conv = RapidGossipSync_update_network_graph_no_std(&this_arg_conv, update_data_ref, current_time_unix_conv);
71288         FREE(update_data);
71289         return tag_ptr(ret_conv, true);
71290 }
71291
71292 jboolean  CS_LDK_RapidGossipSync_is_initial_sync_complete(int64_t this_arg) {
71293         LDKRapidGossipSync this_arg_conv;
71294         this_arg_conv.inner = untag_ptr(this_arg);
71295         this_arg_conv.is_owned = ptr_is_owned(this_arg);
71296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
71297         this_arg_conv.is_owned = false;
71298         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
71299         return ret_conv;
71300 }
71301
71302 void  CS_LDK_GraphSyncError_free(int64_t this_ptr) {
71303         if (!ptr_is_owned(this_ptr)) return;
71304         void* this_ptr_ptr = untag_ptr(this_ptr);
71305         CHECK_ACCESS(this_ptr_ptr);
71306         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
71307         FREE(untag_ptr(this_ptr));
71308         GraphSyncError_free(this_ptr_conv);
71309 }
71310
71311 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
71312         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
71313         *ret_copy = GraphSyncError_clone(arg);
71314         int64_t ret_ref = tag_ptr(ret_copy, true);
71315         return ret_ref;
71316 }
71317 int64_t  CS_LDK_GraphSyncError_clone_ptr(int64_t arg) {
71318         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
71319         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
71320         return ret_conv;
71321 }
71322
71323 int64_t  CS_LDK_GraphSyncError_clone(int64_t orig) {
71324         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
71325         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
71326         *ret_copy = GraphSyncError_clone(orig_conv);
71327         int64_t ret_ref = tag_ptr(ret_copy, true);
71328         return ret_ref;
71329 }
71330
71331 int64_t  CS_LDK_GraphSyncError_decode_error(int64_t a) {
71332         void* a_ptr = untag_ptr(a);
71333         CHECK_ACCESS(a_ptr);
71334         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
71335         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
71336         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
71337         *ret_copy = GraphSyncError_decode_error(a_conv);
71338         int64_t ret_ref = tag_ptr(ret_copy, true);
71339         return ret_ref;
71340 }
71341
71342 int64_t  CS_LDK_GraphSyncError_lightning_error(int64_t a) {
71343         LDKLightningError a_conv;
71344         a_conv.inner = untag_ptr(a);
71345         a_conv.is_owned = ptr_is_owned(a);
71346         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
71347         a_conv = LightningError_clone(&a_conv);
71348         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
71349         *ret_copy = GraphSyncError_lightning_error(a_conv);
71350         int64_t ret_ref = tag_ptr(ret_copy, true);
71351         return ret_ref;
71352 }
71353