Update auto-generated bindings with new NetworkGraph API
[rust-lightning] / lightning-c-bindings / include / lightning.h
1 /* Text to put at the beginning of the generated file. Probably a license. */
2
3 /* Generated with cbindgen:0.14.4 */
4
5 /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
6
7 #include <stdarg.h>
8 #include <stdbool.h>
9 #include <stdint.h>
10 #include <stdlib.h>
11
12 /**
13  * An error when accessing the chain via [`Access`].
14  *
15  * [`Access`]: trait.Access.html
16  */
17 typedef enum LDKAccessError {
18    /**
19     * The requested chain is unknown.
20     */
21    LDKAccessError_UnknownChain,
22    /**
23     * The requested transaction doesn't exist or hasn't confirmed.
24     */
25    LDKAccessError_UnknownTx,
26    /**
27     * Must be last for serialization purposes
28     */
29    LDKAccessError_Sentinel,
30 } LDKAccessError;
31
32 /**
33  * An error enum representing a failure to persist a channel monitor update.
34  */
35 typedef enum LDKChannelMonitorUpdateErr {
36    /**
37     * Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
38     * our state failed, but is expected to succeed at some point in the future).
39     *
40     * Such a failure will \"freeze\" a channel, preventing us from revoking old states or
41     * submitting new commitment transactions to the counterparty. Once the update(s) which failed
42     * have been successfully applied, ChannelManager::channel_monitor_updated can be used to
43     * restore the channel to an operational state.
44     *
45     * Note that a given ChannelManager will *never* re-generate a given ChannelMonitorUpdate. If
46     * you return a TemporaryFailure you must ensure that it is written to disk safely before
47     * writing out the latest ChannelManager state.
48     *
49     * Even when a channel has been \"frozen\" updates to the ChannelMonitor can continue to occur
50     * (eg if an inbound HTLC which we forwarded was claimed upstream resulting in us attempting
51     * to claim it on this channel) and those updates must be applied wherever they can be. At
52     * least one such updated ChannelMonitor must be persisted otherwise PermanentFailure should
53     * be returned to get things on-chain ASAP using only the in-memory copy. Obviously updates to
54     * the channel which would invalidate previous ChannelMonitors are not made when a channel has
55     * been \"frozen\".
56     *
57     * Note that even if updates made after TemporaryFailure succeed you must still call
58     * channel_monitor_updated to ensure you have the latest monitor and re-enable normal channel
59     * operation.
60     *
61     * Note that the update being processed here will not be replayed for you when you call
62     * ChannelManager::channel_monitor_updated, so you must store the update itself along
63     * with the persisted ChannelMonitor on your own local disk prior to returning a
64     * TemporaryFailure. You may, of course, employ a journaling approach, storing only the
65     * ChannelMonitorUpdate on disk without updating the monitor itself, replaying the journal at
66     * reload-time.
67     *
68     * For deployments where a copy of ChannelMonitors and other local state are backed up in a
69     * remote location (with local copies persisted immediately), it is anticipated that all
70     * updates will return TemporaryFailure until the remote copies could be updated.
71     */
72    LDKChannelMonitorUpdateErr_TemporaryFailure,
73    /**
74     * Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a
75     * different watchtower and cannot update with all watchtowers that were previously informed
76     * of this channel).
77     *
78     * At reception of this error, ChannelManager will force-close the channel and return at
79     * least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at
80     * least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel
81     * update must be rejected.
82     *
83     * This failure may also signal a failure to update the local persisted copy of one of
84     * the channel monitor instance.
85     *
86     * Note that even when you fail a holder commitment transaction update, you must store the
87     * update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor
88     * broadcasts it (e.g distributed channel-monitor deployment)
89     *
90     * In case of distributed watchtowers deployment, the new version must be written to disk, as
91     * state may have been stored but rejected due to a block forcing a commitment broadcast. This
92     * storage is used to claim outputs of rejected state confirmed onchain by another watchtower,
93     * lagging behind on block processing.
94     */
95    LDKChannelMonitorUpdateErr_PermanentFailure,
96    /**
97     * Must be last for serialization purposes
98     */
99    LDKChannelMonitorUpdateErr_Sentinel,
100 } LDKChannelMonitorUpdateErr;
101
102 /**
103  * An enum that represents the speed at which we want a transaction to confirm used for feerate
104  * estimation.
105  */
106 typedef enum LDKConfirmationTarget {
107    /**
108     * We are happy with this transaction confirming slowly when feerate drops some.
109     */
110    LDKConfirmationTarget_Background,
111    /**
112     * We'd like this transaction to confirm without major delay, but 12-18 blocks is fine.
113     */
114    LDKConfirmationTarget_Normal,
115    /**
116     * We'd like this transaction to confirm in the next few blocks.
117     */
118    LDKConfirmationTarget_HighPriority,
119    /**
120     * Must be last for serialization purposes
121     */
122    LDKConfirmationTarget_Sentinel,
123 } LDKConfirmationTarget;
124
125 /**
126  * An enum representing the available verbosity levels of the logger.
127  */
128 typedef enum LDKLevel {
129    /**
130     *Designates logger being silent
131     */
132    LDKLevel_Off,
133    /**
134     * Designates very serious errors
135     */
136    LDKLevel_Error,
137    /**
138     * Designates hazardous situations
139     */
140    LDKLevel_Warn,
141    /**
142     * Designates useful information
143     */
144    LDKLevel_Info,
145    /**
146     * Designates lower priority information
147     */
148    LDKLevel_Debug,
149    /**
150     * Designates very low priority, often extremely verbose, information
151     */
152    LDKLevel_Trace,
153    /**
154     * Must be last for serialization purposes
155     */
156    LDKLevel_Sentinel,
157 } LDKLevel;
158
159 typedef enum LDKNetwork {
160    LDKNetwork_Bitcoin,
161    LDKNetwork_Testnet,
162    LDKNetwork_Regtest,
163    /**
164     * Must be last for serialization purposes
165     */
166    LDKNetwork_Sentinel,
167 } LDKNetwork;
168
169 typedef enum LDKSecp256k1Error {
170    LDKSecp256k1Error_IncorrectSignature,
171    LDKSecp256k1Error_InvalidMessage,
172    LDKSecp256k1Error_InvalidPublicKey,
173    LDKSecp256k1Error_InvalidSignature,
174    LDKSecp256k1Error_InvalidSecretKey,
175    LDKSecp256k1Error_InvalidRecoveryId,
176    LDKSecp256k1Error_InvalidTweak,
177    LDKSecp256k1Error_NotEnoughMemory,
178    LDKSecp256k1Error_CallbackPanicked,
179    /**
180     * Must be last for serialization purposes
181     */
182    LDKSecp256k1Error_Sentinel,
183 } LDKSecp256k1Error;
184
185 /**
186  * A serialized transaction, in (pointer, length) form.
187  *
188  * This type optionally owns its own memory, and thus the semantics around access change based on
189  * the `data_is_owned` flag. If `data_is_owned` is set, you must call `Transaction_free` to free
190  * the underlying buffer before the object goes out of scope. If `data_is_owned` is not set, any
191  * access to the buffer after the scope in which the object was provided to you is invalid. eg,
192  * access after you return from the call in which a `!data_is_owned` `Transaction` is provided to
193  * you would be invalid.
194  *
195  * Note that, while it may change in the future, because transactions on the Rust side are stored
196  * in a deserialized form, all `Transaction`s generated on the Rust side will have `data_is_owned`
197  * set. Similarly, while it may change in the future, all `Transaction`s you pass to Rust may have
198  * `data_is_owned` either set or unset at your discretion.
199  */
200 typedef struct LDKTransaction {
201    /**
202     * This is non-const for your convenience, an object passed to Rust is never written to.
203     */
204    uint8_t *data;
205    uintptr_t datalen;
206    bool data_is_owned;
207 } LDKTransaction;
208
209 typedef struct LDKCVecTempl_u8 {
210    uint8_t *data;
211    uintptr_t datalen;
212 } LDKCVecTempl_u8;
213
214 typedef LDKCVecTempl_u8 LDKCVec_u8Z;
215
216 /**
217  * A transaction output including a scriptPubKey and value.
218  * This type *does* own its own memory, so must be free'd appropriately.
219  */
220 typedef struct LDKTxOut {
221    LDKCVec_u8Z script_pubkey;
222    uint64_t value;
223 } LDKTxOut;
224
225 typedef struct LDKC2TupleTempl_usize__Transaction {
226    uintptr_t a;
227    LDKTransaction b;
228 } LDKC2TupleTempl_usize__Transaction;
229
230 typedef LDKC2TupleTempl_usize__Transaction LDKC2Tuple_usizeTransactionZ;
231
232 typedef union LDKCResultPtr_u8__ChannelMonitorUpdateErr {
233    uint8_t *result;
234    LDKChannelMonitorUpdateErr *err;
235 } LDKCResultPtr_u8__ChannelMonitorUpdateErr;
236
237 typedef struct LDKCResultTempl_u8__ChannelMonitorUpdateErr {
238    LDKCResultPtr_u8__ChannelMonitorUpdateErr contents;
239    bool result_ok;
240 } LDKCResultTempl_u8__ChannelMonitorUpdateErr;
241
242 typedef LDKCResultTempl_u8__ChannelMonitorUpdateErr LDKCResult_NoneChannelMonitorUpdateErrZ;
243
244
245
246 /**
247  * General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
248  * inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
249  * means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
250  * corrupted.
251  * Contains a developer-readable error message.
252  */
253 typedef struct MUST_USE_STRUCT LDKMonitorUpdateError {
254    /**
255     * Nearly everywhere, inner must be non-null, however in places where
256     * the Rust equivalent takes an Option, it may be set to null to indicate None.
257     */
258    LDKnativeMonitorUpdateError *inner;
259    bool is_owned;
260 } LDKMonitorUpdateError;
261
262 typedef union LDKCResultPtr_u8__MonitorUpdateError {
263    uint8_t *result;
264    LDKMonitorUpdateError *err;
265 } LDKCResultPtr_u8__MonitorUpdateError;
266
267 typedef struct LDKCResultTempl_u8__MonitorUpdateError {
268    LDKCResultPtr_u8__MonitorUpdateError contents;
269    bool result_ok;
270 } LDKCResultTempl_u8__MonitorUpdateError;
271
272 typedef LDKCResultTempl_u8__MonitorUpdateError LDKCResult_NoneMonitorUpdateErrorZ;
273
274
275
276 /**
277  * A reference to a transaction output.
278  *
279  * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
280  * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
281  */
282 typedef struct MUST_USE_STRUCT LDKOutPoint {
283    /**
284     * Nearly everywhere, inner must be non-null, however in places where
285     * the Rust equivalent takes an Option, it may be set to null to indicate None.
286     */
287    LDKnativeOutPoint *inner;
288    bool is_owned;
289 } LDKOutPoint;
290
291 typedef struct LDKC2TupleTempl_OutPoint__CVec_u8Z {
292    LDKOutPoint a;
293    LDKCVec_u8Z b;
294 } LDKC2TupleTempl_OutPoint__CVec_u8Z;
295
296 typedef LDKC2TupleTempl_OutPoint__CVec_u8Z LDKC2Tuple_OutPointScriptZ;
297
298 typedef struct LDKC2TupleTempl_u32__TxOut {
299    uint32_t a;
300    LDKTxOut b;
301 } LDKC2TupleTempl_u32__TxOut;
302
303 typedef LDKC2TupleTempl_u32__TxOut LDKC2Tuple_u32TxOutZ;
304
305 /**
306  * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to
307  * look up the corresponding function in rust-lightning's docs.
308  */
309 typedef struct LDKThirtyTwoBytes {
310    uint8_t data[32];
311 } LDKThirtyTwoBytes;
312
313 typedef struct LDKCVecTempl_C2TupleTempl_u32__TxOut {
314    LDKC2TupleTempl_u32__TxOut *data;
315    uintptr_t datalen;
316 } LDKCVecTempl_C2TupleTempl_u32__TxOut;
317
318 typedef struct LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut {
319    LDKThirtyTwoBytes a;
320    LDKCVecTempl_C2TupleTempl_u32__TxOut b;
321 } LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut;
322
323 typedef LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ;
324
325 typedef LDKCVecTempl_C2TupleTempl_u32__TxOut LDKCVec_C2Tuple_u32TxOutZZ;
326
327 typedef struct LDKC2TupleTempl_u64__u64 {
328    uint64_t a;
329    uint64_t b;
330 } LDKC2TupleTempl_u64__u64;
331
332 typedef LDKC2TupleTempl_u64__u64 LDKC2Tuple_u64u64Z;
333
334 typedef struct LDKSignature {
335    uint8_t compact_form[64];
336 } LDKSignature;
337
338 typedef struct LDKCVecTempl_Signature {
339    LDKSignature *data;
340    uintptr_t datalen;
341 } LDKCVecTempl_Signature;
342
343 typedef struct LDKC2TupleTempl_Signature__CVecTempl_Signature {
344    LDKSignature a;
345    LDKCVecTempl_Signature b;
346 } LDKC2TupleTempl_Signature__CVecTempl_Signature;
347
348 typedef LDKC2TupleTempl_Signature__CVecTempl_Signature LDKC2Tuple_SignatureCVec_SignatureZZ;
349
350 typedef LDKCVecTempl_Signature LDKCVec_SignatureZ;
351
352 typedef union LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8 {
353    LDKC2TupleTempl_Signature__CVecTempl_Signature *result;
354    uint8_t *err;
355 } LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8;
356
357 typedef struct LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8 {
358    LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8 contents;
359    bool result_ok;
360 } LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8;
361
362 typedef LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ;
363
364 typedef union LDKCResultPtr_Signature__u8 {
365    LDKSignature *result;
366    uint8_t *err;
367 } LDKCResultPtr_Signature__u8;
368
369 typedef struct LDKCResultTempl_Signature__u8 {
370    LDKCResultPtr_Signature__u8 contents;
371    bool result_ok;
372 } LDKCResultTempl_Signature__u8;
373
374 typedef LDKCResultTempl_Signature__u8 LDKCResult_SignatureNoneZ;
375
376 typedef union LDKCResultPtr_CVecTempl_Signature_____u8 {
377    LDKCVecTempl_Signature *result;
378    uint8_t *err;
379 } LDKCResultPtr_CVecTempl_Signature_____u8;
380
381 typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 {
382    LDKCResultPtr_CVecTempl_Signature_____u8 contents;
383    bool result_ok;
384 } LDKCResultTempl_CVecTempl_Signature_____u8;
385
386 typedef LDKCResultTempl_CVecTempl_Signature_____u8 LDKCResult_CVec_SignatureZNoneZ;
387
388 /**
389  * A Rust str object, ie a reference to a UTF8-valid string.
390  * This is *not* null-terminated so cannot be used directly as a C string!
391  */
392 typedef struct LDKStr {
393    const uint8_t *chars;
394    uintptr_t len;
395 } LDKStr;
396
397 /**
398  * Indicates an error on the client's part (usually some variant of attempting to use too-low or
399  * too-high values)
400  */
401 typedef enum LDKAPIError_Tag {
402    /**
403     * Indicates the API was wholly misused (see err for more). Cases where these can be returned
404     * are documented, but generally indicates some precondition of a function was violated.
405     */
406    LDKAPIError_APIMisuseError,
407    /**
408     * Due to a high feerate, we were unable to complete the request.
409     * For example, this may be returned if the feerate implies we cannot open a channel at the
410     * requested value, but opening a larger channel would succeed.
411     */
412    LDKAPIError_FeeRateTooHigh,
413    /**
414     * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route,
415     * too-many-hops, etc).
416     */
417    LDKAPIError_RouteError,
418    /**
419     * We were unable to complete the request as the Channel required to do so is unable to
420     * complete the request (or was not found). This can take many forms, including disconnected
421     * peer, channel at capacity, channel shutting down, etc.
422     */
423    LDKAPIError_ChannelUnavailable,
424    /**
425     * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the
426     * attempted action to fail.
427     */
428    LDKAPIError_MonitorUpdateFailed,
429    /**
430     * Must be last for serialization purposes
431     */
432    LDKAPIError_Sentinel,
433 } LDKAPIError_Tag;
434
435 typedef struct LDKAPIError_LDKAPIMisuseError_Body {
436    LDKCVec_u8Z err;
437 } LDKAPIError_LDKAPIMisuseError_Body;
438
439 typedef struct LDKAPIError_LDKFeeRateTooHigh_Body {
440    LDKCVec_u8Z err;
441    uint32_t feerate;
442 } LDKAPIError_LDKFeeRateTooHigh_Body;
443
444 typedef struct LDKAPIError_LDKRouteError_Body {
445    LDKStr err;
446 } LDKAPIError_LDKRouteError_Body;
447
448 typedef struct LDKAPIError_LDKChannelUnavailable_Body {
449    LDKCVec_u8Z err;
450 } LDKAPIError_LDKChannelUnavailable_Body;
451
452 typedef struct LDKAPIError {
453    LDKAPIError_Tag tag;
454    union {
455       LDKAPIError_LDKAPIMisuseError_Body api_misuse_error;
456       LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high;
457       LDKAPIError_LDKRouteError_Body route_error;
458       LDKAPIError_LDKChannelUnavailable_Body channel_unavailable;
459    };
460 } LDKAPIError;
461
462 typedef union LDKCResultPtr_u8__APIError {
463    uint8_t *result;
464    LDKAPIError *err;
465 } LDKCResultPtr_u8__APIError;
466
467 typedef struct LDKCResultTempl_u8__APIError {
468    LDKCResultPtr_u8__APIError contents;
469    bool result_ok;
470 } LDKCResultTempl_u8__APIError;
471
472 typedef LDKCResultTempl_u8__APIError LDKCResult_NoneAPIErrorZ;
473
474
475
476 /**
477  * If a payment fails to send, it can be in one of several states. This enum is returned as the
478  * Err() type describing which state the payment is in, see the description of individual enum
479  * states for more.
480  */
481 typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
482    /**
483     * Nearly everywhere, inner must be non-null, however in places where
484     * the Rust equivalent takes an Option, it may be set to null to indicate None.
485     */
486    LDKnativePaymentSendFailure *inner;
487    bool is_owned;
488 } LDKPaymentSendFailure;
489
490 typedef union LDKCResultPtr_u8__PaymentSendFailure {
491    uint8_t *result;
492    LDKPaymentSendFailure *err;
493 } LDKCResultPtr_u8__PaymentSendFailure;
494
495 typedef struct LDKCResultTempl_u8__PaymentSendFailure {
496    LDKCResultPtr_u8__PaymentSendFailure contents;
497    bool result_ok;
498 } LDKCResultTempl_u8__PaymentSendFailure;
499
500 typedef LDKCResultTempl_u8__PaymentSendFailure LDKCResult_NonePaymentSendFailureZ;
501
502
503
504 /**
505  * A channel_announcement message to be sent or received from a peer
506  */
507 typedef struct MUST_USE_STRUCT LDKChannelAnnouncement {
508    /**
509     * Nearly everywhere, inner must be non-null, however in places where
510     * the Rust equivalent takes an Option, it may be set to null to indicate None.
511     */
512    LDKnativeChannelAnnouncement *inner;
513    bool is_owned;
514 } LDKChannelAnnouncement;
515
516
517
518 /**
519  * A channel_update message to be sent or received from a peer
520  */
521 typedef struct MUST_USE_STRUCT LDKChannelUpdate {
522    /**
523     * Nearly everywhere, inner must be non-null, however in places where
524     * the Rust equivalent takes an Option, it may be set to null to indicate None.
525     */
526    LDKnativeChannelUpdate *inner;
527    bool is_owned;
528 } LDKChannelUpdate;
529
530 typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate {
531    LDKChannelAnnouncement a;
532    LDKChannelUpdate b;
533    LDKChannelUpdate c;
534 } LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate;
535
536 typedef LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ;
537
538
539
540 /**
541  * Error for PeerManager errors. If you get one of these, you must disconnect the socket and
542  * generate no further read_event/write_buffer_space_avail calls for the descriptor, only
543  * triggering a single socket_disconnected call (unless it was provided in response to a
544  * new_*_connection event, in which case no such socket_disconnected() must be called and the
545  * socket silently disconencted).
546  */
547 typedef struct MUST_USE_STRUCT LDKPeerHandleError {
548    /**
549     * Nearly everywhere, inner must be non-null, however in places where
550     * the Rust equivalent takes an Option, it may be set to null to indicate None.
551     */
552    LDKnativePeerHandleError *inner;
553    bool is_owned;
554 } LDKPeerHandleError;
555
556 typedef union LDKCResultPtr_u8__PeerHandleError {
557    uint8_t *result;
558    LDKPeerHandleError *err;
559 } LDKCResultPtr_u8__PeerHandleError;
560
561 typedef struct LDKCResultTempl_u8__PeerHandleError {
562    LDKCResultPtr_u8__PeerHandleError contents;
563    bool result_ok;
564 } LDKCResultTempl_u8__PeerHandleError;
565
566 typedef LDKCResultTempl_u8__PeerHandleError LDKCResult_NonePeerHandleErrorZ;
567
568
569
570 /**
571  * Information about an HTLC as it appears in a commitment transaction
572  */
573 typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment {
574    /**
575     * Nearly everywhere, inner must be non-null, however in places where
576     * the Rust equivalent takes an Option, it may be set to null to indicate None.
577     */
578    LDKnativeHTLCOutputInCommitment *inner;
579    bool is_owned;
580 } LDKHTLCOutputInCommitment;
581
582 typedef struct LDKC2TupleTempl_HTLCOutputInCommitment__Signature {
583    LDKHTLCOutputInCommitment a;
584    LDKSignature b;
585 } LDKC2TupleTempl_HTLCOutputInCommitment__Signature;
586
587 typedef LDKC2TupleTempl_HTLCOutputInCommitment__Signature LDKC2Tuple_HTLCOutputInCommitmentSignatureZ;
588
589
590
591 /**
592  * An Err type for failure to process messages.
593  */
594 typedef struct MUST_USE_STRUCT LDKLightningError {
595    /**
596     * Nearly everywhere, inner must be non-null, however in places where
597     * the Rust equivalent takes an Option, it may be set to null to indicate None.
598     */
599    LDKnativeLightningError *inner;
600    bool is_owned;
601 } LDKLightningError;
602
603 typedef union LDKCResultPtr_u8__LightningError {
604    uint8_t *result;
605    LDKLightningError *err;
606 } LDKCResultPtr_u8__LightningError;
607
608 typedef struct LDKCResultTempl_u8__LightningError {
609    LDKCResultPtr_u8__LightningError contents;
610    bool result_ok;
611 } LDKCResultTempl_u8__LightningError;
612
613 typedef LDKCResultTempl_u8__LightningError LDKCResult_NoneLightningErrorZ;
614
615 typedef struct LDKPublicKey {
616    uint8_t compressed_form[33];
617 } LDKPublicKey;
618
619 /**
620  * When on-chain outputs are created by rust-lightning (which our counterparty is not able to
621  * claim at any point in the future) an event is generated which you must track and be able to
622  * spend on-chain. The information needed to do this is provided in this enum, including the
623  * outpoint describing which txid and output index is available, the full output which exists at
624  * that txid/index, and any keys or other information required to sign.
625  */
626 typedef enum LDKSpendableOutputDescriptor_Tag {
627    /**
628     * An output to a script which was provided via KeysInterface, thus you should already know
629     * how to spend it. No keys are provided as rust-lightning was never given any keys - only the
630     * script_pubkey as it appears in the output.
631     * These may include outputs from a transaction punishing our counterparty or claiming an HTLC
632     * on-chain using the payment preimage or after it has timed out.
633     */
634    LDKSpendableOutputDescriptor_StaticOutput,
635    /**
636     * An output to a P2WSH script which can be spent with a single signature after a CSV delay.
637     *
638     * The witness in the spending input should be:
639     * <BIP 143 signature> <empty vector> (MINIMALIF standard rule) <provided witnessScript>
640     *
641     * Note that the nSequence field in the spending input must be set to to_self_delay
642     * (which means the transaction is not broadcastable until at least to_self_delay
643     * blocks after the outpoint confirms).
644     *
645     * These are generally the result of a \"revocable\" output to us, spendable only by us unless
646     * it is an output from an old state which we broadcast (which should never happen).
647     *
648     * To derive the delayed_payment key which is used to sign for this input, you must pass the
649     * holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in
650     * ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to
651     * chan_utils::derive_private_key. The public key can be generated without the secret key
652     * using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in
653     * ChannelKeys::pubkeys().
654     *
655     * To derive the revocation_pubkey provided here (which is used in the witness
656     * script generation), you must pass the counterparty revocation_basepoint (which appears in the
657     * call to ChannelKeys::on_accept) and the provided per_commitment point
658     * to chan_utils::derive_public_revocation_key.
659     *
660     * The witness script which is hashed and included in the output script_pubkey may be
661     * regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey
662     * (derived as above), and the to_self_delay contained here to
663     * chan_utils::get_revokeable_redeemscript.
664     */
665    LDKSpendableOutputDescriptor_DynamicOutputP2WSH,
666    /**
667     * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
668     * corresponds to the public key in ChannelKeys::pubkeys().payment_point).
669     * The witness in the spending input, is, thus, simply:
670     * <BIP 143 signature> <payment key>
671     *
672     * These are generally the result of our counterparty having broadcast the current state,
673     * allowing us to claim the non-HTLC-encumbered outputs immediately.
674     */
675    LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment,
676    /**
677     * Must be last for serialization purposes
678     */
679    LDKSpendableOutputDescriptor_Sentinel,
680 } LDKSpendableOutputDescriptor_Tag;
681
682 typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body {
683    LDKOutPoint outpoint;
684    LDKTxOut output;
685 } LDKSpendableOutputDescriptor_LDKStaticOutput_Body;
686
687 typedef struct LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body {
688    LDKOutPoint outpoint;
689    LDKPublicKey per_commitment_point;
690    uint16_t to_self_delay;
691    LDKTxOut output;
692    LDKC2Tuple_u64u64Z key_derivation_params;
693    LDKPublicKey revocation_pubkey;
694 } LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body;
695
696 typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body {
697    LDKOutPoint outpoint;
698    LDKTxOut output;
699    LDKC2Tuple_u64u64Z key_derivation_params;
700 } LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body;
701
702 typedef struct LDKSpendableOutputDescriptor {
703    LDKSpendableOutputDescriptor_Tag tag;
704    union {
705       LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output;
706       LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body dynamic_output_p2wsh;
707       LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body static_output_counterparty_payment;
708    };
709 } LDKSpendableOutputDescriptor;
710
711 typedef struct LDKCVecTempl_SpendableOutputDescriptor {
712    LDKSpendableOutputDescriptor *data;
713    uintptr_t datalen;
714 } LDKCVecTempl_SpendableOutputDescriptor;
715
716 typedef LDKCVecTempl_SpendableOutputDescriptor LDKCVec_SpendableOutputDescriptorZ;
717
718 /**
719  * An Event which you should probably take some action in response to.
720  *
721  * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
722  * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
723  * written as it makes no sense to respond to it after reconnecting to peers).
724  */
725 typedef enum LDKEvent_Tag {
726    /**
727     * Used to indicate that the client should generate a funding transaction with the given
728     * parameters and then call ChannelManager::funding_transaction_generated.
729     * Generated in ChannelManager message handling.
730     * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
731     * counterparty can steal your funds!
732     */
733    LDKEvent_FundingGenerationReady,
734    /**
735     * Used to indicate that the client may now broadcast the funding transaction it created for a
736     * channel. Broadcasting such a transaction prior to this event may lead to our counterparty
737     * trivially stealing all funds in the funding transaction!
738     */
739    LDKEvent_FundingBroadcastSafe,
740    /**
741     * Indicates we've received money! Just gotta dig out that payment preimage and feed it to
742     * ChannelManager::claim_funds to get it....
743     * Note that if the preimage is not known or the amount paid is incorrect, you should call
744     * ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
745     * network congestion.
746     * The amount paid should be considered 'incorrect' when it is less than or more than twice
747     * the amount expected.
748     * If you fail to call either ChannelManager::claim_funds or
749     * ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
750     * automatically failed.
751     */
752    LDKEvent_PaymentReceived,
753    /**
754     * Indicates an outbound payment we made succeeded (ie it made it all the way to its target
755     * and we got back the payment preimage for it).
756     * Note that duplicative PaymentSent Events may be generated - it is your responsibility to
757     * deduplicate them by payment_preimage (which MUST be unique)!
758     */
759    LDKEvent_PaymentSent,
760    /**
761     * Indicates an outbound payment we made failed. Probably some intermediary node dropped
762     * something. You may wish to retry with a different route.
763     * Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
764     * deduplicate them by payment_hash (which MUST be unique)!
765     */
766    LDKEvent_PaymentFailed,
767    /**
768     * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
769     * time in the future.
770     */
771    LDKEvent_PendingHTLCsForwardable,
772    /**
773     * Used to indicate that an output was generated on-chain which you should know how to spend.
774     * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
775     * counterparty spending them due to some kind of timeout. Thus, you need to store them
776     * somewhere and spend them when you create on-chain transactions.
777     */
778    LDKEvent_SpendableOutputs,
779    /**
780     * Must be last for serialization purposes
781     */
782    LDKEvent_Sentinel,
783 } LDKEvent_Tag;
784
785 typedef struct LDKEvent_LDKFundingGenerationReady_Body {
786    LDKThirtyTwoBytes temporary_channel_id;
787    uint64_t channel_value_satoshis;
788    LDKCVec_u8Z output_script;
789    uint64_t user_channel_id;
790 } LDKEvent_LDKFundingGenerationReady_Body;
791
792 typedef struct LDKEvent_LDKFundingBroadcastSafe_Body {
793    LDKOutPoint funding_txo;
794    uint64_t user_channel_id;
795 } LDKEvent_LDKFundingBroadcastSafe_Body;
796
797 typedef struct LDKEvent_LDKPaymentReceived_Body {
798    LDKThirtyTwoBytes payment_hash;
799    LDKThirtyTwoBytes payment_secret;
800    uint64_t amt;
801 } LDKEvent_LDKPaymentReceived_Body;
802
803 typedef struct LDKEvent_LDKPaymentSent_Body {
804    LDKThirtyTwoBytes payment_preimage;
805 } LDKEvent_LDKPaymentSent_Body;
806
807 typedef struct LDKEvent_LDKPaymentFailed_Body {
808    LDKThirtyTwoBytes payment_hash;
809    bool rejected_by_dest;
810 } LDKEvent_LDKPaymentFailed_Body;
811
812 typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body {
813    uint64_t time_forwardable;
814 } LDKEvent_LDKPendingHTLCsForwardable_Body;
815
816 typedef struct LDKEvent_LDKSpendableOutputs_Body {
817    LDKCVec_SpendableOutputDescriptorZ outputs;
818 } LDKEvent_LDKSpendableOutputs_Body;
819
820 typedef struct LDKEvent {
821    LDKEvent_Tag tag;
822    union {
823       LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready;
824       LDKEvent_LDKFundingBroadcastSafe_Body funding_broadcast_safe;
825       LDKEvent_LDKPaymentReceived_Body payment_received;
826       LDKEvent_LDKPaymentSent_Body payment_sent;
827       LDKEvent_LDKPaymentFailed_Body payment_failed;
828       LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable;
829       LDKEvent_LDKSpendableOutputs_Body spendable_outputs;
830    };
831 } LDKEvent;
832
833
834
835 /**
836  * An accept_channel message to be sent or received from a peer
837  */
838 typedef struct MUST_USE_STRUCT LDKAcceptChannel {
839    /**
840     * Nearly everywhere, inner must be non-null, however in places where
841     * the Rust equivalent takes an Option, it may be set to null to indicate None.
842     */
843    LDKnativeAcceptChannel *inner;
844    bool is_owned;
845 } LDKAcceptChannel;
846
847
848
849 /**
850  * An open_channel message to be sent or received from a peer
851  */
852 typedef struct MUST_USE_STRUCT LDKOpenChannel {
853    /**
854     * Nearly everywhere, inner must be non-null, however in places where
855     * the Rust equivalent takes an Option, it may be set to null to indicate None.
856     */
857    LDKnativeOpenChannel *inner;
858    bool is_owned;
859 } LDKOpenChannel;
860
861
862
863 /**
864  * A funding_created message to be sent or received from a peer
865  */
866 typedef struct MUST_USE_STRUCT LDKFundingCreated {
867    /**
868     * Nearly everywhere, inner must be non-null, however in places where
869     * the Rust equivalent takes an Option, it may be set to null to indicate None.
870     */
871    LDKnativeFundingCreated *inner;
872    bool is_owned;
873 } LDKFundingCreated;
874
875
876
877 /**
878  * A funding_signed message to be sent or received from a peer
879  */
880 typedef struct MUST_USE_STRUCT LDKFundingSigned {
881    /**
882     * Nearly everywhere, inner must be non-null, however in places where
883     * the Rust equivalent takes an Option, it may be set to null to indicate None.
884     */
885    LDKnativeFundingSigned *inner;
886    bool is_owned;
887 } LDKFundingSigned;
888
889
890
891 /**
892  * A funding_locked message to be sent or received from a peer
893  */
894 typedef struct MUST_USE_STRUCT LDKFundingLocked {
895    /**
896     * Nearly everywhere, inner must be non-null, however in places where
897     * the Rust equivalent takes an Option, it may be set to null to indicate None.
898     */
899    LDKnativeFundingLocked *inner;
900    bool is_owned;
901 } LDKFundingLocked;
902
903
904
905 /**
906  * An announcement_signatures message to be sent or received from a peer
907  */
908 typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures {
909    /**
910     * Nearly everywhere, inner must be non-null, however in places where
911     * the Rust equivalent takes an Option, it may be set to null to indicate None.
912     */
913    LDKnativeAnnouncementSignatures *inner;
914    bool is_owned;
915 } LDKAnnouncementSignatures;
916
917
918
919 /**
920  * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
921  * transaction updates if they were pending.
922  */
923 typedef struct MUST_USE_STRUCT LDKCommitmentUpdate {
924    /**
925     * Nearly everywhere, inner must be non-null, however in places where
926     * the Rust equivalent takes an Option, it may be set to null to indicate None.
927     */
928    LDKnativeCommitmentUpdate *inner;
929    bool is_owned;
930 } LDKCommitmentUpdate;
931
932
933
934 /**
935  * A revoke_and_ack message to be sent or received from a peer
936  */
937 typedef struct MUST_USE_STRUCT LDKRevokeAndACK {
938    /**
939     * Nearly everywhere, inner must be non-null, however in places where
940     * the Rust equivalent takes an Option, it may be set to null to indicate None.
941     */
942    LDKnativeRevokeAndACK *inner;
943    bool is_owned;
944 } LDKRevokeAndACK;
945
946
947
948 /**
949  * A closing_signed message to be sent or received from a peer
950  */
951 typedef struct MUST_USE_STRUCT LDKClosingSigned {
952    /**
953     * Nearly everywhere, inner must be non-null, however in places where
954     * the Rust equivalent takes an Option, it may be set to null to indicate None.
955     */
956    LDKnativeClosingSigned *inner;
957    bool is_owned;
958 } LDKClosingSigned;
959
960
961
962 /**
963  * A shutdown message to be sent or received from a peer
964  */
965 typedef struct MUST_USE_STRUCT LDKShutdown {
966    /**
967     * Nearly everywhere, inner must be non-null, however in places where
968     * the Rust equivalent takes an Option, it may be set to null to indicate None.
969     */
970    LDKnativeShutdown *inner;
971    bool is_owned;
972 } LDKShutdown;
973
974
975
976 /**
977  * A channel_reestablish message to be sent or received from a peer
978  */
979 typedef struct MUST_USE_STRUCT LDKChannelReestablish {
980    /**
981     * Nearly everywhere, inner must be non-null, however in places where
982     * the Rust equivalent takes an Option, it may be set to null to indicate None.
983     */
984    LDKnativeChannelReestablish *inner;
985    bool is_owned;
986 } LDKChannelReestablish;
987
988
989
990 /**
991  * A node_announcement message to be sent or received from a peer
992  */
993 typedef struct MUST_USE_STRUCT LDKNodeAnnouncement {
994    /**
995     * Nearly everywhere, inner must be non-null, however in places where
996     * the Rust equivalent takes an Option, it may be set to null to indicate None.
997     */
998    LDKnativeNodeAnnouncement *inner;
999    bool is_owned;
1000 } LDKNodeAnnouncement;
1001
1002
1003
1004 /**
1005  * An error message to be sent or received from a peer
1006  */
1007 typedef struct MUST_USE_STRUCT LDKErrorMessage {
1008    /**
1009     * Nearly everywhere, inner must be non-null, however in places where
1010     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1011     */
1012    LDKnativeErrorMessage *inner;
1013    bool is_owned;
1014 } LDKErrorMessage;
1015
1016 /**
1017  * Used to put an error message in a LightningError
1018  */
1019 typedef enum LDKErrorAction_Tag {
1020    /**
1021     * The peer took some action which made us think they were useless. Disconnect them.
1022     */
1023    LDKErrorAction_DisconnectPeer,
1024    /**
1025     * The peer did something harmless that we weren't able to process, just log and ignore
1026     */
1027    LDKErrorAction_IgnoreError,
1028    /**
1029     * The peer did something incorrect. Tell them.
1030     */
1031    LDKErrorAction_SendErrorMessage,
1032    /**
1033     * Must be last for serialization purposes
1034     */
1035    LDKErrorAction_Sentinel,
1036 } LDKErrorAction_Tag;
1037
1038 typedef struct LDKErrorAction_LDKDisconnectPeer_Body {
1039    LDKErrorMessage msg;
1040 } LDKErrorAction_LDKDisconnectPeer_Body;
1041
1042 typedef struct LDKErrorAction_LDKSendErrorMessage_Body {
1043    LDKErrorMessage msg;
1044 } LDKErrorAction_LDKSendErrorMessage_Body;
1045
1046 typedef struct LDKErrorAction {
1047    LDKErrorAction_Tag tag;
1048    union {
1049       LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer;
1050       LDKErrorAction_LDKSendErrorMessage_Body send_error_message;
1051    };
1052 } LDKErrorAction;
1053
1054 /**
1055  * The information we received from a peer along the route of a payment we originated. This is
1056  * returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
1057  * RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
1058  */
1059 typedef enum LDKHTLCFailChannelUpdate_Tag {
1060    /**
1061     * We received an error which included a full ChannelUpdate message.
1062     */
1063    LDKHTLCFailChannelUpdate_ChannelUpdateMessage,
1064    /**
1065     * We received an error which indicated only that a channel has been closed
1066     */
1067    LDKHTLCFailChannelUpdate_ChannelClosed,
1068    /**
1069     * We received an error which indicated only that a node has failed
1070     */
1071    LDKHTLCFailChannelUpdate_NodeFailure,
1072    /**
1073     * Must be last for serialization purposes
1074     */
1075    LDKHTLCFailChannelUpdate_Sentinel,
1076 } LDKHTLCFailChannelUpdate_Tag;
1077
1078 typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body {
1079    LDKChannelUpdate msg;
1080 } LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body;
1081
1082 typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body {
1083    uint64_t short_channel_id;
1084    bool is_permanent;
1085 } LDKHTLCFailChannelUpdate_LDKChannelClosed_Body;
1086
1087 typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body {
1088    LDKPublicKey node_id;
1089    bool is_permanent;
1090 } LDKHTLCFailChannelUpdate_LDKNodeFailure_Body;
1091
1092 typedef struct LDKHTLCFailChannelUpdate {
1093    LDKHTLCFailChannelUpdate_Tag tag;
1094    union {
1095       LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body channel_update_message;
1096       LDKHTLCFailChannelUpdate_LDKChannelClosed_Body channel_closed;
1097       LDKHTLCFailChannelUpdate_LDKNodeFailure_Body node_failure;
1098    };
1099 } LDKHTLCFailChannelUpdate;
1100
1101 /**
1102  * An event generated by ChannelManager which indicates a message should be sent to a peer (or
1103  * broadcast to most peers).
1104  * These events are handled by PeerManager::process_events if you are using a PeerManager.
1105  */
1106 typedef enum LDKMessageSendEvent_Tag {
1107    /**
1108     * Used to indicate that we've accepted a channel open and should send the accept_channel
1109     * message provided to the given peer.
1110     */
1111    LDKMessageSendEvent_SendAcceptChannel,
1112    /**
1113     * Used to indicate that we've initiated a channel open and should send the open_channel
1114     * message provided to the given peer.
1115     */
1116    LDKMessageSendEvent_SendOpenChannel,
1117    /**
1118     * Used to indicate that a funding_created message should be sent to the peer with the given node_id.
1119     */
1120    LDKMessageSendEvent_SendFundingCreated,
1121    /**
1122     * Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
1123     */
1124    LDKMessageSendEvent_SendFundingSigned,
1125    /**
1126     * Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
1127     */
1128    LDKMessageSendEvent_SendFundingLocked,
1129    /**
1130     * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
1131     */
1132    LDKMessageSendEvent_SendAnnouncementSignatures,
1133    /**
1134     * Used to indicate that a series of HTLC update messages, as well as a commitment_signed
1135     * message should be sent to the peer with the given node_id.
1136     */
1137    LDKMessageSendEvent_UpdateHTLCs,
1138    /**
1139     * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
1140     */
1141    LDKMessageSendEvent_SendRevokeAndACK,
1142    /**
1143     * Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
1144     */
1145    LDKMessageSendEvent_SendClosingSigned,
1146    /**
1147     * Used to indicate that a shutdown message should be sent to the peer with the given node_id.
1148     */
1149    LDKMessageSendEvent_SendShutdown,
1150    /**
1151     * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
1152     */
1153    LDKMessageSendEvent_SendChannelReestablish,
1154    /**
1155     * Used to indicate that a channel_announcement and channel_update should be broadcast to all
1156     * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
1157     *
1158     * Note that after doing so, you very likely (unless you did so very recently) want to call
1159     * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
1160     * This ensures that any nodes which see our channel_announcement also have a relevant
1161     * node_announcement, including relevant feature flags which may be important for routing
1162     * through or to us.
1163     */
1164    LDKMessageSendEvent_BroadcastChannelAnnouncement,
1165    /**
1166     * Used to indicate that a node_announcement should be broadcast to all peers.
1167     */
1168    LDKMessageSendEvent_BroadcastNodeAnnouncement,
1169    /**
1170     * Used to indicate that a channel_update should be broadcast to all peers.
1171     */
1172    LDKMessageSendEvent_BroadcastChannelUpdate,
1173    /**
1174     * Broadcast an error downstream to be handled
1175     */
1176    LDKMessageSendEvent_HandleError,
1177    /**
1178     * When a payment fails we may receive updates back from the hop where it failed. In such
1179     * cases this event is generated so that we can inform the network graph of this information.
1180     */
1181    LDKMessageSendEvent_PaymentFailureNetworkUpdate,
1182    /**
1183     * Must be last for serialization purposes
1184     */
1185    LDKMessageSendEvent_Sentinel,
1186 } LDKMessageSendEvent_Tag;
1187
1188 typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body {
1189    LDKPublicKey node_id;
1190    LDKAcceptChannel msg;
1191 } LDKMessageSendEvent_LDKSendAcceptChannel_Body;
1192
1193 typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body {
1194    LDKPublicKey node_id;
1195    LDKOpenChannel msg;
1196 } LDKMessageSendEvent_LDKSendOpenChannel_Body;
1197
1198 typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body {
1199    LDKPublicKey node_id;
1200    LDKFundingCreated msg;
1201 } LDKMessageSendEvent_LDKSendFundingCreated_Body;
1202
1203 typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body {
1204    LDKPublicKey node_id;
1205    LDKFundingSigned msg;
1206 } LDKMessageSendEvent_LDKSendFundingSigned_Body;
1207
1208 typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body {
1209    LDKPublicKey node_id;
1210    LDKFundingLocked msg;
1211 } LDKMessageSendEvent_LDKSendFundingLocked_Body;
1212
1213 typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body {
1214    LDKPublicKey node_id;
1215    LDKAnnouncementSignatures msg;
1216 } LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body;
1217
1218 typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body {
1219    LDKPublicKey node_id;
1220    LDKCommitmentUpdate updates;
1221 } LDKMessageSendEvent_LDKUpdateHTLCs_Body;
1222
1223 typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body {
1224    LDKPublicKey node_id;
1225    LDKRevokeAndACK msg;
1226 } LDKMessageSendEvent_LDKSendRevokeAndACK_Body;
1227
1228 typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body {
1229    LDKPublicKey node_id;
1230    LDKClosingSigned msg;
1231 } LDKMessageSendEvent_LDKSendClosingSigned_Body;
1232
1233 typedef struct LDKMessageSendEvent_LDKSendShutdown_Body {
1234    LDKPublicKey node_id;
1235    LDKShutdown msg;
1236 } LDKMessageSendEvent_LDKSendShutdown_Body;
1237
1238 typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body {
1239    LDKPublicKey node_id;
1240    LDKChannelReestablish msg;
1241 } LDKMessageSendEvent_LDKSendChannelReestablish_Body;
1242
1243 typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body {
1244    LDKChannelAnnouncement msg;
1245    LDKChannelUpdate update_msg;
1246 } LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body;
1247
1248 typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body {
1249    LDKNodeAnnouncement msg;
1250 } LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body;
1251
1252 typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body {
1253    LDKChannelUpdate msg;
1254 } LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body;
1255
1256 typedef struct LDKMessageSendEvent_LDKHandleError_Body {
1257    LDKPublicKey node_id;
1258    LDKErrorAction action;
1259 } LDKMessageSendEvent_LDKHandleError_Body;
1260
1261 typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body {
1262    LDKHTLCFailChannelUpdate update;
1263 } LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body;
1264
1265 typedef struct LDKMessageSendEvent {
1266    LDKMessageSendEvent_Tag tag;
1267    union {
1268       LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel;
1269       LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel;
1270       LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created;
1271       LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed;
1272       LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked;
1273       LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures;
1274       LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs;
1275       LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack;
1276       LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed;
1277       LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown;
1278       LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish;
1279       LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement;
1280       LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement;
1281       LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
1282       LDKMessageSendEvent_LDKHandleError_Body handle_error;
1283       LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update;
1284    };
1285 } LDKMessageSendEvent;
1286
1287 typedef struct LDKCVecTempl_MessageSendEvent {
1288    LDKMessageSendEvent *data;
1289    uintptr_t datalen;
1290 } LDKCVecTempl_MessageSendEvent;
1291
1292 typedef LDKCVecTempl_MessageSendEvent LDKCVec_MessageSendEventZ;
1293
1294 /**
1295  * A trait indicating an object may generate message send events
1296  */
1297 typedef struct LDKMessageSendEventsProvider {
1298    void *this_arg;
1299    /**
1300     * Gets the list of pending events which were generated by previous actions, clearing the list
1301     * in the process.
1302     */
1303    LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg);
1304    void (*free)(void *this_arg);
1305 } LDKMessageSendEventsProvider;
1306
1307 typedef struct LDKCVecTempl_Event {
1308    LDKEvent *data;
1309    uintptr_t datalen;
1310 } LDKCVecTempl_Event;
1311
1312 typedef LDKCVecTempl_Event LDKCVec_EventZ;
1313
1314 /**
1315  * A trait indicating an object may generate events
1316  */
1317 typedef struct LDKEventsProvider {
1318    void *this_arg;
1319    /**
1320     * Gets the list of pending events which were generated by previous actions, clearing the list
1321     * in the process.
1322     */
1323    LDKCVec_EventZ (*get_and_clear_pending_events)(const void *this_arg);
1324    void (*free)(void *this_arg);
1325 } LDKEventsProvider;
1326
1327 /**
1328  * A trait encapsulating the operations required of a logger
1329  */
1330 typedef struct LDKLogger {
1331    void *this_arg;
1332    /**
1333     * Logs the `Record`
1334     */
1335    void (*log)(const void *this_arg, const char *record);
1336    void (*free)(void *this_arg);
1337 } LDKLogger;
1338
1339
1340
1341 /**
1342  * Configuration we set when applicable.
1343  *
1344  * Default::default() provides sane defaults.
1345  */
1346 typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig {
1347    /**
1348     * Nearly everywhere, inner must be non-null, however in places where
1349     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1350     */
1351    LDKnativeChannelHandshakeConfig *inner;
1352    bool is_owned;
1353 } LDKChannelHandshakeConfig;
1354
1355
1356
1357 /**
1358  * Optional channel limits which are applied during channel creation.
1359  *
1360  * These limits are only applied to our counterparty's limits, not our own.
1361  *
1362  * Use 0/<type>::max_value() as appropriate to skip checking.
1363  *
1364  * Provides sane defaults for most configurations.
1365  *
1366  * Most additional limits are disabled except those with which specify a default in individual
1367  * field documentation. Note that this may result in barely-usable channels, but since they
1368  * are applied mostly only to incoming channels that's not much of a problem.
1369  */
1370 typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits {
1371    /**
1372     * Nearly everywhere, inner must be non-null, however in places where
1373     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1374     */
1375    LDKnativeChannelHandshakeLimits *inner;
1376    bool is_owned;
1377 } LDKChannelHandshakeLimits;
1378
1379
1380
1381 /**
1382  * Options which apply on a per-channel basis and may change at runtime or based on negotiation
1383  * with our counterparty.
1384  */
1385 typedef struct MUST_USE_STRUCT LDKChannelConfig {
1386    /**
1387     * Nearly everywhere, inner must be non-null, however in places where
1388     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1389     */
1390    LDKnativeChannelConfig *inner;
1391    bool is_owned;
1392 } LDKChannelConfig;
1393
1394 typedef struct LDKu8slice {
1395    const uint8_t *data;
1396    uintptr_t datalen;
1397 } LDKu8slice;
1398
1399
1400
1401 /**
1402  * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
1403  *
1404  * Default::default() provides sane defaults for most configurations
1405  * (but currently with 0 relay fees!)
1406  */
1407 typedef struct MUST_USE_STRUCT LDKUserConfig {
1408    /**
1409     * Nearly everywhere, inner must be non-null, however in places where
1410     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1411     */
1412    LDKnativeUserConfig *inner;
1413    bool is_owned;
1414 } LDKUserConfig;
1415
1416 typedef union LDKCResultPtr_TxOut__AccessError {
1417    LDKTxOut *result;
1418    LDKAccessError *err;
1419 } LDKCResultPtr_TxOut__AccessError;
1420
1421 typedef struct LDKCResultTempl_TxOut__AccessError {
1422    LDKCResultPtr_TxOut__AccessError contents;
1423    bool result_ok;
1424 } LDKCResultTempl_TxOut__AccessError;
1425
1426 typedef LDKCResultTempl_TxOut__AccessError LDKCResult_TxOutAccessErrorZ;
1427
1428 /**
1429  * The `Access` trait defines behavior for accessing chain data and state, such as blocks and
1430  * UTXOs.
1431  */
1432 typedef struct LDKAccess {
1433    void *this_arg;
1434    /**
1435     * Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
1436     * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
1437     * is unknown.
1438     *
1439     * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
1440     */
1441    LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id);
1442    void (*free)(void *this_arg);
1443 } LDKAccess;
1444
1445
1446
1447 /**
1448  * One counterparty's public keys which do not change over the life of a channel.
1449  */
1450 typedef struct MUST_USE_STRUCT LDKChannelPublicKeys {
1451    /**
1452     * Nearly everywhere, inner must be non-null, however in places where
1453     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1454     */
1455    LDKnativeChannelPublicKeys *inner;
1456    bool is_owned;
1457 } LDKChannelPublicKeys;
1458
1459
1460
1461 /**
1462  * The per-commitment point and a set of pre-calculated public keys used for transaction creation
1463  * in the signer.
1464  * The pre-calculated keys are an optimization, because ChannelKeys has enough
1465  * information to re-derive them.
1466  */
1467 typedef struct MUST_USE_STRUCT LDKPreCalculatedTxCreationKeys {
1468    /**
1469     * Nearly everywhere, inner must be non-null, however in places where
1470     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1471     */
1472    LDKnativePreCalculatedTxCreationKeys *inner;
1473    bool is_owned;
1474 } LDKPreCalculatedTxCreationKeys;
1475
1476 typedef struct LDKCVecTempl_HTLCOutputInCommitment {
1477    LDKHTLCOutputInCommitment *data;
1478    uintptr_t datalen;
1479 } LDKCVecTempl_HTLCOutputInCommitment;
1480
1481 typedef LDKCVecTempl_HTLCOutputInCommitment LDKCVec_HTLCOutputInCommitmentZ;
1482
1483
1484
1485 /**
1486  * We use this to track holder commitment transactions and put off signing them until we are ready
1487  * to broadcast. This class can be used inside a signer implementation to generate a signature
1488  * given the relevant secret key.
1489  */
1490 typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction {
1491    /**
1492     * Nearly everywhere, inner must be non-null, however in places where
1493     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1494     */
1495    LDKnativeHolderCommitmentTransaction *inner;
1496    bool is_owned;
1497 } LDKHolderCommitmentTransaction;
1498
1499
1500
1501 /**
1502  * The unsigned part of a channel_announcement
1503  */
1504 typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
1505    /**
1506     * Nearly everywhere, inner must be non-null, however in places where
1507     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1508     */
1509    LDKnativeUnsignedChannelAnnouncement *inner;
1510    bool is_owned;
1511 } LDKUnsignedChannelAnnouncement;
1512
1513 /**
1514  * Set of lightning keys needed to operate a channel as described in BOLT 3.
1515  *
1516  * Signing services could be implemented on a hardware wallet. In this case,
1517  * the current ChannelKeys would be a front-end on top of a communication
1518  * channel connected to your secure device and lightning key material wouldn't
1519  * reside on a hot server. Nevertheless, a this deployment would still need
1520  * to trust the ChannelManager to avoid loss of funds as this latest component
1521  * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
1522  *
1523  * A more secure iteration would be to use hashlock (or payment points) to pair
1524  * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
1525  * at the price of more state and computation on the hardware wallet side. In the future,
1526  * we are looking forward to design such interface.
1527  *
1528  * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
1529  * to act, as liveness and breach reply correctness are always going to be hard requirements
1530  * of LN security model, orthogonal of key management issues.
1531  *
1532  * If you're implementing a custom signer, you almost certainly want to implement
1533  * Readable/Writable to serialize out a unique reference to this set of keys so
1534  * that you can serialize the full ChannelManager object.
1535  *
1536  */
1537 typedef struct LDKChannelKeys {
1538    void *this_arg;
1539    /**
1540     * Gets the per-commitment point for a specific commitment number
1541     *
1542     * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
1543     */
1544    LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx);
1545    /**
1546     * Gets the commitment secret for a specific commitment number as part of the revocation process
1547     *
1548     * An external signer implementation should error here if the commitment was already signed
1549     * and should refuse to sign it in the future.
1550     *
1551     * May be called more than once for the same index.
1552     *
1553     * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
1554     * TODO: return a Result so we can signal a validation error
1555     */
1556    LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx);
1557    /**
1558     * Gets the holder's channel public keys and basepoints
1559     */
1560    LDKChannelPublicKeys pubkeys;
1561    /**
1562     * Fill in the pubkeys field as a reference to it will be given to Rust after this returns
1563     * Note that this takes a pointer to this object, not the this_ptr like other methods do
1564     * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
1565     */
1566    void (*set_pubkeys)(const LDKChannelKeys*);
1567    /**
1568     * Gets arbitrary identifiers describing the set of keys which are provided back to you in
1569     * some SpendableOutputDescriptor types. These should be sufficient to identify this
1570     * ChannelKeys object uniquely and lookup or re-derive its keys.
1571     */
1572    LDKC2Tuple_u64u64Z (*key_derivation_params)(const void *this_arg);
1573    /**
1574     * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
1575     *
1576     * Note that if signing fails or is rejected, the channel will be force-closed.
1577     */
1578    LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, uint32_t feerate_per_kw, LDKTransaction commitment_tx, const LDKPreCalculatedTxCreationKeys *keys, LDKCVec_HTLCOutputInCommitmentZ htlcs);
1579    /**
1580     * Create a signature for a holder's commitment transaction. This will only ever be called with
1581     * the same holder_commitment_tx (or a copy thereof), though there are currently no guarantees
1582     * that it will not be called multiple times.
1583     * An external signer implementation should check that the commitment has not been revoked.
1584     */
1585    LDKCResult_SignatureNoneZ (*sign_holder_commitment)(const void *this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx);
1586    /**
1587     * Create a signature for each HTLC transaction spending a holder's commitment transaction.
1588     *
1589     * Unlike sign_holder_commitment, this may be called multiple times with *different*
1590     * holder_commitment_tx values. While this will never be called with a revoked
1591     * holder_commitment_tx, it is possible that it is called with the second-latest
1592     * holder_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
1593     * ChannelMonitor decided to broadcast before it had been updated to the latest.
1594     *
1595     * Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
1596     * holder_commitment_tx. For those HTLCs which have transaction_output_index set to None
1597     * (implying they were considered dust at the time the commitment transaction was negotiated),
1598     * a corresponding None should be included in the return value. All other positions in the
1599     * return value must contain a signature.
1600     */
1601    LDKCResult_CVec_SignatureZNoneZ (*sign_holder_commitment_htlc_transactions)(const void *this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx);
1602    /**
1603     * Create a signature for the given input in a transaction spending an HTLC or commitment
1604     * transaction output when our counterparty broadcasts an old state.
1605     *
1606     * A justice transaction may claim multiples outputs at the same time if timelocks are
1607     * similar, but only a signature for the input at index `input` should be signed for here.
1608     * It may be called multiples time for same output(s) if a fee-bump is needed with regards
1609     * to an upcoming timelock expiration.
1610     *
1611     * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
1612     *
1613     * per_commitment_key is revocation secret which was provided by our counterparty when they
1614     * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
1615     * not allow the spending of any funds by itself (you need our holder revocation_secret to do
1616     * so).
1617     *
1618     * htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
1619     * changing the format of the witness script (which is committed to in the BIP 143
1620     * signatures).
1621     */
1622    LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const LDKHTLCOutputInCommitment *htlc);
1623    /**
1624     * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
1625     * transaction, either offered or received.
1626     *
1627     * Such a transaction may claim multiples offered outputs at same time if we know the
1628     * preimage for each when we create it, but only the input at index `input` should be
1629     * signed for here. It may be called multiple times for same output(s) if a fee-bump is
1630     * needed with regards to an upcoming timelock expiration.
1631     *
1632     * Witness_script is either a offered or received script as defined in BOLT3 for HTLC
1633     * outputs.
1634     *
1635     * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
1636     *
1637     * Per_commitment_point is the dynamic point corresponding to the channel state
1638     * detected onchain. It has been generated by our counterparty and is used to derive
1639     * channel state keys, which are then included in the witness script and committed to in the
1640     * BIP 143 signature.
1641     */
1642    LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment *htlc);
1643    /**
1644     * Create a signature for a (proposed) closing transaction.
1645     *
1646     * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
1647     * chosen to forgo their output as dust.
1648     */
1649    LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, LDKTransaction closing_tx);
1650    /**
1651     * Signs a channel announcement message with our funding key, proving it comes from one
1652     * of the channel participants.
1653     *
1654     * Note that if this fails or is rejected, the channel will not be publicly announced and
1655     * our counterparty may (though likely will not) close the channel on us for violating the
1656     * protocol.
1657     */
1658    LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const LDKUnsignedChannelAnnouncement *msg);
1659    /**
1660     * Set the counterparty channel basepoints and counterparty_selected/holder_selected_contest_delay.
1661     * This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels.
1662     *
1663     * We bind holder_selected_contest_delay late here for API convenience.
1664     *
1665     * Will be called before any signatures are applied.
1666     */
1667    void (*on_accept)(void *this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay);
1668    void *(*clone)(const void *this_arg);
1669    void (*free)(void *this_arg);
1670 } LDKChannelKeys;
1671
1672
1673
1674 /**
1675  * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
1676  * on-chain transactions to ensure no loss of funds occurs.
1677  *
1678  * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
1679  * information and are actively monitoring the chain.
1680  *
1681  * Pending Events or updated HTLCs which have not yet been read out by
1682  * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
1683  * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
1684  * gotten are fully handled before re-serializing the new state.
1685  */
1686 typedef struct MUST_USE_STRUCT LDKChannelMonitor {
1687    /**
1688     * Nearly everywhere, inner must be non-null, however in places where
1689     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1690     */
1691    LDKnativeChannelMonitor *inner;
1692    bool is_owned;
1693 } LDKChannelMonitor;
1694
1695
1696
1697 /**
1698  * An update generated by the underlying Channel itself which contains some new information the
1699  * ChannelMonitor should be made aware of.
1700  */
1701 typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
1702    /**
1703     * Nearly everywhere, inner must be non-null, however in places where
1704     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1705     */
1706    LDKnativeChannelMonitorUpdate *inner;
1707    bool is_owned;
1708 } LDKChannelMonitorUpdate;
1709
1710
1711
1712 /**
1713  * An event to be processed by the ChannelManager.
1714  */
1715 typedef struct MUST_USE_STRUCT LDKMonitorEvent {
1716    /**
1717     * Nearly everywhere, inner must be non-null, however in places where
1718     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1719     */
1720    LDKnativeMonitorEvent *inner;
1721    bool is_owned;
1722 } LDKMonitorEvent;
1723
1724 typedef struct LDKCVecTempl_MonitorEvent {
1725    LDKMonitorEvent *data;
1726    uintptr_t datalen;
1727 } LDKCVecTempl_MonitorEvent;
1728
1729 typedef LDKCVecTempl_MonitorEvent LDKCVec_MonitorEventZ;
1730
1731 /**
1732  * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
1733  * blocks are connected and disconnected.
1734  *
1735  * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
1736  * responsible for maintaining a set of monitors such that they can be updated accordingly as
1737  * channel state changes and HTLCs are resolved. See method documentation for specific
1738  * requirements.
1739  *
1740  * Implementations **must** ensure that updates are successfully applied and persisted upon method
1741  * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down
1742  * without taking any further action such as persisting the current state.
1743  *
1744  * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
1745  * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
1746  * could result in a revoked transaction being broadcast, allowing the counterparty to claim all
1747  * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
1748  * multiple instances.
1749  *
1750  * [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html
1751  * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
1752  * [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure
1753  */
1754 typedef struct LDKWatch {
1755    void *this_arg;
1756    /**
1757     * Watches a channel identified by `funding_txo` using `monitor`.
1758     *
1759     * Implementations are responsible for watching the chain for the funding transaction along
1760     * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
1761     * calling [`block_connected`] and [`block_disconnected`] on the monitor.
1762     *
1763     * [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch
1764     * [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected
1765     * [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
1766     */
1767    LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor);
1768    /**
1769     * Updates a channel identified by `funding_txo` by applying `update` to its monitor.
1770     *
1771     * Implementations must call [`update_monitor`] with the given update. See
1772     * [`ChannelMonitorUpdateErr`] for invariants around returning an error.
1773     *
1774     * [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor
1775     * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
1776     */
1777    LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update);
1778    /**
1779     * Returns any monitor events since the last call. Subsequent calls must only return new
1780     * events.
1781     */
1782    LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg);
1783    void (*free)(void *this_arg);
1784 } LDKWatch;
1785
1786 /**
1787  * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to
1788  * channels.
1789  *
1790  * This is useful in order to have a [`Watch`] implementation convey to a chain source which
1791  * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in
1792  * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If
1793  * receiving full blocks from a chain source, any further filtering is unnecessary.
1794  *
1795  * After an output has been registered, subsequent block retrievals from the chain source must not
1796  * exclude any transactions matching the new criteria nor any in-block descendants of such
1797  * transactions.
1798  *
1799  * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter`
1800  * should not block on I/O. Implementations should instead queue the newly monitored data to be
1801  * processed later. Then, in order to block until the data has been processed, any `Watch`
1802  * invocation that has called the `Filter` must return [`TemporaryFailure`].
1803  *
1804  * [`Watch`]: trait.Watch.html
1805  * [`TemporaryFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.TemporaryFailure
1806  * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki
1807  * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
1808  */
1809 typedef struct LDKFilter {
1810    void *this_arg;
1811    /**
1812     * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
1813     * a spending condition.
1814     */
1815    void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey);
1816    /**
1817     * Registers interest in spends of a transaction output identified by `outpoint` having
1818     * `script_pubkey` as the spending condition.
1819     */
1820    void (*register_output)(const void *this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey);
1821    void (*free)(void *this_arg);
1822 } LDKFilter;
1823
1824 /**
1825  * An interface to send a transaction to the Bitcoin network.
1826  */
1827 typedef struct LDKBroadcasterInterface {
1828    void *this_arg;
1829    /**
1830     * Sends a transaction out to (hopefully) be mined.
1831     */
1832    void (*broadcast_transaction)(const void *this_arg, LDKTransaction tx);
1833    void (*free)(void *this_arg);
1834 } LDKBroadcasterInterface;
1835
1836 /**
1837  * A trait which should be implemented to provide feerate information on a number of time
1838  * horizons.
1839  *
1840  * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
1841  * called from inside the library in response to chain events, P2P events, or timer events).
1842  */
1843 typedef struct LDKFeeEstimator {
1844    void *this_arg;
1845    /**
1846     * Gets estimated satoshis of fee required per 1000 Weight-Units.
1847     *
1848     * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
1849     * don't put us below 1 satoshi-per-byte).
1850     *
1851     * This translates to:
1852     *  * satoshis-per-byte * 250
1853     *  * ceil(satoshis-per-kbyte / 4)
1854     */
1855    uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, LDKConfirmationTarget confirmation_target);
1856    void (*free)(void *this_arg);
1857 } LDKFeeEstimator;
1858
1859 /**
1860  * `Persist` defines behavior for persisting channel monitors: this could mean
1861  * writing once to disk, and/or uploading to one or more backup services.
1862  *
1863  * Note that for every new monitor, you **must** persist the new `ChannelMonitor`
1864  * to disk/backups. And, on every update, you **must** persist either the
1865  * `ChannelMonitorUpdate` or the updated monitor itself. Otherwise, there is risk
1866  * of situations such as revoking a transaction, then crashing before this
1867  * revocation can be persisted, then unintentionally broadcasting a revoked
1868  * transaction and losing money. This is a risk because previous channel states
1869  * are toxic, so it's important that whatever channel state is persisted is
1870  * kept up-to-date.
1871  */
1872 typedef struct LDKPersist {
1873    void *this_arg;
1874    /**
1875     * Persist a new channel's data. The data can be stored any way you want, but
1876     * the identifier provided by Rust-Lightning is the channel's outpoint (and
1877     * it is up to you to maintain a correct mapping between the outpoint and the
1878     * stored channel data). Note that you **must** persist every new monitor to
1879     * disk. See the `Persist` trait documentation for more details.
1880     *
1881     * See [`ChannelMonitor::serialize_for_disk`] for writing out a `ChannelMonitor`,
1882     * and [`ChannelMonitorUpdateErr`] for requirements when returning errors.
1883     *
1884     * [`ChannelMonitor::serialize_for_disk`]: struct.ChannelMonitor.html#method.serialize_for_disk
1885     * [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html
1886     */
1887    LDKCResult_NoneChannelMonitorUpdateErrZ (*persist_new_channel)(const void *this_arg, LDKOutPoint id, const LDKChannelMonitor *data);
1888    /**
1889     * Update one channel's data. The provided `ChannelMonitor` has already
1890     * applied the given update.
1891     *
1892     * Note that on every update, you **must** persist either the
1893     * `ChannelMonitorUpdate` or the updated monitor itself to disk/backups. See
1894     * the `Persist` trait documentation for more details.
1895     *
1896     * If an implementer chooses to persist the updates only, they need to make
1897     * sure that all the updates are applied to the `ChannelMonitors` *before*
1898     * the set of channel monitors is given to the `ChannelManager`
1899     * deserialization routine. See [`ChannelMonitor::update_monitor`] for
1900     * applying a monitor update to a monitor. If full `ChannelMonitors` are
1901     * persisted, then there is no need to persist individual updates.
1902     *
1903     * Note that there could be a performance tradeoff between persisting complete
1904     * channel monitors on every update vs. persisting only updates and applying
1905     * them in batches. The size of each monitor grows `O(number of state updates)`
1906     * whereas updates are small and `O(1)`.
1907     *
1908     * See [`ChannelMonitor::serialize_for_disk`] for writing out a `ChannelMonitor`,
1909     * [`ChannelMonitorUpdate::write`] for writing out an update, and
1910     * [`ChannelMonitorUpdateErr`] for requirements when returning errors.
1911     *
1912     * [`ChannelMonitor::update_monitor`]: struct.ChannelMonitor.html#impl-1
1913     * [`ChannelMonitor::serialize_for_disk`]: struct.ChannelMonitor.html#method.serialize_for_disk
1914     * [`ChannelMonitorUpdate::write`]: struct.ChannelMonitorUpdate.html#method.write
1915     * [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html
1916     */
1917    LDKCResult_NoneChannelMonitorUpdateErrZ (*update_persisted_channel)(const void *this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate *update, const LDKChannelMonitor *data);
1918    void (*free)(void *this_arg);
1919 } LDKPersist;
1920
1921
1922
1923 /**
1924  * An implementation of [`chain::Watch`] for monitoring channels.
1925  *
1926  * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by
1927  * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally
1928  * or used independently to monitor channels remotely. See the [module-level documentation] for
1929  * details.
1930  *
1931  * [`chain::Watch`]: ../trait.Watch.html
1932  * [`ChannelManager`]: ../../ln/channelmanager/struct.ChannelManager.html
1933  * [module-level documentation]: index.html
1934  */
1935 typedef struct MUST_USE_STRUCT LDKChainMonitor {
1936    /**
1937     * Nearly everywhere, inner must be non-null, however in places where
1938     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1939     */
1940    LDKnativeChainMonitor *inner;
1941    bool is_owned;
1942 } LDKChainMonitor;
1943
1944 typedef struct LDKCVecTempl_C2TupleTempl_usize__Transaction {
1945    LDKC2TupleTempl_usize__Transaction *data;
1946    uintptr_t datalen;
1947 } LDKCVecTempl_C2TupleTempl_usize__Transaction;
1948
1949 typedef LDKCVecTempl_C2TupleTempl_usize__Transaction LDKCVec_C2Tuple_usizeTransactionZZ;
1950
1951
1952
1953 /**
1954  * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
1955  * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
1956  * preimage claim backward will lead to loss of funds.
1957  *
1958  * [`chain::Watch`]: ../trait.Watch.html
1959  */
1960 typedef struct MUST_USE_STRUCT LDKHTLCUpdate {
1961    /**
1962     * Nearly everywhere, inner must be non-null, however in places where
1963     * the Rust equivalent takes an Option, it may be set to null to indicate None.
1964     */
1965    LDKnativeHTLCUpdate *inner;
1966    bool is_owned;
1967 } LDKHTLCUpdate;
1968
1969 typedef struct LDKCVecTempl_Transaction {
1970    LDKTransaction *data;
1971    uintptr_t datalen;
1972 } LDKCVecTempl_Transaction;
1973
1974 typedef LDKCVecTempl_Transaction LDKCVec_TransactionZ;
1975
1976 typedef struct LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut {
1977    LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut *data;
1978    uintptr_t datalen;
1979 } LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut;
1980
1981 typedef LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ;
1982
1983 typedef struct LDKSecretKey {
1984    uint8_t bytes[32];
1985 } LDKSecretKey;
1986
1987 /**
1988  * A trait to describe an object which can get user secrets and key material.
1989  */
1990 typedef struct LDKKeysInterface {
1991    void *this_arg;
1992    /**
1993     * Get node secret key (aka node_id or network_key)
1994     */
1995    LDKSecretKey (*get_node_secret)(const void *this_arg);
1996    /**
1997     * Get destination redeemScript to encumber static protocol exit points.
1998     */
1999    LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
2000    /**
2001     * Get shutdown_pubkey to use as PublicKey at channel closure
2002     */
2003    LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg);
2004    /**
2005     * Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
2006     * restarted with some stale data!
2007     */
2008    LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis);
2009    /**
2010     * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
2011     * onion packets and for temporary channel IDs. There is no requirement that these be
2012     * persisted anywhere, though they must be unique across restarts.
2013     */
2014    LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg);
2015    void (*free)(void *this_arg);
2016 } LDKKeysInterface;
2017
2018
2019
2020 /**
2021  * A simple implementation of ChannelKeys that just keeps the private keys in memory.
2022  */
2023 typedef struct MUST_USE_STRUCT LDKInMemoryChannelKeys {
2024    /**
2025     * Nearly everywhere, inner must be non-null, however in places where
2026     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2027     */
2028    LDKnativeInMemoryChannelKeys *inner;
2029    bool is_owned;
2030 } LDKInMemoryChannelKeys;
2031
2032
2033
2034 /**
2035  * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key
2036  * and derives keys from that.
2037  *
2038  * Your node_id is seed/0'
2039  * ChannelMonitor closes may use seed/1'
2040  * Cooperative closes may use seed/2'
2041  * The two close keys may be needed to claim on-chain funds!
2042  */
2043 typedef struct MUST_USE_STRUCT LDKKeysManager {
2044    /**
2045     * Nearly everywhere, inner must be non-null, however in places where
2046     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2047     */
2048    LDKnativeKeysManager *inner;
2049    bool is_owned;
2050 } LDKKeysManager;
2051
2052
2053
2054 /**
2055  * Manager which keeps track of a number of channels and sends messages to the appropriate
2056  * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
2057  *
2058  * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
2059  * to individual Channels.
2060  *
2061  * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
2062  * all peers during write/read (though does not modify this instance, only the instance being
2063  * serialized). This will result in any channels which have not yet exchanged funding_created (ie
2064  * called funding_transaction_generated for outbound channels).
2065  *
2066  * Note that you can be a bit lazier about writing out ChannelManager than you can be with
2067  * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
2068  * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
2069  * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
2070  * the serialization process). If the deserialized version is out-of-date compared to the
2071  * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
2072  * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
2073  *
2074  * Note that the deserializer is only implemented for (Sha256dHash, ChannelManager), which
2075  * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
2076  * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
2077  * block_connected() to step towards your best block) upon deserialization before using the
2078  * object!
2079  *
2080  * Note that ChannelManager is responsible for tracking liveness of its channels and generating
2081  * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
2082  * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
2083  * offline for a full minute. In order to track this, you must call
2084  * timer_chan_freshness_every_min roughly once per minute, though it doesn't have to be perfect.
2085  *
2086  * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
2087  * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
2088  * essentially you should default to using a SimpleRefChannelManager, and use a
2089  * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
2090  * you're using lightning-net-tokio.
2091  */
2092 typedef struct MUST_USE_STRUCT LDKChannelManager {
2093    /**
2094     * Nearly everywhere, inner must be non-null, however in places where
2095     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2096     */
2097    LDKnativeChannelManager *inner;
2098    bool is_owned;
2099 } LDKChannelManager;
2100
2101
2102
2103 /**
2104  * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
2105  */
2106 typedef struct MUST_USE_STRUCT LDKChannelDetails {
2107    /**
2108     * Nearly everywhere, inner must be non-null, however in places where
2109     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2110     */
2111    LDKnativeChannelDetails *inner;
2112    bool is_owned;
2113 } LDKChannelDetails;
2114
2115
2116
2117 /**
2118  * Features used within an `init` message.
2119  */
2120 typedef struct MUST_USE_STRUCT LDKInitFeatures {
2121    /**
2122     * Nearly everywhere, inner must be non-null, however in places where
2123     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2124     */
2125    LDKnativeInitFeatures *inner;
2126    bool is_owned;
2127 } LDKInitFeatures;
2128
2129 typedef struct LDKCVecTempl_ChannelDetails {
2130    LDKChannelDetails *data;
2131    uintptr_t datalen;
2132 } LDKCVecTempl_ChannelDetails;
2133
2134 typedef LDKCVecTempl_ChannelDetails LDKCVec_ChannelDetailsZ;
2135
2136
2137
2138 /**
2139  * A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
2140  * it can take multiple paths. Each path is composed of one or more hops through the network.
2141  */
2142 typedef struct MUST_USE_STRUCT LDKRoute {
2143    /**
2144     * Nearly everywhere, inner must be non-null, however in places where
2145     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2146     */
2147    LDKnativeRoute *inner;
2148    bool is_owned;
2149 } LDKRoute;
2150
2151 typedef struct LDKThreeBytes {
2152    uint8_t data[3];
2153 } LDKThreeBytes;
2154
2155 typedef struct LDKFourBytes {
2156    uint8_t data[4];
2157 } LDKFourBytes;
2158
2159 typedef struct LDKSixteenBytes {
2160    uint8_t data[16];
2161 } LDKSixteenBytes;
2162
2163 typedef struct LDKTenBytes {
2164    uint8_t data[10];
2165 } LDKTenBytes;
2166
2167 /**
2168  * An address which can be used to connect to a remote peer
2169  */
2170 typedef enum LDKNetAddress_Tag {
2171    /**
2172     * An IPv4 address/port on which the peer is listening.
2173     */
2174    LDKNetAddress_IPv4,
2175    /**
2176     * An IPv6 address/port on which the peer is listening.
2177     */
2178    LDKNetAddress_IPv6,
2179    /**
2180     * An old-style Tor onion address/port on which the peer is listening.
2181     */
2182    LDKNetAddress_OnionV2,
2183    /**
2184     * A new-style Tor onion address/port on which the peer is listening.
2185     * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2186     * wrap as base32 and append \".onion\".
2187     */
2188    LDKNetAddress_OnionV3,
2189    /**
2190     * Must be last for serialization purposes
2191     */
2192    LDKNetAddress_Sentinel,
2193 } LDKNetAddress_Tag;
2194
2195 typedef struct LDKNetAddress_LDKIPv4_Body {
2196    LDKFourBytes addr;
2197    uint16_t port;
2198 } LDKNetAddress_LDKIPv4_Body;
2199
2200 typedef struct LDKNetAddress_LDKIPv6_Body {
2201    LDKSixteenBytes addr;
2202    uint16_t port;
2203 } LDKNetAddress_LDKIPv6_Body;
2204
2205 typedef struct LDKNetAddress_LDKOnionV2_Body {
2206    LDKTenBytes addr;
2207    uint16_t port;
2208 } LDKNetAddress_LDKOnionV2_Body;
2209
2210 typedef struct LDKNetAddress_LDKOnionV3_Body {
2211    LDKThirtyTwoBytes ed25519_pubkey;
2212    uint16_t checksum;
2213    uint8_t version;
2214    uint16_t port;
2215 } LDKNetAddress_LDKOnionV3_Body;
2216
2217 typedef struct LDKNetAddress {
2218    LDKNetAddress_Tag tag;
2219    union {
2220       LDKNetAddress_LDKIPv4_Body i_pv4;
2221       LDKNetAddress_LDKIPv6_Body i_pv6;
2222       LDKNetAddress_LDKOnionV2_Body onion_v2;
2223       LDKNetAddress_LDKOnionV3_Body onion_v3;
2224    };
2225 } LDKNetAddress;
2226
2227 typedef struct LDKCVecTempl_NetAddress {
2228    LDKNetAddress *data;
2229    uintptr_t datalen;
2230 } LDKCVecTempl_NetAddress;
2231
2232 typedef LDKCVecTempl_NetAddress LDKCVec_NetAddressZ;
2233
2234
2235
2236 /**
2237  * An update_add_htlc message to be sent or received from a peer
2238  */
2239 typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC {
2240    /**
2241     * Nearly everywhere, inner must be non-null, however in places where
2242     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2243     */
2244    LDKnativeUpdateAddHTLC *inner;
2245    bool is_owned;
2246 } LDKUpdateAddHTLC;
2247
2248
2249
2250 /**
2251  * An update_fulfill_htlc message to be sent or received from a peer
2252  */
2253 typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC {
2254    /**
2255     * Nearly everywhere, inner must be non-null, however in places where
2256     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2257     */
2258    LDKnativeUpdateFulfillHTLC *inner;
2259    bool is_owned;
2260 } LDKUpdateFulfillHTLC;
2261
2262
2263
2264 /**
2265  * An update_fail_htlc message to be sent or received from a peer
2266  */
2267 typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC {
2268    /**
2269     * Nearly everywhere, inner must be non-null, however in places where
2270     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2271     */
2272    LDKnativeUpdateFailHTLC *inner;
2273    bool is_owned;
2274 } LDKUpdateFailHTLC;
2275
2276
2277
2278 /**
2279  * An update_fail_malformed_htlc message to be sent or received from a peer
2280  */
2281 typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC {
2282    /**
2283     * Nearly everywhere, inner must be non-null, however in places where
2284     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2285     */
2286    LDKnativeUpdateFailMalformedHTLC *inner;
2287    bool is_owned;
2288 } LDKUpdateFailMalformedHTLC;
2289
2290
2291
2292 /**
2293  * A commitment_signed message to be sent or received from a peer
2294  */
2295 typedef struct MUST_USE_STRUCT LDKCommitmentSigned {
2296    /**
2297     * Nearly everywhere, inner must be non-null, however in places where
2298     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2299     */
2300    LDKnativeCommitmentSigned *inner;
2301    bool is_owned;
2302 } LDKCommitmentSigned;
2303
2304
2305
2306 /**
2307  * An update_fee message to be sent or received from a peer
2308  */
2309 typedef struct MUST_USE_STRUCT LDKUpdateFee {
2310    /**
2311     * Nearly everywhere, inner must be non-null, however in places where
2312     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2313     */
2314    LDKnativeUpdateFee *inner;
2315    bool is_owned;
2316 } LDKUpdateFee;
2317
2318
2319
2320 /**
2321  * An init message to be sent or received from a peer
2322  */
2323 typedef struct MUST_USE_STRUCT LDKInit {
2324    /**
2325     * Nearly everywhere, inner must be non-null, however in places where
2326     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2327     */
2328    LDKnativeInit *inner;
2329    bool is_owned;
2330 } LDKInit;
2331
2332 /**
2333  * A trait to describe an object which can receive channel messages.
2334  *
2335  * Messages MAY be called in parallel when they originate from different their_node_ids, however
2336  * they MUST NOT be called in parallel when the two calls have the same their_node_id.
2337  */
2338 typedef struct LDKChannelMessageHandler {
2339    void *this_arg;
2340    /**
2341     * Handle an incoming open_channel message from the given peer.
2342     */
2343    void (*handle_open_channel)(const void *this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg);
2344    /**
2345     * Handle an incoming accept_channel message from the given peer.
2346     */
2347    void (*handle_accept_channel)(const void *this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg);
2348    /**
2349     * Handle an incoming funding_created message from the given peer.
2350     */
2351    void (*handle_funding_created)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg);
2352    /**
2353     * Handle an incoming funding_signed message from the given peer.
2354     */
2355    void (*handle_funding_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg);
2356    /**
2357     * Handle an incoming funding_locked message from the given peer.
2358     */
2359    void (*handle_funding_locked)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg);
2360    /**
2361     * Handle an incoming shutdown message from the given peer.
2362     */
2363    void (*handle_shutdown)(const void *this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg);
2364    /**
2365     * Handle an incoming closing_signed message from the given peer.
2366     */
2367    void (*handle_closing_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg);
2368    /**
2369     * Handle an incoming update_add_htlc message from the given peer.
2370     */
2371    void (*handle_update_add_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg);
2372    /**
2373     * Handle an incoming update_fulfill_htlc message from the given peer.
2374     */
2375    void (*handle_update_fulfill_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg);
2376    /**
2377     * Handle an incoming update_fail_htlc message from the given peer.
2378     */
2379    void (*handle_update_fail_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg);
2380    /**
2381     * Handle an incoming update_fail_malformed_htlc message from the given peer.
2382     */
2383    void (*handle_update_fail_malformed_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg);
2384    /**
2385     * Handle an incoming commitment_signed message from the given peer.
2386     */
2387    void (*handle_commitment_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg);
2388    /**
2389     * Handle an incoming revoke_and_ack message from the given peer.
2390     */
2391    void (*handle_revoke_and_ack)(const void *this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg);
2392    /**
2393     * Handle an incoming update_fee message from the given peer.
2394     */
2395    void (*handle_update_fee)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg);
2396    /**
2397     * Handle an incoming announcement_signatures message from the given peer.
2398     */
2399    void (*handle_announcement_signatures)(const void *this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg);
2400    /**
2401     * Indicates a connection to the peer failed/an existing connection was lost. If no connection
2402     * is believed to be possible in the future (eg they're sending us messages we don't
2403     * understand or indicate they require unknown feature bits), no_connection_possible is set
2404     * and any outstanding channels should be failed.
2405     */
2406    void (*peer_disconnected)(const void *this_arg, LDKPublicKey their_node_id, bool no_connection_possible);
2407    /**
2408     * Handle a peer reconnecting, possibly generating channel_reestablish message(s).
2409     */
2410    void (*peer_connected)(const void *this_arg, LDKPublicKey their_node_id, const LDKInit *msg);
2411    /**
2412     * Handle an incoming channel_reestablish message from the given peer.
2413     */
2414    void (*handle_channel_reestablish)(const void *this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg);
2415    /**
2416     * Handle an incoming error message from the given peer.
2417     */
2418    void (*handle_error)(const void *this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg);
2419    LDKMessageSendEventsProvider MessageSendEventsProvider;
2420    void (*free)(void *this_arg);
2421 } LDKChannelMessageHandler;
2422
2423
2424
2425 /**
2426  * Arguments for the creation of a ChannelManager that are not deserialized.
2427  *
2428  * At a high-level, the process for deserializing a ChannelManager and resuming normal operation
2429  * is:
2430  * 1) Deserialize all stored ChannelMonitors.
2431  * 2) Deserialize the ChannelManager by filling in this struct and calling <(Sha256dHash,
2432  *    ChannelManager)>::read(reader, args).
2433  *    This may result in closing some Channels if the ChannelMonitor is newer than the stored
2434  *    ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted.
2435  * 3) Register all relevant ChannelMonitor outpoints with your chain watch mechanism using
2436  *    ChannelMonitor::get_outputs_to_watch() and ChannelMonitor::get_funding_txo().
2437  * 4) Reconnect blocks on your ChannelMonitors.
2438  * 5) Move the ChannelMonitors into your local chain::Watch.
2439  * 6) Disconnect/connect blocks on the ChannelManager.
2440  */
2441 typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs {
2442    /**
2443     * Nearly everywhere, inner must be non-null, however in places where
2444     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2445     */
2446    LDKnativeChannelManagerReadArgs *inner;
2447    bool is_owned;
2448 } LDKChannelManagerReadArgs;
2449
2450 typedef struct LDKCVecTempl_ChannelMonitor {
2451    LDKChannelMonitor *data;
2452    uintptr_t datalen;
2453 } LDKCVecTempl_ChannelMonitor;
2454
2455 typedef LDKCVecTempl_ChannelMonitor LDKCVec_ChannelMonitorZ;
2456
2457
2458
2459 /**
2460  * An error in decoding a message or struct.
2461  */
2462 typedef struct MUST_USE_STRUCT LDKDecodeError {
2463    /**
2464     * Nearly everywhere, inner must be non-null, however in places where
2465     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2466     */
2467    LDKnativeDecodeError *inner;
2468    bool is_owned;
2469 } LDKDecodeError;
2470
2471
2472
2473 /**
2474  * A ping message to be sent or received from a peer
2475  */
2476 typedef struct MUST_USE_STRUCT LDKPing {
2477    /**
2478     * Nearly everywhere, inner must be non-null, however in places where
2479     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2480     */
2481    LDKnativePing *inner;
2482    bool is_owned;
2483 } LDKPing;
2484
2485
2486
2487 /**
2488  * A pong message to be sent or received from a peer
2489  */
2490 typedef struct MUST_USE_STRUCT LDKPong {
2491    /**
2492     * Nearly everywhere, inner must be non-null, however in places where
2493     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2494     */
2495    LDKnativePong *inner;
2496    bool is_owned;
2497 } LDKPong;
2498
2499
2500
2501 /**
2502  * Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2503  * This is used to convince the recipient that the channel is at a certain commitment
2504  * number even if they lost that data due to a local failure.  Of course, the peer may lie
2505  * and even later commitments may have been revoked.
2506  */
2507 typedef struct MUST_USE_STRUCT LDKDataLossProtect {
2508    /**
2509     * Nearly everywhere, inner must be non-null, however in places where
2510     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2511     */
2512    LDKnativeDataLossProtect *inner;
2513    bool is_owned;
2514 } LDKDataLossProtect;
2515
2516
2517
2518 /**
2519  * The unsigned part of a node_announcement
2520  */
2521 typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement {
2522    /**
2523     * Nearly everywhere, inner must be non-null, however in places where
2524     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2525     */
2526    LDKnativeUnsignedNodeAnnouncement *inner;
2527    bool is_owned;
2528 } LDKUnsignedNodeAnnouncement;
2529
2530
2531
2532 /**
2533  * Features used within a `node_announcement` message.
2534  */
2535 typedef struct MUST_USE_STRUCT LDKNodeFeatures {
2536    /**
2537     * Nearly everywhere, inner must be non-null, however in places where
2538     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2539     */
2540    LDKnativeNodeFeatures *inner;
2541    bool is_owned;
2542 } LDKNodeFeatures;
2543
2544
2545
2546 /**
2547  * Features used within a `channel_announcement` message.
2548  */
2549 typedef struct MUST_USE_STRUCT LDKChannelFeatures {
2550    /**
2551     * Nearly everywhere, inner must be non-null, however in places where
2552     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2553     */
2554    LDKnativeChannelFeatures *inner;
2555    bool is_owned;
2556 } LDKChannelFeatures;
2557
2558
2559
2560 /**
2561  * The unsigned part of a channel_update
2562  */
2563 typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate {
2564    /**
2565     * Nearly everywhere, inner must be non-null, however in places where
2566     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2567     */
2568    LDKnativeUnsignedChannelUpdate *inner;
2569    bool is_owned;
2570 } LDKUnsignedChannelUpdate;
2571
2572
2573
2574 /**
2575  * A query_channel_range message is used to query a peer for channel
2576  * UTXOs in a range of blocks. The recipient of a query makes a best
2577  * effort to reply to the query using one or more reply_channel_range
2578  * messages.
2579  */
2580 typedef struct MUST_USE_STRUCT LDKQueryChannelRange {
2581    /**
2582     * Nearly everywhere, inner must be non-null, however in places where
2583     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2584     */
2585    LDKnativeQueryChannelRange *inner;
2586    bool is_owned;
2587 } LDKQueryChannelRange;
2588
2589
2590
2591 /**
2592  * A reply_channel_range message is a reply to a query_channel_range
2593  * message. Multiple reply_channel_range messages can be sent in reply
2594  * to a single query_channel_range message. The query recipient makes a
2595  * best effort to respond based on their local network view which may
2596  * not be a perfect view of the network. The short_channel_ids in the
2597  * reply are encoded. We only support encoding_type=0 uncompressed
2598  * serialization and do not support encoding_type=1 zlib serialization.
2599  */
2600 typedef struct MUST_USE_STRUCT LDKReplyChannelRange {
2601    /**
2602     * Nearly everywhere, inner must be non-null, however in places where
2603     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2604     */
2605    LDKnativeReplyChannelRange *inner;
2606    bool is_owned;
2607 } LDKReplyChannelRange;
2608
2609 typedef struct LDKCVecTempl_u64 {
2610    uint64_t *data;
2611    uintptr_t datalen;
2612 } LDKCVecTempl_u64;
2613
2614 typedef LDKCVecTempl_u64 LDKCVec_u64Z;
2615
2616
2617
2618 /**
2619  * A query_short_channel_ids message is used to query a peer for
2620  * routing gossip messages related to one or more short_channel_ids.
2621  * The query recipient will reply with the latest, if available,
2622  * channel_announcement, channel_update and node_announcement messages
2623  * it maintains for the requested short_channel_ids followed by a
2624  * reply_short_channel_ids_end message. The short_channel_ids sent in
2625  * this query are encoded. We only support encoding_type=0 uncompressed
2626  * serialization and do not support encoding_type=1 zlib serialization.
2627  */
2628 typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds {
2629    /**
2630     * Nearly everywhere, inner must be non-null, however in places where
2631     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2632     */
2633    LDKnativeQueryShortChannelIds *inner;
2634    bool is_owned;
2635 } LDKQueryShortChannelIds;
2636
2637
2638
2639 /**
2640  * A reply_short_channel_ids_end message is sent as a reply to a
2641  * query_short_channel_ids message. The query recipient makes a best
2642  * effort to respond based on their local network view which may not be
2643  * a perfect view of the network.
2644  */
2645 typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd {
2646    /**
2647     * Nearly everywhere, inner must be non-null, however in places where
2648     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2649     */
2650    LDKnativeReplyShortChannelIdsEnd *inner;
2651    bool is_owned;
2652 } LDKReplyShortChannelIdsEnd;
2653
2654
2655
2656 /**
2657  * A gossip_timestamp_filter message is used by a node to request
2658  * gossip relay for messages in the requested time range when the
2659  * gossip_queries feature has been negotiated.
2660  */
2661 typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter {
2662    /**
2663     * Nearly everywhere, inner must be non-null, however in places where
2664     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2665     */
2666    LDKnativeGossipTimestampFilter *inner;
2667    bool is_owned;
2668 } LDKGossipTimestampFilter;
2669
2670 typedef struct LDKCVecTempl_UpdateAddHTLC {
2671    LDKUpdateAddHTLC *data;
2672    uintptr_t datalen;
2673 } LDKCVecTempl_UpdateAddHTLC;
2674
2675 typedef LDKCVecTempl_UpdateAddHTLC LDKCVec_UpdateAddHTLCZ;
2676
2677 typedef struct LDKCVecTempl_UpdateFulfillHTLC {
2678    LDKUpdateFulfillHTLC *data;
2679    uintptr_t datalen;
2680 } LDKCVecTempl_UpdateFulfillHTLC;
2681
2682 typedef LDKCVecTempl_UpdateFulfillHTLC LDKCVec_UpdateFulfillHTLCZ;
2683
2684 typedef struct LDKCVecTempl_UpdateFailHTLC {
2685    LDKUpdateFailHTLC *data;
2686    uintptr_t datalen;
2687 } LDKCVecTempl_UpdateFailHTLC;
2688
2689 typedef LDKCVecTempl_UpdateFailHTLC LDKCVec_UpdateFailHTLCZ;
2690
2691 typedef struct LDKCVecTempl_UpdateFailMalformedHTLC {
2692    LDKUpdateFailMalformedHTLC *data;
2693    uintptr_t datalen;
2694 } LDKCVecTempl_UpdateFailMalformedHTLC;
2695
2696 typedef LDKCVecTempl_UpdateFailMalformedHTLC LDKCVec_UpdateFailMalformedHTLCZ;
2697
2698 typedef union LDKCResultPtr_bool__LightningError {
2699    bool *result;
2700    LDKLightningError *err;
2701 } LDKCResultPtr_bool__LightningError;
2702
2703 typedef struct LDKCResultTempl_bool__LightningError {
2704    LDKCResultPtr_bool__LightningError contents;
2705    bool result_ok;
2706 } LDKCResultTempl_bool__LightningError;
2707
2708 typedef LDKCResultTempl_bool__LightningError LDKCResult_boolLightningErrorZ;
2709
2710 typedef struct LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate {
2711    LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *data;
2712    uintptr_t datalen;
2713 } LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate;
2714
2715 typedef LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ;
2716
2717 typedef struct LDKCVecTempl_NodeAnnouncement {
2718    LDKNodeAnnouncement *data;
2719    uintptr_t datalen;
2720 } LDKCVecTempl_NodeAnnouncement;
2721
2722 typedef LDKCVecTempl_NodeAnnouncement LDKCVec_NodeAnnouncementZ;
2723
2724 /**
2725  * A trait to describe an object which can receive routing messages.
2726  */
2727 typedef struct LDKRoutingMessageHandler {
2728    void *this_arg;
2729    /**
2730     * Handle an incoming node_announcement message, returning true if it should be forwarded on,
2731     * false or returning an Err otherwise.
2732     */
2733    LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const LDKNodeAnnouncement *msg);
2734    /**
2735     * Handle a channel_announcement message, returning true if it should be forwarded on, false
2736     * or returning an Err otherwise.
2737     */
2738    LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const LDKChannelAnnouncement *msg);
2739    /**
2740     * Handle an incoming channel_update message, returning true if it should be forwarded on,
2741     * false or returning an Err otherwise.
2742     */
2743    LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const LDKChannelUpdate *msg);
2744    /**
2745     * Handle some updates to the route graph that we learned due to an outbound failed payment.
2746     */
2747    void (*handle_htlc_fail_channel_update)(const void *this_arg, const LDKHTLCFailChannelUpdate *update);
2748    /**
2749     * Gets a subset of the channel announcements and updates required to dump our routing table
2750     * to a remote node, starting at the short_channel_id indicated by starting_point and
2751     * including the batch_amount entries immediately higher in numerical value than starting_point.
2752     */
2753    LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcements)(const void *this_arg, uint64_t starting_point, uint8_t batch_amount);
2754    /**
2755     * Gets a subset of the node announcements required to dump our routing table to a remote node,
2756     * starting at the node *after* the provided publickey and including batch_amount entries
2757     * immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
2758     * If None is provided for starting_point, we start at the first node.
2759     */
2760    LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, LDKPublicKey starting_point, uint8_t batch_amount);
2761    /**
2762     * Returns whether a full sync should be requested from a peer.
2763     */
2764    bool (*should_request_full_sync)(const void *this_arg, LDKPublicKey node_id);
2765    void (*free)(void *this_arg);
2766 } LDKRoutingMessageHandler;
2767
2768
2769
2770 /**
2771  * Provides references to trait impls which handle different types of messages.
2772  */
2773 typedef struct MUST_USE_STRUCT LDKMessageHandler {
2774    /**
2775     * Nearly everywhere, inner must be non-null, however in places where
2776     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2777     */
2778    LDKnativeMessageHandler *inner;
2779    bool is_owned;
2780 } LDKMessageHandler;
2781
2782 /**
2783  * Provides an object which can be used to send data to and which uniquely identifies a connection
2784  * to a remote host. You will need to be able to generate multiple of these which meet Eq and
2785  * implement Hash to meet the PeerManager API.
2786  *
2787  * For efficiency, Clone should be relatively cheap for this type.
2788  *
2789  * You probably want to just extend an int and put a file descriptor in a struct and implement
2790  * send_data. Note that if you are using a higher-level net library that may call close() itself,
2791  * be careful to ensure you don't have races whereby you might register a new connection with an
2792  * fd which is the same as a previous one which has yet to be removed via
2793  * PeerManager::socket_disconnected().
2794  */
2795 typedef struct LDKSocketDescriptor {
2796    void *this_arg;
2797    /**
2798     * Attempts to send some data from the given slice to the peer.
2799     *
2800     * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected.
2801     * Note that in the disconnected case, socket_disconnected must still fire and further write
2802     * attempts may occur until that time.
2803     *
2804     * If the returned size is smaller than data.len(), a write_available event must
2805     * trigger the next time more data can be written. Additionally, until the a send_data event
2806     * completes fully, no further read_events should trigger on the same peer!
2807     *
2808     * If a read_event on this descriptor had previously returned true (indicating that read
2809     * events should be paused to prevent DoS in the send buffer), resume_read may be set
2810     * indicating that read events on this descriptor should resume. A resume_read of false does
2811     * *not* imply that further read events should be paused.
2812     */
2813    uintptr_t (*send_data)(void *this_arg, LDKu8slice data, bool resume_read);
2814    /**
2815     * Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no
2816     * more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with
2817     * this descriptor. No socket_disconnected call should be generated as a result of this call,
2818     * though races may occur whereby disconnect_socket is called after a call to
2819     * socket_disconnected but prior to socket_disconnected returning.
2820     */
2821    void (*disconnect_socket)(void *this_arg);
2822    bool (*eq)(const void *this_arg, const LDKSocketDescriptor *other_arg);
2823    uint64_t (*hash)(const void *this_arg);
2824    void *(*clone)(const void *this_arg);
2825    void (*free)(void *this_arg);
2826 } LDKSocketDescriptor;
2827
2828
2829
2830 /**
2831  * A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket
2832  * events into messages which it passes on to its MessageHandlers.
2833  *
2834  * Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager
2835  * a SimpleRefPeerManager, for conciseness. See their documentation for more details, but
2836  * essentially you should default to using a SimpleRefPeerManager, and use a
2837  * SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when
2838  * you're using lightning-net-tokio.
2839  */
2840 typedef struct MUST_USE_STRUCT LDKPeerManager {
2841    /**
2842     * Nearly everywhere, inner must be non-null, however in places where
2843     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2844     */
2845    LDKnativePeerManager *inner;
2846    bool is_owned;
2847 } LDKPeerManager;
2848
2849 typedef struct LDKCVecTempl_PublicKey {
2850    LDKPublicKey *data;
2851    uintptr_t datalen;
2852 } LDKCVecTempl_PublicKey;
2853
2854 typedef LDKCVecTempl_PublicKey LDKCVec_PublicKeyZ;
2855
2856 typedef union LDKCResultPtr_CVecTempl_u8_____PeerHandleError {
2857    LDKCVecTempl_u8 *result;
2858    LDKPeerHandleError *err;
2859 } LDKCResultPtr_CVecTempl_u8_____PeerHandleError;
2860
2861 typedef struct LDKCResultTempl_CVecTempl_u8_____PeerHandleError {
2862    LDKCResultPtr_CVecTempl_u8_____PeerHandleError contents;
2863    bool result_ok;
2864 } LDKCResultTempl_CVecTempl_u8_____PeerHandleError;
2865
2866 typedef LDKCResultTempl_CVecTempl_u8_____PeerHandleError LDKCResult_CVec_u8ZPeerHandleErrorZ;
2867
2868 typedef union LDKCResultPtr_bool__PeerHandleError {
2869    bool *result;
2870    LDKPeerHandleError *err;
2871 } LDKCResultPtr_bool__PeerHandleError;
2872
2873 typedef struct LDKCResultTempl_bool__PeerHandleError {
2874    LDKCResultPtr_bool__PeerHandleError contents;
2875    bool result_ok;
2876 } LDKCResultTempl_bool__PeerHandleError;
2877
2878 typedef LDKCResultTempl_bool__PeerHandleError LDKCResult_boolPeerHandleErrorZ;
2879
2880 typedef union LDKCResultPtr_SecretKey__Secp256k1Error {
2881    LDKSecretKey *result;
2882    LDKSecp256k1Error *err;
2883 } LDKCResultPtr_SecretKey__Secp256k1Error;
2884
2885 typedef struct LDKCResultTempl_SecretKey__Secp256k1Error {
2886    LDKCResultPtr_SecretKey__Secp256k1Error contents;
2887    bool result_ok;
2888 } LDKCResultTempl_SecretKey__Secp256k1Error;
2889
2890 typedef LDKCResultTempl_SecretKey__Secp256k1Error LDKCResult_SecretKeySecpErrorZ;
2891
2892 typedef union LDKCResultPtr_PublicKey__Secp256k1Error {
2893    LDKPublicKey *result;
2894    LDKSecp256k1Error *err;
2895 } LDKCResultPtr_PublicKey__Secp256k1Error;
2896
2897 typedef struct LDKCResultTempl_PublicKey__Secp256k1Error {
2898    LDKCResultPtr_PublicKey__Secp256k1Error contents;
2899    bool result_ok;
2900 } LDKCResultTempl_PublicKey__Secp256k1Error;
2901
2902 typedef LDKCResultTempl_PublicKey__Secp256k1Error LDKCResult_PublicKeySecpErrorZ;
2903
2904
2905
2906 /**
2907  * The set of public keys which are used in the creation of one commitment transaction.
2908  * These are derived from the channel base keys and per-commitment data.
2909  *
2910  * A broadcaster key is provided from potential broadcaster of the computed transaction.
2911  * A countersignatory key is coming from a protocol participant unable to broadcast the
2912  * transaction.
2913  *
2914  * These keys are assumed to be good, either because the code derived them from
2915  * channel basepoints via the new function, or they were obtained via
2916  * PreCalculatedTxCreationKeys.trust_key_derivation because we trusted the source of the
2917  * pre-calculated keys.
2918  */
2919 typedef struct MUST_USE_STRUCT LDKTxCreationKeys {
2920    /**
2921     * Nearly everywhere, inner must be non-null, however in places where
2922     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2923     */
2924    LDKnativeTxCreationKeys *inner;
2925    bool is_owned;
2926 } LDKTxCreationKeys;
2927
2928 typedef union LDKCResultPtr_TxCreationKeys__Secp256k1Error {
2929    LDKTxCreationKeys *result;
2930    LDKSecp256k1Error *err;
2931 } LDKCResultPtr_TxCreationKeys__Secp256k1Error;
2932
2933 typedef struct LDKCResultTempl_TxCreationKeys__Secp256k1Error {
2934    LDKCResultPtr_TxCreationKeys__Secp256k1Error contents;
2935    bool result_ok;
2936 } LDKCResultTempl_TxCreationKeys__Secp256k1Error;
2937
2938 typedef LDKCResultTempl_TxCreationKeys__Secp256k1Error LDKCResult_TxCreationKeysSecpErrorZ;
2939
2940 typedef struct LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature {
2941    LDKC2TupleTempl_HTLCOutputInCommitment__Signature *data;
2942    uintptr_t datalen;
2943 } LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature;
2944
2945 typedef LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ;
2946
2947
2948
2949 /**
2950  * A hop in a route
2951  */
2952 typedef struct MUST_USE_STRUCT LDKRouteHop {
2953    /**
2954     * Nearly everywhere, inner must be non-null, however in places where
2955     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2956     */
2957    LDKnativeRouteHop *inner;
2958    bool is_owned;
2959 } LDKRouteHop;
2960
2961 typedef struct LDKCVecTempl_RouteHop {
2962    LDKRouteHop *data;
2963    uintptr_t datalen;
2964 } LDKCVecTempl_RouteHop;
2965
2966 typedef struct LDKCVecTempl_CVecTempl_RouteHop {
2967    LDKCVecTempl_RouteHop *data;
2968    uintptr_t datalen;
2969 } LDKCVecTempl_CVecTempl_RouteHop;
2970
2971 typedef LDKCVecTempl_CVecTempl_RouteHop LDKCVec_CVec_RouteHopZZ;
2972
2973
2974
2975 /**
2976  * A channel descriptor which provides a last-hop route to get_route
2977  */
2978 typedef struct MUST_USE_STRUCT LDKRouteHint {
2979    /**
2980     * Nearly everywhere, inner must be non-null, however in places where
2981     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2982     */
2983    LDKnativeRouteHint *inner;
2984    bool is_owned;
2985 } LDKRouteHint;
2986
2987
2988
2989 /**
2990  * Fees for routing via a given channel or a node
2991  */
2992 typedef struct MUST_USE_STRUCT LDKRoutingFees {
2993    /**
2994     * Nearly everywhere, inner must be non-null, however in places where
2995     * the Rust equivalent takes an Option, it may be set to null to indicate None.
2996     */
2997    LDKnativeRoutingFees *inner;
2998    bool is_owned;
2999 } LDKRoutingFees;
3000
3001 typedef union LDKCResultPtr_Route__LightningError {
3002    LDKRoute *result;
3003    LDKLightningError *err;
3004 } LDKCResultPtr_Route__LightningError;
3005
3006 typedef struct LDKCResultTempl_Route__LightningError {
3007    LDKCResultPtr_Route__LightningError contents;
3008    bool result_ok;
3009 } LDKCResultTempl_Route__LightningError;
3010
3011 typedef LDKCResultTempl_Route__LightningError LDKCResult_RouteLightningErrorZ;
3012
3013
3014
3015 /**
3016  * Represents the network as nodes and channels between them
3017  */
3018 typedef struct MUST_USE_STRUCT LDKNetworkGraph {
3019    /**
3020     * Nearly everywhere, inner must be non-null, however in places where
3021     * the Rust equivalent takes an Option, it may be set to null to indicate None.
3022     */
3023    LDKnativeNetworkGraph *inner;
3024    bool is_owned;
3025 } LDKNetworkGraph;
3026
3027 typedef struct LDKCVecTempl_RouteHint {
3028    LDKRouteHint *data;
3029    uintptr_t datalen;
3030 } LDKCVecTempl_RouteHint;
3031
3032 typedef LDKCVecTempl_RouteHint LDKCVec_RouteHintZ;
3033
3034
3035
3036 /**
3037  * A simple newtype for RwLockReadGuard<'a, NetworkGraph>.
3038  * This exists only to make accessing a RwLock<NetworkGraph> possible from
3039  * the C bindings, as it can be done directly in Rust code.
3040  */
3041 typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph {
3042    /**
3043     * Nearly everywhere, inner must be non-null, however in places where
3044     * the Rust equivalent takes an Option, it may be set to null to indicate None.
3045     */
3046    LDKnativeLockedNetworkGraph *inner;
3047    bool is_owned;
3048 } LDKLockedNetworkGraph;
3049
3050
3051
3052 /**
3053  * Receives and validates network updates from peers,
3054  * stores authentic and relevant data as a network graph.
3055  * This network graph is then used for routing payments.
3056  * Provides interface to help with initial routing sync by
3057  * serving historical announcements.
3058  */
3059 typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler {
3060    /**
3061     * Nearly everywhere, inner must be non-null, however in places where
3062     * the Rust equivalent takes an Option, it may be set to null to indicate None.
3063     */
3064    LDKnativeNetGraphMsgHandler *inner;
3065    bool is_owned;
3066 } LDKNetGraphMsgHandler;
3067
3068
3069
3070 /**
3071  * Details about one direction of a channel. Received
3072  * within a channel update.
3073  */
3074 typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo {
3075    /**
3076     * Nearly everywhere, inner must be non-null, however in places where
3077     * the Rust equivalent takes an Option, it may be set to null to indicate None.
3078     */
3079    LDKnativeDirectionalChannelInfo *inner;
3080    bool is_owned;
3081 } LDKDirectionalChannelInfo;
3082
3083
3084
3085 /**
3086  * Details about a channel (both directions).
3087  * Received within a channel announcement.
3088  */
3089 typedef struct MUST_USE_STRUCT LDKChannelInfo {
3090    /**
3091     * Nearly everywhere, inner must be non-null, however in places where
3092     * the Rust equivalent takes an Option, it may be set to null to indicate None.
3093     */
3094    LDKnativeChannelInfo *inner;
3095    bool is_owned;
3096 } LDKChannelInfo;
3097
3098
3099
3100 /**
3101  * Information received in the latest node_announcement from this node.
3102  */
3103 typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo {
3104    /**
3105     * Nearly everywhere, inner must be non-null, however in places where
3106     * the Rust equivalent takes an Option, it may be set to null to indicate None.
3107     */
3108    LDKnativeNodeAnnouncementInfo *inner;
3109    bool is_owned;
3110 } LDKNodeAnnouncementInfo;
3111
3112
3113
3114 /**
3115  * Details about a node in the network, known from the network announcement.
3116  */
3117 typedef struct MUST_USE_STRUCT LDKNodeInfo {
3118    /**
3119     * Nearly everywhere, inner must be non-null, however in places where
3120     * the Rust equivalent takes an Option, it may be set to null to indicate None.
3121     */
3122    LDKnativeNodeInfo *inner;
3123    bool is_owned;
3124 } LDKNodeInfo;
3125
3126 typedef LDKCVecTempl_RouteHop LDKCVec_RouteHopZ;
3127
3128 extern const void (*C2Tuple_HTLCOutputInCommitmentSignatureZ_free)(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ);
3129
3130 extern const void (*C2Tuple_OutPointScriptZ_free)(LDKC2Tuple_OutPointScriptZ);
3131
3132 extern const void (*C2Tuple_SignatureCVec_SignatureZZ_free)(LDKC2Tuple_SignatureCVec_SignatureZZ);
3133
3134 extern const void (*C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free)(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ);
3135
3136 extern const void (*C2Tuple_u32TxOutZ_free)(LDKC2Tuple_u32TxOutZ);
3137
3138 extern const void (*C2Tuple_u64u64Z_free)(LDKC2Tuple_u64u64Z);
3139
3140 extern const void (*C2Tuple_usizeTransactionZ_free)(LDKC2Tuple_usizeTransactionZ);
3141
3142 extern const void (*C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free)(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ);
3143
3144 extern const uint64_t CLOSED_CHANNEL_UPDATE_ID;
3145
3146 extern const void (*CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free)(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ);
3147
3148 extern const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok)(LDKC2Tuple_SignatureCVec_SignatureZZ);
3149
3150 extern const void (*CResult_CVec_SignatureZNoneZ_free)(LDKCResult_CVec_SignatureZNoneZ);
3151
3152 extern const LDKCResult_CVec_SignatureZNoneZ (*CResult_CVec_SignatureZNoneZ_ok)(LDKCVec_SignatureZ);
3153
3154 extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_err)(LDKPeerHandleError);
3155
3156 extern const void (*CResult_CVec_u8ZPeerHandleErrorZ_free)(LDKCResult_CVec_u8ZPeerHandleErrorZ);
3157
3158 extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_ok)(LDKCVec_u8Z);
3159
3160 extern const LDKCResult_NoneAPIErrorZ (*CResult_NoneAPIErrorZ_err)(LDKAPIError);
3161
3162 extern const void (*CResult_NoneAPIErrorZ_free)(LDKCResult_NoneAPIErrorZ);
3163
3164 extern const LDKCResult_NoneChannelMonitorUpdateErrZ (*CResult_NoneChannelMonitorUpdateErrZ_err)(LDKChannelMonitorUpdateErr);
3165
3166 extern const void (*CResult_NoneChannelMonitorUpdateErrZ_free)(LDKCResult_NoneChannelMonitorUpdateErrZ);
3167
3168 extern const LDKCResult_NoneLightningErrorZ (*CResult_NoneLightningErrorZ_err)(LDKLightningError);
3169
3170 extern const void (*CResult_NoneLightningErrorZ_free)(LDKCResult_NoneLightningErrorZ);
3171
3172 extern const LDKCResult_NoneMonitorUpdateErrorZ (*CResult_NoneMonitorUpdateErrorZ_err)(LDKMonitorUpdateError);
3173
3174 extern const void (*CResult_NoneMonitorUpdateErrorZ_free)(LDKCResult_NoneMonitorUpdateErrorZ);
3175
3176 extern const LDKCResult_NonePaymentSendFailureZ (*CResult_NonePaymentSendFailureZ_err)(LDKPaymentSendFailure);
3177
3178 extern const void (*CResult_NonePaymentSendFailureZ_free)(LDKCResult_NonePaymentSendFailureZ);
3179
3180 extern const LDKCResult_NonePeerHandleErrorZ (*CResult_NonePeerHandleErrorZ_err)(LDKPeerHandleError);
3181
3182 extern const void (*CResult_NonePeerHandleErrorZ_free)(LDKCResult_NonePeerHandleErrorZ);
3183
3184 extern const LDKCResult_PublicKeySecpErrorZ (*CResult_PublicKeySecpErrorZ_err)(LDKSecp256k1Error);
3185
3186 extern const void (*CResult_PublicKeySecpErrorZ_free)(LDKCResult_PublicKeySecpErrorZ);
3187
3188 extern const LDKCResult_PublicKeySecpErrorZ (*CResult_PublicKeySecpErrorZ_ok)(LDKPublicKey);
3189
3190 extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_err)(LDKLightningError);
3191
3192 extern const void (*CResult_RouteLightningErrorZ_free)(LDKCResult_RouteLightningErrorZ);
3193
3194 extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_ok)(LDKRoute);
3195
3196 extern const LDKCResult_SecretKeySecpErrorZ (*CResult_SecretKeySecpErrorZ_err)(LDKSecp256k1Error);
3197
3198 extern const void (*CResult_SecretKeySecpErrorZ_free)(LDKCResult_SecretKeySecpErrorZ);
3199
3200 extern const LDKCResult_SecretKeySecpErrorZ (*CResult_SecretKeySecpErrorZ_ok)(LDKSecretKey);
3201
3202 extern const void (*CResult_SignatureNoneZ_free)(LDKCResult_SignatureNoneZ);
3203
3204 extern const LDKCResult_SignatureNoneZ (*CResult_SignatureNoneZ_ok)(LDKSignature);
3205
3206 extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_err)(LDKSecp256k1Error);
3207
3208 extern const void (*CResult_TxCreationKeysSecpErrorZ_free)(LDKCResult_TxCreationKeysSecpErrorZ);
3209
3210 extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_ok)(LDKTxCreationKeys);
3211
3212 extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_err)(LDKAccessError);
3213
3214 extern const void (*CResult_TxOutAccessErrorZ_free)(LDKCResult_TxOutAccessErrorZ);
3215
3216 extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_ok)(LDKTxOut);
3217
3218 extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_err)(LDKLightningError);
3219
3220 extern const void (*CResult_boolLightningErrorZ_free)(LDKCResult_boolLightningErrorZ);
3221
3222 extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_ok)(bool);
3223
3224 extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_err)(LDKPeerHandleError);
3225
3226 extern const void (*CResult_boolPeerHandleErrorZ_free)(LDKCResult_boolPeerHandleErrorZ);
3227
3228 extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_ok)(bool);
3229
3230 extern const void (*CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free)(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ);
3231
3232 extern const void (*CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free)(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ);
3233
3234 extern const void (*CVec_C2Tuple_u32TxOutZZ_free)(LDKCVec_C2Tuple_u32TxOutZZ);
3235
3236 extern const void (*CVec_C2Tuple_usizeTransactionZZ_free)(LDKCVec_C2Tuple_usizeTransactionZZ);
3237
3238 extern const void (*CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free)(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ);
3239
3240 extern const void (*CVec_CVec_RouteHopZZ_free)(LDKCVec_CVec_RouteHopZZ);
3241
3242 extern const void (*CVec_ChannelDetailsZ_free)(LDKCVec_ChannelDetailsZ);
3243
3244 extern const void (*CVec_ChannelMonitorZ_free)(LDKCVec_ChannelMonitorZ);
3245
3246 extern const void (*CVec_EventZ_free)(LDKCVec_EventZ);
3247
3248 extern const void (*CVec_HTLCOutputInCommitmentZ_free)(LDKCVec_HTLCOutputInCommitmentZ);
3249
3250 extern const void (*CVec_MessageSendEventZ_free)(LDKCVec_MessageSendEventZ);
3251
3252 extern const void (*CVec_MonitorEventZ_free)(LDKCVec_MonitorEventZ);
3253
3254 extern const void (*CVec_NetAddressZ_free)(LDKCVec_NetAddressZ);
3255
3256 extern const void (*CVec_NodeAnnouncementZ_free)(LDKCVec_NodeAnnouncementZ);
3257
3258 extern const void (*CVec_PublicKeyZ_free)(LDKCVec_PublicKeyZ);
3259
3260 extern const void (*CVec_RouteHintZ_free)(LDKCVec_RouteHintZ);
3261
3262 extern const void (*CVec_RouteHopZ_free)(LDKCVec_RouteHopZ);
3263
3264 extern const void (*CVec_SignatureZ_free)(LDKCVec_SignatureZ);
3265
3266 extern const void (*CVec_SpendableOutputDescriptorZ_free)(LDKCVec_SpendableOutputDescriptorZ);
3267
3268 extern const void (*CVec_TransactionZ_free)(LDKCVec_TransactionZ);
3269
3270 extern const void (*CVec_UpdateAddHTLCZ_free)(LDKCVec_UpdateAddHTLCZ);
3271
3272 extern const void (*CVec_UpdateFailHTLCZ_free)(LDKCVec_UpdateFailHTLCZ);
3273
3274 extern const void (*CVec_UpdateFailMalformedHTLCZ_free)(LDKCVec_UpdateFailMalformedHTLCZ);
3275
3276 extern const void (*CVec_UpdateFulfillHTLCZ_free)(LDKCVec_UpdateFulfillHTLCZ);
3277
3278 extern const void (*CVec_u64Z_free)(LDKCVec_u64Z);
3279
3280 extern const void (*CVec_u8Z_free)(LDKCVec_u8Z);
3281
3282 extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT;
3283
3284 void Transaction_free(LDKTransaction _res);
3285
3286 void TxOut_free(LDKTxOut _res);
3287
3288 LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, LDKTransaction b);
3289
3290 LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void);
3291
3292 LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void);
3293
3294 LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(LDKOutPoint a, LDKCVec_u8Z b);
3295
3296 LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, LDKTxOut b);
3297
3298 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(LDKThirtyTwoBytes a, LDKCVec_C2Tuple_u32TxOutZZ b);
3299
3300 LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b);
3301
3302 LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(LDKSignature a, LDKCVec_SignatureZ b);
3303
3304 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void);
3305
3306 LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void);
3307
3308 LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void);
3309
3310 LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void);
3311
3312 LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void);
3313
3314 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(LDKChannelAnnouncement a, LDKChannelUpdate b, LDKChannelUpdate c);
3315
3316 LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void);
3317
3318 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ C2Tuple_HTLCOutputInCommitmentSignatureZ_new(LDKHTLCOutputInCommitment a, LDKSignature b);
3319
3320 LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void);
3321
3322 void Event_free(LDKEvent this_ptr);
3323
3324 LDKEvent Event_clone(const LDKEvent *orig);
3325
3326 void MessageSendEvent_free(LDKMessageSendEvent this_ptr);
3327
3328 LDKMessageSendEvent MessageSendEvent_clone(const LDKMessageSendEvent *orig);
3329
3330 /**
3331  * Calls the free function if one is set
3332  */
3333 void MessageSendEventsProvider_free(LDKMessageSendEventsProvider this_ptr);
3334
3335 /**
3336  * Calls the free function if one is set
3337  */
3338 void EventsProvider_free(LDKEventsProvider this_ptr);
3339
3340 void APIError_free(LDKAPIError this_ptr);
3341
3342 LDKAPIError APIError_clone(const LDKAPIError *orig);
3343
3344 LDKLevel Level_clone(const LDKLevel *orig);
3345
3346 /**
3347  * Returns the most verbose logging level.
3348  */
3349 MUST_USE_RES LDKLevel Level_max(void);
3350
3351 /**
3352  * Calls the free function if one is set
3353  */
3354 void Logger_free(LDKLogger this_ptr);
3355
3356 void ChannelHandshakeConfig_free(LDKChannelHandshakeConfig this_ptr);
3357
3358 LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const LDKChannelHandshakeConfig *orig);
3359
3360 /**
3361  * Confirmations we will wait for before considering the channel locked in.
3362  * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
3363  * equivalent limit applied to outbound channels).
3364  *
3365  * Default value: 6.
3366  */
3367 uint32_t ChannelHandshakeConfig_get_minimum_depth(const LDKChannelHandshakeConfig *this_ptr);
3368
3369 /**
3370  * Confirmations we will wait for before considering the channel locked in.
3371  * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
3372  * equivalent limit applied to outbound channels).
3373  *
3374  * Default value: 6.
3375  */
3376 void ChannelHandshakeConfig_set_minimum_depth(LDKChannelHandshakeConfig *this_ptr, uint32_t val);
3377
3378 /**
3379  * Set to the amount of time we require our counterparty to wait to claim their money.
3380  *
3381  * It's one of the main parameter of our security model. We (or one of our watchtowers) MUST
3382  * be online to check for peer having broadcast a revoked transaction to steal our funds
3383  * at least once every our_to_self_delay blocks.
3384  *
3385  * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
3386  * case of an honest unilateral channel close, which implicitly decrease the economic value of
3387  * our channel.
3388  *
3389  * Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel
3390  * opening so you can tweak config to ask for more security, not less.
3391  */
3392 uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const LDKChannelHandshakeConfig *this_ptr);
3393
3394 /**
3395  * Set to the amount of time we require our counterparty to wait to claim their money.
3396  *
3397  * It's one of the main parameter of our security model. We (or one of our watchtowers) MUST
3398  * be online to check for peer having broadcast a revoked transaction to steal our funds
3399  * at least once every our_to_self_delay blocks.
3400  *
3401  * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
3402  * case of an honest unilateral channel close, which implicitly decrease the economic value of
3403  * our channel.
3404  *
3405  * Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel
3406  * opening so you can tweak config to ask for more security, not less.
3407  */
3408 void ChannelHandshakeConfig_set_our_to_self_delay(LDKChannelHandshakeConfig *this_ptr, uint16_t val);
3409
3410 /**
3411  * Set to the smallest value HTLC we will accept to process.
3412  *
3413  * This value is sent to our counterparty on channel-open and we close the channel any time
3414  * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
3415  *
3416  * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
3417  * by the protocol.
3418  */
3419 uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const LDKChannelHandshakeConfig *this_ptr);
3420
3421 /**
3422  * Set to the smallest value HTLC we will accept to process.
3423  *
3424  * This value is sent to our counterparty on channel-open and we close the channel any time
3425  * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
3426  *
3427  * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
3428  * by the protocol.
3429  */
3430 void ChannelHandshakeConfig_set_our_htlc_minimum_msat(LDKChannelHandshakeConfig *this_ptr, uint64_t val);
3431
3432 MUST_USE_RES LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg);
3433
3434 MUST_USE_RES LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void);
3435
3436 void ChannelHandshakeLimits_free(LDKChannelHandshakeLimits this_ptr);
3437
3438 LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const LDKChannelHandshakeLimits *orig);
3439
3440 /**
3441  * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
3442  * only applies to inbound channels.
3443  *
3444  * Default value: 0.
3445  */
3446 uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const LDKChannelHandshakeLimits *this_ptr);
3447
3448 /**
3449  * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
3450  * only applies to inbound channels.
3451  *
3452  * Default value: 0.
3453  */
3454 void ChannelHandshakeLimits_set_min_funding_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
3455
3456 /**
3457  * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
3458  * you to limit the maximum minimum-size they can require.
3459  *
3460  * Default value: u64::max_value.
3461  */
3462 uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const LDKChannelHandshakeLimits *this_ptr);
3463
3464 /**
3465  * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
3466  * you to limit the maximum minimum-size they can require.
3467  *
3468  * Default value: u64::max_value.
3469  */
3470 void ChannelHandshakeLimits_set_max_htlc_minimum_msat(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
3471
3472 /**
3473  * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
3474  * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
3475  *
3476  * Default value: 0.
3477  */
3478 uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const LDKChannelHandshakeLimits *this_ptr);
3479
3480 /**
3481  * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
3482  * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
3483  *
3484  * Default value: 0.
3485  */
3486 void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
3487
3488 /**
3489  * The remote node will require we keep a certain amount in direct payment to ourselves at all
3490  * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
3491  * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
3492  *
3493  * Default value: u64::max_value.
3494  */
3495 uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const LDKChannelHandshakeLimits *this_ptr);
3496
3497 /**
3498  * The remote node will require we keep a certain amount in direct payment to ourselves at all
3499  * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
3500  * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
3501  *
3502  * Default value: u64::max_value.
3503  */
3504 void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
3505
3506 /**
3507  * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
3508  * time. This allows you to set a minimum such value.
3509  *
3510  * Default value: 0.
3511  */
3512 uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const LDKChannelHandshakeLimits *this_ptr);
3513
3514 /**
3515  * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
3516  * time. This allows you to set a minimum such value.
3517  *
3518  * Default value: 0.
3519  */
3520 void ChannelHandshakeLimits_set_min_max_accepted_htlcs(LDKChannelHandshakeLimits *this_ptr, uint16_t val);
3521
3522 /**
3523  * Outputs below a certain value will not be added to on-chain transactions. The dust value is
3524  * required to always be higher than this value so this only applies to HTLC outputs (and
3525  * potentially to-self outputs before any payments have been made).
3526  * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
3527  * This setting allows you to set a minimum dust limit for their commitment transactions,
3528  * reflecting the reality that tiny outputs are not considered standard transactions and will
3529  * not propagate through the Bitcoin network.
3530  *
3531  * Default value: 546, the current dust limit on the Bitcoin network.
3532  */
3533 uint64_t ChannelHandshakeLimits_get_min_dust_limit_satoshis(const LDKChannelHandshakeLimits *this_ptr);
3534
3535 /**
3536  * Outputs below a certain value will not be added to on-chain transactions. The dust value is
3537  * required to always be higher than this value so this only applies to HTLC outputs (and
3538  * potentially to-self outputs before any payments have been made).
3539  * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
3540  * This setting allows you to set a minimum dust limit for their commitment transactions,
3541  * reflecting the reality that tiny outputs are not considered standard transactions and will
3542  * not propagate through the Bitcoin network.
3543  *
3544  * Default value: 546, the current dust limit on the Bitcoin network.
3545  */
3546 void ChannelHandshakeLimits_set_min_dust_limit_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
3547
3548 /**
3549  * Maximum allowed threshold above which outputs will not be generated in their commitment
3550  * transactions.
3551  * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
3552  *
3553  * Default value: u64::max_value.
3554  */
3555 uint64_t ChannelHandshakeLimits_get_max_dust_limit_satoshis(const LDKChannelHandshakeLimits *this_ptr);
3556
3557 /**
3558  * Maximum allowed threshold above which outputs will not be generated in their commitment
3559  * transactions.
3560  * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
3561  *
3562  * Default value: u64::max_value.
3563  */
3564 void ChannelHandshakeLimits_set_max_dust_limit_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
3565
3566 /**
3567  * Before a channel is usable the funding transaction will need to be confirmed by at least a
3568  * certain number of blocks, specified by the node which is not the funder (as the funder can
3569  * assume they aren't going to double-spend themselves).
3570  * This config allows you to set a limit on the maximum amount of time to wait.
3571  *
3572  * Default value: 144, or roughly one day and only applies to outbound channels.
3573  */
3574 uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const LDKChannelHandshakeLimits *this_ptr);
3575
3576 /**
3577  * Before a channel is usable the funding transaction will need to be confirmed by at least a
3578  * certain number of blocks, specified by the node which is not the funder (as the funder can
3579  * assume they aren't going to double-spend themselves).
3580  * This config allows you to set a limit on the maximum amount of time to wait.
3581  *
3582  * Default value: 144, or roughly one day and only applies to outbound channels.
3583  */
3584 void ChannelHandshakeLimits_set_max_minimum_depth(LDKChannelHandshakeLimits *this_ptr, uint32_t val);
3585
3586 /**
3587  * Set to force the incoming channel to match our announced channel preference in
3588  * ChannelConfig.
3589  *
3590  * Default value: true, to make the default that no announced channels are possible (which is
3591  * appropriate for any nodes which are not online very reliably).
3592  */
3593 bool ChannelHandshakeLimits_get_force_announced_channel_preference(const LDKChannelHandshakeLimits *this_ptr);
3594
3595 /**
3596  * Set to force the incoming channel to match our announced channel preference in
3597  * ChannelConfig.
3598  *
3599  * Default value: true, to make the default that no announced channels are possible (which is
3600  * appropriate for any nodes which are not online very reliably).
3601  */
3602 void ChannelHandshakeLimits_set_force_announced_channel_preference(LDKChannelHandshakeLimits *this_ptr, bool val);
3603
3604 /**
3605  * Set to the amount of time we're willing to wait to claim money back to us.
3606  *
3607  * Not checking this value would be a security issue, as our peer would be able to set it to
3608  * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
3609  *
3610  * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
3611  * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
3612  */
3613 uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const LDKChannelHandshakeLimits *this_ptr);
3614
3615 /**
3616  * Set to the amount of time we're willing to wait to claim money back to us.
3617  *
3618  * Not checking this value would be a security issue, as our peer would be able to set it to
3619  * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
3620  *
3621  * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
3622  * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
3623  */
3624 void ChannelHandshakeLimits_set_their_to_self_delay(LDKChannelHandshakeLimits *this_ptr, uint16_t val);
3625
3626 MUST_USE_RES LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint64_t min_dust_limit_satoshis_arg, uint64_t max_dust_limit_satoshis_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg);
3627
3628 MUST_USE_RES LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void);
3629
3630 void ChannelConfig_free(LDKChannelConfig this_ptr);
3631
3632 LDKChannelConfig ChannelConfig_clone(const LDKChannelConfig *orig);
3633
3634 /**
3635  * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
3636  * This may be allowed to change at runtime in a later update, however doing so must result in
3637  * update messages sent to notify all nodes of our updated relay fee.
3638  *
3639  * Default value: 0.
3640  */
3641 uint32_t ChannelConfig_get_fee_proportional_millionths(const LDKChannelConfig *this_ptr);
3642
3643 /**
3644  * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
3645  * This may be allowed to change at runtime in a later update, however doing so must result in
3646  * update messages sent to notify all nodes of our updated relay fee.
3647  *
3648  * Default value: 0.
3649  */
3650 void ChannelConfig_set_fee_proportional_millionths(LDKChannelConfig *this_ptr, uint32_t val);
3651
3652 /**
3653  * Set to announce the channel publicly and notify all nodes that they can route via this
3654  * channel.
3655  *
3656  * This should only be set to true for nodes which expect to be online reliably.
3657  *
3658  * As the node which funds a channel picks this value this will only apply for new outbound
3659  * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
3660  *
3661  * This cannot be changed after the initial channel handshake.
3662  *
3663  * Default value: false.
3664  */
3665 bool ChannelConfig_get_announced_channel(const LDKChannelConfig *this_ptr);
3666
3667 /**
3668  * Set to announce the channel publicly and notify all nodes that they can route via this
3669  * channel.
3670  *
3671  * This should only be set to true for nodes which expect to be online reliably.
3672  *
3673  * As the node which funds a channel picks this value this will only apply for new outbound
3674  * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
3675  *
3676  * This cannot be changed after the initial channel handshake.
3677  *
3678  * Default value: false.
3679  */
3680 void ChannelConfig_set_announced_channel(LDKChannelConfig *this_ptr, bool val);
3681
3682 /**
3683  * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
3684  * supports it, they will then enforce the mutual-close output to us matches what we provided
3685  * at intialization, preventing us from closing to an alternate pubkey.
3686  *
3687  * This is set to true by default to provide a slight increase in security, though ultimately
3688  * any attacker who is able to take control of a channel can just as easily send the funds via
3689  * lightning payments, so we never require that our counterparties support this option.
3690  *
3691  * This cannot be changed after a channel has been initialized.
3692  *
3693  * Default value: true.
3694  */
3695 bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const LDKChannelConfig *this_ptr);
3696
3697 /**
3698  * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
3699  * supports it, they will then enforce the mutual-close output to us matches what we provided
3700  * at intialization, preventing us from closing to an alternate pubkey.
3701  *
3702  * This is set to true by default to provide a slight increase in security, though ultimately
3703  * any attacker who is able to take control of a channel can just as easily send the funds via
3704  * lightning payments, so we never require that our counterparties support this option.
3705  *
3706  * This cannot be changed after a channel has been initialized.
3707  *
3708  * Default value: true.
3709  */
3710 void ChannelConfig_set_commit_upfront_shutdown_pubkey(LDKChannelConfig *this_ptr, bool val);
3711
3712 MUST_USE_RES LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg);
3713
3714 MUST_USE_RES LDKChannelConfig ChannelConfig_default(void);
3715
3716 LDKCVec_u8Z ChannelConfig_write(const LDKChannelConfig *obj);
3717
3718 LDKChannelConfig ChannelConfig_read(LDKu8slice ser);
3719
3720 void UserConfig_free(LDKUserConfig this_ptr);
3721
3722 LDKUserConfig UserConfig_clone(const LDKUserConfig *orig);
3723
3724 /**
3725  * Channel config that we propose to our counterparty.
3726  */
3727 LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const LDKUserConfig *this_ptr);
3728
3729 /**
3730  * Channel config that we propose to our counterparty.
3731  */
3732 void UserConfig_set_own_channel_config(LDKUserConfig *this_ptr, LDKChannelHandshakeConfig val);
3733
3734 /**
3735  * Limits applied to our counterparty's proposed channel config settings.
3736  */
3737 LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const LDKUserConfig *this_ptr);
3738
3739 /**
3740  * Limits applied to our counterparty's proposed channel config settings.
3741  */
3742 void UserConfig_set_peer_channel_config_limits(LDKUserConfig *this_ptr, LDKChannelHandshakeLimits val);
3743
3744 /**
3745  * Channel config which affects behavior during channel lifetime.
3746  */
3747 LDKChannelConfig UserConfig_get_channel_options(const LDKUserConfig *this_ptr);
3748
3749 /**
3750  * Channel config which affects behavior during channel lifetime.
3751  */
3752 void UserConfig_set_channel_options(LDKUserConfig *this_ptr, LDKChannelConfig val);
3753
3754 MUST_USE_RES LDKUserConfig UserConfig_new(LDKChannelHandshakeConfig own_channel_config_arg, LDKChannelHandshakeLimits peer_channel_config_limits_arg, LDKChannelConfig channel_options_arg);
3755
3756 MUST_USE_RES LDKUserConfig UserConfig_default(void);
3757
3758 LDKAccessError AccessError_clone(const LDKAccessError *orig);
3759
3760 /**
3761  * Calls the free function if one is set
3762  */
3763 void Access_free(LDKAccess this_ptr);
3764
3765 /**
3766  * Calls the free function if one is set
3767  */
3768 void Watch_free(LDKWatch this_ptr);
3769
3770 /**
3771  * Calls the free function if one is set
3772  */
3773 void Filter_free(LDKFilter this_ptr);
3774
3775 /**
3776  * Calls the free function if one is set
3777  */
3778 void BroadcasterInterface_free(LDKBroadcasterInterface this_ptr);
3779
3780 LDKConfirmationTarget ConfirmationTarget_clone(const LDKConfirmationTarget *orig);
3781
3782 /**
3783  * Calls the free function if one is set
3784  */
3785 void FeeEstimator_free(LDKFeeEstimator this_ptr);
3786
3787 void ChainMonitor_free(LDKChainMonitor this_ptr);
3788
3789 /**
3790  * Dispatches to per-channel monitors, which are responsible for updating their on-chain view
3791  * of a channel and reacting accordingly based on transactions in the connected block. See
3792  * [`ChannelMonitor::block_connected`] for details. Any HTLCs that were resolved on chain will
3793  * be returned by [`chain::Watch::release_pending_monitor_events`].
3794  *
3795  * Calls back to [`chain::Filter`] if any monitor indicated new outputs to watch. Subsequent
3796  * calls must not exclude any transactions matching the new outputs nor any in-block
3797  * descendants of such transactions. It is not necessary to re-fetch the block to obtain
3798  * updated `txdata`.
3799  *
3800  * [`ChannelMonitor::block_connected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_connected
3801  * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events
3802  * [`chain::Filter`]: ../trait.Filter.html
3803  */
3804 void ChainMonitor_block_connected(const LDKChainMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height);
3805
3806 /**
3807  * Dispatches to per-channel monitors, which are responsible for updating their on-chain view
3808  * of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for
3809  * details.
3810  *
3811  * [`ChannelMonitor::block_disconnected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
3812  */
3813 void ChainMonitor_block_disconnected(const LDKChainMonitor *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height);
3814
3815 /**
3816  * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels.
3817  *
3818  * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor
3819  * will call back to it indicating transactions and outputs of interest. This allows clients to
3820  * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may
3821  * always need to fetch full blocks absent another means for determining which blocks contain
3822  * transactions relevant to the watched channels.
3823  *
3824  * [`chain::Filter`]: ../trait.Filter.html
3825  */
3826 MUST_USE_RES LDKChainMonitor ChainMonitor_new(LDKFilter *chain_source, LDKBroadcasterInterface broadcaster, LDKLogger logger, LDKFeeEstimator feeest, LDKPersist persister);
3827
3828 LDKWatch ChainMonitor_as_Watch(const LDKChainMonitor *this_arg);
3829
3830 LDKEventsProvider ChainMonitor_as_EventsProvider(const LDKChainMonitor *this_arg);
3831
3832 void ChannelMonitorUpdate_free(LDKChannelMonitorUpdate this_ptr);
3833
3834 LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const LDKChannelMonitorUpdate *orig);
3835
3836 /**
3837  * The sequence number of this update. Updates *must* be replayed in-order according to this
3838  * sequence number (and updates may panic if they are not). The update_id values are strictly
3839  * increasing and increase by one for each new update, with one exception specified below.
3840  *
3841  * This sequence number is also used to track up to which points updates which returned
3842  * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
3843  * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
3844  *
3845  * The only instance where update_id values are not strictly increasing is the case where we
3846  * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See
3847  * its docs for more details.
3848  *
3849  * [`CLOSED_CHANNEL_UPDATE_ID`]: constant.CLOSED_CHANNEL_UPDATE_ID.html
3850  */
3851 uint64_t ChannelMonitorUpdate_get_update_id(const LDKChannelMonitorUpdate *this_ptr);
3852
3853 /**
3854  * The sequence number of this update. Updates *must* be replayed in-order according to this
3855  * sequence number (and updates may panic if they are not). The update_id values are strictly
3856  * increasing and increase by one for each new update, with one exception specified below.
3857  *
3858  * This sequence number is also used to track up to which points updates which returned
3859  * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
3860  * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
3861  *
3862  * The only instance where update_id values are not strictly increasing is the case where we
3863  * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See
3864  * its docs for more details.
3865  *
3866  * [`CLOSED_CHANNEL_UPDATE_ID`]: constant.CLOSED_CHANNEL_UPDATE_ID.html
3867  */
3868 void ChannelMonitorUpdate_set_update_id(LDKChannelMonitorUpdate *this_ptr, uint64_t val);
3869
3870 LDKCVec_u8Z ChannelMonitorUpdate_write(const LDKChannelMonitorUpdate *obj);
3871
3872 LDKChannelMonitorUpdate ChannelMonitorUpdate_read(LDKu8slice ser);
3873
3874 LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const LDKChannelMonitorUpdateErr *orig);
3875
3876 void MonitorUpdateError_free(LDKMonitorUpdateError this_ptr);
3877
3878 void MonitorEvent_free(LDKMonitorEvent this_ptr);
3879
3880 LDKMonitorEvent MonitorEvent_clone(const LDKMonitorEvent *orig);
3881
3882 void HTLCUpdate_free(LDKHTLCUpdate this_ptr);
3883
3884 LDKHTLCUpdate HTLCUpdate_clone(const LDKHTLCUpdate *orig);
3885
3886 LDKCVec_u8Z HTLCUpdate_write(const LDKHTLCUpdate *obj);
3887
3888 LDKHTLCUpdate HTLCUpdate_read(LDKu8slice ser);
3889
3890 void ChannelMonitor_free(LDKChannelMonitor this_ptr);
3891
3892 /**
3893  * Updates a ChannelMonitor on the basis of some new information provided by the Channel
3894  * itself.
3895  *
3896  * panics if the given update is not the next update by update_id.
3897  */
3898 MUST_USE_RES LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(LDKChannelMonitor *this_arg, const LDKChannelMonitorUpdate *updates, const LDKBroadcasterInterface *broadcaster, const LDKFeeEstimator *fee_estimator, const LDKLogger *logger);
3899
3900 /**
3901  * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
3902  * ChannelMonitor.
3903  */
3904 MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const LDKChannelMonitor *this_arg);
3905
3906 /**
3907  * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
3908  */
3909 MUST_USE_RES LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const LDKChannelMonitor *this_arg);
3910
3911 /**
3912  * Get the list of HTLCs who's status has been updated on chain. This should be called by
3913  * ChannelManager via [`chain::Watch::release_pending_monitor_events`].
3914  *
3915  * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events
3916  */
3917 MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(LDKChannelMonitor *this_arg);
3918
3919 /**
3920  * Gets the list of pending events which were generated by previous actions, clearing the list
3921  * in the process.
3922  *
3923  * This is called by ChainMonitor::get_and_clear_pending_events() and is equivalent to
3924  * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
3925  * no internal locking in ChannelMonitors.
3926  */
3927 MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(LDKChannelMonitor *this_arg);
3928
3929 /**
3930  * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of
3931  * the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of
3932  * fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows
3933  * a higher revocation secret than the holder commitment number we are aware of. Broadcasting these
3934  * transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to
3935  * broadcast them if counterparty don't close channel with his higher commitment transaction after a
3936  * substantial amount of time (a month or even a year) to get back funds. Best may be to contact
3937  * out-of-band the other node operator to coordinate with him if option is available to you.
3938  * In any-case, choice is up to the user.
3939  */
3940 MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(LDKChannelMonitor *this_arg, const LDKLogger *logger);
3941
3942 /**
3943  * Processes transactions in a newly connected block, which may result in any of the following:
3944  * - update the monitor's state against resolved HTLCs
3945  * - punish the counterparty in the case of seeing a revoked commitment transaction
3946  * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration
3947  * - detect settled outputs for later spending
3948  * - schedule and bump any in-flight claims
3949  *
3950  * Returns any new outputs to watch from `txdata`; after called, these are also included in
3951  * [`get_outputs_to_watch`].
3952  *
3953  * [`get_outputs_to_watch`]: #method.get_outputs_to_watch
3954  */
3955 MUST_USE_RES LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ChannelMonitor_block_connected(LDKChannelMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, LDKBroadcasterInterface broadcaster, LDKFeeEstimator fee_estimator, LDKLogger logger);
3956
3957 /**
3958  * Determines if the disconnected block contained any transactions of interest and updates
3959  * appropriately.
3960  */
3961 void ChannelMonitor_block_disconnected(LDKChannelMonitor *this_arg, const uint8_t (*header)[80], uint32_t height, LDKBroadcasterInterface broadcaster, LDKFeeEstimator fee_estimator, LDKLogger logger);
3962
3963 /**
3964  * Calls the free function if one is set
3965  */
3966 void Persist_free(LDKPersist this_ptr);
3967
3968 void OutPoint_free(LDKOutPoint this_ptr);
3969
3970 LDKOutPoint OutPoint_clone(const LDKOutPoint *orig);
3971
3972 /**
3973  * The referenced transaction's txid.
3974  */
3975 const uint8_t (*OutPoint_get_txid(const LDKOutPoint *this_ptr))[32];
3976
3977 /**
3978  * The referenced transaction's txid.
3979  */
3980 void OutPoint_set_txid(LDKOutPoint *this_ptr, LDKThirtyTwoBytes val);
3981
3982 /**
3983  * The index of the referenced output in its transaction's vout.
3984  */
3985 uint16_t OutPoint_get_index(const LDKOutPoint *this_ptr);
3986
3987 /**
3988  * The index of the referenced output in its transaction's vout.
3989  */
3990 void OutPoint_set_index(LDKOutPoint *this_ptr, uint16_t val);
3991
3992 MUST_USE_RES LDKOutPoint OutPoint_new(LDKThirtyTwoBytes txid_arg, uint16_t index_arg);
3993
3994 /**
3995  * Convert an `OutPoint` to a lightning channel id.
3996  */
3997 MUST_USE_RES LDKThirtyTwoBytes OutPoint_to_channel_id(const LDKOutPoint *this_arg);
3998
3999 LDKCVec_u8Z OutPoint_write(const LDKOutPoint *obj);
4000
4001 LDKOutPoint OutPoint_read(LDKu8slice ser);
4002
4003 void SpendableOutputDescriptor_free(LDKSpendableOutputDescriptor this_ptr);
4004
4005 LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const LDKSpendableOutputDescriptor *orig);
4006
4007 LDKChannelKeys ChannelKeys_clone(const LDKChannelKeys *orig);
4008
4009 /**
4010  * Calls the free function if one is set
4011  */
4012 void ChannelKeys_free(LDKChannelKeys this_ptr);
4013
4014 /**
4015  * Calls the free function if one is set
4016  */
4017 void KeysInterface_free(LDKKeysInterface this_ptr);
4018
4019 void InMemoryChannelKeys_free(LDKInMemoryChannelKeys this_ptr);
4020
4021 LDKInMemoryChannelKeys InMemoryChannelKeys_clone(const LDKInMemoryChannelKeys *orig);
4022
4023 /**
4024  * Private key of anchor tx
4025  */
4026 const uint8_t (*InMemoryChannelKeys_get_funding_key(const LDKInMemoryChannelKeys *this_ptr))[32];
4027
4028 /**
4029  * Private key of anchor tx
4030  */
4031 void InMemoryChannelKeys_set_funding_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
4032
4033 /**
4034  * Holder secret key for blinded revocation pubkey
4035  */
4036 const uint8_t (*InMemoryChannelKeys_get_revocation_base_key(const LDKInMemoryChannelKeys *this_ptr))[32];
4037
4038 /**
4039  * Holder secret key for blinded revocation pubkey
4040  */
4041 void InMemoryChannelKeys_set_revocation_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
4042
4043 /**
4044  * Holder secret key used for our balance in counterparty-broadcasted commitment transactions
4045  */
4046 const uint8_t (*InMemoryChannelKeys_get_payment_key(const LDKInMemoryChannelKeys *this_ptr))[32];
4047
4048 /**
4049  * Holder secret key used for our balance in counterparty-broadcasted commitment transactions
4050  */
4051 void InMemoryChannelKeys_set_payment_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
4052
4053 /**
4054  * Holder secret key used in HTLC tx
4055  */
4056 const uint8_t (*InMemoryChannelKeys_get_delayed_payment_base_key(const LDKInMemoryChannelKeys *this_ptr))[32];
4057
4058 /**
4059  * Holder secret key used in HTLC tx
4060  */
4061 void InMemoryChannelKeys_set_delayed_payment_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
4062
4063 /**
4064  * Holder htlc secret key used in commitment tx htlc outputs
4065  */
4066 const uint8_t (*InMemoryChannelKeys_get_htlc_base_key(const LDKInMemoryChannelKeys *this_ptr))[32];
4067
4068 /**
4069  * Holder htlc secret key used in commitment tx htlc outputs
4070  */
4071 void InMemoryChannelKeys_set_htlc_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
4072
4073 /**
4074  * Commitment seed
4075  */
4076 const uint8_t (*InMemoryChannelKeys_get_commitment_seed(const LDKInMemoryChannelKeys *this_ptr))[32];
4077
4078 /**
4079  * Commitment seed
4080  */
4081 void InMemoryChannelKeys_set_commitment_seed(LDKInMemoryChannelKeys *this_ptr, LDKThirtyTwoBytes val);
4082
4083 /**
4084  * Create a new InMemoryChannelKeys
4085  */
4086 MUST_USE_RES LDKInMemoryChannelKeys InMemoryChannelKeys_new(LDKSecretKey funding_key, LDKSecretKey revocation_base_key, LDKSecretKey payment_key, LDKSecretKey delayed_payment_base_key, LDKSecretKey htlc_base_key, LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, LDKC2Tuple_u64u64Z key_derivation_params);
4087
4088 /**
4089  * Counterparty pubkeys.
4090  * Will panic if on_accept wasn't called.
4091  */
4092 MUST_USE_RES LDKChannelPublicKeys InMemoryChannelKeys_counterparty_pubkeys(const LDKInMemoryChannelKeys *this_arg);
4093
4094 /**
4095  * The contest_delay value specified by our counterparty and applied on holder-broadcastable
4096  * transactions, ie the amount of time that we have to wait to recover our funds if we
4097  * broadcast a transaction. You'll likely want to pass this to the
4098  * ln::chan_utils::build*_transaction functions when signing holder's transactions.
4099  * Will panic if on_accept wasn't called.
4100  */
4101 MUST_USE_RES uint16_t InMemoryChannelKeys_counterparty_selected_contest_delay(const LDKInMemoryChannelKeys *this_arg);
4102
4103 /**
4104  * The contest_delay value specified by us and applied on transactions broadcastable
4105  * by our counterparty, ie the amount of time that they have to wait to recover their funds
4106  * if they broadcast a transaction.
4107  * Will panic if on_accept wasn't called.
4108  */
4109 MUST_USE_RES uint16_t InMemoryChannelKeys_holder_selected_contest_delay(const LDKInMemoryChannelKeys *this_arg);
4110
4111 LDKChannelKeys InMemoryChannelKeys_as_ChannelKeys(const LDKInMemoryChannelKeys *this_arg);
4112
4113 LDKCVec_u8Z InMemoryChannelKeys_write(const LDKInMemoryChannelKeys *obj);
4114
4115 LDKInMemoryChannelKeys InMemoryChannelKeys_read(LDKu8slice ser);
4116
4117 void KeysManager_free(LDKKeysManager this_ptr);
4118
4119 /**
4120  * Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your
4121  * CSRNG is busted) this may panic (but more importantly, you will possibly lose funds).
4122  * starting_time isn't strictly required to actually be a time, but it must absolutely,
4123  * without a doubt, be unique to this instance. ie if you start multiple times with the same
4124  * seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to
4125  * simply use the current time (with very high precision).
4126  *
4127  * The seed MUST be backed up safely prior to use so that the keys can be re-created, however,
4128  * obviously, starting_time should be unique every time you reload the library - it is only
4129  * used to generate new ephemeral key data (which will be stored by the individual channel if
4130  * necessary).
4131  *
4132  * Note that the seed is required to recover certain on-chain funds independent of
4133  * ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any
4134  * channel, and some on-chain during-closing funds.
4135  *
4136  * Note that until the 0.1 release there is no guarantee of backward compatibility between
4137  * versions. Once the library is more fully supported, the docs will be updated to include a
4138  * detailed description of the guarantee.
4139  */
4140 MUST_USE_RES LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], LDKNetwork network, uint64_t starting_time_secs, uint32_t starting_time_nanos);
4141
4142 /**
4143  * Derive an old set of ChannelKeys for per-channel secrets based on a key derivation
4144  * parameters.
4145  * Key derivation parameters are accessible through a per-channel secrets
4146  * ChannelKeys::key_derivation_params and is provided inside DynamicOuputP2WSH in case of
4147  * onchain output detection for which a corresponding delayed_payment_key must be derived.
4148  */
4149 MUST_USE_RES LDKInMemoryChannelKeys KeysManager_derive_channel_keys(const LDKKeysManager *this_arg, uint64_t channel_value_satoshis, uint64_t params_1, uint64_t params_2);
4150
4151 LDKKeysInterface KeysManager_as_KeysInterface(const LDKKeysManager *this_arg);
4152
4153 void ChannelManager_free(LDKChannelManager this_ptr);
4154
4155 void ChannelDetails_free(LDKChannelDetails this_ptr);
4156
4157 LDKChannelDetails ChannelDetails_clone(const LDKChannelDetails *orig);
4158
4159 /**
4160  * The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
4161  * thereafter this is the txid of the funding transaction xor the funding transaction output).
4162  * Note that this means this value is *not* persistent - it can change once during the
4163  * lifetime of the channel.
4164  */
4165 const uint8_t (*ChannelDetails_get_channel_id(const LDKChannelDetails *this_ptr))[32];
4166
4167 /**
4168  * The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
4169  * thereafter this is the txid of the funding transaction xor the funding transaction output).
4170  * Note that this means this value is *not* persistent - it can change once during the
4171  * lifetime of the channel.
4172  */
4173 void ChannelDetails_set_channel_id(LDKChannelDetails *this_ptr, LDKThirtyTwoBytes val);
4174
4175 /**
4176  * The node_id of our counterparty
4177  */
4178 LDKPublicKey ChannelDetails_get_remote_network_id(const LDKChannelDetails *this_ptr);
4179
4180 /**
4181  * The node_id of our counterparty
4182  */
4183 void ChannelDetails_set_remote_network_id(LDKChannelDetails *this_ptr, LDKPublicKey val);
4184
4185 /**
4186  * The Features the channel counterparty provided upon last connection.
4187  * Useful for routing as it is the most up-to-date copy of the counterparty's features and
4188  * many routing-relevant features are present in the init context.
4189  */
4190 LDKInitFeatures ChannelDetails_get_counterparty_features(const LDKChannelDetails *this_ptr);
4191
4192 /**
4193  * The Features the channel counterparty provided upon last connection.
4194  * Useful for routing as it is the most up-to-date copy of the counterparty's features and
4195  * many routing-relevant features are present in the init context.
4196  */
4197 void ChannelDetails_set_counterparty_features(LDKChannelDetails *this_ptr, LDKInitFeatures val);
4198
4199 /**
4200  * The value, in satoshis, of this channel as appears in the funding output
4201  */
4202 uint64_t ChannelDetails_get_channel_value_satoshis(const LDKChannelDetails *this_ptr);
4203
4204 /**
4205  * The value, in satoshis, of this channel as appears in the funding output
4206  */
4207 void ChannelDetails_set_channel_value_satoshis(LDKChannelDetails *this_ptr, uint64_t val);
4208
4209 /**
4210  * The user_id passed in to create_channel, or 0 if the channel was inbound.
4211  */
4212 uint64_t ChannelDetails_get_user_id(const LDKChannelDetails *this_ptr);
4213
4214 /**
4215  * The user_id passed in to create_channel, or 0 if the channel was inbound.
4216  */
4217 void ChannelDetails_set_user_id(LDKChannelDetails *this_ptr, uint64_t val);
4218
4219 /**
4220  * The available outbound capacity for sending HTLCs to the remote peer. This does not include
4221  * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
4222  * available for inclusion in new outbound HTLCs). This further does not include any pending
4223  * outgoing HTLCs which are awaiting some other resolution to be sent.
4224  */
4225 uint64_t ChannelDetails_get_outbound_capacity_msat(const LDKChannelDetails *this_ptr);
4226
4227 /**
4228  * The available outbound capacity for sending HTLCs to the remote peer. This does not include
4229  * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
4230  * available for inclusion in new outbound HTLCs). This further does not include any pending
4231  * outgoing HTLCs which are awaiting some other resolution to be sent.
4232  */
4233 void ChannelDetails_set_outbound_capacity_msat(LDKChannelDetails *this_ptr, uint64_t val);
4234
4235 /**
4236  * The available inbound capacity for the remote peer to send HTLCs to us. This does not
4237  * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
4238  * available for inclusion in new inbound HTLCs).
4239  * Note that there are some corner cases not fully handled here, so the actual available
4240  * inbound capacity may be slightly higher than this.
4241  */
4242 uint64_t ChannelDetails_get_inbound_capacity_msat(const LDKChannelDetails *this_ptr);
4243
4244 /**
4245  * The available inbound capacity for the remote peer to send HTLCs to us. This does not
4246  * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
4247  * available for inclusion in new inbound HTLCs).
4248  * Note that there are some corner cases not fully handled here, so the actual available
4249  * inbound capacity may be slightly higher than this.
4250  */
4251 void ChannelDetails_set_inbound_capacity_msat(LDKChannelDetails *this_ptr, uint64_t val);
4252
4253 /**
4254  * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
4255  * the peer is connected, and (c) no monitor update failure is pending resolution.
4256  */
4257 bool ChannelDetails_get_is_live(const LDKChannelDetails *this_ptr);
4258
4259 /**
4260  * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
4261  * the peer is connected, and (c) no monitor update failure is pending resolution.
4262  */
4263 void ChannelDetails_set_is_live(LDKChannelDetails *this_ptr, bool val);
4264
4265 void PaymentSendFailure_free(LDKPaymentSendFailure this_ptr);
4266
4267 /**
4268  * Constructs a new ChannelManager to hold several channels and route between them.
4269  *
4270  * This is the main \"logic hub\" for all channel-related actions, and implements
4271  * ChannelMessageHandler.
4272  *
4273  * Non-proportional fees are fixed according to our risk using the provided fee estimator.
4274  *
4275  * panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
4276  *
4277  * Users must provide the current blockchain height from which to track onchain channel
4278  * funding outpoints and send payments with reliable timelocks.
4279  *
4280  * Users need to notify the new ChannelManager when a new block is connected or
4281  * disconnected using its `block_connected` and `block_disconnected` methods.
4282  */
4283 MUST_USE_RES LDKChannelManager ChannelManager_new(LDKNetwork network, LDKFeeEstimator fee_est, LDKWatch chain_monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKKeysInterface keys_manager, LDKUserConfig config, uintptr_t current_blockchain_height);
4284
4285 /**
4286  * Creates a new outbound channel to the given remote node and with the given value.
4287  *
4288  * user_id will be provided back as user_channel_id in FundingGenerationReady and
4289  * FundingBroadcastSafe events to allow tracking of which events correspond with which
4290  * create_channel call. Note that user_channel_id defaults to 0 for inbound channels, so you
4291  * may wish to avoid using 0 for user_id here.
4292  *
4293  * If successful, will generate a SendOpenChannel message event, so you should probably poll
4294  * PeerManager::process_events afterwards.
4295  *
4296  * Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
4297  * greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
4298  */
4299 MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_create_channel(const LDKChannelManager *this_arg, LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_id, LDKUserConfig override_config);
4300
4301 /**
4302  * Gets the list of open channels, in random order. See ChannelDetail field documentation for
4303  * more information.
4304  */
4305 MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const LDKChannelManager *this_arg);
4306
4307 /**
4308  * Gets the list of usable channels, in random order. Useful as an argument to
4309  * get_route to ensure non-announced channels are used.
4310  *
4311  * These are guaranteed to have their is_live value set to true, see the documentation for
4312  * ChannelDetails::is_live for more info on exactly what the criteria are.
4313  */
4314 MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const LDKChannelManager *this_arg);
4315
4316 /**
4317  * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
4318  * will be accepted on the given channel, and after additional timeout/the closing of all
4319  * pending HTLCs, the channel will be closed on chain.
4320  *
4321  * May generate a SendShutdown message event on success, which should be relayed.
4322  */
4323 MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]);
4324
4325 /**
4326  * Force closes a channel, immediately broadcasting the latest local commitment transaction to
4327  * the chain and rejecting new HTLCs on the given channel.
4328  */
4329 void ChannelManager_force_close_channel(const LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]);
4330
4331 /**
4332  * Force close all channels, immediately broadcasting the latest local commitment transaction
4333  * for each to the chain and rejecting new HTLCs on each.
4334  */
4335 void ChannelManager_force_close_all_channels(const LDKChannelManager *this_arg);
4336
4337 /**
4338  * Sends a payment along a given route.
4339  *
4340  * Value parameters are provided via the last hop in route, see documentation for RouteHop
4341  * fields for more info.
4342  *
4343  * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
4344  * payment), we don't do anything to stop you! We always try to ensure that if the provided
4345  * next hop knows the preimage to payment_hash they can claim an additional amount as
4346  * specified in the last hop in the route! Thus, you should probably do your own
4347  * payment_preimage tracking (which you should already be doing as they represent \"proof of
4348  * payment\") and prevent double-sends yourself.
4349  *
4350  * May generate SendHTLCs message(s) event on success, which should be relayed.
4351  *
4352  * Each path may have a different return value, and PaymentSendValue may return a Vec with
4353  * each entry matching the corresponding-index entry in the route paths, see
4354  * PaymentSendFailure for more info.
4355  *
4356  * In general, a path may raise:
4357  *  * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
4358  *    node public key) is specified.
4359  *  * APIError::ChannelUnavailable if the next-hop channel is not available for updates
4360  *    (including due to previous monitor update failure or new permanent monitor update
4361  *    failure).
4362  *  * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
4363  *    relevant updates.
4364  *
4365  * Note that depending on the type of the PaymentSendFailure the HTLC may have been
4366  * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
4367  * different route unless you intend to pay twice!
4368  *
4369  * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
4370  * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
4371  * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
4372  * must not contain multiple paths as multi-path payments require a recipient-provided
4373  * payment_secret.
4374  * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
4375  * bit set (either as required or as available). If multiple paths are present in the Route,
4376  * we assume the invoice had the basic_mpp feature set.
4377  */
4378 MUST_USE_RES LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(const LDKChannelManager *this_arg, const LDKRoute *route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret);
4379
4380 /**
4381  * Call this upon creation of a funding transaction for the given channel.
4382  *
4383  * Note that ALL inputs in the transaction pointed to by funding_txo MUST spend SegWit outputs
4384  * or your counterparty can steal your funds!
4385  *
4386  * Panics if a funding transaction has already been provided for this channel.
4387  *
4388  * May panic if the funding_txo is duplicative with some other channel (note that this should
4389  * be trivially prevented by using unique funding transaction keys per-channel).
4390  */
4391 void ChannelManager_funding_transaction_generated(const LDKChannelManager *this_arg, const uint8_t (*temporary_channel_id)[32], LDKOutPoint funding_txo);
4392
4393 /**
4394  * Generates a signed node_announcement from the given arguments and creates a
4395  * BroadcastNodeAnnouncement event. Note that such messages will be ignored unless peers have
4396  * seen a channel_announcement from us (ie unless we have public channels open).
4397  *
4398  * RGB is a node \"color\" and alias is a printable human-readable string to describe this node
4399  * to humans. They carry no in-protocol meaning.
4400  *
4401  * addresses represent the set (possibly empty) of socket addresses on which this node accepts
4402  * incoming connections. These will be broadcast to the network, publicly tying these
4403  * addresses together. If you wish to preserve user privacy, addresses should likely contain
4404  * only Tor Onion addresses.
4405  *
4406  * Panics if addresses is absurdly large (more than 500).
4407  */
4408 void ChannelManager_broadcast_node_announcement(const LDKChannelManager *this_arg, LDKThreeBytes rgb, LDKThirtyTwoBytes alias, LDKCVec_NetAddressZ addresses);
4409
4410 /**
4411  * Processes HTLCs which are pending waiting on random forward delay.
4412  *
4413  * Should only really ever be called in response to a PendingHTLCsForwardable event.
4414  * Will likely generate further events.
4415  */
4416 void ChannelManager_process_pending_htlc_forwards(const LDKChannelManager *this_arg);
4417
4418 /**
4419  * If a peer is disconnected we mark any channels with that peer as 'disabled'.
4420  * After some time, if channels are still disabled we need to broadcast a ChannelUpdate
4421  * to inform the network about the uselessness of these channels.
4422  *
4423  * This method handles all the details, and must be called roughly once per minute.
4424  */
4425 void ChannelManager_timer_chan_freshness_every_min(const LDKChannelManager *this_arg);
4426
4427 /**
4428  * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
4429  * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources
4430  * along the path (including in our own channel on which we received it).
4431  * Returns false if no payment was found to fail backwards, true if the process of failing the
4432  * HTLC backwards has been started.
4433  */
4434 MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const LDKChannelManager *this_arg, const uint8_t (*payment_hash)[32], LDKThirtyTwoBytes payment_secret);
4435
4436 /**
4437  * Provides a payment preimage in response to a PaymentReceived event, returning true and
4438  * generating message events for the net layer to claim the payment, if possible. Thus, you
4439  * should probably kick the net layer to go send messages if this returns true!
4440  *
4441  * You must specify the expected amounts for this HTLC, and we will only claim HTLCs
4442  * available within a few percent of the expected amount. This is critical for several
4443  * reasons : a) it avoids providing senders with `proof-of-payment` (in the form of the
4444  * payment_preimage without having provided the full value and b) it avoids certain
4445  * privacy-breaking recipient-probing attacks which may reveal payment activity to
4446  * motivated attackers.
4447  *
4448  * Note that the privacy concerns in (b) are not relevant in payments with a payment_secret
4449  * set. Thus, for such payments we will claim any payments which do not under-pay.
4450  *
4451  * May panic if called except in response to a PaymentReceived event.
4452  */
4453 MUST_USE_RES bool ChannelManager_claim_funds(const LDKChannelManager *this_arg, LDKThirtyTwoBytes payment_preimage, LDKThirtyTwoBytes payment_secret, uint64_t expected_amount);
4454
4455 /**
4456  * Gets the node_id held by this ChannelManager
4457  */
4458 MUST_USE_RES LDKPublicKey ChannelManager_get_our_node_id(const LDKChannelManager *this_arg);
4459
4460 /**
4461  * Restores a single, given channel to normal operation after a
4462  * ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update
4463  * operation.
4464  *
4465  * All ChannelMonitor updates up to and including highest_applied_update_id must have been
4466  * fully committed in every copy of the given channels' ChannelMonitors.
4467  *
4468  * Note that there is no effect to calling with a highest_applied_update_id other than the
4469  * current latest ChannelMonitorUpdate and one call to this function after multiple
4470  * ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field
4471  * exists largely only to prevent races between this and concurrent update_monitor calls.
4472  *
4473  * Thus, the anticipated use is, at a high level:
4474  *  1) You register a chain::Watch with this ChannelManager,
4475  *  2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
4476  *     said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
4477  *     any time it cannot do so instantly,
4478  *  3) update(s) are applied to each remote copy of a ChannelMonitor,
4479  *  4) once all remote copies are updated, you call this function with the update_id that
4480  *     completed, and once it is the latest the Channel will be re-enabled.
4481  */
4482 void ChannelManager_channel_monitor_updated(const LDKChannelManager *this_arg, const LDKOutPoint *funding_txo, uint64_t highest_applied_update_id);
4483
4484 LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const LDKChannelManager *this_arg);
4485
4486 LDKEventsProvider ChannelManager_as_EventsProvider(const LDKChannelManager *this_arg);
4487
4488 /**
4489  * Updates channel state based on transactions seen in a connected block.
4490  */
4491 void ChannelManager_block_connected(const LDKChannelManager *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height);
4492
4493 /**
4494  * Updates channel state based on a disconnected block.
4495  *
4496  * If necessary, the channel may be force-closed without letting the counterparty participate
4497  * in the shutdown.
4498  */
4499 void ChannelManager_block_disconnected(const LDKChannelManager *this_arg, const uint8_t (*header)[80]);
4500
4501 LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const LDKChannelManager *this_arg);
4502
4503 void ChannelManagerReadArgs_free(LDKChannelManagerReadArgs this_ptr);
4504
4505 /**
4506  * The keys provider which will give us relevant keys. Some keys will be loaded during
4507  * deserialization.
4508  */
4509 const LDKKeysInterface *ChannelManagerReadArgs_get_keys_manager(const LDKChannelManagerReadArgs *this_ptr);
4510
4511 /**
4512  * The keys provider which will give us relevant keys. Some keys will be loaded during
4513  * deserialization.
4514  */
4515 void ChannelManagerReadArgs_set_keys_manager(LDKChannelManagerReadArgs *this_ptr, LDKKeysInterface val);
4516
4517 /**
4518  * The fee_estimator for use in the ChannelManager in the future.
4519  *
4520  * No calls to the FeeEstimator will be made during deserialization.
4521  */
4522 const LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const LDKChannelManagerReadArgs *this_ptr);
4523
4524 /**
4525  * The fee_estimator for use in the ChannelManager in the future.
4526  *
4527  * No calls to the FeeEstimator will be made during deserialization.
4528  */
4529 void ChannelManagerReadArgs_set_fee_estimator(LDKChannelManagerReadArgs *this_ptr, LDKFeeEstimator val);
4530
4531 /**
4532  * The chain::Watch for use in the ChannelManager in the future.
4533  *
4534  * No calls to the chain::Watch will be made during deserialization. It is assumed that
4535  * you have deserialized ChannelMonitors separately and will add them to your
4536  * chain::Watch after deserializing this ChannelManager.
4537  */
4538 const LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const LDKChannelManagerReadArgs *this_ptr);
4539
4540 /**
4541  * The chain::Watch for use in the ChannelManager in the future.
4542  *
4543  * No calls to the chain::Watch will be made during deserialization. It is assumed that
4544  * you have deserialized ChannelMonitors separately and will add them to your
4545  * chain::Watch after deserializing this ChannelManager.
4546  */
4547 void ChannelManagerReadArgs_set_chain_monitor(LDKChannelManagerReadArgs *this_ptr, LDKWatch val);
4548
4549 /**
4550  * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
4551  * used to broadcast the latest local commitment transactions of channels which must be
4552  * force-closed during deserialization.
4553  */
4554 const LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const LDKChannelManagerReadArgs *this_ptr);
4555
4556 /**
4557  * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
4558  * used to broadcast the latest local commitment transactions of channels which must be
4559  * force-closed during deserialization.
4560  */
4561 void ChannelManagerReadArgs_set_tx_broadcaster(LDKChannelManagerReadArgs *this_ptr, LDKBroadcasterInterface val);
4562
4563 /**
4564  * The Logger for use in the ChannelManager and which may be used to log information during
4565  * deserialization.
4566  */
4567 const LDKLogger *ChannelManagerReadArgs_get_logger(const LDKChannelManagerReadArgs *this_ptr);
4568
4569 /**
4570  * The Logger for use in the ChannelManager and which may be used to log information during
4571  * deserialization.
4572  */
4573 void ChannelManagerReadArgs_set_logger(LDKChannelManagerReadArgs *this_ptr, LDKLogger val);
4574
4575 /**
4576  * Default settings used for new channels. Any existing channels will continue to use the
4577  * runtime settings which were stored when the ChannelManager was serialized.
4578  */
4579 LDKUserConfig ChannelManagerReadArgs_get_default_config(const LDKChannelManagerReadArgs *this_ptr);
4580
4581 /**
4582  * Default settings used for new channels. Any existing channels will continue to use the
4583  * runtime settings which were stored when the ChannelManager was serialized.
4584  */
4585 void ChannelManagerReadArgs_set_default_config(LDKChannelManagerReadArgs *this_ptr, LDKUserConfig val);
4586
4587 /**
4588  * Simple utility function to create a ChannelManagerReadArgs which creates the monitor
4589  * HashMap for you. This is primarily useful for C bindings where it is not practical to
4590  * populate a HashMap directly from C.
4591  */
4592 MUST_USE_RES LDKChannelManagerReadArgs ChannelManagerReadArgs_new(LDKKeysInterface keys_manager, LDKFeeEstimator fee_estimator, LDKWatch chain_monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKUserConfig default_config, LDKCVec_ChannelMonitorZ channel_monitors);
4593
4594 void DecodeError_free(LDKDecodeError this_ptr);
4595
4596 void Init_free(LDKInit this_ptr);
4597
4598 LDKInit Init_clone(const LDKInit *orig);
4599
4600 void ErrorMessage_free(LDKErrorMessage this_ptr);
4601
4602 LDKErrorMessage ErrorMessage_clone(const LDKErrorMessage *orig);
4603
4604 /**
4605  * The channel ID involved in the error
4606  */
4607 const uint8_t (*ErrorMessage_get_channel_id(const LDKErrorMessage *this_ptr))[32];
4608
4609 /**
4610  * The channel ID involved in the error
4611  */
4612 void ErrorMessage_set_channel_id(LDKErrorMessage *this_ptr, LDKThirtyTwoBytes val);
4613
4614 /**
4615  * A possibly human-readable error description.
4616  * The string should be sanitized before it is used (e.g. emitted to logs
4617  * or printed to stdout).  Otherwise, a well crafted error message may trigger a security
4618  * vulnerability in the terminal emulator or the logging subsystem.
4619  */
4620 LDKStr ErrorMessage_get_data(const LDKErrorMessage *this_ptr);
4621
4622 /**
4623  * A possibly human-readable error description.
4624  * The string should be sanitized before it is used (e.g. emitted to logs
4625  * or printed to stdout).  Otherwise, a well crafted error message may trigger a security
4626  * vulnerability in the terminal emulator or the logging subsystem.
4627  */
4628 void ErrorMessage_set_data(LDKErrorMessage *this_ptr, LDKCVec_u8Z val);
4629
4630 MUST_USE_RES LDKErrorMessage ErrorMessage_new(LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z data_arg);
4631
4632 void Ping_free(LDKPing this_ptr);
4633
4634 LDKPing Ping_clone(const LDKPing *orig);
4635
4636 /**
4637  * The desired response length
4638  */
4639 uint16_t Ping_get_ponglen(const LDKPing *this_ptr);
4640
4641 /**
4642  * The desired response length
4643  */
4644 void Ping_set_ponglen(LDKPing *this_ptr, uint16_t val);
4645
4646 /**
4647  * The ping packet size.
4648  * This field is not sent on the wire. byteslen zeros are sent.
4649  */
4650 uint16_t Ping_get_byteslen(const LDKPing *this_ptr);
4651
4652 /**
4653  * The ping packet size.
4654  * This field is not sent on the wire. byteslen zeros are sent.
4655  */
4656 void Ping_set_byteslen(LDKPing *this_ptr, uint16_t val);
4657
4658 MUST_USE_RES LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg);
4659
4660 void Pong_free(LDKPong this_ptr);
4661
4662 LDKPong Pong_clone(const LDKPong *orig);
4663
4664 /**
4665  * The pong packet size.
4666  * This field is not sent on the wire. byteslen zeros are sent.
4667  */
4668 uint16_t Pong_get_byteslen(const LDKPong *this_ptr);
4669
4670 /**
4671  * The pong packet size.
4672  * This field is not sent on the wire. byteslen zeros are sent.
4673  */
4674 void Pong_set_byteslen(LDKPong *this_ptr, uint16_t val);
4675
4676 MUST_USE_RES LDKPong Pong_new(uint16_t byteslen_arg);
4677
4678 void OpenChannel_free(LDKOpenChannel this_ptr);
4679
4680 LDKOpenChannel OpenChannel_clone(const LDKOpenChannel *orig);
4681
4682 /**
4683  * The genesis hash of the blockchain where the channel is to be opened
4684  */
4685 const uint8_t (*OpenChannel_get_chain_hash(const LDKOpenChannel *this_ptr))[32];
4686
4687 /**
4688  * The genesis hash of the blockchain where the channel is to be opened
4689  */
4690 void OpenChannel_set_chain_hash(LDKOpenChannel *this_ptr, LDKThirtyTwoBytes val);
4691
4692 /**
4693  * A temporary channel ID, until the funding outpoint is announced
4694  */
4695 const uint8_t (*OpenChannel_get_temporary_channel_id(const LDKOpenChannel *this_ptr))[32];
4696
4697 /**
4698  * A temporary channel ID, until the funding outpoint is announced
4699  */
4700 void OpenChannel_set_temporary_channel_id(LDKOpenChannel *this_ptr, LDKThirtyTwoBytes val);
4701
4702 /**
4703  * The channel value
4704  */
4705 uint64_t OpenChannel_get_funding_satoshis(const LDKOpenChannel *this_ptr);
4706
4707 /**
4708  * The channel value
4709  */
4710 void OpenChannel_set_funding_satoshis(LDKOpenChannel *this_ptr, uint64_t val);
4711
4712 /**
4713  * The amount to push to the counterparty as part of the open, in milli-satoshi
4714  */
4715 uint64_t OpenChannel_get_push_msat(const LDKOpenChannel *this_ptr);
4716
4717 /**
4718  * The amount to push to the counterparty as part of the open, in milli-satoshi
4719  */
4720 void OpenChannel_set_push_msat(LDKOpenChannel *this_ptr, uint64_t val);
4721
4722 /**
4723  * The threshold below which outputs on transactions broadcast by sender will be omitted
4724  */
4725 uint64_t OpenChannel_get_dust_limit_satoshis(const LDKOpenChannel *this_ptr);
4726
4727 /**
4728  * The threshold below which outputs on transactions broadcast by sender will be omitted
4729  */
4730 void OpenChannel_set_dust_limit_satoshis(LDKOpenChannel *this_ptr, uint64_t val);
4731
4732 /**
4733  * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
4734  */
4735 uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const LDKOpenChannel *this_ptr);
4736
4737 /**
4738  * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
4739  */
4740 void OpenChannel_set_max_htlc_value_in_flight_msat(LDKOpenChannel *this_ptr, uint64_t val);
4741
4742 /**
4743  * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
4744  */
4745 uint64_t OpenChannel_get_channel_reserve_satoshis(const LDKOpenChannel *this_ptr);
4746
4747 /**
4748  * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
4749  */
4750 void OpenChannel_set_channel_reserve_satoshis(LDKOpenChannel *this_ptr, uint64_t val);
4751
4752 /**
4753  * The minimum HTLC size incoming to sender, in milli-satoshi
4754  */
4755 uint64_t OpenChannel_get_htlc_minimum_msat(const LDKOpenChannel *this_ptr);
4756
4757 /**
4758  * The minimum HTLC size incoming to sender, in milli-satoshi
4759  */
4760 void OpenChannel_set_htlc_minimum_msat(LDKOpenChannel *this_ptr, uint64_t val);
4761
4762 /**
4763  * The feerate per 1000-weight of sender generated transactions, until updated by update_fee
4764  */
4765 uint32_t OpenChannel_get_feerate_per_kw(const LDKOpenChannel *this_ptr);
4766
4767 /**
4768  * The feerate per 1000-weight of sender generated transactions, until updated by update_fee
4769  */
4770 void OpenChannel_set_feerate_per_kw(LDKOpenChannel *this_ptr, uint32_t val);
4771
4772 /**
4773  * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
4774  */
4775 uint16_t OpenChannel_get_to_self_delay(const LDKOpenChannel *this_ptr);
4776
4777 /**
4778  * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
4779  */
4780 void OpenChannel_set_to_self_delay(LDKOpenChannel *this_ptr, uint16_t val);
4781
4782 /**
4783  * The maximum number of inbound HTLCs towards sender
4784  */
4785 uint16_t OpenChannel_get_max_accepted_htlcs(const LDKOpenChannel *this_ptr);
4786
4787 /**
4788  * The maximum number of inbound HTLCs towards sender
4789  */
4790 void OpenChannel_set_max_accepted_htlcs(LDKOpenChannel *this_ptr, uint16_t val);
4791
4792 /**
4793  * The sender's key controlling the funding transaction
4794  */
4795 LDKPublicKey OpenChannel_get_funding_pubkey(const LDKOpenChannel *this_ptr);
4796
4797 /**
4798  * The sender's key controlling the funding transaction
4799  */
4800 void OpenChannel_set_funding_pubkey(LDKOpenChannel *this_ptr, LDKPublicKey val);
4801
4802 /**
4803  * Used to derive a revocation key for transactions broadcast by counterparty
4804  */
4805 LDKPublicKey OpenChannel_get_revocation_basepoint(const LDKOpenChannel *this_ptr);
4806
4807 /**
4808  * Used to derive a revocation key for transactions broadcast by counterparty
4809  */
4810 void OpenChannel_set_revocation_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val);
4811
4812 /**
4813  * A payment key to sender for transactions broadcast by counterparty
4814  */
4815 LDKPublicKey OpenChannel_get_payment_point(const LDKOpenChannel *this_ptr);
4816
4817 /**
4818  * A payment key to sender for transactions broadcast by counterparty
4819  */
4820 void OpenChannel_set_payment_point(LDKOpenChannel *this_ptr, LDKPublicKey val);
4821
4822 /**
4823  * Used to derive a payment key to sender for transactions broadcast by sender
4824  */
4825 LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const LDKOpenChannel *this_ptr);
4826
4827 /**
4828  * Used to derive a payment key to sender for transactions broadcast by sender
4829  */
4830 void OpenChannel_set_delayed_payment_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val);
4831
4832 /**
4833  * Used to derive an HTLC payment key to sender
4834  */
4835 LDKPublicKey OpenChannel_get_htlc_basepoint(const LDKOpenChannel *this_ptr);
4836
4837 /**
4838  * Used to derive an HTLC payment key to sender
4839  */
4840 void OpenChannel_set_htlc_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val);
4841
4842 /**
4843  * The first to-be-broadcast-by-sender transaction's per commitment point
4844  */
4845 LDKPublicKey OpenChannel_get_first_per_commitment_point(const LDKOpenChannel *this_ptr);
4846
4847 /**
4848  * The first to-be-broadcast-by-sender transaction's per commitment point
4849  */
4850 void OpenChannel_set_first_per_commitment_point(LDKOpenChannel *this_ptr, LDKPublicKey val);
4851
4852 /**
4853  * Channel flags
4854  */
4855 uint8_t OpenChannel_get_channel_flags(const LDKOpenChannel *this_ptr);
4856
4857 /**
4858  * Channel flags
4859  */
4860 void OpenChannel_set_channel_flags(LDKOpenChannel *this_ptr, uint8_t val);
4861
4862 void AcceptChannel_free(LDKAcceptChannel this_ptr);
4863
4864 LDKAcceptChannel AcceptChannel_clone(const LDKAcceptChannel *orig);
4865
4866 /**
4867  * A temporary channel ID, until the funding outpoint is announced
4868  */
4869 const uint8_t (*AcceptChannel_get_temporary_channel_id(const LDKAcceptChannel *this_ptr))[32];
4870
4871 /**
4872  * A temporary channel ID, until the funding outpoint is announced
4873  */
4874 void AcceptChannel_set_temporary_channel_id(LDKAcceptChannel *this_ptr, LDKThirtyTwoBytes val);
4875
4876 /**
4877  * The threshold below which outputs on transactions broadcast by sender will be omitted
4878  */
4879 uint64_t AcceptChannel_get_dust_limit_satoshis(const LDKAcceptChannel *this_ptr);
4880
4881 /**
4882  * The threshold below which outputs on transactions broadcast by sender will be omitted
4883  */
4884 void AcceptChannel_set_dust_limit_satoshis(LDKAcceptChannel *this_ptr, uint64_t val);
4885
4886 /**
4887  * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
4888  */
4889 uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const LDKAcceptChannel *this_ptr);
4890
4891 /**
4892  * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
4893  */
4894 void AcceptChannel_set_max_htlc_value_in_flight_msat(LDKAcceptChannel *this_ptr, uint64_t val);
4895
4896 /**
4897  * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
4898  */
4899 uint64_t AcceptChannel_get_channel_reserve_satoshis(const LDKAcceptChannel *this_ptr);
4900
4901 /**
4902  * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
4903  */
4904 void AcceptChannel_set_channel_reserve_satoshis(LDKAcceptChannel *this_ptr, uint64_t val);
4905
4906 /**
4907  * The minimum HTLC size incoming to sender, in milli-satoshi
4908  */
4909 uint64_t AcceptChannel_get_htlc_minimum_msat(const LDKAcceptChannel *this_ptr);
4910
4911 /**
4912  * The minimum HTLC size incoming to sender, in milli-satoshi
4913  */
4914 void AcceptChannel_set_htlc_minimum_msat(LDKAcceptChannel *this_ptr, uint64_t val);
4915
4916 /**
4917  * Minimum depth of the funding transaction before the channel is considered open
4918  */
4919 uint32_t AcceptChannel_get_minimum_depth(const LDKAcceptChannel *this_ptr);
4920
4921 /**
4922  * Minimum depth of the funding transaction before the channel is considered open
4923  */
4924 void AcceptChannel_set_minimum_depth(LDKAcceptChannel *this_ptr, uint32_t val);
4925
4926 /**
4927  * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
4928  */
4929 uint16_t AcceptChannel_get_to_self_delay(const LDKAcceptChannel *this_ptr);
4930
4931 /**
4932  * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
4933  */
4934 void AcceptChannel_set_to_self_delay(LDKAcceptChannel *this_ptr, uint16_t val);
4935
4936 /**
4937  * The maximum number of inbound HTLCs towards sender
4938  */
4939 uint16_t AcceptChannel_get_max_accepted_htlcs(const LDKAcceptChannel *this_ptr);
4940
4941 /**
4942  * The maximum number of inbound HTLCs towards sender
4943  */
4944 void AcceptChannel_set_max_accepted_htlcs(LDKAcceptChannel *this_ptr, uint16_t val);
4945
4946 /**
4947  * The sender's key controlling the funding transaction
4948  */
4949 LDKPublicKey AcceptChannel_get_funding_pubkey(const LDKAcceptChannel *this_ptr);
4950
4951 /**
4952  * The sender's key controlling the funding transaction
4953  */
4954 void AcceptChannel_set_funding_pubkey(LDKAcceptChannel *this_ptr, LDKPublicKey val);
4955
4956 /**
4957  * Used to derive a revocation key for transactions broadcast by counterparty
4958  */
4959 LDKPublicKey AcceptChannel_get_revocation_basepoint(const LDKAcceptChannel *this_ptr);
4960
4961 /**
4962  * Used to derive a revocation key for transactions broadcast by counterparty
4963  */
4964 void AcceptChannel_set_revocation_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val);
4965
4966 /**
4967  * A payment key to sender for transactions broadcast by counterparty
4968  */
4969 LDKPublicKey AcceptChannel_get_payment_point(const LDKAcceptChannel *this_ptr);
4970
4971 /**
4972  * A payment key to sender for transactions broadcast by counterparty
4973  */
4974 void AcceptChannel_set_payment_point(LDKAcceptChannel *this_ptr, LDKPublicKey val);
4975
4976 /**
4977  * Used to derive a payment key to sender for transactions broadcast by sender
4978  */
4979 LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const LDKAcceptChannel *this_ptr);
4980
4981 /**
4982  * Used to derive a payment key to sender for transactions broadcast by sender
4983  */
4984 void AcceptChannel_set_delayed_payment_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val);
4985
4986 /**
4987  * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
4988  */
4989 LDKPublicKey AcceptChannel_get_htlc_basepoint(const LDKAcceptChannel *this_ptr);
4990
4991 /**
4992  * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
4993  */
4994 void AcceptChannel_set_htlc_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val);
4995
4996 /**
4997  * The first to-be-broadcast-by-sender transaction's per commitment point
4998  */
4999 LDKPublicKey AcceptChannel_get_first_per_commitment_point(const LDKAcceptChannel *this_ptr);
5000
5001 /**
5002  * The first to-be-broadcast-by-sender transaction's per commitment point
5003  */
5004 void AcceptChannel_set_first_per_commitment_point(LDKAcceptChannel *this_ptr, LDKPublicKey val);
5005
5006 void FundingCreated_free(LDKFundingCreated this_ptr);
5007
5008 LDKFundingCreated FundingCreated_clone(const LDKFundingCreated *orig);
5009
5010 /**
5011  * A temporary channel ID, until the funding is established
5012  */
5013 const uint8_t (*FundingCreated_get_temporary_channel_id(const LDKFundingCreated *this_ptr))[32];
5014
5015 /**
5016  * A temporary channel ID, until the funding is established
5017  */
5018 void FundingCreated_set_temporary_channel_id(LDKFundingCreated *this_ptr, LDKThirtyTwoBytes val);
5019
5020 /**
5021  * The funding transaction ID
5022  */
5023 const uint8_t (*FundingCreated_get_funding_txid(const LDKFundingCreated *this_ptr))[32];
5024
5025 /**
5026  * The funding transaction ID
5027  */
5028 void FundingCreated_set_funding_txid(LDKFundingCreated *this_ptr, LDKThirtyTwoBytes val);
5029
5030 /**
5031  * The specific output index funding this channel
5032  */
5033 uint16_t FundingCreated_get_funding_output_index(const LDKFundingCreated *this_ptr);
5034
5035 /**
5036  * The specific output index funding this channel
5037  */
5038 void FundingCreated_set_funding_output_index(LDKFundingCreated *this_ptr, uint16_t val);
5039
5040 /**
5041  * The signature of the channel initiator (funder) on the funding transaction
5042  */
5043 LDKSignature FundingCreated_get_signature(const LDKFundingCreated *this_ptr);
5044
5045 /**
5046  * The signature of the channel initiator (funder) on the funding transaction
5047  */
5048 void FundingCreated_set_signature(LDKFundingCreated *this_ptr, LDKSignature val);
5049
5050 MUST_USE_RES LDKFundingCreated FundingCreated_new(LDKThirtyTwoBytes temporary_channel_id_arg, LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, LDKSignature signature_arg);
5051
5052 void FundingSigned_free(LDKFundingSigned this_ptr);
5053
5054 LDKFundingSigned FundingSigned_clone(const LDKFundingSigned *orig);
5055
5056 /**
5057  * The channel ID
5058  */
5059 const uint8_t (*FundingSigned_get_channel_id(const LDKFundingSigned *this_ptr))[32];
5060
5061 /**
5062  * The channel ID
5063  */
5064 void FundingSigned_set_channel_id(LDKFundingSigned *this_ptr, LDKThirtyTwoBytes val);
5065
5066 /**
5067  * The signature of the channel acceptor (fundee) on the funding transaction
5068  */
5069 LDKSignature FundingSigned_get_signature(const LDKFundingSigned *this_ptr);
5070
5071 /**
5072  * The signature of the channel acceptor (fundee) on the funding transaction
5073  */
5074 void FundingSigned_set_signature(LDKFundingSigned *this_ptr, LDKSignature val);
5075
5076 MUST_USE_RES LDKFundingSigned FundingSigned_new(LDKThirtyTwoBytes channel_id_arg, LDKSignature signature_arg);
5077
5078 void FundingLocked_free(LDKFundingLocked this_ptr);
5079
5080 LDKFundingLocked FundingLocked_clone(const LDKFundingLocked *orig);
5081
5082 /**
5083  * The channel ID
5084  */
5085 const uint8_t (*FundingLocked_get_channel_id(const LDKFundingLocked *this_ptr))[32];
5086
5087 /**
5088  * The channel ID
5089  */
5090 void FundingLocked_set_channel_id(LDKFundingLocked *this_ptr, LDKThirtyTwoBytes val);
5091
5092 /**
5093  * The per-commitment point of the second commitment transaction
5094  */
5095 LDKPublicKey FundingLocked_get_next_per_commitment_point(const LDKFundingLocked *this_ptr);
5096
5097 /**
5098  * The per-commitment point of the second commitment transaction
5099  */
5100 void FundingLocked_set_next_per_commitment_point(LDKFundingLocked *this_ptr, LDKPublicKey val);
5101
5102 MUST_USE_RES LDKFundingLocked FundingLocked_new(LDKThirtyTwoBytes channel_id_arg, LDKPublicKey next_per_commitment_point_arg);
5103
5104 void Shutdown_free(LDKShutdown this_ptr);
5105
5106 LDKShutdown Shutdown_clone(const LDKShutdown *orig);
5107
5108 /**
5109  * The channel ID
5110  */
5111 const uint8_t (*Shutdown_get_channel_id(const LDKShutdown *this_ptr))[32];
5112
5113 /**
5114  * The channel ID
5115  */
5116 void Shutdown_set_channel_id(LDKShutdown *this_ptr, LDKThirtyTwoBytes val);
5117
5118 /**
5119  * The destination of this peer's funds on closing.
5120  * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
5121  */
5122 LDKu8slice Shutdown_get_scriptpubkey(const LDKShutdown *this_ptr);
5123
5124 /**
5125  * The destination of this peer's funds on closing.
5126  * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
5127  */
5128 void Shutdown_set_scriptpubkey(LDKShutdown *this_ptr, LDKCVec_u8Z val);
5129
5130 MUST_USE_RES LDKShutdown Shutdown_new(LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z scriptpubkey_arg);
5131
5132 void ClosingSigned_free(LDKClosingSigned this_ptr);
5133
5134 LDKClosingSigned ClosingSigned_clone(const LDKClosingSigned *orig);
5135
5136 /**
5137  * The channel ID
5138  */
5139 const uint8_t (*ClosingSigned_get_channel_id(const LDKClosingSigned *this_ptr))[32];
5140
5141 /**
5142  * The channel ID
5143  */
5144 void ClosingSigned_set_channel_id(LDKClosingSigned *this_ptr, LDKThirtyTwoBytes val);
5145
5146 /**
5147  * The proposed total fee for the closing transaction
5148  */
5149 uint64_t ClosingSigned_get_fee_satoshis(const LDKClosingSigned *this_ptr);
5150
5151 /**
5152  * The proposed total fee for the closing transaction
5153  */
5154 void ClosingSigned_set_fee_satoshis(LDKClosingSigned *this_ptr, uint64_t val);
5155
5156 /**
5157  * A signature on the closing transaction
5158  */
5159 LDKSignature ClosingSigned_get_signature(const LDKClosingSigned *this_ptr);
5160
5161 /**
5162  * A signature on the closing transaction
5163  */
5164 void ClosingSigned_set_signature(LDKClosingSigned *this_ptr, LDKSignature val);
5165
5166 MUST_USE_RES LDKClosingSigned ClosingSigned_new(LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, LDKSignature signature_arg);
5167
5168 void UpdateAddHTLC_free(LDKUpdateAddHTLC this_ptr);
5169
5170 LDKUpdateAddHTLC UpdateAddHTLC_clone(const LDKUpdateAddHTLC *orig);
5171
5172 /**
5173  * The channel ID
5174  */
5175 const uint8_t (*UpdateAddHTLC_get_channel_id(const LDKUpdateAddHTLC *this_ptr))[32];
5176
5177 /**
5178  * The channel ID
5179  */
5180 void UpdateAddHTLC_set_channel_id(LDKUpdateAddHTLC *this_ptr, LDKThirtyTwoBytes val);
5181
5182 /**
5183  * The HTLC ID
5184  */
5185 uint64_t UpdateAddHTLC_get_htlc_id(const LDKUpdateAddHTLC *this_ptr);
5186
5187 /**
5188  * The HTLC ID
5189  */
5190 void UpdateAddHTLC_set_htlc_id(LDKUpdateAddHTLC *this_ptr, uint64_t val);
5191
5192 /**
5193  * The HTLC value in milli-satoshi
5194  */
5195 uint64_t UpdateAddHTLC_get_amount_msat(const LDKUpdateAddHTLC *this_ptr);
5196
5197 /**
5198  * The HTLC value in milli-satoshi
5199  */
5200 void UpdateAddHTLC_set_amount_msat(LDKUpdateAddHTLC *this_ptr, uint64_t val);
5201
5202 /**
5203  * The payment hash, the pre-image of which controls HTLC redemption
5204  */
5205 const uint8_t (*UpdateAddHTLC_get_payment_hash(const LDKUpdateAddHTLC *this_ptr))[32];
5206
5207 /**
5208  * The payment hash, the pre-image of which controls HTLC redemption
5209  */
5210 void UpdateAddHTLC_set_payment_hash(LDKUpdateAddHTLC *this_ptr, LDKThirtyTwoBytes val);
5211
5212 /**
5213  * The expiry height of the HTLC
5214  */
5215 uint32_t UpdateAddHTLC_get_cltv_expiry(const LDKUpdateAddHTLC *this_ptr);
5216
5217 /**
5218  * The expiry height of the HTLC
5219  */
5220 void UpdateAddHTLC_set_cltv_expiry(LDKUpdateAddHTLC *this_ptr, uint32_t val);
5221
5222 void UpdateFulfillHTLC_free(LDKUpdateFulfillHTLC this_ptr);
5223
5224 LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const LDKUpdateFulfillHTLC *orig);
5225
5226 /**
5227  * The channel ID
5228  */
5229 const uint8_t (*UpdateFulfillHTLC_get_channel_id(const LDKUpdateFulfillHTLC *this_ptr))[32];
5230
5231 /**
5232  * The channel ID
5233  */
5234 void UpdateFulfillHTLC_set_channel_id(LDKUpdateFulfillHTLC *this_ptr, LDKThirtyTwoBytes val);
5235
5236 /**
5237  * The HTLC ID
5238  */
5239 uint64_t UpdateFulfillHTLC_get_htlc_id(const LDKUpdateFulfillHTLC *this_ptr);
5240
5241 /**
5242  * The HTLC ID
5243  */
5244 void UpdateFulfillHTLC_set_htlc_id(LDKUpdateFulfillHTLC *this_ptr, uint64_t val);
5245
5246 /**
5247  * The pre-image of the payment hash, allowing HTLC redemption
5248  */
5249 const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const LDKUpdateFulfillHTLC *this_ptr))[32];
5250
5251 /**
5252  * The pre-image of the payment hash, allowing HTLC redemption
5253  */
5254 void UpdateFulfillHTLC_set_payment_preimage(LDKUpdateFulfillHTLC *this_ptr, LDKThirtyTwoBytes val);
5255
5256 MUST_USE_RES LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, LDKThirtyTwoBytes payment_preimage_arg);
5257
5258 void UpdateFailHTLC_free(LDKUpdateFailHTLC this_ptr);
5259
5260 LDKUpdateFailHTLC UpdateFailHTLC_clone(const LDKUpdateFailHTLC *orig);
5261
5262 /**
5263  * The channel ID
5264  */
5265 const uint8_t (*UpdateFailHTLC_get_channel_id(const LDKUpdateFailHTLC *this_ptr))[32];
5266
5267 /**
5268  * The channel ID
5269  */
5270 void UpdateFailHTLC_set_channel_id(LDKUpdateFailHTLC *this_ptr, LDKThirtyTwoBytes val);
5271
5272 /**
5273  * The HTLC ID
5274  */
5275 uint64_t UpdateFailHTLC_get_htlc_id(const LDKUpdateFailHTLC *this_ptr);
5276
5277 /**
5278  * The HTLC ID
5279  */
5280 void UpdateFailHTLC_set_htlc_id(LDKUpdateFailHTLC *this_ptr, uint64_t val);
5281
5282 void UpdateFailMalformedHTLC_free(LDKUpdateFailMalformedHTLC this_ptr);
5283
5284 LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const LDKUpdateFailMalformedHTLC *orig);
5285
5286 /**
5287  * The channel ID
5288  */
5289 const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const LDKUpdateFailMalformedHTLC *this_ptr))[32];
5290
5291 /**
5292  * The channel ID
5293  */
5294 void UpdateFailMalformedHTLC_set_channel_id(LDKUpdateFailMalformedHTLC *this_ptr, LDKThirtyTwoBytes val);
5295
5296 /**
5297  * The HTLC ID
5298  */
5299 uint64_t UpdateFailMalformedHTLC_get_htlc_id(const LDKUpdateFailMalformedHTLC *this_ptr);
5300
5301 /**
5302  * The HTLC ID
5303  */
5304 void UpdateFailMalformedHTLC_set_htlc_id(LDKUpdateFailMalformedHTLC *this_ptr, uint64_t val);
5305
5306 /**
5307  * The failure code
5308  */
5309 uint16_t UpdateFailMalformedHTLC_get_failure_code(const LDKUpdateFailMalformedHTLC *this_ptr);
5310
5311 /**
5312  * The failure code
5313  */
5314 void UpdateFailMalformedHTLC_set_failure_code(LDKUpdateFailMalformedHTLC *this_ptr, uint16_t val);
5315
5316 void CommitmentSigned_free(LDKCommitmentSigned this_ptr);
5317
5318 LDKCommitmentSigned CommitmentSigned_clone(const LDKCommitmentSigned *orig);
5319
5320 /**
5321  * The channel ID
5322  */
5323 const uint8_t (*CommitmentSigned_get_channel_id(const LDKCommitmentSigned *this_ptr))[32];
5324
5325 /**
5326  * The channel ID
5327  */
5328 void CommitmentSigned_set_channel_id(LDKCommitmentSigned *this_ptr, LDKThirtyTwoBytes val);
5329
5330 /**
5331  * A signature on the commitment transaction
5332  */
5333 LDKSignature CommitmentSigned_get_signature(const LDKCommitmentSigned *this_ptr);
5334
5335 /**
5336  * A signature on the commitment transaction
5337  */
5338 void CommitmentSigned_set_signature(LDKCommitmentSigned *this_ptr, LDKSignature val);
5339
5340 /**
5341  * Signatures on the HTLC transactions
5342  */
5343 void CommitmentSigned_set_htlc_signatures(LDKCommitmentSigned *this_ptr, LDKCVec_SignatureZ val);
5344
5345 MUST_USE_RES LDKCommitmentSigned CommitmentSigned_new(LDKThirtyTwoBytes channel_id_arg, LDKSignature signature_arg, LDKCVec_SignatureZ htlc_signatures_arg);
5346
5347 void RevokeAndACK_free(LDKRevokeAndACK this_ptr);
5348
5349 LDKRevokeAndACK RevokeAndACK_clone(const LDKRevokeAndACK *orig);
5350
5351 /**
5352  * The channel ID
5353  */
5354 const uint8_t (*RevokeAndACK_get_channel_id(const LDKRevokeAndACK *this_ptr))[32];
5355
5356 /**
5357  * The channel ID
5358  */
5359 void RevokeAndACK_set_channel_id(LDKRevokeAndACK *this_ptr, LDKThirtyTwoBytes val);
5360
5361 /**
5362  * The secret corresponding to the per-commitment point
5363  */
5364 const uint8_t (*RevokeAndACK_get_per_commitment_secret(const LDKRevokeAndACK *this_ptr))[32];
5365
5366 /**
5367  * The secret corresponding to the per-commitment point
5368  */
5369 void RevokeAndACK_set_per_commitment_secret(LDKRevokeAndACK *this_ptr, LDKThirtyTwoBytes val);
5370
5371 /**
5372  * The next sender-broadcast commitment transaction's per-commitment point
5373  */
5374 LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const LDKRevokeAndACK *this_ptr);
5375
5376 /**
5377  * The next sender-broadcast commitment transaction's per-commitment point
5378  */
5379 void RevokeAndACK_set_next_per_commitment_point(LDKRevokeAndACK *this_ptr, LDKPublicKey val);
5380
5381 MUST_USE_RES LDKRevokeAndACK RevokeAndACK_new(LDKThirtyTwoBytes channel_id_arg, LDKThirtyTwoBytes per_commitment_secret_arg, LDKPublicKey next_per_commitment_point_arg);
5382
5383 void UpdateFee_free(LDKUpdateFee this_ptr);
5384
5385 LDKUpdateFee UpdateFee_clone(const LDKUpdateFee *orig);
5386
5387 /**
5388  * The channel ID
5389  */
5390 const uint8_t (*UpdateFee_get_channel_id(const LDKUpdateFee *this_ptr))[32];
5391
5392 /**
5393  * The channel ID
5394  */
5395 void UpdateFee_set_channel_id(LDKUpdateFee *this_ptr, LDKThirtyTwoBytes val);
5396
5397 /**
5398  * Fee rate per 1000-weight of the transaction
5399  */
5400 uint32_t UpdateFee_get_feerate_per_kw(const LDKUpdateFee *this_ptr);
5401
5402 /**
5403  * Fee rate per 1000-weight of the transaction
5404  */
5405 void UpdateFee_set_feerate_per_kw(LDKUpdateFee *this_ptr, uint32_t val);
5406
5407 MUST_USE_RES LDKUpdateFee UpdateFee_new(LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg);
5408
5409 void DataLossProtect_free(LDKDataLossProtect this_ptr);
5410
5411 LDKDataLossProtect DataLossProtect_clone(const LDKDataLossProtect *orig);
5412
5413 /**
5414  * Proof that the sender knows the per-commitment secret of a specific commitment transaction
5415  * belonging to the recipient
5416  */
5417 const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const LDKDataLossProtect *this_ptr))[32];
5418
5419 /**
5420  * Proof that the sender knows the per-commitment secret of a specific commitment transaction
5421  * belonging to the recipient
5422  */
5423 void DataLossProtect_set_your_last_per_commitment_secret(LDKDataLossProtect *this_ptr, LDKThirtyTwoBytes val);
5424
5425 /**
5426  * The sender's per-commitment point for their current commitment transaction
5427  */
5428 LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const LDKDataLossProtect *this_ptr);
5429
5430 /**
5431  * The sender's per-commitment point for their current commitment transaction
5432  */
5433 void DataLossProtect_set_my_current_per_commitment_point(LDKDataLossProtect *this_ptr, LDKPublicKey val);
5434
5435 MUST_USE_RES LDKDataLossProtect DataLossProtect_new(LDKThirtyTwoBytes your_last_per_commitment_secret_arg, LDKPublicKey my_current_per_commitment_point_arg);
5436
5437 void ChannelReestablish_free(LDKChannelReestablish this_ptr);
5438
5439 LDKChannelReestablish ChannelReestablish_clone(const LDKChannelReestablish *orig);
5440
5441 /**
5442  * The channel ID
5443  */
5444 const uint8_t (*ChannelReestablish_get_channel_id(const LDKChannelReestablish *this_ptr))[32];
5445
5446 /**
5447  * The channel ID
5448  */
5449 void ChannelReestablish_set_channel_id(LDKChannelReestablish *this_ptr, LDKThirtyTwoBytes val);
5450
5451 /**
5452  * The next commitment number for the sender
5453  */
5454 uint64_t ChannelReestablish_get_next_local_commitment_number(const LDKChannelReestablish *this_ptr);
5455
5456 /**
5457  * The next commitment number for the sender
5458  */
5459 void ChannelReestablish_set_next_local_commitment_number(LDKChannelReestablish *this_ptr, uint64_t val);
5460
5461 /**
5462  * The next commitment number for the recipient
5463  */
5464 uint64_t ChannelReestablish_get_next_remote_commitment_number(const LDKChannelReestablish *this_ptr);
5465
5466 /**
5467  * The next commitment number for the recipient
5468  */
5469 void ChannelReestablish_set_next_remote_commitment_number(LDKChannelReestablish *this_ptr, uint64_t val);
5470
5471 void AnnouncementSignatures_free(LDKAnnouncementSignatures this_ptr);
5472
5473 LDKAnnouncementSignatures AnnouncementSignatures_clone(const LDKAnnouncementSignatures *orig);
5474
5475 /**
5476  * The channel ID
5477  */
5478 const uint8_t (*AnnouncementSignatures_get_channel_id(const LDKAnnouncementSignatures *this_ptr))[32];
5479
5480 /**
5481  * The channel ID
5482  */
5483 void AnnouncementSignatures_set_channel_id(LDKAnnouncementSignatures *this_ptr, LDKThirtyTwoBytes val);
5484
5485 /**
5486  * The short channel ID
5487  */
5488 uint64_t AnnouncementSignatures_get_short_channel_id(const LDKAnnouncementSignatures *this_ptr);
5489
5490 /**
5491  * The short channel ID
5492  */
5493 void AnnouncementSignatures_set_short_channel_id(LDKAnnouncementSignatures *this_ptr, uint64_t val);
5494
5495 /**
5496  * A signature by the node key
5497  */
5498 LDKSignature AnnouncementSignatures_get_node_signature(const LDKAnnouncementSignatures *this_ptr);
5499
5500 /**
5501  * A signature by the node key
5502  */
5503 void AnnouncementSignatures_set_node_signature(LDKAnnouncementSignatures *this_ptr, LDKSignature val);
5504
5505 /**
5506  * A signature by the funding key
5507  */
5508 LDKSignature AnnouncementSignatures_get_bitcoin_signature(const LDKAnnouncementSignatures *this_ptr);
5509
5510 /**
5511  * A signature by the funding key
5512  */
5513 void AnnouncementSignatures_set_bitcoin_signature(LDKAnnouncementSignatures *this_ptr, LDKSignature val);
5514
5515 MUST_USE_RES LDKAnnouncementSignatures AnnouncementSignatures_new(LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, LDKSignature node_signature_arg, LDKSignature bitcoin_signature_arg);
5516
5517 void NetAddress_free(LDKNetAddress this_ptr);
5518
5519 LDKNetAddress NetAddress_clone(const LDKNetAddress *orig);
5520
5521 void UnsignedNodeAnnouncement_free(LDKUnsignedNodeAnnouncement this_ptr);
5522
5523 LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const LDKUnsignedNodeAnnouncement *orig);
5524
5525 /**
5526  * The advertised features
5527  */
5528 LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const LDKUnsignedNodeAnnouncement *this_ptr);
5529
5530 /**
5531  * The advertised features
5532  */
5533 void UnsignedNodeAnnouncement_set_features(LDKUnsignedNodeAnnouncement *this_ptr, LDKNodeFeatures val);
5534
5535 /**
5536  * A strictly monotonic announcement counter, with gaps allowed
5537  */
5538 uint32_t UnsignedNodeAnnouncement_get_timestamp(const LDKUnsignedNodeAnnouncement *this_ptr);
5539
5540 /**
5541  * A strictly monotonic announcement counter, with gaps allowed
5542  */
5543 void UnsignedNodeAnnouncement_set_timestamp(LDKUnsignedNodeAnnouncement *this_ptr, uint32_t val);
5544
5545 /**
5546  * The node_id this announcement originated from (don't rebroadcast the node_announcement back
5547  * to this node).
5548  */
5549 LDKPublicKey UnsignedNodeAnnouncement_get_node_id(const LDKUnsignedNodeAnnouncement *this_ptr);
5550
5551 /**
5552  * The node_id this announcement originated from (don't rebroadcast the node_announcement back
5553  * to this node).
5554  */
5555 void UnsignedNodeAnnouncement_set_node_id(LDKUnsignedNodeAnnouncement *this_ptr, LDKPublicKey val);
5556
5557 /**
5558  * An RGB color for UI purposes
5559  */
5560 const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const LDKUnsignedNodeAnnouncement *this_ptr))[3];
5561
5562 /**
5563  * An RGB color for UI purposes
5564  */
5565 void UnsignedNodeAnnouncement_set_rgb(LDKUnsignedNodeAnnouncement *this_ptr, LDKThreeBytes val);
5566
5567 /**
5568  * An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
5569  * of uniqueness.
5570  */
5571 const uint8_t (*UnsignedNodeAnnouncement_get_alias(const LDKUnsignedNodeAnnouncement *this_ptr))[32];
5572
5573 /**
5574  * An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
5575  * of uniqueness.
5576  */
5577 void UnsignedNodeAnnouncement_set_alias(LDKUnsignedNodeAnnouncement *this_ptr, LDKThirtyTwoBytes val);
5578
5579 /**
5580  * List of addresses on which this node is reachable
5581  */
5582 void UnsignedNodeAnnouncement_set_addresses(LDKUnsignedNodeAnnouncement *this_ptr, LDKCVec_NetAddressZ val);
5583
5584 void NodeAnnouncement_free(LDKNodeAnnouncement this_ptr);
5585
5586 LDKNodeAnnouncement NodeAnnouncement_clone(const LDKNodeAnnouncement *orig);
5587
5588 /**
5589  * The signature by the node key
5590  */
5591 LDKSignature NodeAnnouncement_get_signature(const LDKNodeAnnouncement *this_ptr);
5592
5593 /**
5594  * The signature by the node key
5595  */
5596 void NodeAnnouncement_set_signature(LDKNodeAnnouncement *this_ptr, LDKSignature val);
5597
5598 /**
5599  * The actual content of the announcement
5600  */
5601 LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const LDKNodeAnnouncement *this_ptr);
5602
5603 /**
5604  * The actual content of the announcement
5605  */
5606 void NodeAnnouncement_set_contents(LDKNodeAnnouncement *this_ptr, LDKUnsignedNodeAnnouncement val);
5607
5608 MUST_USE_RES LDKNodeAnnouncement NodeAnnouncement_new(LDKSignature signature_arg, LDKUnsignedNodeAnnouncement contents_arg);
5609
5610 void UnsignedChannelAnnouncement_free(LDKUnsignedChannelAnnouncement this_ptr);
5611
5612 LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const LDKUnsignedChannelAnnouncement *orig);
5613
5614 /**
5615  * The advertised channel features
5616  */
5617 LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const LDKUnsignedChannelAnnouncement *this_ptr);
5618
5619 /**
5620  * The advertised channel features
5621  */
5622 void UnsignedChannelAnnouncement_set_features(LDKUnsignedChannelAnnouncement *this_ptr, LDKChannelFeatures val);
5623
5624 /**
5625  * The genesis hash of the blockchain where the channel is to be opened
5626  */
5627 const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const LDKUnsignedChannelAnnouncement *this_ptr))[32];
5628
5629 /**
5630  * The genesis hash of the blockchain where the channel is to be opened
5631  */
5632 void UnsignedChannelAnnouncement_set_chain_hash(LDKUnsignedChannelAnnouncement *this_ptr, LDKThirtyTwoBytes val);
5633
5634 /**
5635  * The short channel ID
5636  */
5637 uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const LDKUnsignedChannelAnnouncement *this_ptr);
5638
5639 /**
5640  * The short channel ID
5641  */
5642 void UnsignedChannelAnnouncement_set_short_channel_id(LDKUnsignedChannelAnnouncement *this_ptr, uint64_t val);
5643
5644 /**
5645  * One of the two node_ids which are endpoints of this channel
5646  */
5647 LDKPublicKey UnsignedChannelAnnouncement_get_node_id_1(const LDKUnsignedChannelAnnouncement *this_ptr);
5648
5649 /**
5650  * One of the two node_ids which are endpoints of this channel
5651  */
5652 void UnsignedChannelAnnouncement_set_node_id_1(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val);
5653
5654 /**
5655  * The other of the two node_ids which are endpoints of this channel
5656  */
5657 LDKPublicKey UnsignedChannelAnnouncement_get_node_id_2(const LDKUnsignedChannelAnnouncement *this_ptr);
5658
5659 /**
5660  * The other of the two node_ids which are endpoints of this channel
5661  */
5662 void UnsignedChannelAnnouncement_set_node_id_2(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val);
5663
5664 /**
5665  * The funding key for the first node
5666  */
5667 LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_1(const LDKUnsignedChannelAnnouncement *this_ptr);
5668
5669 /**
5670  * The funding key for the first node
5671  */
5672 void UnsignedChannelAnnouncement_set_bitcoin_key_1(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val);
5673
5674 /**
5675  * The funding key for the second node
5676  */
5677 LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const LDKUnsignedChannelAnnouncement *this_ptr);
5678
5679 /**
5680  * The funding key for the second node
5681  */
5682 void UnsignedChannelAnnouncement_set_bitcoin_key_2(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val);
5683
5684 void ChannelAnnouncement_free(LDKChannelAnnouncement this_ptr);
5685
5686 LDKChannelAnnouncement ChannelAnnouncement_clone(const LDKChannelAnnouncement *orig);
5687
5688 /**
5689  * Authentication of the announcement by the first public node
5690  */
5691 LDKSignature ChannelAnnouncement_get_node_signature_1(const LDKChannelAnnouncement *this_ptr);
5692
5693 /**
5694  * Authentication of the announcement by the first public node
5695  */
5696 void ChannelAnnouncement_set_node_signature_1(LDKChannelAnnouncement *this_ptr, LDKSignature val);
5697
5698 /**
5699  * Authentication of the announcement by the second public node
5700  */
5701 LDKSignature ChannelAnnouncement_get_node_signature_2(const LDKChannelAnnouncement *this_ptr);
5702
5703 /**
5704  * Authentication of the announcement by the second public node
5705  */
5706 void ChannelAnnouncement_set_node_signature_2(LDKChannelAnnouncement *this_ptr, LDKSignature val);
5707
5708 /**
5709  * Proof of funding UTXO ownership by the first public node
5710  */
5711 LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const LDKChannelAnnouncement *this_ptr);
5712
5713 /**
5714  * Proof of funding UTXO ownership by the first public node
5715  */
5716 void ChannelAnnouncement_set_bitcoin_signature_1(LDKChannelAnnouncement *this_ptr, LDKSignature val);
5717
5718 /**
5719  * Proof of funding UTXO ownership by the second public node
5720  */
5721 LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const LDKChannelAnnouncement *this_ptr);
5722
5723 /**
5724  * Proof of funding UTXO ownership by the second public node
5725  */
5726 void ChannelAnnouncement_set_bitcoin_signature_2(LDKChannelAnnouncement *this_ptr, LDKSignature val);
5727
5728 /**
5729  * The actual announcement
5730  */
5731 LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const LDKChannelAnnouncement *this_ptr);
5732
5733 /**
5734  * The actual announcement
5735  */
5736 void ChannelAnnouncement_set_contents(LDKChannelAnnouncement *this_ptr, LDKUnsignedChannelAnnouncement val);
5737
5738 MUST_USE_RES LDKChannelAnnouncement ChannelAnnouncement_new(LDKSignature node_signature_1_arg, LDKSignature node_signature_2_arg, LDKSignature bitcoin_signature_1_arg, LDKSignature bitcoin_signature_2_arg, LDKUnsignedChannelAnnouncement contents_arg);
5739
5740 void UnsignedChannelUpdate_free(LDKUnsignedChannelUpdate this_ptr);
5741
5742 LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const LDKUnsignedChannelUpdate *orig);
5743
5744 /**
5745  * The genesis hash of the blockchain where the channel is to be opened
5746  */
5747 const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const LDKUnsignedChannelUpdate *this_ptr))[32];
5748
5749 /**
5750  * The genesis hash of the blockchain where the channel is to be opened
5751  */
5752 void UnsignedChannelUpdate_set_chain_hash(LDKUnsignedChannelUpdate *this_ptr, LDKThirtyTwoBytes val);
5753
5754 /**
5755  * The short channel ID
5756  */
5757 uint64_t UnsignedChannelUpdate_get_short_channel_id(const LDKUnsignedChannelUpdate *this_ptr);
5758
5759 /**
5760  * The short channel ID
5761  */
5762 void UnsignedChannelUpdate_set_short_channel_id(LDKUnsignedChannelUpdate *this_ptr, uint64_t val);
5763
5764 /**
5765  * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
5766  */
5767 uint32_t UnsignedChannelUpdate_get_timestamp(const LDKUnsignedChannelUpdate *this_ptr);
5768
5769 /**
5770  * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
5771  */
5772 void UnsignedChannelUpdate_set_timestamp(LDKUnsignedChannelUpdate *this_ptr, uint32_t val);
5773
5774 /**
5775  * Channel flags
5776  */
5777 uint8_t UnsignedChannelUpdate_get_flags(const LDKUnsignedChannelUpdate *this_ptr);
5778
5779 /**
5780  * Channel flags
5781  */
5782 void UnsignedChannelUpdate_set_flags(LDKUnsignedChannelUpdate *this_ptr, uint8_t val);
5783
5784 /**
5785  * The number of blocks to subtract from incoming HTLC cltv_expiry values
5786  */
5787 uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const LDKUnsignedChannelUpdate *this_ptr);
5788
5789 /**
5790  * The number of blocks to subtract from incoming HTLC cltv_expiry values
5791  */
5792 void UnsignedChannelUpdate_set_cltv_expiry_delta(LDKUnsignedChannelUpdate *this_ptr, uint16_t val);
5793
5794 /**
5795  * The minimum HTLC size incoming to sender, in milli-satoshi
5796  */
5797 uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const LDKUnsignedChannelUpdate *this_ptr);
5798
5799 /**
5800  * The minimum HTLC size incoming to sender, in milli-satoshi
5801  */
5802 void UnsignedChannelUpdate_set_htlc_minimum_msat(LDKUnsignedChannelUpdate *this_ptr, uint64_t val);
5803
5804 /**
5805  * The base HTLC fee charged by sender, in milli-satoshi
5806  */
5807 uint32_t UnsignedChannelUpdate_get_fee_base_msat(const LDKUnsignedChannelUpdate *this_ptr);
5808
5809 /**
5810  * The base HTLC fee charged by sender, in milli-satoshi
5811  */
5812 void UnsignedChannelUpdate_set_fee_base_msat(LDKUnsignedChannelUpdate *this_ptr, uint32_t val);
5813
5814 /**
5815  * The amount to fee multiplier, in micro-satoshi
5816  */
5817 uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const LDKUnsignedChannelUpdate *this_ptr);
5818
5819 /**
5820  * The amount to fee multiplier, in micro-satoshi
5821  */
5822 void UnsignedChannelUpdate_set_fee_proportional_millionths(LDKUnsignedChannelUpdate *this_ptr, uint32_t val);
5823
5824 void ChannelUpdate_free(LDKChannelUpdate this_ptr);
5825
5826 LDKChannelUpdate ChannelUpdate_clone(const LDKChannelUpdate *orig);
5827
5828 /**
5829  * A signature of the channel update
5830  */
5831 LDKSignature ChannelUpdate_get_signature(const LDKChannelUpdate *this_ptr);
5832
5833 /**
5834  * A signature of the channel update
5835  */
5836 void ChannelUpdate_set_signature(LDKChannelUpdate *this_ptr, LDKSignature val);
5837
5838 /**
5839  * The actual channel update
5840  */
5841 LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const LDKChannelUpdate *this_ptr);
5842
5843 /**
5844  * The actual channel update
5845  */
5846 void ChannelUpdate_set_contents(LDKChannelUpdate *this_ptr, LDKUnsignedChannelUpdate val);
5847
5848 MUST_USE_RES LDKChannelUpdate ChannelUpdate_new(LDKSignature signature_arg, LDKUnsignedChannelUpdate contents_arg);
5849
5850 void QueryChannelRange_free(LDKQueryChannelRange this_ptr);
5851
5852 LDKQueryChannelRange QueryChannelRange_clone(const LDKQueryChannelRange *orig);
5853
5854 /**
5855  * The genesis hash of the blockchain being queried
5856  */
5857 const uint8_t (*QueryChannelRange_get_chain_hash(const LDKQueryChannelRange *this_ptr))[32];
5858
5859 /**
5860  * The genesis hash of the blockchain being queried
5861  */
5862 void QueryChannelRange_set_chain_hash(LDKQueryChannelRange *this_ptr, LDKThirtyTwoBytes val);
5863
5864 /**
5865  * The height of the first block for the channel UTXOs being queried
5866  */
5867 uint32_t QueryChannelRange_get_first_blocknum(const LDKQueryChannelRange *this_ptr);
5868
5869 /**
5870  * The height of the first block for the channel UTXOs being queried
5871  */
5872 void QueryChannelRange_set_first_blocknum(LDKQueryChannelRange *this_ptr, uint32_t val);
5873
5874 /**
5875  * The number of blocks to include in the query results
5876  */
5877 uint32_t QueryChannelRange_get_number_of_blocks(const LDKQueryChannelRange *this_ptr);
5878
5879 /**
5880  * The number of blocks to include in the query results
5881  */
5882 void QueryChannelRange_set_number_of_blocks(LDKQueryChannelRange *this_ptr, uint32_t val);
5883
5884 MUST_USE_RES LDKQueryChannelRange QueryChannelRange_new(LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg);
5885
5886 void ReplyChannelRange_free(LDKReplyChannelRange this_ptr);
5887
5888 LDKReplyChannelRange ReplyChannelRange_clone(const LDKReplyChannelRange *orig);
5889
5890 /**
5891  * The genesis hash of the blockchain being queried
5892  */
5893 const uint8_t (*ReplyChannelRange_get_chain_hash(const LDKReplyChannelRange *this_ptr))[32];
5894
5895 /**
5896  * The genesis hash of the blockchain being queried
5897  */
5898 void ReplyChannelRange_set_chain_hash(LDKReplyChannelRange *this_ptr, LDKThirtyTwoBytes val);
5899
5900 /**
5901  * The height of the first block in the range of the reply
5902  */
5903 uint32_t ReplyChannelRange_get_first_blocknum(const LDKReplyChannelRange *this_ptr);
5904
5905 /**
5906  * The height of the first block in the range of the reply
5907  */
5908 void ReplyChannelRange_set_first_blocknum(LDKReplyChannelRange *this_ptr, uint32_t val);
5909
5910 /**
5911  * The number of blocks included in the range of the reply
5912  */
5913 uint32_t ReplyChannelRange_get_number_of_blocks(const LDKReplyChannelRange *this_ptr);
5914
5915 /**
5916  * The number of blocks included in the range of the reply
5917  */
5918 void ReplyChannelRange_set_number_of_blocks(LDKReplyChannelRange *this_ptr, uint32_t val);
5919
5920 /**
5921  * Indicates if the query recipient maintains up-to-date channel
5922  * information for the chain_hash
5923  */
5924 bool ReplyChannelRange_get_full_information(const LDKReplyChannelRange *this_ptr);
5925
5926 /**
5927  * Indicates if the query recipient maintains up-to-date channel
5928  * information for the chain_hash
5929  */
5930 void ReplyChannelRange_set_full_information(LDKReplyChannelRange *this_ptr, bool val);
5931
5932 /**
5933  * The short_channel_ids in the channel range
5934  */
5935 void ReplyChannelRange_set_short_channel_ids(LDKReplyChannelRange *this_ptr, LDKCVec_u64Z val);
5936
5937 MUST_USE_RES LDKReplyChannelRange ReplyChannelRange_new(LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool full_information_arg, LDKCVec_u64Z short_channel_ids_arg);
5938
5939 void QueryShortChannelIds_free(LDKQueryShortChannelIds this_ptr);
5940
5941 LDKQueryShortChannelIds QueryShortChannelIds_clone(const LDKQueryShortChannelIds *orig);
5942
5943 /**
5944  * The genesis hash of the blockchain being queried
5945  */
5946 const uint8_t (*QueryShortChannelIds_get_chain_hash(const LDKQueryShortChannelIds *this_ptr))[32];
5947
5948 /**
5949  * The genesis hash of the blockchain being queried
5950  */
5951 void QueryShortChannelIds_set_chain_hash(LDKQueryShortChannelIds *this_ptr, LDKThirtyTwoBytes val);
5952
5953 /**
5954  * The short_channel_ids that are being queried
5955  */
5956 void QueryShortChannelIds_set_short_channel_ids(LDKQueryShortChannelIds *this_ptr, LDKCVec_u64Z val);
5957
5958 MUST_USE_RES LDKQueryShortChannelIds QueryShortChannelIds_new(LDKThirtyTwoBytes chain_hash_arg, LDKCVec_u64Z short_channel_ids_arg);
5959
5960 void ReplyShortChannelIdsEnd_free(LDKReplyShortChannelIdsEnd this_ptr);
5961
5962 LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const LDKReplyShortChannelIdsEnd *orig);
5963
5964 /**
5965  * The genesis hash of the blockchain that was queried
5966  */
5967 const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const LDKReplyShortChannelIdsEnd *this_ptr))[32];
5968
5969 /**
5970  * The genesis hash of the blockchain that was queried
5971  */
5972 void ReplyShortChannelIdsEnd_set_chain_hash(LDKReplyShortChannelIdsEnd *this_ptr, LDKThirtyTwoBytes val);
5973
5974 /**
5975  * Indicates if the query recipient maintains up-to-date channel
5976  * information for the chain_hash
5977  */
5978 bool ReplyShortChannelIdsEnd_get_full_information(const LDKReplyShortChannelIdsEnd *this_ptr);
5979
5980 /**
5981  * Indicates if the query recipient maintains up-to-date channel
5982  * information for the chain_hash
5983  */
5984 void ReplyShortChannelIdsEnd_set_full_information(LDKReplyShortChannelIdsEnd *this_ptr, bool val);
5985
5986 MUST_USE_RES LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg);
5987
5988 void GossipTimestampFilter_free(LDKGossipTimestampFilter this_ptr);
5989
5990 LDKGossipTimestampFilter GossipTimestampFilter_clone(const LDKGossipTimestampFilter *orig);
5991
5992 /**
5993  * The genesis hash of the blockchain for channel and node information
5994  */
5995 const uint8_t (*GossipTimestampFilter_get_chain_hash(const LDKGossipTimestampFilter *this_ptr))[32];
5996
5997 /**
5998  * The genesis hash of the blockchain for channel and node information
5999  */
6000 void GossipTimestampFilter_set_chain_hash(LDKGossipTimestampFilter *this_ptr, LDKThirtyTwoBytes val);
6001
6002 /**
6003  * The starting unix timestamp
6004  */
6005 uint32_t GossipTimestampFilter_get_first_timestamp(const LDKGossipTimestampFilter *this_ptr);
6006
6007 /**
6008  * The starting unix timestamp
6009  */
6010 void GossipTimestampFilter_set_first_timestamp(LDKGossipTimestampFilter *this_ptr, uint32_t val);
6011
6012 /**
6013  * The range of information in seconds
6014  */
6015 uint32_t GossipTimestampFilter_get_timestamp_range(const LDKGossipTimestampFilter *this_ptr);
6016
6017 /**
6018  * The range of information in seconds
6019  */
6020 void GossipTimestampFilter_set_timestamp_range(LDKGossipTimestampFilter *this_ptr, uint32_t val);
6021
6022 MUST_USE_RES LDKGossipTimestampFilter GossipTimestampFilter_new(LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg);
6023
6024 void ErrorAction_free(LDKErrorAction this_ptr);
6025
6026 LDKErrorAction ErrorAction_clone(const LDKErrorAction *orig);
6027
6028 void LightningError_free(LDKLightningError this_ptr);
6029
6030 /**
6031  * A human-readable message describing the error
6032  */
6033 LDKStr LightningError_get_err(const LDKLightningError *this_ptr);
6034
6035 /**
6036  * A human-readable message describing the error
6037  */
6038 void LightningError_set_err(LDKLightningError *this_ptr, LDKCVec_u8Z val);
6039
6040 /**
6041  * The action which should be taken against the offending peer.
6042  */
6043 LDKErrorAction LightningError_get_action(const LDKLightningError *this_ptr);
6044
6045 /**
6046  * The action which should be taken against the offending peer.
6047  */
6048 void LightningError_set_action(LDKLightningError *this_ptr, LDKErrorAction val);
6049
6050 MUST_USE_RES LDKLightningError LightningError_new(LDKCVec_u8Z err_arg, LDKErrorAction action_arg);
6051
6052 void CommitmentUpdate_free(LDKCommitmentUpdate this_ptr);
6053
6054 LDKCommitmentUpdate CommitmentUpdate_clone(const LDKCommitmentUpdate *orig);
6055
6056 /**
6057  * update_add_htlc messages which should be sent
6058  */
6059 void CommitmentUpdate_set_update_add_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateAddHTLCZ val);
6060
6061 /**
6062  * update_fulfill_htlc messages which should be sent
6063  */
6064 void CommitmentUpdate_set_update_fulfill_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFulfillHTLCZ val);
6065
6066 /**
6067  * update_fail_htlc messages which should be sent
6068  */
6069 void CommitmentUpdate_set_update_fail_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailHTLCZ val);
6070
6071 /**
6072  * update_fail_malformed_htlc messages which should be sent
6073  */
6074 void CommitmentUpdate_set_update_fail_malformed_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailMalformedHTLCZ val);
6075
6076 /**
6077  * An update_fee message which should be sent
6078  */
6079 LDKUpdateFee CommitmentUpdate_get_update_fee(const LDKCommitmentUpdate *this_ptr);
6080
6081 /**
6082  * An update_fee message which should be sent
6083  */
6084 void CommitmentUpdate_set_update_fee(LDKCommitmentUpdate *this_ptr, LDKUpdateFee val);
6085
6086 /**
6087  * Finally, the commitment_signed message which should be sent
6088  */
6089 LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const LDKCommitmentUpdate *this_ptr);
6090
6091 /**
6092  * Finally, the commitment_signed message which should be sent
6093  */
6094 void CommitmentUpdate_set_commitment_signed(LDKCommitmentUpdate *this_ptr, LDKCommitmentSigned val);
6095
6096 MUST_USE_RES LDKCommitmentUpdate CommitmentUpdate_new(LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, LDKUpdateFee update_fee_arg, LDKCommitmentSigned commitment_signed_arg);
6097
6098 void HTLCFailChannelUpdate_free(LDKHTLCFailChannelUpdate this_ptr);
6099
6100 LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const LDKHTLCFailChannelUpdate *orig);
6101
6102 /**
6103  * Calls the free function if one is set
6104  */
6105 void ChannelMessageHandler_free(LDKChannelMessageHandler this_ptr);
6106
6107 /**
6108  * Calls the free function if one is set
6109  */
6110 void RoutingMessageHandler_free(LDKRoutingMessageHandler this_ptr);
6111
6112 LDKCVec_u8Z AcceptChannel_write(const LDKAcceptChannel *obj);
6113
6114 LDKAcceptChannel AcceptChannel_read(LDKu8slice ser);
6115
6116 LDKCVec_u8Z AnnouncementSignatures_write(const LDKAnnouncementSignatures *obj);
6117
6118 LDKAnnouncementSignatures AnnouncementSignatures_read(LDKu8slice ser);
6119
6120 LDKCVec_u8Z ChannelReestablish_write(const LDKChannelReestablish *obj);
6121
6122 LDKChannelReestablish ChannelReestablish_read(LDKu8slice ser);
6123
6124 LDKCVec_u8Z ClosingSigned_write(const LDKClosingSigned *obj);
6125
6126 LDKClosingSigned ClosingSigned_read(LDKu8slice ser);
6127
6128 LDKCVec_u8Z CommitmentSigned_write(const LDKCommitmentSigned *obj);
6129
6130 LDKCommitmentSigned CommitmentSigned_read(LDKu8slice ser);
6131
6132 LDKCVec_u8Z FundingCreated_write(const LDKFundingCreated *obj);
6133
6134 LDKFundingCreated FundingCreated_read(LDKu8slice ser);
6135
6136 LDKCVec_u8Z FundingSigned_write(const LDKFundingSigned *obj);
6137
6138 LDKFundingSigned FundingSigned_read(LDKu8slice ser);
6139
6140 LDKCVec_u8Z FundingLocked_write(const LDKFundingLocked *obj);
6141
6142 LDKFundingLocked FundingLocked_read(LDKu8slice ser);
6143
6144 LDKCVec_u8Z Init_write(const LDKInit *obj);
6145
6146 LDKInit Init_read(LDKu8slice ser);
6147
6148 LDKCVec_u8Z OpenChannel_write(const LDKOpenChannel *obj);
6149
6150 LDKOpenChannel OpenChannel_read(LDKu8slice ser);
6151
6152 LDKCVec_u8Z RevokeAndACK_write(const LDKRevokeAndACK *obj);
6153
6154 LDKRevokeAndACK RevokeAndACK_read(LDKu8slice ser);
6155
6156 LDKCVec_u8Z Shutdown_write(const LDKShutdown *obj);
6157
6158 LDKShutdown Shutdown_read(LDKu8slice ser);
6159
6160 LDKCVec_u8Z UpdateFailHTLC_write(const LDKUpdateFailHTLC *obj);
6161
6162 LDKUpdateFailHTLC UpdateFailHTLC_read(LDKu8slice ser);
6163
6164 LDKCVec_u8Z UpdateFailMalformedHTLC_write(const LDKUpdateFailMalformedHTLC *obj);
6165
6166 LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_read(LDKu8slice ser);
6167
6168 LDKCVec_u8Z UpdateFee_write(const LDKUpdateFee *obj);
6169
6170 LDKUpdateFee UpdateFee_read(LDKu8slice ser);
6171
6172 LDKCVec_u8Z UpdateFulfillHTLC_write(const LDKUpdateFulfillHTLC *obj);
6173
6174 LDKUpdateFulfillHTLC UpdateFulfillHTLC_read(LDKu8slice ser);
6175
6176 LDKCVec_u8Z UpdateAddHTLC_write(const LDKUpdateAddHTLC *obj);
6177
6178 LDKUpdateAddHTLC UpdateAddHTLC_read(LDKu8slice ser);
6179
6180 LDKCVec_u8Z Ping_write(const LDKPing *obj);
6181
6182 LDKPing Ping_read(LDKu8slice ser);
6183
6184 LDKCVec_u8Z Pong_write(const LDKPong *obj);
6185
6186 LDKPong Pong_read(LDKu8slice ser);
6187
6188 LDKCVec_u8Z UnsignedChannelAnnouncement_write(const LDKUnsignedChannelAnnouncement *obj);
6189
6190 LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_read(LDKu8slice ser);
6191
6192 LDKCVec_u8Z ChannelAnnouncement_write(const LDKChannelAnnouncement *obj);
6193
6194 LDKChannelAnnouncement ChannelAnnouncement_read(LDKu8slice ser);
6195
6196 LDKCVec_u8Z UnsignedChannelUpdate_write(const LDKUnsignedChannelUpdate *obj);
6197
6198 LDKUnsignedChannelUpdate UnsignedChannelUpdate_read(LDKu8slice ser);
6199
6200 LDKCVec_u8Z ChannelUpdate_write(const LDKChannelUpdate *obj);
6201
6202 LDKChannelUpdate ChannelUpdate_read(LDKu8slice ser);
6203
6204 LDKCVec_u8Z ErrorMessage_write(const LDKErrorMessage *obj);
6205
6206 LDKErrorMessage ErrorMessage_read(LDKu8slice ser);
6207
6208 LDKCVec_u8Z UnsignedNodeAnnouncement_write(const LDKUnsignedNodeAnnouncement *obj);
6209
6210 LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_read(LDKu8slice ser);
6211
6212 LDKCVec_u8Z NodeAnnouncement_write(const LDKNodeAnnouncement *obj);
6213
6214 LDKNodeAnnouncement NodeAnnouncement_read(LDKu8slice ser);
6215
6216 LDKQueryShortChannelIds QueryShortChannelIds_read(LDKu8slice ser);
6217
6218 LDKCVec_u8Z QueryShortChannelIds_write(const LDKQueryShortChannelIds *obj);
6219
6220 LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_read(LDKu8slice ser);
6221
6222 LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const LDKReplyShortChannelIdsEnd *obj);
6223
6224 LDKQueryChannelRange QueryChannelRange_read(LDKu8slice ser);
6225
6226 LDKCVec_u8Z QueryChannelRange_write(const LDKQueryChannelRange *obj);
6227
6228 LDKReplyChannelRange ReplyChannelRange_read(LDKu8slice ser);
6229
6230 LDKCVec_u8Z ReplyChannelRange_write(const LDKReplyChannelRange *obj);
6231
6232 LDKGossipTimestampFilter GossipTimestampFilter_read(LDKu8slice ser);
6233
6234 LDKCVec_u8Z GossipTimestampFilter_write(const LDKGossipTimestampFilter *obj);
6235
6236 void MessageHandler_free(LDKMessageHandler this_ptr);
6237
6238 /**
6239  * A message handler which handles messages specific to channels. Usually this is just a
6240  * ChannelManager object.
6241  */
6242 const LDKChannelMessageHandler *MessageHandler_get_chan_handler(const LDKMessageHandler *this_ptr);
6243
6244 /**
6245  * A message handler which handles messages specific to channels. Usually this is just a
6246  * ChannelManager object.
6247  */
6248 void MessageHandler_set_chan_handler(LDKMessageHandler *this_ptr, LDKChannelMessageHandler val);
6249
6250 /**
6251  * A message handler which handles messages updating our knowledge of the network channel
6252  * graph. Usually this is just a NetGraphMsgHandlerMonitor object.
6253  */
6254 const LDKRoutingMessageHandler *MessageHandler_get_route_handler(const LDKMessageHandler *this_ptr);
6255
6256 /**
6257  * A message handler which handles messages updating our knowledge of the network channel
6258  * graph. Usually this is just a NetGraphMsgHandlerMonitor object.
6259  */
6260 void MessageHandler_set_route_handler(LDKMessageHandler *this_ptr, LDKRoutingMessageHandler val);
6261
6262 MUST_USE_RES LDKMessageHandler MessageHandler_new(LDKChannelMessageHandler chan_handler_arg, LDKRoutingMessageHandler route_handler_arg);
6263
6264 LDKSocketDescriptor SocketDescriptor_clone(const LDKSocketDescriptor *orig);
6265
6266 /**
6267  * Calls the free function if one is set
6268  */
6269 void SocketDescriptor_free(LDKSocketDescriptor this_ptr);
6270
6271 void PeerHandleError_free(LDKPeerHandleError this_ptr);
6272
6273 /**
6274  * Used to indicate that we probably can't make any future connections to this peer, implying
6275  * we should go ahead and force-close any channels we have with it.
6276  */
6277 bool PeerHandleError_get_no_connection_possible(const LDKPeerHandleError *this_ptr);
6278
6279 /**
6280  * Used to indicate that we probably can't make any future connections to this peer, implying
6281  * we should go ahead and force-close any channels we have with it.
6282  */
6283 void PeerHandleError_set_no_connection_possible(LDKPeerHandleError *this_ptr, bool val);
6284
6285 MUST_USE_RES LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg);
6286
6287 void PeerManager_free(LDKPeerManager this_ptr);
6288
6289 /**
6290  * Constructs a new PeerManager with the given message handlers and node_id secret key
6291  * ephemeral_random_data is used to derive per-connection ephemeral keys and must be
6292  * cryptographically secure random bytes.
6293  */
6294 MUST_USE_RES LDKPeerManager PeerManager_new(LDKMessageHandler message_handler, LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], LDKLogger logger);
6295
6296 /**
6297  * Get the list of node ids for peers which have completed the initial handshake.
6298  *
6299  * For outbound connections, this will be the same as the their_node_id parameter passed in to
6300  * new_outbound_connection, however entries will only appear once the initial handshake has
6301  * completed and we are sure the remote peer has the private key for the given node_id.
6302  */
6303 MUST_USE_RES LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const LDKPeerManager *this_arg);
6304
6305 /**
6306  * Indicates a new outbound connection has been established to a node with the given node_id.
6307  * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new
6308  * descriptor but must disconnect the connection immediately.
6309  *
6310  * Returns a small number of bytes to send to the remote node (currently always 50).
6311  *
6312  * Panics if descriptor is duplicative with some other descriptor which has not yet had a
6313  * socket_disconnected().
6314  */
6315 MUST_USE_RES LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const LDKPeerManager *this_arg, LDKPublicKey their_node_id, LDKSocketDescriptor descriptor);
6316
6317 /**
6318  * Indicates a new inbound connection has been established.
6319  *
6320  * May refuse the connection by returning an Err, but will never write bytes to the remote end
6321  * (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT
6322  * call socket_disconnected for the new descriptor but must disconnect the connection
6323  * immediately.
6324  *
6325  * Panics if descriptor is duplicative with some other descriptor which has not yet had
6326  * socket_disconnected called.
6327  */
6328 MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const LDKPeerManager *this_arg, LDKSocketDescriptor descriptor);
6329
6330 /**
6331  * Indicates that there is room to write data to the given socket descriptor.
6332  *
6333  * May return an Err to indicate that the connection should be closed.
6334  *
6335  * Will most likely call send_data on the descriptor passed in (or the descriptor handed into
6336  * new_*\\_connection) before returning. Thus, be very careful with reentrancy issues! The
6337  * invariants around calling write_buffer_space_avail in case a write did not fully complete
6338  * must still hold - be ready to call write_buffer_space_avail again if a write call generated
6339  * here isn't sufficient! Panics if the descriptor was not previously registered in a
6340  * new_\\*_connection event.
6341  */
6342 MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const LDKPeerManager *this_arg, LDKSocketDescriptor *descriptor);
6343
6344 /**
6345  * Indicates that data was read from the given socket descriptor.
6346  *
6347  * May return an Err to indicate that the connection should be closed.
6348  *
6349  * Will *not* call back into send_data on any descriptors to avoid reentrancy complexity.
6350  * Thus, however, you almost certainly want to call process_events() after any read_event to
6351  * generate send_data calls to handle responses.
6352  *
6353  * If Ok(true) is returned, further read_events should not be triggered until a send_data call
6354  * on this file descriptor has resume_read set (preventing DoS issues in the send buffer).
6355  *
6356  * Panics if the descriptor was not previously registered in a new_*_connection event.
6357  */
6358 MUST_USE_RES LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const LDKPeerManager *this_arg, LDKSocketDescriptor *peer_descriptor, LDKu8slice data);
6359
6360 /**
6361  * Checks for any events generated by our handlers and processes them. Includes sending most
6362  * response messages as well as messages generated by calls to handler functions directly (eg
6363  * functions like ChannelManager::process_pending_htlc_forward or send_payment).
6364  */
6365 void PeerManager_process_events(const LDKPeerManager *this_arg);
6366
6367 /**
6368  * Indicates that the given socket descriptor's connection is now closed.
6369  *
6370  * This must only be called if the socket has been disconnected by the peer or your own
6371  * decision to disconnect it and must NOT be called in any case where other parts of this
6372  * library (eg PeerHandleError, explicit disconnect_socket calls) instruct you to disconnect
6373  * the peer.
6374  *
6375  * Panics if the descriptor was not previously registered in a successful new_*_connection event.
6376  */
6377 void PeerManager_socket_disconnected(const LDKPeerManager *this_arg, const LDKSocketDescriptor *descriptor);
6378
6379 /**
6380  * This function should be called roughly once every 30 seconds.
6381  * It will send pings to each peer and disconnect those which did not respond to the last round of pings.
6382  * Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues!
6383  */
6384 void PeerManager_timer_tick_occured(const LDKPeerManager *this_arg);
6385
6386 /**
6387  * Build the commitment secret from the seed and the commitment number
6388  */
6389 LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx);
6390
6391 /**
6392  * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
6393  * from the base secret and the per_commitment_point.
6394  *
6395  * Note that this is infallible iff we trust that at least one of the two input keys are randomly
6396  * generated (ie our own).
6397  */
6398 LDKCResult_SecretKeySecpErrorZ derive_private_key(LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]);
6399
6400 /**
6401  * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
6402  * from the base point and the per_commitment_key. This is the public equivalent of
6403  * derive_private_key - using only public keys to derive a public key instead of private keys.
6404  *
6405  * Note that this is infallible iff we trust that at least one of the two input keys are randomly
6406  * generated (ie our own).
6407  */
6408 LDKCResult_PublicKeySecpErrorZ derive_public_key(LDKPublicKey per_commitment_point, LDKPublicKey base_point);
6409
6410 /**
6411  * Derives a per-commitment-transaction revocation key from its constituent parts.
6412  *
6413  * Only the cheating participant owns a valid witness to propagate a revoked
6414  * commitment transaction, thus per_commitment_secret always come from cheater
6415  * and revocation_base_secret always come from punisher, which is the broadcaster
6416  * of the transaction spending with this key knowledge.
6417  *
6418  * Note that this is infallible iff we trust that at least one of the two input keys are randomly
6419  * generated (ie our own).
6420  */
6421 LDKCResult_SecretKeySecpErrorZ derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]);
6422
6423 /**
6424  * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
6425  * the public equivalend of derive_private_revocation_key - using only public keys to derive a
6426  * public key instead of private keys.
6427  *
6428  * Only the cheating participant owns a valid witness to propagate a revoked
6429  * commitment transaction, thus per_commitment_point always come from cheater
6430  * and revocation_base_point always come from punisher, which is the broadcaster
6431  * of the transaction spending with this key knowledge.
6432  *
6433  * Note that this is infallible iff we trust that at least one of the two input keys are randomly
6434  * generated (ie our own).
6435  */
6436 LDKCResult_PublicKeySecpErrorZ derive_public_revocation_key(LDKPublicKey per_commitment_point, LDKPublicKey countersignatory_revocation_base_point);
6437
6438 void TxCreationKeys_free(LDKTxCreationKeys this_ptr);
6439
6440 LDKTxCreationKeys TxCreationKeys_clone(const LDKTxCreationKeys *orig);
6441
6442 /**
6443  * The broadcaster's per-commitment public key which was used to derive the other keys.
6444  */
6445 LDKPublicKey TxCreationKeys_get_per_commitment_point(const LDKTxCreationKeys *this_ptr);
6446
6447 /**
6448  * The broadcaster's per-commitment public key which was used to derive the other keys.
6449  */
6450 void TxCreationKeys_set_per_commitment_point(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
6451
6452 /**
6453  * The revocation key which is used to allow the broadcaster of the commitment
6454  * transaction to provide their counterparty the ability to punish them if they broadcast
6455  * an old state.
6456  */
6457 LDKPublicKey TxCreationKeys_get_revocation_key(const LDKTxCreationKeys *this_ptr);
6458
6459 /**
6460  * The revocation key which is used to allow the broadcaster of the commitment
6461  * transaction to provide their counterparty the ability to punish them if they broadcast
6462  * an old state.
6463  */
6464 void TxCreationKeys_set_revocation_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
6465
6466 /**
6467  * Broadcaster's HTLC Key
6468  */
6469 LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const LDKTxCreationKeys *this_ptr);
6470
6471 /**
6472  * Broadcaster's HTLC Key
6473  */
6474 void TxCreationKeys_set_broadcaster_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
6475
6476 /**
6477  * Countersignatory's HTLC Key
6478  */
6479 LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const LDKTxCreationKeys *this_ptr);
6480
6481 /**
6482  * Countersignatory's HTLC Key
6483  */
6484 void TxCreationKeys_set_countersignatory_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
6485
6486 /**
6487  * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
6488  */
6489 LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const LDKTxCreationKeys *this_ptr);
6490
6491 /**
6492  * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
6493  */
6494 void TxCreationKeys_set_broadcaster_delayed_payment_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
6495
6496 MUST_USE_RES LDKTxCreationKeys TxCreationKeys_new(LDKPublicKey per_commitment_point_arg, LDKPublicKey revocation_key_arg, LDKPublicKey broadcaster_htlc_key_arg, LDKPublicKey countersignatory_htlc_key_arg, LDKPublicKey broadcaster_delayed_payment_key_arg);
6497
6498 LDKCVec_u8Z TxCreationKeys_write(const LDKTxCreationKeys *obj);
6499
6500 LDKTxCreationKeys TxCreationKeys_read(LDKu8slice ser);
6501
6502 void PreCalculatedTxCreationKeys_free(LDKPreCalculatedTxCreationKeys this_ptr);
6503
6504 LDKPreCalculatedTxCreationKeys PreCalculatedTxCreationKeys_clone(const LDKPreCalculatedTxCreationKeys *orig);
6505
6506 /**
6507  * Create a new PreCalculatedTxCreationKeys from TxCreationKeys
6508  */
6509 MUST_USE_RES LDKPreCalculatedTxCreationKeys PreCalculatedTxCreationKeys_new(LDKTxCreationKeys keys);
6510
6511 /**
6512  * The pre-calculated transaction creation public keys.
6513  * An external validating signer should not trust these keys.
6514  */
6515 MUST_USE_RES LDKTxCreationKeys PreCalculatedTxCreationKeys_trust_key_derivation(const LDKPreCalculatedTxCreationKeys *this_arg);
6516
6517 /**
6518  * The transaction per-commitment point
6519  */
6520 MUST_USE_RES LDKPublicKey PreCalculatedTxCreationKeys_per_commitment_point(const LDKPreCalculatedTxCreationKeys *this_arg);
6521
6522 void ChannelPublicKeys_free(LDKChannelPublicKeys this_ptr);
6523
6524 LDKChannelPublicKeys ChannelPublicKeys_clone(const LDKChannelPublicKeys *orig);
6525
6526 /**
6527  * The public key which is used to sign all commitment transactions, as it appears in the
6528  * on-chain channel lock-in 2-of-2 multisig output.
6529  */
6530 LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const LDKChannelPublicKeys *this_ptr);
6531
6532 /**
6533  * The public key which is used to sign all commitment transactions, as it appears in the
6534  * on-chain channel lock-in 2-of-2 multisig output.
6535  */
6536 void ChannelPublicKeys_set_funding_pubkey(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
6537
6538 /**
6539  * The base point which is used (with derive_public_revocation_key) to derive per-commitment
6540  * revocation keys. This is combined with the per-commitment-secret generated by the
6541  * counterparty to create a secret which the counterparty can reveal to revoke previous
6542  * states.
6543  */
6544 LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const LDKChannelPublicKeys *this_ptr);
6545
6546 /**
6547  * The base point which is used (with derive_public_revocation_key) to derive per-commitment
6548  * revocation keys. This is combined with the per-commitment-secret generated by the
6549  * counterparty to create a secret which the counterparty can reveal to revoke previous
6550  * states.
6551  */
6552 void ChannelPublicKeys_set_revocation_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
6553
6554 /**
6555  * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
6556  * spendable primary channel balance on the broadcaster's commitment transaction. This key is
6557  * static across every commitment transaction.
6558  */
6559 LDKPublicKey ChannelPublicKeys_get_payment_point(const LDKChannelPublicKeys *this_ptr);
6560
6561 /**
6562  * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
6563  * spendable primary channel balance on the broadcaster's commitment transaction. This key is
6564  * static across every commitment transaction.
6565  */
6566 void ChannelPublicKeys_set_payment_point(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
6567
6568 /**
6569  * The base point which is used (with derive_public_key) to derive a per-commitment payment
6570  * public key which receives non-HTLC-encumbered funds which are only available for spending
6571  * after some delay (or can be claimed via the revocation path).
6572  */
6573 LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const LDKChannelPublicKeys *this_ptr);
6574
6575 /**
6576  * The base point which is used (with derive_public_key) to derive a per-commitment payment
6577  * public key which receives non-HTLC-encumbered funds which are only available for spending
6578  * after some delay (or can be claimed via the revocation path).
6579  */
6580 void ChannelPublicKeys_set_delayed_payment_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
6581
6582 /**
6583  * The base point which is used (with derive_public_key) to derive a per-commitment public key
6584  * which is used to encumber HTLC-in-flight outputs.
6585  */
6586 LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const LDKChannelPublicKeys *this_ptr);
6587
6588 /**
6589  * The base point which is used (with derive_public_key) to derive a per-commitment public key
6590  * which is used to encumber HTLC-in-flight outputs.
6591  */
6592 void ChannelPublicKeys_set_htlc_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
6593
6594 MUST_USE_RES LDKChannelPublicKeys ChannelPublicKeys_new(LDKPublicKey funding_pubkey_arg, LDKPublicKey revocation_basepoint_arg, LDKPublicKey payment_point_arg, LDKPublicKey delayed_payment_basepoint_arg, LDKPublicKey htlc_basepoint_arg);
6595
6596 LDKCVec_u8Z ChannelPublicKeys_write(const LDKChannelPublicKeys *obj);
6597
6598 LDKChannelPublicKeys ChannelPublicKeys_read(LDKu8slice ser);
6599
6600 /**
6601  * Create a new TxCreationKeys from channel base points and the per-commitment point
6602  */
6603 MUST_USE_RES LDKCResult_TxCreationKeysSecpErrorZ TxCreationKeys_derive_new(LDKPublicKey per_commitment_point, LDKPublicKey broadcaster_delayed_payment_base, LDKPublicKey broadcaster_htlc_base, LDKPublicKey countersignatory_revocation_base, LDKPublicKey countersignatory_htlc_base);
6604
6605 /**
6606  * A script either spendable by the revocation
6607  * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
6608  * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
6609  */
6610 LDKCVec_u8Z get_revokeable_redeemscript(LDKPublicKey revocation_key, uint16_t contest_delay, LDKPublicKey broadcaster_delayed_payment_key);
6611
6612 void HTLCOutputInCommitment_free(LDKHTLCOutputInCommitment this_ptr);
6613
6614 LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const LDKHTLCOutputInCommitment *orig);
6615
6616 /**
6617  * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
6618  * Note that this is not the same as whether it is ountbound *from us*. To determine that you
6619  * need to compare this value to whether the commitment transaction in question is that of
6620  * the counterparty or our own.
6621  */
6622 bool HTLCOutputInCommitment_get_offered(const LDKHTLCOutputInCommitment *this_ptr);
6623
6624 /**
6625  * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
6626  * Note that this is not the same as whether it is ountbound *from us*. To determine that you
6627  * need to compare this value to whether the commitment transaction in question is that of
6628  * the counterparty or our own.
6629  */
6630 void HTLCOutputInCommitment_set_offered(LDKHTLCOutputInCommitment *this_ptr, bool val);
6631
6632 /**
6633  * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
6634  * this divided by 1000.
6635  */
6636 uint64_t HTLCOutputInCommitment_get_amount_msat(const LDKHTLCOutputInCommitment *this_ptr);
6637
6638 /**
6639  * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
6640  * this divided by 1000.
6641  */
6642 void HTLCOutputInCommitment_set_amount_msat(LDKHTLCOutputInCommitment *this_ptr, uint64_t val);
6643
6644 /**
6645  * The CLTV lock-time at which this HTLC expires.
6646  */
6647 uint32_t HTLCOutputInCommitment_get_cltv_expiry(const LDKHTLCOutputInCommitment *this_ptr);
6648
6649 /**
6650  * The CLTV lock-time at which this HTLC expires.
6651  */
6652 void HTLCOutputInCommitment_set_cltv_expiry(LDKHTLCOutputInCommitment *this_ptr, uint32_t val);
6653
6654 /**
6655  * The hash of the preimage which unlocks this HTLC.
6656  */
6657 const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const LDKHTLCOutputInCommitment *this_ptr))[32];
6658
6659 /**
6660  * The hash of the preimage which unlocks this HTLC.
6661  */
6662 void HTLCOutputInCommitment_set_payment_hash(LDKHTLCOutputInCommitment *this_ptr, LDKThirtyTwoBytes val);
6663
6664 LDKCVec_u8Z HTLCOutputInCommitment_write(const LDKHTLCOutputInCommitment *obj);
6665
6666 LDKHTLCOutputInCommitment HTLCOutputInCommitment_read(LDKu8slice ser);
6667
6668 /**
6669  * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
6670  * does not need to have its previous_output_index filled.
6671  */
6672 LDKCVec_u8Z get_htlc_redeemscript(const LDKHTLCOutputInCommitment *htlc, const LDKTxCreationKeys *keys);
6673
6674 /**
6675  * Gets the redeemscript for a funding output from the two funding public keys.
6676  * Note that the order of funding public keys does not matter.
6677  */
6678 LDKCVec_u8Z make_funding_redeemscript(LDKPublicKey broadcaster, LDKPublicKey countersignatory);
6679
6680 /**
6681  * panics if htlc.transaction_output_index.is_none()!
6682  */
6683 LDKTransaction build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const LDKHTLCOutputInCommitment *htlc, LDKPublicKey broadcaster_delayed_payment_key, LDKPublicKey revocation_key);
6684
6685 void HolderCommitmentTransaction_free(LDKHolderCommitmentTransaction this_ptr);
6686
6687 LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const LDKHolderCommitmentTransaction *orig);
6688
6689 /**
6690  * The commitment transaction itself, in unsigned form.
6691  */
6692 LDKTransaction HolderCommitmentTransaction_get_unsigned_tx(const LDKHolderCommitmentTransaction *this_ptr);
6693
6694 /**
6695  * The commitment transaction itself, in unsigned form.
6696  */
6697 void HolderCommitmentTransaction_set_unsigned_tx(LDKHolderCommitmentTransaction *this_ptr, LDKTransaction val);
6698
6699 /**
6700  * Our counterparty's signature for the transaction, above.
6701  */
6702 LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const LDKHolderCommitmentTransaction *this_ptr);
6703
6704 /**
6705  * Our counterparty's signature for the transaction, above.
6706  */
6707 void HolderCommitmentTransaction_set_counterparty_sig(LDKHolderCommitmentTransaction *this_ptr, LDKSignature val);
6708
6709 /**
6710  * The feerate paid per 1000-weight-unit in this commitment transaction. This value is
6711  * controlled by the channel initiator.
6712  */
6713 uint32_t HolderCommitmentTransaction_get_feerate_per_kw(const LDKHolderCommitmentTransaction *this_ptr);
6714
6715 /**
6716  * The feerate paid per 1000-weight-unit in this commitment transaction. This value is
6717  * controlled by the channel initiator.
6718  */
6719 void HolderCommitmentTransaction_set_feerate_per_kw(LDKHolderCommitmentTransaction *this_ptr, uint32_t val);
6720
6721 /**
6722  * The HTLCs and counterparty htlc signatures which were included in this commitment transaction.
6723  *
6724  * Note that this includes all HTLCs, including ones which were considered dust and not
6725  * actually included in the transaction as it appears on-chain, but who's value is burned as
6726  * fees and not included in the to_holder or to_counterparty outputs.
6727  *
6728  * The counterparty HTLC signatures in the second element will always be set for non-dust HTLCs, ie
6729  * those for which transaction_output_index.is_some().
6730  */
6731 void HolderCommitmentTransaction_set_per_htlc(LDKHolderCommitmentTransaction *this_ptr, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val);
6732
6733 /**
6734  * Generate a new HolderCommitmentTransaction based on a raw commitment transaction,
6735  * counterparty signature and both parties keys.
6736  *
6737  * The unsigned transaction outputs must be consistent with htlc_data.  This function
6738  * only checks that the shape and amounts are consistent, but does not check the scriptPubkey.
6739  */
6740 MUST_USE_RES LDKHolderCommitmentTransaction HolderCommitmentTransaction_new_missing_holder_sig(LDKTransaction unsigned_tx, LDKSignature counterparty_sig, LDKPublicKey holder_funding_key, LDKPublicKey counterparty_funding_key, LDKTxCreationKeys keys, uint32_t feerate_per_kw, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data);
6741
6742 /**
6743  * The pre-calculated transaction creation public keys.
6744  * An external validating signer should not trust these keys.
6745  */
6746 MUST_USE_RES LDKTxCreationKeys HolderCommitmentTransaction_trust_key_derivation(const LDKHolderCommitmentTransaction *this_arg);
6747
6748 /**
6749  * Get the txid of the holder commitment transaction contained in this
6750  * HolderCommitmentTransaction
6751  */
6752 MUST_USE_RES LDKThirtyTwoBytes HolderCommitmentTransaction_txid(const LDKHolderCommitmentTransaction *this_arg);
6753
6754 /**
6755  * Gets holder signature for the contained commitment transaction given holder funding private key.
6756  *
6757  * Funding key is your key included in the 2-2 funding_outpoint lock. Should be provided
6758  * by your ChannelKeys.
6759  * Funding redeemscript is script locking funding_outpoint. This is the mutlsig script
6760  * between your own funding key and your counterparty's. Currently, this is provided in
6761  * ChannelKeys::sign_holder_commitment() calls directly.
6762  * Channel value is amount locked in funding_outpoint.
6763  */
6764 MUST_USE_RES LDKSignature HolderCommitmentTransaction_get_holder_sig(const LDKHolderCommitmentTransaction *this_arg, const uint8_t (*funding_key)[32], LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis);
6765
6766 /**
6767  * Get a signature for each HTLC which was included in the commitment transaction (ie for
6768  * which HTLCOutputInCommitment::transaction_output_index.is_some()).
6769  *
6770  * The returned Vec has one entry for each HTLC, and in the same order. For HTLCs which were
6771  * considered dust and not included, a None entry exists, for all others a signature is
6772  * included.
6773  */
6774 MUST_USE_RES LDKCResult_CVec_SignatureZNoneZ HolderCommitmentTransaction_get_htlc_sigs(const LDKHolderCommitmentTransaction *this_arg, const uint8_t (*htlc_base_key)[32], uint16_t counterparty_selected_contest_delay);
6775
6776 LDKCVec_u8Z HolderCommitmentTransaction_write(const LDKHolderCommitmentTransaction *obj);
6777
6778 LDKHolderCommitmentTransaction HolderCommitmentTransaction_read(LDKu8slice ser);
6779
6780 void InitFeatures_free(LDKInitFeatures this_ptr);
6781
6782 void NodeFeatures_free(LDKNodeFeatures this_ptr);
6783
6784 void ChannelFeatures_free(LDKChannelFeatures this_ptr);
6785
6786 void RouteHop_free(LDKRouteHop this_ptr);
6787
6788 LDKRouteHop RouteHop_clone(const LDKRouteHop *orig);
6789
6790 /**
6791  * The node_id of the node at this hop.
6792  */
6793 LDKPublicKey RouteHop_get_pubkey(const LDKRouteHop *this_ptr);
6794
6795 /**
6796  * The node_id of the node at this hop.
6797  */
6798 void RouteHop_set_pubkey(LDKRouteHop *this_ptr, LDKPublicKey val);
6799
6800 /**
6801  * The node_announcement features of the node at this hop. For the last hop, these may be
6802  * amended to match the features present in the invoice this node generated.
6803  */
6804 LDKNodeFeatures RouteHop_get_node_features(const LDKRouteHop *this_ptr);
6805
6806 /**
6807  * The node_announcement features of the node at this hop. For the last hop, these may be
6808  * amended to match the features present in the invoice this node generated.
6809  */
6810 void RouteHop_set_node_features(LDKRouteHop *this_ptr, LDKNodeFeatures val);
6811
6812 /**
6813  * The channel that should be used from the previous hop to reach this node.
6814  */
6815 uint64_t RouteHop_get_short_channel_id(const LDKRouteHop *this_ptr);
6816
6817 /**
6818  * The channel that should be used from the previous hop to reach this node.
6819  */
6820 void RouteHop_set_short_channel_id(LDKRouteHop *this_ptr, uint64_t val);
6821
6822 /**
6823  * The channel_announcement features of the channel that should be used from the previous hop
6824  * to reach this node.
6825  */
6826 LDKChannelFeatures RouteHop_get_channel_features(const LDKRouteHop *this_ptr);
6827
6828 /**
6829  * The channel_announcement features of the channel that should be used from the previous hop
6830  * to reach this node.
6831  */
6832 void RouteHop_set_channel_features(LDKRouteHop *this_ptr, LDKChannelFeatures val);
6833
6834 /**
6835  * The fee taken on this hop. For the last hop, this should be the full value of the payment.
6836  */
6837 uint64_t RouteHop_get_fee_msat(const LDKRouteHop *this_ptr);
6838
6839 /**
6840  * The fee taken on this hop. For the last hop, this should be the full value of the payment.
6841  */
6842 void RouteHop_set_fee_msat(LDKRouteHop *this_ptr, uint64_t val);
6843
6844 /**
6845  * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
6846  * expected at the destination, in excess of the current block height.
6847  */
6848 uint32_t RouteHop_get_cltv_expiry_delta(const LDKRouteHop *this_ptr);
6849
6850 /**
6851  * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
6852  * expected at the destination, in excess of the current block height.
6853  */
6854 void RouteHop_set_cltv_expiry_delta(LDKRouteHop *this_ptr, uint32_t val);
6855
6856 MUST_USE_RES LDKRouteHop RouteHop_new(LDKPublicKey pubkey_arg, LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg);
6857
6858 void Route_free(LDKRoute this_ptr);
6859
6860 LDKRoute Route_clone(const LDKRoute *orig);
6861
6862 /**
6863  * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
6864  * last RouteHop in each path must be the same.
6865  * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the
6866  * destination. Thus, this must always be at least length one. While the maximum length of any
6867  * given path is variable, keeping the length of any path to less than 20 should currently
6868  * ensure it is viable.
6869  */
6870 void Route_set_paths(LDKRoute *this_ptr, LDKCVec_CVec_RouteHopZZ val);
6871
6872 MUST_USE_RES LDKRoute Route_new(LDKCVec_CVec_RouteHopZZ paths_arg);
6873
6874 LDKCVec_u8Z Route_write(const LDKRoute *obj);
6875
6876 LDKRoute Route_read(LDKu8slice ser);
6877
6878 void RouteHint_free(LDKRouteHint this_ptr);
6879
6880 LDKRouteHint RouteHint_clone(const LDKRouteHint *orig);
6881
6882 /**
6883  * The node_id of the non-target end of the route
6884  */
6885 LDKPublicKey RouteHint_get_src_node_id(const LDKRouteHint *this_ptr);
6886
6887 /**
6888  * The node_id of the non-target end of the route
6889  */
6890 void RouteHint_set_src_node_id(LDKRouteHint *this_ptr, LDKPublicKey val);
6891
6892 /**
6893  * The short_channel_id of this channel
6894  */
6895 uint64_t RouteHint_get_short_channel_id(const LDKRouteHint *this_ptr);
6896
6897 /**
6898  * The short_channel_id of this channel
6899  */
6900 void RouteHint_set_short_channel_id(LDKRouteHint *this_ptr, uint64_t val);
6901
6902 /**
6903  * The fees which must be paid to use this channel
6904  */
6905 LDKRoutingFees RouteHint_get_fees(const LDKRouteHint *this_ptr);
6906
6907 /**
6908  * The fees which must be paid to use this channel
6909  */
6910 void RouteHint_set_fees(LDKRouteHint *this_ptr, LDKRoutingFees val);
6911
6912 /**
6913  * The difference in CLTV values between this node and the next node.
6914  */
6915 uint16_t RouteHint_get_cltv_expiry_delta(const LDKRouteHint *this_ptr);
6916
6917 /**
6918  * The difference in CLTV values between this node and the next node.
6919  */
6920 void RouteHint_set_cltv_expiry_delta(LDKRouteHint *this_ptr, uint16_t val);
6921
6922 /**
6923  * The minimum value, in msat, which must be relayed to the next hop.
6924  */
6925 uint64_t RouteHint_get_htlc_minimum_msat(const LDKRouteHint *this_ptr);
6926
6927 /**
6928  * The minimum value, in msat, which must be relayed to the next hop.
6929  */
6930 void RouteHint_set_htlc_minimum_msat(LDKRouteHint *this_ptr, uint64_t val);
6931
6932 MUST_USE_RES LDKRouteHint RouteHint_new(LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg);
6933
6934 /**
6935  * Gets a route from us to the given target node.
6936  *
6937  * Extra routing hops between known nodes and the target will be used if they are included in
6938  * last_hops.
6939  *
6940  * If some channels aren't announced, it may be useful to fill in a first_hops with the
6941  * results from a local ChannelManager::list_usable_channels() call. If it is filled in, our
6942  * view of our local channels (from net_graph_msg_handler) will be ignored, and only those in first_hops
6943  * will be used.
6944  *
6945  * Panics if first_hops contains channels without short_channel_ids
6946  * (ChannelManager::list_usable_channels will never include such channels).
6947  *
6948  * The fees on channels from us to next-hops are ignored (as they are assumed to all be
6949  * equal), however the enabled/disabled bit on such channels as well as the htlc_minimum_msat
6950  * *is* checked as they may change based on the receiving node.
6951  */
6952 LDKCResult_RouteLightningErrorZ get_route(LDKPublicKey our_node_id, const LDKNetworkGraph *network, LDKPublicKey target, LDKCVec_ChannelDetailsZ *first_hops, LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, LDKLogger logger);
6953
6954 void NetworkGraph_free(LDKNetworkGraph this_ptr);
6955
6956 void LockedNetworkGraph_free(LDKLockedNetworkGraph this_ptr);
6957
6958 void NetGraphMsgHandler_free(LDKNetGraphMsgHandler this_ptr);
6959
6960 /**
6961  * Creates a new tracker of the actual state of the network of channels and nodes,
6962  * assuming a fresh network graph.
6963  * Chain monitor is used to make sure announced channels exist on-chain,
6964  * channel data is correct, and that the announcement is signed with
6965  * channel owners' keys.
6966  */
6967 MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_new(LDKAccess *chain_access, LDKLogger logger);
6968
6969 /**
6970  * Creates a new tracker of the actual state of the network of channels and nodes,
6971  * assuming an existing Network Graph.
6972  */
6973 MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(LDKAccess *chain_access, LDKLogger logger, LDKNetworkGraph network_graph);
6974
6975 /**
6976  * Take a read lock on the network_graph and return it in the C-bindings
6977  * newtype helper. This is likely only useful when called via the C
6978  * bindings as you can call `self.network_graph.read().unwrap()` in Rust
6979  * yourself.
6980  */
6981 MUST_USE_RES LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const LDKNetGraphMsgHandler *this_arg);
6982
6983 /**
6984  * Get a reference to the NetworkGraph which this read-lock contains.
6985  */
6986 MUST_USE_RES LDKNetworkGraph LockedNetworkGraph_graph(const LDKLockedNetworkGraph *this_arg);
6987
6988 LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const LDKNetGraphMsgHandler *this_arg);
6989
6990 void DirectionalChannelInfo_free(LDKDirectionalChannelInfo this_ptr);
6991
6992 /**
6993  * When the last update to the channel direction was issued.
6994  * Value is opaque, as set in the announcement.
6995  */
6996 uint32_t DirectionalChannelInfo_get_last_update(const LDKDirectionalChannelInfo *this_ptr);
6997
6998 /**
6999  * When the last update to the channel direction was issued.
7000  * Value is opaque, as set in the announcement.
7001  */
7002 void DirectionalChannelInfo_set_last_update(LDKDirectionalChannelInfo *this_ptr, uint32_t val);
7003
7004 /**
7005  * Whether the channel can be currently used for payments (in this one direction).
7006  */
7007 bool DirectionalChannelInfo_get_enabled(const LDKDirectionalChannelInfo *this_ptr);
7008
7009 /**
7010  * Whether the channel can be currently used for payments (in this one direction).
7011  */
7012 void DirectionalChannelInfo_set_enabled(LDKDirectionalChannelInfo *this_ptr, bool val);
7013
7014 /**
7015  * The difference in CLTV values that you must have when routing through this channel.
7016  */
7017 uint16_t DirectionalChannelInfo_get_cltv_expiry_delta(const LDKDirectionalChannelInfo *this_ptr);
7018
7019 /**
7020  * The difference in CLTV values that you must have when routing through this channel.
7021  */
7022 void DirectionalChannelInfo_set_cltv_expiry_delta(LDKDirectionalChannelInfo *this_ptr, uint16_t val);
7023
7024 /**
7025  * The minimum value, which must be relayed to the next hop via the channel
7026  */
7027 uint64_t DirectionalChannelInfo_get_htlc_minimum_msat(const LDKDirectionalChannelInfo *this_ptr);
7028
7029 /**
7030  * The minimum value, which must be relayed to the next hop via the channel
7031  */
7032 void DirectionalChannelInfo_set_htlc_minimum_msat(LDKDirectionalChannelInfo *this_ptr, uint64_t val);
7033
7034 /**
7035  * Most recent update for the channel received from the network
7036  * Mostly redundant with the data we store in fields explicitly.
7037  * Everything else is useful only for sending out for initial routing sync.
7038  * Not stored if contains excess data to prevent DoS.
7039  */
7040 LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const LDKDirectionalChannelInfo *this_ptr);
7041
7042 /**
7043  * Most recent update for the channel received from the network
7044  * Mostly redundant with the data we store in fields explicitly.
7045  * Everything else is useful only for sending out for initial routing sync.
7046  * Not stored if contains excess data to prevent DoS.
7047  */
7048 void DirectionalChannelInfo_set_last_update_message(LDKDirectionalChannelInfo *this_ptr, LDKChannelUpdate val);
7049
7050 LDKCVec_u8Z DirectionalChannelInfo_write(const LDKDirectionalChannelInfo *obj);
7051
7052 LDKDirectionalChannelInfo DirectionalChannelInfo_read(LDKu8slice ser);
7053
7054 void ChannelInfo_free(LDKChannelInfo this_ptr);
7055
7056 /**
7057  * Protocol features of a channel communicated during its announcement
7058  */
7059 LDKChannelFeatures ChannelInfo_get_features(const LDKChannelInfo *this_ptr);
7060
7061 /**
7062  * Protocol features of a channel communicated during its announcement
7063  */
7064 void ChannelInfo_set_features(LDKChannelInfo *this_ptr, LDKChannelFeatures val);
7065
7066 /**
7067  * Source node of the first direction of a channel
7068  */
7069 LDKPublicKey ChannelInfo_get_node_one(const LDKChannelInfo *this_ptr);
7070
7071 /**
7072  * Source node of the first direction of a channel
7073  */
7074 void ChannelInfo_set_node_one(LDKChannelInfo *this_ptr, LDKPublicKey val);
7075
7076 /**
7077  * Details about the first direction of a channel
7078  */
7079 LDKDirectionalChannelInfo ChannelInfo_get_one_to_two(const LDKChannelInfo *this_ptr);
7080
7081 /**
7082  * Details about the first direction of a channel
7083  */
7084 void ChannelInfo_set_one_to_two(LDKChannelInfo *this_ptr, LDKDirectionalChannelInfo val);
7085
7086 /**
7087  * Source node of the second direction of a channel
7088  */
7089 LDKPublicKey ChannelInfo_get_node_two(const LDKChannelInfo *this_ptr);
7090
7091 /**
7092  * Source node of the second direction of a channel
7093  */
7094 void ChannelInfo_set_node_two(LDKChannelInfo *this_ptr, LDKPublicKey val);
7095
7096 /**
7097  * Details about the second direction of a channel
7098  */
7099 LDKDirectionalChannelInfo ChannelInfo_get_two_to_one(const LDKChannelInfo *this_ptr);
7100
7101 /**
7102  * Details about the second direction of a channel
7103  */
7104 void ChannelInfo_set_two_to_one(LDKChannelInfo *this_ptr, LDKDirectionalChannelInfo val);
7105
7106 /**
7107  * An initial announcement of the channel
7108  * Mostly redundant with the data we store in fields explicitly.
7109  * Everything else is useful only for sending out for initial routing sync.
7110  * Not stored if contains excess data to prevent DoS.
7111  */
7112 LDKChannelAnnouncement ChannelInfo_get_announcement_message(const LDKChannelInfo *this_ptr);
7113
7114 /**
7115  * An initial announcement of the channel
7116  * Mostly redundant with the data we store in fields explicitly.
7117  * Everything else is useful only for sending out for initial routing sync.
7118  * Not stored if contains excess data to prevent DoS.
7119  */
7120 void ChannelInfo_set_announcement_message(LDKChannelInfo *this_ptr, LDKChannelAnnouncement val);
7121
7122 LDKCVec_u8Z ChannelInfo_write(const LDKChannelInfo *obj);
7123
7124 LDKChannelInfo ChannelInfo_read(LDKu8slice ser);
7125
7126 void RoutingFees_free(LDKRoutingFees this_ptr);
7127
7128 LDKRoutingFees RoutingFees_clone(const LDKRoutingFees *orig);
7129
7130 /**
7131  * Flat routing fee in satoshis
7132  */
7133 uint32_t RoutingFees_get_base_msat(const LDKRoutingFees *this_ptr);
7134
7135 /**
7136  * Flat routing fee in satoshis
7137  */
7138 void RoutingFees_set_base_msat(LDKRoutingFees *this_ptr, uint32_t val);
7139
7140 /**
7141  * Liquidity-based routing fee in millionths of a routed amount.
7142  * In other words, 10000 is 1%.
7143  */
7144 uint32_t RoutingFees_get_proportional_millionths(const LDKRoutingFees *this_ptr);
7145
7146 /**
7147  * Liquidity-based routing fee in millionths of a routed amount.
7148  * In other words, 10000 is 1%.
7149  */
7150 void RoutingFees_set_proportional_millionths(LDKRoutingFees *this_ptr, uint32_t val);
7151
7152 MUST_USE_RES LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg);
7153
7154 LDKRoutingFees RoutingFees_read(LDKu8slice ser);
7155
7156 LDKCVec_u8Z RoutingFees_write(const LDKRoutingFees *obj);
7157
7158 void NodeAnnouncementInfo_free(LDKNodeAnnouncementInfo this_ptr);
7159
7160 /**
7161  * Protocol features the node announced support for
7162  */
7163 LDKNodeFeatures NodeAnnouncementInfo_get_features(const LDKNodeAnnouncementInfo *this_ptr);
7164
7165 /**
7166  * Protocol features the node announced support for
7167  */
7168 void NodeAnnouncementInfo_set_features(LDKNodeAnnouncementInfo *this_ptr, LDKNodeFeatures val);
7169
7170 /**
7171  * When the last known update to the node state was issued.
7172  * Value is opaque, as set in the announcement.
7173  */
7174 uint32_t NodeAnnouncementInfo_get_last_update(const LDKNodeAnnouncementInfo *this_ptr);
7175
7176 /**
7177  * When the last known update to the node state was issued.
7178  * Value is opaque, as set in the announcement.
7179  */
7180 void NodeAnnouncementInfo_set_last_update(LDKNodeAnnouncementInfo *this_ptr, uint32_t val);
7181
7182 /**
7183  * Color assigned to the node
7184  */
7185 const uint8_t (*NodeAnnouncementInfo_get_rgb(const LDKNodeAnnouncementInfo *this_ptr))[3];
7186
7187 /**
7188  * Color assigned to the node
7189  */
7190 void NodeAnnouncementInfo_set_rgb(LDKNodeAnnouncementInfo *this_ptr, LDKThreeBytes val);
7191
7192 /**
7193  * Moniker assigned to the node.
7194  * May be invalid or malicious (eg control chars),
7195  * should not be exposed to the user.
7196  */
7197 const uint8_t (*NodeAnnouncementInfo_get_alias(const LDKNodeAnnouncementInfo *this_ptr))[32];
7198
7199 /**
7200  * Moniker assigned to the node.
7201  * May be invalid or malicious (eg control chars),
7202  * should not be exposed to the user.
7203  */
7204 void NodeAnnouncementInfo_set_alias(LDKNodeAnnouncementInfo *this_ptr, LDKThirtyTwoBytes val);
7205
7206 /**
7207  * Internet-level addresses via which one can connect to the node
7208  */
7209 void NodeAnnouncementInfo_set_addresses(LDKNodeAnnouncementInfo *this_ptr, LDKCVec_NetAddressZ val);
7210
7211 /**
7212  * An initial announcement of the node
7213  * Mostly redundant with the data we store in fields explicitly.
7214  * Everything else is useful only for sending out for initial routing sync.
7215  * Not stored if contains excess data to prevent DoS.
7216  */
7217 LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const LDKNodeAnnouncementInfo *this_ptr);
7218
7219 /**
7220  * An initial announcement of the node
7221  * Mostly redundant with the data we store in fields explicitly.
7222  * Everything else is useful only for sending out for initial routing sync.
7223  * Not stored if contains excess data to prevent DoS.
7224  */
7225 void NodeAnnouncementInfo_set_announcement_message(LDKNodeAnnouncementInfo *this_ptr, LDKNodeAnnouncement val);
7226
7227 MUST_USE_RES LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(LDKNodeFeatures features_arg, uint32_t last_update_arg, LDKThreeBytes rgb_arg, LDKThirtyTwoBytes alias_arg, LDKCVec_NetAddressZ addresses_arg, LDKNodeAnnouncement announcement_message_arg);
7228
7229 LDKCVec_u8Z NodeAnnouncementInfo_write(const LDKNodeAnnouncementInfo *obj);
7230
7231 LDKNodeAnnouncementInfo NodeAnnouncementInfo_read(LDKu8slice ser);
7232
7233 void NodeInfo_free(LDKNodeInfo this_ptr);
7234
7235 /**
7236  * All valid channels a node has announced
7237  */
7238 void NodeInfo_set_channels(LDKNodeInfo *this_ptr, LDKCVec_u64Z val);
7239
7240 /**
7241  * Lowest fees enabling routing via any of the enabled, known channels to a node.
7242  * The two fields (flat and proportional fee) are independent,
7243  * meaning they don't have to refer to the same channel.
7244  */
7245 LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const LDKNodeInfo *this_ptr);
7246
7247 /**
7248  * Lowest fees enabling routing via any of the enabled, known channels to a node.
7249  * The two fields (flat and proportional fee) are independent,
7250  * meaning they don't have to refer to the same channel.
7251  */
7252 void NodeInfo_set_lowest_inbound_channel_fees(LDKNodeInfo *this_ptr, LDKRoutingFees val);
7253
7254 /**
7255  * More information about a node from node_announcement.
7256  * Optional because we store a Node entry after learning about it from
7257  * a channel announcement, but before receiving a node announcement.
7258  */
7259 LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const LDKNodeInfo *this_ptr);
7260
7261 /**
7262  * More information about a node from node_announcement.
7263  * Optional because we store a Node entry after learning about it from
7264  * a channel announcement, but before receiving a node announcement.
7265  */
7266 void NodeInfo_set_announcement_info(LDKNodeInfo *this_ptr, LDKNodeAnnouncementInfo val);
7267
7268 MUST_USE_RES LDKNodeInfo NodeInfo_new(LDKCVec_u64Z channels_arg, LDKRoutingFees lowest_inbound_channel_fees_arg, LDKNodeAnnouncementInfo announcement_info_arg);
7269
7270 LDKCVec_u8Z NodeInfo_write(const LDKNodeInfo *obj);
7271
7272 LDKNodeInfo NodeInfo_read(LDKu8slice ser);
7273
7274 LDKCVec_u8Z NetworkGraph_write(const LDKNetworkGraph *obj);
7275
7276 LDKNetworkGraph NetworkGraph_read(LDKu8slice ser);
7277
7278 /**
7279  * Creates a new, empty, network graph.
7280  */
7281 MUST_USE_RES LDKNetworkGraph NetworkGraph_new(void);
7282
7283 /**
7284  * For an already known node (from channel announcements), update its stored properties from a
7285  * given node announcement.
7286  *
7287  * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
7288  * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
7289  * routing messages from a source using a protocol other than the lightning P2P protocol.
7290  */
7291 MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(LDKNetworkGraph *this_arg, const LDKNodeAnnouncement *msg);
7292
7293 /**
7294  * For an already known node (from channel announcements), update its stored properties from a
7295  * given node announcement without verifying the associated signatures. Because we aren't
7296  * given the associated signatures here we cannot relay the node announcement to any of our
7297  * peers.
7298  */
7299 MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(LDKNetworkGraph *this_arg, const LDKUnsignedNodeAnnouncement *msg);
7300
7301 /**
7302  * Store or update channel info from a channel announcement.
7303  *
7304  * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
7305  * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
7306  * routing messages from a source using a protocol other than the lightning P2P protocol.
7307  *
7308  * If a `chain::Access` object is provided via `chain_access`, it will be called to verify
7309  * the corresponding UTXO exists on chain and is correctly-formatted.
7310  */
7311 MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(LDKNetworkGraph *this_arg, const LDKChannelAnnouncement *msg, LDKAccess *chain_access);
7312
7313 /**
7314  * Store or update channel info from a channel announcement without verifying the associated
7315  * signatures. Because we aren't given the associated signatures here we cannot relay the
7316  * channel announcement to any of our peers.
7317  *
7318  * If a `chain::Access` object is provided via `chain_access`, it will be called to verify
7319  * the corresponding UTXO exists on chain and is correctly-formatted.
7320  */
7321 MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(LDKNetworkGraph *this_arg, const LDKUnsignedChannelAnnouncement *msg, LDKAccess *chain_access);
7322
7323 /**
7324  * Close a channel if a corresponding HTLC fail was sent.
7325  * If permanent, removes a channel from the local storage.
7326  * May cause the removal of nodes too, if this was their last channel.
7327  * If not permanent, makes channels unavailable for routing.
7328  */
7329 void NetworkGraph_close_channel_from_update(LDKNetworkGraph *this_arg, uint64_t short_channel_id, bool is_permanent);
7330
7331 /**
7332  * For an already known (from announcement) channel, update info about one of the directions
7333  * of the channel.
7334  *
7335  * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
7336  * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
7337  * routing messages from a source using a protocol other than the lightning P2P protocol.
7338  */
7339 MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(LDKNetworkGraph *this_arg, const LDKChannelUpdate *msg);
7340
7341 /**
7342  * For an already known (from announcement) channel, update info about one of the directions
7343  * of the channel without verifying the associated signatures. Because we aren't given the
7344  * associated signatures here we cannot relay the channel update to any of our peers.
7345  */
7346 MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(LDKNetworkGraph *this_arg, const LDKUnsignedChannelUpdate *msg);
7347
7348 /* Text to put at the end of the generated file */