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