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