--- /dev/null
+/* Text to put at the beginning of the generated file. Probably a license. */
+
+/* Generated with cbindgen:0.14.4 */
+
+/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
+
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+/**
+ * Used to give chain error details upstream
+ */
+typedef enum LDKChainError {
+ /**
+ * Client doesn't support UTXO lookup (but the chain hash matches our genesis block hash)
+ */
+ LDKChainError_NotSupported,
+ /**
+ * Chain isn't the one watched
+ */
+ LDKChainError_NotWatched,
+ /**
+ * Tx doesn't exist or is unconfirmed
+ */
+ LDKChainError_UnknownTx,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKChainError_Sentinel,
+} LDKChainError;
+
+/**
+ * An error enum representing a failure to persist a channel monitor update.
+ */
+typedef enum LDKChannelMonitorUpdateErr {
+ /**
+ * Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
+ * our state failed, but is expected to succeed at some point in the future).
+ *
+ * Such a failure will \"freeze\" a channel, preventing us from revoking old states or
+ * submitting new commitment transactions to the remote party. Once the update(s) which failed
+ * have been successfully applied, ChannelManager::channel_monitor_updated can be used to
+ * restore the channel to an operational state.
+ *
+ * Note that a given ChannelManager will *never* re-generate a given ChannelMonitorUpdate. If
+ * you return a TemporaryFailure you must ensure that it is written to disk safely before
+ * writing out the latest ChannelManager state.
+ *
+ * Even when a channel has been \"frozen\" updates to the ChannelMonitor can continue to occur
+ * (eg if an inbound HTLC which we forwarded was claimed upstream resulting in us attempting
+ * to claim it on this channel) and those updates must be applied wherever they can be. At
+ * least one such updated ChannelMonitor must be persisted otherwise PermanentFailure should
+ * be returned to get things on-chain ASAP using only the in-memory copy. Obviously updates to
+ * the channel which would invalidate previous ChannelMonitors are not made when a channel has
+ * been \"frozen\".
+ *
+ * Note that even if updates made after TemporaryFailure succeed you must still call
+ * channel_monitor_updated to ensure you have the latest monitor and re-enable normal channel
+ * operation.
+ *
+ * Note that the update being processed here will not be replayed for you when you call
+ * ChannelManager::channel_monitor_updated, so you must store the update itself along
+ * with the persisted ChannelMonitor on your own local disk prior to returning a
+ * TemporaryFailure. You may, of course, employ a journaling approach, storing only the
+ * ChannelMonitorUpdate on disk without updating the monitor itself, replaying the journal at
+ * reload-time.
+ *
+ * For deployments where a copy of ChannelMonitors and other local state are backed up in a
+ * remote location (with local copies persisted immediately), it is anticipated that all
+ * updates will return TemporaryFailure until the remote copies could be updated.
+ */
+ LDKChannelMonitorUpdateErr_TemporaryFailure,
+ /**
+ * Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a
+ * different watchtower and cannot update with all watchtowers that were previously informed
+ * of this channel). This will force-close the channel in question (which will generate one
+ * final ChannelMonitorUpdate which must be delivered to at least one ChannelMonitor copy).
+ *
+ * Should also be used to indicate a failure to update the local persisted copy of the channel
+ * monitor.
+ */
+ LDKChannelMonitorUpdateErr_PermanentFailure,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKChannelMonitorUpdateErr_Sentinel,
+} LDKChannelMonitorUpdateErr;
+
+/**
+ * An enum that represents the speed at which we want a transaction to confirm used for feerate
+ * estimation.
+ */
+typedef enum LDKConfirmationTarget {
+ /**
+ * We are happy with this transaction confirming slowly when feerate drops some.
+ */
+ LDKConfirmationTarget_Background,
+ /**
+ * We'd like this transaction to confirm without major delay, but 12-18 blocks is fine.
+ */
+ LDKConfirmationTarget_Normal,
+ /**
+ * We'd like this transaction to confirm in the next few blocks.
+ */
+ LDKConfirmationTarget_HighPriority,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKConfirmationTarget_Sentinel,
+} LDKConfirmationTarget;
+
+/**
+ * An enum representing the available verbosity levels of the logger.
+ */
+typedef enum LDKLevel {
+ /**
+ *Designates logger being silent
+ */
+ LDKLevel_Off,
+ /**
+ * Designates very serious errors
+ */
+ LDKLevel_Error,
+ /**
+ * Designates hazardous situations
+ */
+ LDKLevel_Warn,
+ /**
+ * Designates useful information
+ */
+ LDKLevel_Info,
+ /**
+ * Designates lower priority information
+ */
+ LDKLevel_Debug,
+ /**
+ * Designates very low priority, often extremely verbose, information
+ */
+ LDKLevel_Trace,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKLevel_Sentinel,
+} LDKLevel;
+
+typedef enum LDKNetwork {
+ LDKNetwork_Bitcoin,
+ LDKNetwork_Testnet,
+ LDKNetwork_Regtest,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKNetwork_Sentinel,
+} LDKNetwork;
+
+typedef enum LDKSecp256k1Error {
+ LDKSecp256k1Error_IncorrectSignature,
+ LDKSecp256k1Error_InvalidMessage,
+ LDKSecp256k1Error_InvalidPublicKey,
+ LDKSecp256k1Error_InvalidSignature,
+ LDKSecp256k1Error_InvalidSecretKey,
+ LDKSecp256k1Error_InvalidRecoveryId,
+ LDKSecp256k1Error_InvalidTweak,
+ LDKSecp256k1Error_NotEnoughMemory,
+ LDKSecp256k1Error_CallbackPanicked,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKSecp256k1Error_Sentinel,
+} LDKSecp256k1Error;
+
+typedef struct LDKCVecTempl_u8 {
+ uint8_t *data;
+ uintptr_t datalen;
+} LDKCVecTempl_u8;
+
+typedef LDKCVecTempl_u8 LDKCVec_u8Z;
+
+/**
+ * A transaction output including a scriptPubKey and value.
+ * This type *does* own its own memory, so must be free'd appropriately.
+ */
+typedef struct LDKTxOut {
+ LDKCVec_u8Z script_pubkey;
+ uint64_t value;
+} LDKTxOut;
+
+/**
+ * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to
+ * look up the corresponding function in rust-lightning's docs.
+ */
+typedef struct LDKThirtyTwoBytes {
+ uint8_t data[32];
+} LDKThirtyTwoBytes;
+
+typedef struct LDKC2TupleTempl_ThirtyTwoBytes__u32 {
+ LDKThirtyTwoBytes *a;
+ uint32_t *b;
+} LDKC2TupleTempl_ThirtyTwoBytes__u32;
+
+typedef LDKC2TupleTempl_ThirtyTwoBytes__u32 LDKC2Tuple_Txidu32Z;
+
+typedef struct LDKC2TupleTempl_CVec_u8Z__u64 {
+ LDKCVec_u8Z *a;
+ uint64_t *b;
+} LDKC2TupleTempl_CVec_u8Z__u64;
+
+typedef LDKC2TupleTempl_CVec_u8Z__u64 LDKC2Tuple_Scriptu64Z;
+
+typedef struct LDKC2TupleTempl_u64__u64 {
+ uint64_t *a;
+ uint64_t *b;
+} LDKC2TupleTempl_u64__u64;
+
+typedef LDKC2TupleTempl_u64__u64 LDKC2Tuple_u64u64Z;
+
+typedef struct LDKSignature {
+ uint8_t compact_form[64];
+} LDKSignature;
+
+typedef struct LDKCVecTempl_Signature {
+ LDKSignature *data;
+ uintptr_t datalen;
+} LDKCVecTempl_Signature;
+
+typedef struct LDKC2TupleTempl_Signature__CVecTempl_Signature {
+ LDKSignature *a;
+ LDKCVecTempl_Signature *b;
+} LDKC2TupleTempl_Signature__CVecTempl_Signature;
+
+typedef LDKC2TupleTempl_Signature__CVecTempl_Signature LDKC2Tuple_SignatureCVec_SignatureZZ;
+
+typedef LDKCVecTempl_Signature LDKCVec_SignatureZ;
+
+typedef union LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8 {
+ LDKC2TupleTempl_Signature__CVecTempl_Signature *result;
+ uint8_t *err;
+} LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8;
+
+typedef struct LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8 {
+ LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8 contents;
+ bool result_ok;
+} LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8;
+
+typedef LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ;
+
+typedef union LDKCResultPtr_Signature__u8 {
+ LDKSignature *result;
+ uint8_t *err;
+} LDKCResultPtr_Signature__u8;
+
+typedef struct LDKCResultTempl_Signature__u8 {
+ LDKCResultPtr_Signature__u8 contents;
+ bool result_ok;
+} LDKCResultTempl_Signature__u8;
+
+typedef LDKCResultTempl_Signature__u8 LDKCResult_SignatureNoneZ;
+
+typedef union LDKCResultPtr_CVecTempl_Signature_____u8 {
+ LDKCVecTempl_Signature *result;
+ uint8_t *err;
+} LDKCResultPtr_CVecTempl_Signature_____u8;
+
+typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 {
+ LDKCResultPtr_CVecTempl_Signature_____u8 contents;
+ bool result_ok;
+} LDKCResultTempl_CVecTempl_Signature_____u8;
+
+typedef LDKCResultTempl_CVecTempl_Signature_____u8 LDKCResult_CVec_SignatureZNoneZ;
+
+/**
+ * A Rust str object, ie a reference to a UTF8-valid string.
+ * This is *not* null-terminated so cannot be used directly as a C string!
+ */
+typedef struct LDKStr {
+ const uint8_t *chars;
+ uintptr_t len;
+} LDKStr;
+
+/**
+ * Indicates an error on the client's part (usually some variant of attempting to use too-low or
+ * too-high values)
+ */
+typedef enum LDKAPIError_Tag {
+ /**
+ * Indicates the API was wholly misused (see err for more). Cases where these can be returned
+ * are documented, but generally indicates some precondition of a function was violated.
+ */
+ LDKAPIError_APIMisuseError,
+ /**
+ * Due to a high feerate, we were unable to complete the request.
+ * For example, this may be returned if the feerate implies we cannot open a channel at the
+ * requested value, but opening a larger channel would succeed.
+ */
+ LDKAPIError_FeeRateTooHigh,
+ /**
+ * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route,
+ * too-many-hops, etc).
+ */
+ LDKAPIError_RouteError,
+ /**
+ * We were unable to complete the request as the Channel required to do so is unable to
+ * complete the request (or was not found). This can take many forms, including disconnected
+ * peer, channel at capacity, channel shutting down, etc.
+ */
+ LDKAPIError_ChannelUnavailable,
+ /**
+ * An attempt to call add/update_monitor returned an Err (ie you did this!), causing the
+ * attempted action to fail.
+ */
+ LDKAPIError_MonitorUpdateFailed,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKAPIError_Sentinel,
+} LDKAPIError_Tag;
+
+typedef struct LDKAPIError_LDKAPIMisuseError_Body {
+ LDKCVec_u8Z err;
+} LDKAPIError_LDKAPIMisuseError_Body;
+
+typedef struct LDKAPIError_LDKFeeRateTooHigh_Body {
+ LDKCVec_u8Z err;
+ uint32_t feerate;
+} LDKAPIError_LDKFeeRateTooHigh_Body;
+
+typedef struct LDKAPIError_LDKRouteError_Body {
+ LDKStr err;
+} LDKAPIError_LDKRouteError_Body;
+
+typedef struct LDKAPIError_LDKChannelUnavailable_Body {
+ LDKCVec_u8Z err;
+} LDKAPIError_LDKChannelUnavailable_Body;
+
+typedef struct LDKAPIError {
+ LDKAPIError_Tag tag;
+ union {
+ LDKAPIError_LDKAPIMisuseError_Body api_misuse_error;
+ LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high;
+ LDKAPIError_LDKRouteError_Body route_error;
+ LDKAPIError_LDKChannelUnavailable_Body channel_unavailable;
+ };
+} LDKAPIError;
+
+typedef union LDKCResultPtr_u8__APIError {
+ uint8_t *result;
+ LDKAPIError *err;
+} LDKCResultPtr_u8__APIError;
+
+typedef struct LDKCResultTempl_u8__APIError {
+ LDKCResultPtr_u8__APIError contents;
+ bool result_ok;
+} LDKCResultTempl_u8__APIError;
+
+typedef LDKCResultTempl_u8__APIError LDKCResult_NoneAPIErrorZ;
+
+
+
+/**
+ * If a payment fails to send, it can be in one of several states. This enum is returned as the
+ * Err() type describing which state the payment is in, see the description of individual enum
+ * states for more.
+ */
+typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativePaymentSendFailure *inner;
+ bool is_owned;
+} LDKPaymentSendFailure;
+
+typedef union LDKCResultPtr_u8__PaymentSendFailure {
+ uint8_t *result;
+ LDKPaymentSendFailure *err;
+} LDKCResultPtr_u8__PaymentSendFailure;
+
+typedef struct LDKCResultTempl_u8__PaymentSendFailure {
+ LDKCResultPtr_u8__PaymentSendFailure contents;
+ bool result_ok;
+} LDKCResultTempl_u8__PaymentSendFailure;
+
+typedef LDKCResultTempl_u8__PaymentSendFailure LDKCResult_NonePaymentSendFailureZ;
+
+typedef union LDKCResultPtr_u8__ChannelMonitorUpdateErr {
+ uint8_t *result;
+ LDKChannelMonitorUpdateErr *err;
+} LDKCResultPtr_u8__ChannelMonitorUpdateErr;
+
+typedef struct LDKCResultTempl_u8__ChannelMonitorUpdateErr {
+ LDKCResultPtr_u8__ChannelMonitorUpdateErr contents;
+ bool result_ok;
+} LDKCResultTempl_u8__ChannelMonitorUpdateErr;
+
+typedef LDKCResultTempl_u8__ChannelMonitorUpdateErr LDKCResult_NoneChannelMonitorUpdateErrZ;
+
+
+
+/**
+ * General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
+ * inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
+ * means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
+ * corrupted.
+ * Contains a human-readable error message.
+ */
+typedef struct MUST_USE_STRUCT LDKMonitorUpdateError {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeMonitorUpdateError *inner;
+ bool is_owned;
+} LDKMonitorUpdateError;
+
+typedef union LDKCResultPtr_u8__MonitorUpdateError {
+ uint8_t *result;
+ LDKMonitorUpdateError *err;
+} LDKCResultPtr_u8__MonitorUpdateError;
+
+typedef struct LDKCResultTempl_u8__MonitorUpdateError {
+ LDKCResultPtr_u8__MonitorUpdateError contents;
+ bool result_ok;
+} LDKCResultTempl_u8__MonitorUpdateError;
+
+typedef LDKCResultTempl_u8__MonitorUpdateError LDKCResult_NoneMonitorUpdateErrorZ;
+
+
+
+/**
+ * A reference to a transaction output.
+ *
+ * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
+ * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
+ */
+typedef struct MUST_USE_STRUCT LDKOutPoint {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeOutPoint *inner;
+ bool is_owned;
+} LDKOutPoint;
+
+typedef struct LDKC2TupleTempl_OutPoint__CVec_u8Z {
+ LDKOutPoint *a;
+ LDKCVec_u8Z *b;
+} LDKC2TupleTempl_OutPoint__CVec_u8Z;
+
+typedef LDKC2TupleTempl_OutPoint__CVec_u8Z LDKC2Tuple_OutPointScriptZ;
+
+
+
+/**
+ * A channel_announcement message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKChannelAnnouncement {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelAnnouncement *inner;
+ bool is_owned;
+} LDKChannelAnnouncement;
+
+
+
+/**
+ * A channel_update message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKChannelUpdate {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelUpdate *inner;
+ bool is_owned;
+} LDKChannelUpdate;
+
+typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate {
+ LDKChannelAnnouncement *a;
+ LDKChannelUpdate *b;
+ LDKChannelUpdate *c;
+} LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate;
+
+typedef LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ;
+
+
+
+/**
+ * Error for PeerManager errors. If you get one of these, you must disconnect the socket and
+ * generate no further read_event/write_buffer_space_avail calls for the descriptor, only
+ * triggering a single socket_disconnected call (unless it was provided in response to a
+ * new_*_connection event, in which case no such socket_disconnected() must be called and the
+ * socket silently disconencted).
+ */
+typedef struct MUST_USE_STRUCT LDKPeerHandleError {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativePeerHandleError *inner;
+ bool is_owned;
+} LDKPeerHandleError;
+
+typedef union LDKCResultPtr_u8__PeerHandleError {
+ uint8_t *result;
+ LDKPeerHandleError *err;
+} LDKCResultPtr_u8__PeerHandleError;
+
+typedef struct LDKCResultTempl_u8__PeerHandleError {
+ LDKCResultPtr_u8__PeerHandleError contents;
+ bool result_ok;
+} LDKCResultTempl_u8__PeerHandleError;
+
+typedef LDKCResultTempl_u8__PeerHandleError LDKCResult_NonePeerHandleErrorZ;
+
+
+
+/**
+ * Information about an HTLC as it appears in a commitment transaction
+ */
+typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeHTLCOutputInCommitment *inner;
+ bool is_owned;
+} LDKHTLCOutputInCommitment;
+
+typedef struct LDKC2TupleTempl_HTLCOutputInCommitment__Signature {
+ LDKHTLCOutputInCommitment *a;
+ LDKSignature *b;
+} LDKC2TupleTempl_HTLCOutputInCommitment__Signature;
+
+typedef LDKC2TupleTempl_HTLCOutputInCommitment__Signature LDKC2Tuple_HTLCOutputInCommitmentSignatureZ;
+
+typedef struct LDKPublicKey {
+ uint8_t compressed_form[33];
+} LDKPublicKey;
+
+/**
+ * When on-chain outputs are created by rust-lightning (which our counterparty is not able to
+ * claim at any point in the future) an event is generated which you must track and be able to
+ * spend on-chain. The information needed to do this is provided in this enum, including the
+ * outpoint describing which txid and output index is available, the full output which exists at
+ * that txid/index, and any keys or other information required to sign.
+ */
+typedef enum LDKSpendableOutputDescriptor_Tag {
+ /**
+ * An output to a script which was provided via KeysInterface, thus you should already know
+ * how to spend it. No keys are provided as rust-lightning was never given any keys - only the
+ * script_pubkey as it appears in the output.
+ * These may include outputs from a transaction punishing our counterparty or claiming an HTLC
+ * on-chain using the payment preimage or after it has timed out.
+ */
+ LDKSpendableOutputDescriptor_StaticOutput,
+ /**
+ * An output to a P2WSH script which can be spent with a single signature after a CSV delay.
+ *
+ * The witness in the spending input should be:
+ * <BIP 143 signature> <empty vector> (MINIMALIF standard rule) <provided witnessScript>
+ *
+ * Note that the nSequence field in the spending input must be set to to_self_delay
+ * (which means the transaction is not broadcastable until at least to_self_delay
+ * blocks after the outpoint confirms).
+ *
+ * These are generally the result of a \"revocable\" output to us, spendable only by us unless
+ * it is an output from an old state which we broadcast (which should never happen).
+ *
+ * To derive the delayed_payment key which is used to sign for this input, you must pass the
+ * local delayed_payment_base_key (ie the private key which corresponds to the pubkey in
+ * ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to
+ * chan_utils::derive_private_key. The public key can be generated without the secret key
+ * using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in
+ * ChannelKeys::pubkeys().
+ *
+ * To derive the remote_revocation_pubkey provided here (which is used in the witness
+ * script generation), you must pass the remote revocation_basepoint (which appears in the
+ * call to ChannelKeys::on_accept) and the provided per_commitment point
+ * to chan_utils::derive_public_revocation_key.
+ *
+ * The witness script which is hashed and included in the output script_pubkey may be
+ * regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey
+ * (derived as above), and the to_self_delay contained here to
+ * chan_utils::get_revokeable_redeemscript.
+ */
+ LDKSpendableOutputDescriptor_DynamicOutputP2WSH,
+ /**
+ * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
+ * corresponds to the public key in ChannelKeys::pubkeys().payment_point).
+ * The witness in the spending input, is, thus, simply:
+ * <BIP 143 signature> <payment key>
+ *
+ * These are generally the result of our counterparty having broadcast the current state,
+ * allowing us to claim the non-HTLC-encumbered outputs immediately.
+ */
+ LDKSpendableOutputDescriptor_StaticOutputRemotePayment,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKSpendableOutputDescriptor_Sentinel,
+} LDKSpendableOutputDescriptor_Tag;
+
+typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body {
+ LDKOutPoint outpoint;
+ LDKTxOut output;
+} LDKSpendableOutputDescriptor_LDKStaticOutput_Body;
+
+typedef struct LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body {
+ LDKOutPoint outpoint;
+ LDKPublicKey per_commitment_point;
+ uint16_t to_self_delay;
+ LDKTxOut output;
+ LDKC2Tuple_u64u64Z key_derivation_params;
+ LDKPublicKey remote_revocation_pubkey;
+} LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body;
+
+typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputRemotePayment_Body {
+ LDKOutPoint outpoint;
+ LDKTxOut output;
+ LDKC2Tuple_u64u64Z key_derivation_params;
+} LDKSpendableOutputDescriptor_LDKStaticOutputRemotePayment_Body;
+
+typedef struct LDKSpendableOutputDescriptor {
+ LDKSpendableOutputDescriptor_Tag tag;
+ union {
+ LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output;
+ LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body dynamic_output_p2wsh;
+ LDKSpendableOutputDescriptor_LDKStaticOutputRemotePayment_Body static_output_remote_payment;
+ };
+} LDKSpendableOutputDescriptor;
+
+typedef struct LDKCVecTempl_SpendableOutputDescriptor {
+ LDKSpendableOutputDescriptor *data;
+ uintptr_t datalen;
+} LDKCVecTempl_SpendableOutputDescriptor;
+
+typedef LDKCVecTempl_SpendableOutputDescriptor LDKCVec_SpendableOutputDescriptorZ;
+
+/**
+ * An Event which you should probably take some action in response to.
+ *
+ * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
+ * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
+ * written as it makes no sense to respond to it after reconnecting to peers).
+ */
+typedef enum LDKEvent_Tag {
+ /**
+ * Used to indicate that the client should generate a funding transaction with the given
+ * parameters and then call ChannelManager::funding_transaction_generated.
+ * Generated in ChannelManager message handling.
+ * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
+ * counterparty can steal your funds!
+ */
+ LDKEvent_FundingGenerationReady,
+ /**
+ * Used to indicate that the client may now broadcast the funding transaction it created for a
+ * channel. Broadcasting such a transaction prior to this event may lead to our counterparty
+ * trivially stealing all funds in the funding transaction!
+ */
+ LDKEvent_FundingBroadcastSafe,
+ /**
+ * Indicates we've received money! Just gotta dig out that payment preimage and feed it to
+ * ChannelManager::claim_funds to get it....
+ * Note that if the preimage is not known or the amount paid is incorrect, you should call
+ * ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
+ * network congestion.
+ * The amount paid should be considered 'incorrect' when it is less than or more than twice
+ * the amount expected.
+ * If you fail to call either ChannelManager::claim_funds or
+ * ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
+ * automatically failed.
+ */
+ LDKEvent_PaymentReceived,
+ /**
+ * Indicates an outbound payment we made succeeded (ie it made it all the way to its target
+ * and we got back the payment preimage for it).
+ * Note that duplicative PaymentSent Events may be generated - it is your responsibility to
+ * deduplicate them by payment_preimage (which MUST be unique)!
+ */
+ LDKEvent_PaymentSent,
+ /**
+ * Indicates an outbound payment we made failed. Probably some intermediary node dropped
+ * something. You may wish to retry with a different route.
+ * Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
+ * deduplicate them by payment_hash (which MUST be unique)!
+ */
+ LDKEvent_PaymentFailed,
+ /**
+ * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
+ * time in the future.
+ */
+ LDKEvent_PendingHTLCsForwardable,
+ /**
+ * Used to indicate that an output was generated on-chain which you should know how to spend.
+ * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
+ * counterparty spending them due to some kind of timeout. Thus, you need to store them
+ * somewhere and spend them when you create on-chain transactions.
+ */
+ LDKEvent_SpendableOutputs,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKEvent_Sentinel,
+} LDKEvent_Tag;
+
+typedef struct LDKEvent_LDKFundingGenerationReady_Body {
+ LDKThirtyTwoBytes temporary_channel_id;
+ uint64_t channel_value_satoshis;
+ LDKCVec_u8Z output_script;
+ uint64_t user_channel_id;
+} LDKEvent_LDKFundingGenerationReady_Body;
+
+typedef struct LDKEvent_LDKFundingBroadcastSafe_Body {
+ LDKOutPoint funding_txo;
+ uint64_t user_channel_id;
+} LDKEvent_LDKFundingBroadcastSafe_Body;
+
+typedef struct LDKEvent_LDKPaymentReceived_Body {
+ LDKThirtyTwoBytes payment_hash;
+ LDKThirtyTwoBytes payment_secret;
+ uint64_t amt;
+} LDKEvent_LDKPaymentReceived_Body;
+
+typedef struct LDKEvent_LDKPaymentSent_Body {
+ LDKThirtyTwoBytes payment_preimage;
+} LDKEvent_LDKPaymentSent_Body;
+
+typedef struct LDKEvent_LDKPaymentFailed_Body {
+ LDKThirtyTwoBytes payment_hash;
+ bool rejected_by_dest;
+} LDKEvent_LDKPaymentFailed_Body;
+
+typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body {
+ uint64_t time_forwardable;
+} LDKEvent_LDKPendingHTLCsForwardable_Body;
+
+typedef struct LDKEvent_LDKSpendableOutputs_Body {
+ LDKCVec_SpendableOutputDescriptorZ outputs;
+} LDKEvent_LDKSpendableOutputs_Body;
+
+typedef struct LDKEvent {
+ LDKEvent_Tag tag;
+ union {
+ LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready;
+ LDKEvent_LDKFundingBroadcastSafe_Body funding_broadcast_safe;
+ LDKEvent_LDKPaymentReceived_Body payment_received;
+ LDKEvent_LDKPaymentSent_Body payment_sent;
+ LDKEvent_LDKPaymentFailed_Body payment_failed;
+ LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable;
+ LDKEvent_LDKSpendableOutputs_Body spendable_outputs;
+ };
+} LDKEvent;
+
+
+
+/**
+ * An accept_channel message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKAcceptChannel {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeAcceptChannel *inner;
+ bool is_owned;
+} LDKAcceptChannel;
+
+
+
+/**
+ * An open_channel message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKOpenChannel {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeOpenChannel *inner;
+ bool is_owned;
+} LDKOpenChannel;
+
+
+
+/**
+ * A funding_created message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKFundingCreated {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeFundingCreated *inner;
+ bool is_owned;
+} LDKFundingCreated;
+
+
+
+/**
+ * A funding_signed message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKFundingSigned {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeFundingSigned *inner;
+ bool is_owned;
+} LDKFundingSigned;
+
+
+
+/**
+ * A funding_locked message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKFundingLocked {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeFundingLocked *inner;
+ bool is_owned;
+} LDKFundingLocked;
+
+
+
+/**
+ * An announcement_signatures message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeAnnouncementSignatures *inner;
+ bool is_owned;
+} LDKAnnouncementSignatures;
+
+
+
+/**
+ * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
+ * transaction updates if they were pending.
+ */
+typedef struct MUST_USE_STRUCT LDKCommitmentUpdate {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeCommitmentUpdate *inner;
+ bool is_owned;
+} LDKCommitmentUpdate;
+
+
+
+/**
+ * A revoke_and_ack message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKRevokeAndACK {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeRevokeAndACK *inner;
+ bool is_owned;
+} LDKRevokeAndACK;
+
+
+
+/**
+ * A closing_signed message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKClosingSigned {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeClosingSigned *inner;
+ bool is_owned;
+} LDKClosingSigned;
+
+
+
+/**
+ * A shutdown message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKShutdown {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeShutdown *inner;
+ bool is_owned;
+} LDKShutdown;
+
+
+
+/**
+ * A channel_reestablish message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKChannelReestablish {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelReestablish *inner;
+ bool is_owned;
+} LDKChannelReestablish;
+
+
+
+/**
+ * A node_announcement message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKNodeAnnouncement {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeNodeAnnouncement *inner;
+ bool is_owned;
+} LDKNodeAnnouncement;
+
+
+
+/**
+ * An error message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKErrorMessage {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeErrorMessage *inner;
+ bool is_owned;
+} LDKErrorMessage;
+
+/**
+ * Used to put an error message in a LightningError
+ */
+typedef enum LDKErrorAction_Tag {
+ /**
+ * The peer took some action which made us think they were useless. Disconnect them.
+ */
+ LDKErrorAction_DisconnectPeer,
+ /**
+ * The peer did something harmless that we weren't able to process, just log and ignore
+ */
+ LDKErrorAction_IgnoreError,
+ /**
+ * The peer did something incorrect. Tell them.
+ */
+ LDKErrorAction_SendErrorMessage,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKErrorAction_Sentinel,
+} LDKErrorAction_Tag;
+
+typedef struct LDKErrorAction_LDKDisconnectPeer_Body {
+ LDKErrorMessage msg;
+} LDKErrorAction_LDKDisconnectPeer_Body;
+
+typedef struct LDKErrorAction_LDKSendErrorMessage_Body {
+ LDKErrorMessage msg;
+} LDKErrorAction_LDKSendErrorMessage_Body;
+
+typedef struct LDKErrorAction {
+ LDKErrorAction_Tag tag;
+ union {
+ LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer;
+ LDKErrorAction_LDKSendErrorMessage_Body send_error_message;
+ };
+} LDKErrorAction;
+
+/**
+ * The information we received from a peer along the route of a payment we originated. This is
+ * returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
+ * RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
+ */
+typedef enum LDKHTLCFailChannelUpdate_Tag {
+ /**
+ * We received an error which included a full ChannelUpdate message.
+ */
+ LDKHTLCFailChannelUpdate_ChannelUpdateMessage,
+ /**
+ * We received an error which indicated only that a channel has been closed
+ */
+ LDKHTLCFailChannelUpdate_ChannelClosed,
+ /**
+ * We received an error which indicated only that a node has failed
+ */
+ LDKHTLCFailChannelUpdate_NodeFailure,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKHTLCFailChannelUpdate_Sentinel,
+} LDKHTLCFailChannelUpdate_Tag;
+
+typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body {
+ LDKChannelUpdate msg;
+} LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body;
+
+typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body {
+ uint64_t short_channel_id;
+ bool is_permanent;
+} LDKHTLCFailChannelUpdate_LDKChannelClosed_Body;
+
+typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body {
+ LDKPublicKey node_id;
+ bool is_permanent;
+} LDKHTLCFailChannelUpdate_LDKNodeFailure_Body;
+
+typedef struct LDKHTLCFailChannelUpdate {
+ LDKHTLCFailChannelUpdate_Tag tag;
+ union {
+ LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body channel_update_message;
+ LDKHTLCFailChannelUpdate_LDKChannelClosed_Body channel_closed;
+ LDKHTLCFailChannelUpdate_LDKNodeFailure_Body node_failure;
+ };
+} LDKHTLCFailChannelUpdate;
+
+/**
+ * An event generated by ChannelManager which indicates a message should be sent to a peer (or
+ * broadcast to most peers).
+ * These events are handled by PeerManager::process_events if you are using a PeerManager.
+ */
+typedef enum LDKMessageSendEvent_Tag {
+ /**
+ * Used to indicate that we've accepted a channel open and should send the accept_channel
+ * message provided to the given peer.
+ */
+ LDKMessageSendEvent_SendAcceptChannel,
+ /**
+ * Used to indicate that we've initiated a channel open and should send the open_channel
+ * message provided to the given peer.
+ */
+ LDKMessageSendEvent_SendOpenChannel,
+ /**
+ * Used to indicate that a funding_created message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendFundingCreated,
+ /**
+ * Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendFundingSigned,
+ /**
+ * Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendFundingLocked,
+ /**
+ * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendAnnouncementSignatures,
+ /**
+ * Used to indicate that a series of HTLC update messages, as well as a commitment_signed
+ * message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_UpdateHTLCs,
+ /**
+ * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendRevokeAndACK,
+ /**
+ * Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendClosingSigned,
+ /**
+ * Used to indicate that a shutdown message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendShutdown,
+ /**
+ * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendChannelReestablish,
+ /**
+ * Used to indicate that a channel_announcement and channel_update should be broadcast to all
+ * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
+ *
+ * Note that after doing so, you very likely (unless you did so very recently) want to call
+ * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
+ * This ensures that any nodes which see our channel_announcement also have a relevant
+ * node_announcement, including relevant feature flags which may be important for routing
+ * through or to us.
+ */
+ LDKMessageSendEvent_BroadcastChannelAnnouncement,
+ /**
+ * Used to indicate that a node_announcement should be broadcast to all peers.
+ */
+ LDKMessageSendEvent_BroadcastNodeAnnouncement,
+ /**
+ * Used to indicate that a channel_update should be broadcast to all peers.
+ */
+ LDKMessageSendEvent_BroadcastChannelUpdate,
+ /**
+ * Broadcast an error downstream to be handled
+ */
+ LDKMessageSendEvent_HandleError,
+ /**
+ * When a payment fails we may receive updates back from the hop where it failed. In such
+ * cases this event is generated so that we can inform the network graph of this information.
+ */
+ LDKMessageSendEvent_PaymentFailureNetworkUpdate,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKMessageSendEvent_Sentinel,
+} LDKMessageSendEvent_Tag;
+
+typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body {
+ LDKPublicKey node_id;
+ LDKAcceptChannel msg;
+} LDKMessageSendEvent_LDKSendAcceptChannel_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body {
+ LDKPublicKey node_id;
+ LDKOpenChannel msg;
+} LDKMessageSendEvent_LDKSendOpenChannel_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body {
+ LDKPublicKey node_id;
+ LDKFundingCreated msg;
+} LDKMessageSendEvent_LDKSendFundingCreated_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body {
+ LDKPublicKey node_id;
+ LDKFundingSigned msg;
+} LDKMessageSendEvent_LDKSendFundingSigned_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body {
+ LDKPublicKey node_id;
+ LDKFundingLocked msg;
+} LDKMessageSendEvent_LDKSendFundingLocked_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body {
+ LDKPublicKey node_id;
+ LDKAnnouncementSignatures msg;
+} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body;
+
+typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body {
+ LDKPublicKey node_id;
+ LDKCommitmentUpdate updates;
+} LDKMessageSendEvent_LDKUpdateHTLCs_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body {
+ LDKPublicKey node_id;
+ LDKRevokeAndACK msg;
+} LDKMessageSendEvent_LDKSendRevokeAndACK_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body {
+ LDKPublicKey node_id;
+ LDKClosingSigned msg;
+} LDKMessageSendEvent_LDKSendClosingSigned_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendShutdown_Body {
+ LDKPublicKey node_id;
+ LDKShutdown msg;
+} LDKMessageSendEvent_LDKSendShutdown_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body {
+ LDKPublicKey node_id;
+ LDKChannelReestablish msg;
+} LDKMessageSendEvent_LDKSendChannelReestablish_Body;
+
+typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body {
+ LDKChannelAnnouncement msg;
+ LDKChannelUpdate update_msg;
+} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body;
+
+typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body {
+ LDKNodeAnnouncement msg;
+} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body;
+
+typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body {
+ LDKChannelUpdate msg;
+} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body;
+
+typedef struct LDKMessageSendEvent_LDKHandleError_Body {
+ LDKPublicKey node_id;
+ LDKErrorAction action;
+} LDKMessageSendEvent_LDKHandleError_Body;
+
+typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body {
+ LDKHTLCFailChannelUpdate update;
+} LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body;
+
+typedef struct LDKMessageSendEvent {
+ LDKMessageSendEvent_Tag tag;
+ union {
+ LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel;
+ LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel;
+ LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created;
+ LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed;
+ LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked;
+ LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures;
+ LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs;
+ LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack;
+ LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed;
+ LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown;
+ LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish;
+ LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement;
+ LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement;
+ LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
+ LDKMessageSendEvent_LDKHandleError_Body handle_error;
+ LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update;
+ };
+} LDKMessageSendEvent;
+
+typedef struct LDKCVecTempl_MessageSendEvent {
+ LDKMessageSendEvent *data;
+ uintptr_t datalen;
+} LDKCVecTempl_MessageSendEvent;
+
+typedef LDKCVecTempl_MessageSendEvent LDKCVec_MessageSendEventZ;
+
+/**
+ * A trait indicating an object may generate message send events
+ */
+typedef struct LDKMessageSendEventsProvider {
+ void *this_arg;
+ /**
+ * Gets the list of pending events which were generated by previous actions, clearing the list
+ * in the process.
+ */
+ LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKMessageSendEventsProvider;
+
+typedef struct LDKCVecTempl_Event {
+ LDKEvent *data;
+ uintptr_t datalen;
+} LDKCVecTempl_Event;
+
+typedef LDKCVecTempl_Event LDKCVec_EventZ;
+
+/**
+ * A trait indicating an object may generate events
+ */
+typedef struct LDKEventsProvider {
+ void *this_arg;
+ /**
+ * Gets the list of pending events which were generated by previous actions, clearing the list
+ * in the process.
+ */
+ LDKCVec_EventZ (*get_and_clear_pending_events)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKEventsProvider;
+
+/**
+ * A trait encapsulating the operations required of a logger
+ */
+typedef struct LDKLogger {
+ void *this_arg;
+ /**
+ * Logs the `Record`
+ */
+ void (*log)(const void *this_arg, const char *record);
+ void (*free)(void *this_arg);
+} LDKLogger;
+
+
+
+/**
+ * Configuration we set when applicable.
+ *
+ * Default::default() provides sane defaults.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelHandshakeConfig *inner;
+ bool is_owned;
+} LDKChannelHandshakeConfig;
+
+
+
+/**
+ * Optional channel limits which are applied during channel creation.
+ *
+ * These limits are only applied to our counterparty's limits, not our own.
+ *
+ * Use 0/<type>::max_value() as appropriate to skip checking.
+ *
+ * Provides sane defaults for most configurations.
+ *
+ * Most additional limits are disabled except those with which specify a default in individual
+ * field documentation. Note that this may result in barely-usable channels, but since they
+ * are applied mostly only to incoming channels that's not much of a problem.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelHandshakeLimits *inner;
+ bool is_owned;
+} LDKChannelHandshakeLimits;
+
+
+
+/**
+ * Options which apply on a per-channel basis and may change at runtime or based on negotiation
+ * with our counterparty.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelConfig {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelConfig *inner;
+ bool is_owned;
+} LDKChannelConfig;
+
+typedef struct LDKu8slice {
+ const uint8_t *data;
+ uintptr_t datalen;
+} LDKu8slice;
+
+
+
+/**
+ * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
+ *
+ * Default::default() provides sane defaults for most configurations
+ * (but currently with 0 relay fees!)
+ */
+typedef struct MUST_USE_STRUCT LDKUserConfig {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUserConfig *inner;
+ bool is_owned;
+} LDKUserConfig;
+
+typedef union LDKCResultPtr_C2TupleTempl_CVec_u8Z__u64_____ChainError {
+ LDKC2TupleTempl_CVec_u8Z__u64 *result;
+ LDKChainError *err;
+} LDKCResultPtr_C2TupleTempl_CVec_u8Z__u64_____ChainError;
+
+typedef struct LDKCResultTempl_C2TupleTempl_CVec_u8Z__u64_____ChainError {
+ LDKCResultPtr_C2TupleTempl_CVec_u8Z__u64_____ChainError contents;
+ bool result_ok;
+} LDKCResultTempl_C2TupleTempl_CVec_u8Z__u64_____ChainError;
+
+typedef LDKCResultTempl_C2TupleTempl_CVec_u8Z__u64_____ChainError LDKCResult_C2Tuple_Scriptu64ZChainErrorZ;
+
+typedef struct LDKCVecTempl_usize {
+ uintptr_t *data;
+ uintptr_t datalen;
+} LDKCVecTempl_usize;
+
+typedef LDKCVecTempl_usize LDKCVec_usizeZ;
+
+/**
+ * An interface to request notification of certain scripts as they appear the
+ * chain.
+ *
+ * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
+ * called from inside the library in response to ChainListener events, P2P events, or timer
+ * events).
+ */
+typedef struct LDKChainWatchInterface {
+ void *this_arg;
+ /**
+ * Provides a txid/random-scriptPubKey-in-the-tx which much be watched for.
+ */
+ void (*install_watch_tx)(const void *this_arg, const uint8_t (*txid)[32], LDKu8slice script_pub_key);
+ /**
+ * Provides an outpoint which must be watched for, providing any transactions which spend the
+ * given outpoint.
+ */
+ void (*install_watch_outpoint)(const void *this_arg, LDKC2Tuple_Txidu32Z outpoint, LDKu8slice out_script);
+ /**
+ * Indicates that a listener needs to see all transactions.
+ */
+ void (*watch_all_txn)(const void *this_arg);
+ /**
+ * Gets the script and value in satoshis for a given unspent transaction output given a
+ * short_channel_id (aka unspent_tx_output_identier). For BTC/tBTC channels the top three
+ * bytes are the block height, the next 3 the transaction index within the block, and the
+ * final two the output within the transaction.
+ */
+ LDKCResult_C2Tuple_Scriptu64ZChainErrorZ (*get_chain_utxo)(const void *this_arg, LDKThirtyTwoBytes genesis_hash, uint64_t unspent_tx_output_identifier);
+ /**
+ * Gets the list of transaction indices within a given block that the ChainWatchInterface is
+ * watching for.
+ */
+ LDKCVec_usizeZ (*filter_block)(const void *this_arg, LDKu8slice block);
+ /**
+ * Returns a usize that changes when the ChainWatchInterface's watched data is modified.
+ * Users of `filter_block` should pre-save a copy of `reentered`'s return value and use it to
+ * determine whether they need to re-filter a given block.
+ */
+ uintptr_t (*reentered)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKChainWatchInterface;
+
+/**
+ * A reference to a serialized transaction, in (pointer, length) form.
+ * This type does *not* own its own memory, so access to it after, eg, the call in which it was
+ * provided to you are invalid.
+ */
+typedef struct LDKTransaction {
+ const uint8_t *data;
+ uintptr_t datalen;
+} LDKTransaction;
+
+/**
+ * An interface to send a transaction to the Bitcoin network.
+ */
+typedef struct LDKBroadcasterInterface {
+ void *this_arg;
+ /**
+ * Sends a transaction out to (hopefully) be mined.
+ */
+ void (*broadcast_transaction)(const void *this_arg, LDKTransaction tx);
+ void (*free)(void *this_arg);
+} LDKBroadcasterInterface;
+
+typedef struct LDKCVecTempl_CVec_u8Z {
+ LDKCVec_u8Z *data;
+ uintptr_t datalen;
+} LDKCVecTempl_CVec_u8Z;
+
+typedef LDKCVecTempl_CVec_u8Z LDKCVec_TransactionZ;
+
+typedef struct LDKusizeslice {
+ const uintptr_t *data;
+ uintptr_t datalen;
+} LDKusizeslice;
+
+/**
+ * A trait indicating a desire to listen for events from the chain
+ */
+typedef struct LDKChainListener {
+ void *this_arg;
+ /**
+ * Notifies a listener that a block was connected.
+ *
+ * The txn_matched array should be set to references to transactions which matched the
+ * relevant installed watch outpoints/txn, or the full set of transactions in the block.
+ *
+ * Note that if txn_matched includes only matched transactions, and a new
+ * transaction/outpoint is watched during a block_connected call, the block *must* be
+ * re-scanned with the new transaction/outpoints and block_connected should be called
+ * again with the same header and (at least) the new transactions.
+ *
+ * Note that if non-new transaction/outpoints are be registered during a call, a second call
+ * *must not* happen.
+ *
+ * This also means those counting confirmations using block_connected callbacks should watch
+ * for duplicate headers and not count them towards confirmations!
+ */
+ void (*block_connected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height, LDKCVec_TransactionZ txn_matched, LDKusizeslice indexes_of_txn_matched);
+ /**
+ * Notifies a listener that a block was disconnected.
+ * Unlike block_connected, this *must* never be called twice for the same disconnect event.
+ * Height must be the one of the block which was disconnected (not new height of the best chain)
+ */
+ void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height);
+ void (*free)(void *this_arg);
+} LDKChainListener;
+
+/**
+ * A trait which should be implemented to provide feerate information on a number of time
+ * horizons.
+ *
+ * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
+ * called from inside the library in response to ChainListener events, P2P events, or timer
+ * events).
+ */
+typedef struct LDKFeeEstimator {
+ void *this_arg;
+ /**
+ * Gets estimated satoshis of fee required per 1000 Weight-Units.
+ *
+ * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
+ * don't put us below 1 satoshi-per-byte).
+ *
+ * This translates to:
+ * * satoshis-per-byte * 250
+ * * ceil(satoshis-per-kbyte / 4)
+ */
+ uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, LDKConfirmationTarget confirmation_target);
+ void (*free)(void *this_arg);
+} LDKFeeEstimator;
+
+
+
+/**
+ * Utility for tracking registered txn/outpoints and checking for matches
+ */
+typedef struct MUST_USE_STRUCT LDKChainWatchedUtil {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChainWatchedUtil *inner;
+ bool is_owned;
+} LDKChainWatchedUtil;
+
+
+
+/**
+ * Utility for notifying listeners about new blocks, and handling block rescans if new watch
+ * data is registered.
+ *
+ * Rather than using a plain BlockNotifier, it is preferable to use either a BlockNotifierArc
+ * or a BlockNotifierRef for conciseness. See their documentation for more details, but essentially
+ * you should default to using a BlockNotifierRef, and use a BlockNotifierArc instead when you
+ * require ChainListeners with static lifetimes, such as when you're using lightning-net-tokio.
+ */
+typedef struct MUST_USE_STRUCT LDKBlockNotifier {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeBlockNotifier *inner;
+ bool is_owned;
+} LDKBlockNotifier;
+
+
+
+/**
+ * Utility to capture some common parts of ChainWatchInterface implementors.
+ *
+ * Keeping a local copy of this in a ChainWatchInterface implementor is likely useful.
+ */
+typedef struct MUST_USE_STRUCT LDKChainWatchInterfaceUtil {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChainWatchInterfaceUtil *inner;
+ bool is_owned;
+} LDKChainWatchInterfaceUtil;
+
+
+
+/**
+ * One counterparty's public keys which do not change over the life of a channel.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelPublicKeys {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelPublicKeys *inner;
+ bool is_owned;
+} LDKChannelPublicKeys;
+
+
+
+/**
+ * The per-commitment point and a set of pre-calculated public keys used for transaction creation
+ * in the signer.
+ * The pre-calculated keys are an optimization, because ChannelKeys has enough
+ * information to re-derive them.
+ */
+typedef struct MUST_USE_STRUCT LDKPreCalculatedTxCreationKeys {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativePreCalculatedTxCreationKeys *inner;
+ bool is_owned;
+} LDKPreCalculatedTxCreationKeys;
+
+typedef struct LDKCVecTempl_HTLCOutputInCommitment {
+ LDKHTLCOutputInCommitment *data;
+ uintptr_t datalen;
+} LDKCVecTempl_HTLCOutputInCommitment;
+
+typedef LDKCVecTempl_HTLCOutputInCommitment LDKCVec_HTLCOutputInCommitmentZ;
+
+
+
+/**
+ * We use this to track local commitment transactions and put off signing them until we are ready
+ * to broadcast. This class can be used inside a signer implementation to generate a signature
+ * given the relevant secret key.
+ */
+typedef struct MUST_USE_STRUCT LDKLocalCommitmentTransaction {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeLocalCommitmentTransaction *inner;
+ bool is_owned;
+} LDKLocalCommitmentTransaction;
+
+
+
+/**
+ * The unsigned part of a channel_announcement
+ */
+typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUnsignedChannelAnnouncement *inner;
+ bool is_owned;
+} LDKUnsignedChannelAnnouncement;
+
+/**
+ * Set of lightning keys needed to operate a channel as described in BOLT 3.
+ *
+ * Signing services could be implemented on a hardware wallet. In this case,
+ * the current ChannelKeys would be a front-end on top of a communication
+ * channel connected to your secure device and lightning key material wouldn't
+ * reside on a hot server. Nevertheless, a this deployment would still need
+ * to trust the ChannelManager to avoid loss of funds as this latest component
+ * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
+ *
+ * A more secure iteration would be to use hashlock (or payment points) to pair
+ * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
+ * at the price of more state and computation on the hardware wallet side. In the future,
+ * we are looking forward to design such interface.
+ *
+ * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
+ * to act, as liveness and breach reply correctness are always going to be hard requirements
+ * of LN security model, orthogonal of key management issues.
+ *
+ * If you're implementing a custom signer, you almost certainly want to implement
+ * Readable/Writable to serialize out a unique reference to this set of keys so
+ * that you can serialize the full ChannelManager object.
+ *
+ */
+typedef struct LDKChannelKeys {
+ void *this_arg;
+ /**
+ * Gets the per-commitment point for a specific commitment number
+ *
+ * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
+ */
+ LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx);
+ /**
+ * Gets the commitment secret for a specific commitment number as part of the revocation process
+ *
+ * An external signer implementation should error here if the commitment was already signed
+ * and should refuse to sign it in the future.
+ *
+ * May be called more than once for the same index.
+ *
+ * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
+ * TODO: return a Result so we can signal a validation error
+ */
+ LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx);
+ /**
+ * Gets the local channel public keys and basepoints
+ */
+ LDKChannelPublicKeys pubkeys;
+ /**
+ * Fill in the pubkeys field as a reference to it will be given to Rust after this returns
+ * Note that this takes a pointer to this object, not the this_ptr like other methods do
+ * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
+ */
+ void (*set_pubkeys)(const LDKChannelKeys*);
+ /**
+ * Gets arbitrary identifiers describing the set of keys which are provided back to you in
+ * some SpendableOutputDescriptor types. These should be sufficient to identify this
+ * ChannelKeys object uniquely and lookup or re-derive its keys.
+ */
+ LDKC2Tuple_u64u64Z (*key_derivation_params)(const void *this_arg);
+ /**
+ * Create a signature for a remote commitment transaction and associated HTLC transactions.
+ *
+ * Note that if signing fails or is rejected, the channel will be force-closed.
+ */
+ 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);
+ /**
+ * Create a signature for a local commitment transaction. This will only ever be called with
+ * the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
+ * that it will not be called multiple times.
+ * An external signer implementation should check that the commitment has not been revoked.
+ */
+ LDKCResult_SignatureNoneZ (*sign_local_commitment)(const void *this_arg, const LDKLocalCommitmentTransaction *local_commitment_tx);
+ /**
+ * Create a signature for each HTLC transaction spending a local commitment transaction.
+ *
+ * Unlike sign_local_commitment, this may be called multiple times with *different*
+ * local_commitment_tx values. While this will never be called with a revoked
+ * local_commitment_tx, it is possible that it is called with the second-latest
+ * local_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
+ * ChannelMonitor decided to broadcast before it had been updated to the latest.
+ *
+ * Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
+ * local_commitment_tx. For those HTLCs which have transaction_output_index set to None
+ * (implying they were considered dust at the time the commitment transaction was negotiated),
+ * a corresponding None should be included in the return value. All other positions in the
+ * return value must contain a signature.
+ */
+ LDKCResult_CVec_SignatureZNoneZ (*sign_local_commitment_htlc_transactions)(const void *this_arg, const LDKLocalCommitmentTransaction *local_commitment_tx);
+ /**
+ * Create a signature for the given input in a transaction spending an HTLC or commitment
+ * transaction output when our counterparty broadcasts an old state.
+ *
+ * A justice transaction may claim multiples outputs at the same time if timelocks are
+ * similar, but only a signature for the input at index `input` should be signed for here.
+ * It may be called multiples time for same output(s) if a fee-bump is needed with regards
+ * to an upcoming timelock expiration.
+ *
+ * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ *
+ * per_commitment_key is revocation secret which was provided by our counterparty when they
+ * revoked the state which they eventually broadcast. It's not a _local_ secret key and does
+ * not allow the spending of any funds by itself (you need our local revocation_secret to do
+ * so).
+ *
+ * htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
+ * changing the format of the witness script (which is committed to in the BIP 143
+ * signatures).
+ */
+ 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);
+ /**
+ * Create a signature for a claiming transaction for a HTLC output on a remote commitment
+ * transaction, either offered or received.
+ *
+ * Such a transaction may claim multiples offered outputs at same time if we know the
+ * preimage for each when we create it, but only the input at index `input` should be
+ * signed for here. It may be called multiple times for same output(s) if a fee-bump is
+ * needed with regards to an upcoming timelock expiration.
+ *
+ * Witness_script is either a offered or received script as defined in BOLT3 for HTLC
+ * outputs.
+ *
+ * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ *
+ * Per_commitment_point is the dynamic point corresponding to the channel state
+ * detected onchain. It has been generated by our counterparty and is used to derive
+ * channel state keys, which are then included in the witness script and committed to in the
+ * BIP 143 signature.
+ */
+ 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);
+ /**
+ * Create a signature for a (proposed) closing transaction.
+ *
+ * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
+ * chosen to forgo their output as dust.
+ */
+ LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, LDKTransaction closing_tx);
+ /**
+ * Signs a channel announcement message with our funding key, proving it comes from one
+ * of the channel participants.
+ *
+ * Note that if this fails or is rejected, the channel will not be publicly announced and
+ * our counterparty may (though likely will not) close the channel on us for violating the
+ * protocol.
+ */
+ LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const LDKUnsignedChannelAnnouncement *msg);
+ /**
+ * Set the remote channel basepoints and remote/local to_self_delay.
+ * This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels.
+ *
+ * We bind local_to_self_delay late here for API convenience.
+ *
+ * Will be called before any signatures are applied.
+ */
+ void (*on_accept)(void *this_arg, const LDKChannelPublicKeys *channel_points, uint16_t remote_to_self_delay, uint16_t local_to_self_delay);
+ void *(*clone)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKChannelKeys;
+
+typedef struct LDKSecretKey {
+ uint8_t bytes[32];
+} LDKSecretKey;
+
+/**
+ * A trait to describe an object which can get user secrets and key material.
+ */
+typedef struct LDKKeysInterface {
+ void *this_arg;
+ /**
+ * Get node secret key (aka node_id or network_key)
+ */
+ LDKSecretKey (*get_node_secret)(const void *this_arg);
+ /**
+ * Get destination redeemScript to encumber static protocol exit points.
+ */
+ LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
+ /**
+ * Get shutdown_pubkey to use as PublicKey at channel closure
+ */
+ LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg);
+ /**
+ * Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
+ * restarted with some stale data!
+ */
+ LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis);
+ /**
+ * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
+ * onion packets and for temporary channel IDs. There is no requirement that these be
+ * persisted anywhere, though they must be unique across restarts.
+ */
+ LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKKeysInterface;
+
+
+
+/**
+ * A simple implementation of ChannelKeys that just keeps the private keys in memory.
+ */
+typedef struct MUST_USE_STRUCT LDKInMemoryChannelKeys {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeInMemoryChannelKeys *inner;
+ bool is_owned;
+} LDKInMemoryChannelKeys;
+
+
+
+/**
+ * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key
+ * and derives keys from that.
+ *
+ * Your node_id is seed/0'
+ * ChannelMonitor closes may use seed/1'
+ * Cooperative closes may use seed/2'
+ * The two close keys may be needed to claim on-chain funds!
+ */
+typedef struct MUST_USE_STRUCT LDKKeysManager {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeKeysManager *inner;
+ bool is_owned;
+} LDKKeysManager;
+
+
+
+/**
+ * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
+ * on-chain transactions to ensure no loss of funds occurs.
+ *
+ * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
+ * information and are actively monitoring the chain.
+ *
+ * Pending Events or updated HTLCs which have not yet been read out by
+ * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
+ * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
+ * gotten are fully handled before re-serializing the new state.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelMonitor {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelMonitor *inner;
+ bool is_owned;
+} LDKChannelMonitor;
+
+
+
+/**
+ * An update generated by the underlying Channel itself which contains some new information the
+ * ChannelMonitor should be made aware of.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelMonitorUpdate *inner;
+ bool is_owned;
+} LDKChannelMonitorUpdate;
+
+
+
+/**
+ * An event to be processed by the ChannelManager.
+ */
+typedef struct MUST_USE_STRUCT LDKMonitorEvent {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeMonitorEvent *inner;
+ bool is_owned;
+} LDKMonitorEvent;
+
+typedef struct LDKCVecTempl_MonitorEvent {
+ LDKMonitorEvent *data;
+ uintptr_t datalen;
+} LDKCVecTempl_MonitorEvent;
+
+typedef LDKCVecTempl_MonitorEvent LDKCVec_MonitorEventZ;
+
+/**
+ * Simple trait indicating ability to track a set of ChannelMonitors and multiplex events between
+ * them. Generally should be implemented by keeping a local SimpleManyChannelMonitor and passing
+ * events to it, while also taking any add/update_monitor events and passing them to some remote
+ * server(s).
+ *
+ * In general, you must always have at least one local copy in memory, which must never fail to
+ * update (as it is responsible for broadcasting the latest state in case the channel is closed),
+ * and then persist it to various on-disk locations. If, for some reason, the in-memory copy fails
+ * to update (eg out-of-memory or some other condition), you must immediately shut down without
+ * taking any further action such as writing the current state to disk. This should likely be
+ * accomplished via panic!() or abort().
+ *
+ * Note that any updates to a channel's monitor *must* be applied to each instance of the
+ * channel's monitor everywhere (including remote watchtowers) *before* this function returns. If
+ * an update occurs and a remote watchtower is left with old state, it may broadcast transactions
+ * which we have revoked, allowing our counterparty to claim all funds in the channel!
+ *
+ * User needs to notify implementors of ManyChannelMonitor when a new block is connected or
+ * disconnected using their `block_connected` and `block_disconnected` methods. However, rather
+ * than calling these methods directly, the user should register implementors as listeners to the
+ * BlockNotifier and call the BlockNotifier's `block_(dis)connected` methods, which will notify
+ * all registered listeners in one go.
+ */
+typedef struct LDKManyChannelMonitor {
+ void *this_arg;
+ /**
+ * Adds a monitor for the given `funding_txo`.
+ *
+ * Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
+ * any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
+ * callbacks with the funding transaction, or any spends of it.
+ *
+ * Further, the implementer must also ensure that each output returned in
+ * monitor.get_outputs_to_watch() is registered to ensure that the provided monitor learns about
+ * any spends of any of the outputs.
+ *
+ * Any spends of outputs which should have been registered which aren't passed to
+ * ChannelMonitors via block_connected may result in FUNDS LOSS.
+ */
+ LDKCResult_NoneChannelMonitorUpdateErrZ (*add_monitor)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor);
+ /**
+ * Updates a monitor for the given `funding_txo`.
+ *
+ * Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
+ * any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
+ * callbacks with the funding transaction, or any spends of it.
+ *
+ * Further, the implementer must also ensure that each output returned in
+ * monitor.get_watch_outputs() is registered to ensure that the provided monitor learns about
+ * any spends of any of the outputs.
+ *
+ * Any spends of outputs which should have been registered which aren't passed to
+ * ChannelMonitors via block_connected may result in FUNDS LOSS.
+ */
+ LDKCResult_NoneChannelMonitorUpdateErrZ (*update_monitor)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate monitor);
+ /**
+ * Used by ChannelManager to get list of HTLC resolved onchain and which needed to be updated
+ * with success or failure.
+ *
+ * You should probably just call through to
+ * ChannelMonitor::get_and_clear_pending_monitor_events() for each ChannelMonitor and return
+ * the full list.
+ */
+ LDKCVec_MonitorEventZ (*get_and_clear_pending_monitor_events)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKManyChannelMonitor;
+
+
+
+/**
+ * Manager which keeps track of a number of channels and sends messages to the appropriate
+ * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
+ *
+ * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
+ * to individual Channels.
+ *
+ * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
+ * all peers during write/read (though does not modify this instance, only the instance being
+ * serialized). This will result in any channels which have not yet exchanged funding_created (ie
+ * called funding_transaction_generated for outbound channels).
+ *
+ * Note that you can be a bit lazier about writing out ChannelManager than you can be with
+ * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
+ * returning from ManyChannelMonitor::add_/update_monitor, with ChannelManagers, writing updates
+ * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
+ * the serialization process). If the deserialized version is out-of-date compared to the
+ * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
+ * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
+ *
+ * Note that the deserializer is only implemented for (Sha256dHash, ChannelManager), which
+ * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
+ * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
+ * block_connected() to step towards your best block) upon deserialization before using the
+ * object!
+ *
+ * Note that ChannelManager is responsible for tracking liveness of its channels and generating
+ * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
+ * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
+ * offline for a full minute. In order to track this, you must call
+ * timer_chan_freshness_every_min roughly once per minute, though it doesn't have to be perfect.
+ *
+ * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
+ * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
+ * essentially you should default to using a SimpleRefChannelManager, and use a
+ * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
+ * you're using lightning-net-tokio.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelManager {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelManager *inner;
+ bool is_owned;
+} LDKChannelManager;
+
+
+
+/**
+ * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
+ */
+typedef struct MUST_USE_STRUCT LDKChannelDetails {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelDetails *inner;
+ bool is_owned;
+} LDKChannelDetails;
+
+
+
+/**
+ * Features used within an `init` message.
+ */
+typedef struct MUST_USE_STRUCT LDKInitFeatures {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeInitFeatures *inner;
+ bool is_owned;
+} LDKInitFeatures;
+
+typedef struct LDKCVecTempl_ChannelDetails {
+ LDKChannelDetails *data;
+ uintptr_t datalen;
+} LDKCVecTempl_ChannelDetails;
+
+typedef LDKCVecTempl_ChannelDetails LDKCVec_ChannelDetailsZ;
+
+
+
+/**
+ * A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
+ * it can take multiple paths. Each path is composed of one or more hops through the network.
+ */
+typedef struct MUST_USE_STRUCT LDKRoute {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeRoute *inner;
+ bool is_owned;
+} LDKRoute;
+
+typedef struct LDKThreeBytes {
+ uint8_t data[3];
+} LDKThreeBytes;
+
+typedef struct LDKFourBytes {
+ uint8_t data[4];
+} LDKFourBytes;
+
+typedef struct LDKSixteenBytes {
+ uint8_t data[16];
+} LDKSixteenBytes;
+
+typedef struct LDKTenBytes {
+ uint8_t data[10];
+} LDKTenBytes;
+
+/**
+ * An address which can be used to connect to a remote peer
+ */
+typedef enum LDKNetAddress_Tag {
+ /**
+ * An IPv4 address/port on which the peer is listening.
+ */
+ LDKNetAddress_IPv4,
+ /**
+ * An IPv6 address/port on which the peer is listening.
+ */
+ LDKNetAddress_IPv6,
+ /**
+ * An old-style Tor onion address/port on which the peer is listening.
+ */
+ LDKNetAddress_OnionV2,
+ /**
+ * A new-style Tor onion address/port on which the peer is listening.
+ * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
+ * wrap as base32 and append \".onion\".
+ */
+ LDKNetAddress_OnionV3,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKNetAddress_Sentinel,
+} LDKNetAddress_Tag;
+
+typedef struct LDKNetAddress_LDKIPv4_Body {
+ LDKFourBytes addr;
+ uint16_t port;
+} LDKNetAddress_LDKIPv4_Body;
+
+typedef struct LDKNetAddress_LDKIPv6_Body {
+ LDKSixteenBytes addr;
+ uint16_t port;
+} LDKNetAddress_LDKIPv6_Body;
+
+typedef struct LDKNetAddress_LDKOnionV2_Body {
+ LDKTenBytes addr;
+ uint16_t port;
+} LDKNetAddress_LDKOnionV2_Body;
+
+typedef struct LDKNetAddress_LDKOnionV3_Body {
+ LDKThirtyTwoBytes ed25519_pubkey;
+ uint16_t checksum;
+ uint8_t version;
+ uint16_t port;
+} LDKNetAddress_LDKOnionV3_Body;
+
+typedef struct LDKNetAddress {
+ LDKNetAddress_Tag tag;
+ union {
+ LDKNetAddress_LDKIPv4_Body i_pv4;
+ LDKNetAddress_LDKIPv6_Body i_pv6;
+ LDKNetAddress_LDKOnionV2_Body onion_v2;
+ LDKNetAddress_LDKOnionV3_Body onion_v3;
+ };
+} LDKNetAddress;
+
+typedef struct LDKCVecTempl_NetAddress {
+ LDKNetAddress *data;
+ uintptr_t datalen;
+} LDKCVecTempl_NetAddress;
+
+typedef LDKCVecTempl_NetAddress LDKCVec_NetAddressZ;
+
+
+
+/**
+ * An update_add_htlc message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUpdateAddHTLC *inner;
+ bool is_owned;
+} LDKUpdateAddHTLC;
+
+
+
+/**
+ * An update_fulfill_htlc message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUpdateFulfillHTLC *inner;
+ bool is_owned;
+} LDKUpdateFulfillHTLC;
+
+
+
+/**
+ * An update_fail_htlc message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUpdateFailHTLC *inner;
+ bool is_owned;
+} LDKUpdateFailHTLC;
+
+
+
+/**
+ * An update_fail_malformed_htlc message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUpdateFailMalformedHTLC *inner;
+ bool is_owned;
+} LDKUpdateFailMalformedHTLC;
+
+
+
+/**
+ * A commitment_signed message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKCommitmentSigned {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeCommitmentSigned *inner;
+ bool is_owned;
+} LDKCommitmentSigned;
+
+
+
+/**
+ * An update_fee message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKUpdateFee {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUpdateFee *inner;
+ bool is_owned;
+} LDKUpdateFee;
+
+
+
+/**
+ * An init message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKInit {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeInit *inner;
+ bool is_owned;
+} LDKInit;
+
+/**
+ * A trait to describe an object which can receive channel messages.
+ *
+ * Messages MAY be called in parallel when they originate from different their_node_ids, however
+ * they MUST NOT be called in parallel when the two calls have the same their_node_id.
+ */
+typedef struct LDKChannelMessageHandler {
+ void *this_arg;
+ /**
+ * Handle an incoming open_channel message from the given peer.
+ */
+ void (*handle_open_channel)(const void *this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg);
+ /**
+ * Handle an incoming accept_channel message from the given peer.
+ */
+ void (*handle_accept_channel)(const void *this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg);
+ /**
+ * Handle an incoming funding_created message from the given peer.
+ */
+ void (*handle_funding_created)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg);
+ /**
+ * Handle an incoming funding_signed message from the given peer.
+ */
+ void (*handle_funding_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg);
+ /**
+ * Handle an incoming funding_locked message from the given peer.
+ */
+ void (*handle_funding_locked)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg);
+ /**
+ * Handle an incoming shutdown message from the given peer.
+ */
+ void (*handle_shutdown)(const void *this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg);
+ /**
+ * Handle an incoming closing_signed message from the given peer.
+ */
+ void (*handle_closing_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg);
+ /**
+ * Handle an incoming update_add_htlc message from the given peer.
+ */
+ void (*handle_update_add_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg);
+ /**
+ * Handle an incoming update_fulfill_htlc message from the given peer.
+ */
+ void (*handle_update_fulfill_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg);
+ /**
+ * Handle an incoming update_fail_htlc message from the given peer.
+ */
+ void (*handle_update_fail_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg);
+ /**
+ * Handle an incoming update_fail_malformed_htlc message from the given peer.
+ */
+ void (*handle_update_fail_malformed_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg);
+ /**
+ * Handle an incoming commitment_signed message from the given peer.
+ */
+ void (*handle_commitment_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg);
+ /**
+ * Handle an incoming revoke_and_ack message from the given peer.
+ */
+ void (*handle_revoke_and_ack)(const void *this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg);
+ /**
+ * Handle an incoming update_fee message from the given peer.
+ */
+ void (*handle_update_fee)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg);
+ /**
+ * Handle an incoming announcement_signatures message from the given peer.
+ */
+ void (*handle_announcement_signatures)(const void *this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg);
+ /**
+ * Indicates a connection to the peer failed/an existing connection was lost. If no connection
+ * is believed to be possible in the future (eg they're sending us messages we don't
+ * understand or indicate they require unknown feature bits), no_connection_possible is set
+ * and any outstanding channels should be failed.
+ */
+ void (*peer_disconnected)(const void *this_arg, LDKPublicKey their_node_id, bool no_connection_possible);
+ /**
+ * Handle a peer reconnecting, possibly generating channel_reestablish message(s).
+ */
+ void (*peer_connected)(const void *this_arg, LDKPublicKey their_node_id, const LDKInit *msg);
+ /**
+ * Handle an incoming channel_reestablish message from the given peer.
+ */
+ void (*handle_channel_reestablish)(const void *this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg);
+ /**
+ * Handle an incoming error message from the given peer.
+ */
+ void (*handle_error)(const void *this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg);
+ LDKMessageSendEventsProvider MessageSendEventsProvider;
+ void (*free)(void *this_arg);
+} LDKChannelMessageHandler;
+
+
+
+/**
+ * Arguments for the creation of a ChannelManager that are not deserialized.
+ *
+ * At a high-level, the process for deserializing a ChannelManager and resuming normal operation
+ * is:
+ * 1) Deserialize all stored ChannelMonitors.
+ * 2) Deserialize the ChannelManager by filling in this struct and calling <(Sha256dHash,
+ * ChannelManager)>::read(reader, args).
+ * This may result in closing some Channels if the ChannelMonitor is newer than the stored
+ * ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted.
+ * 3) Register all relevant ChannelMonitor outpoints with your chain watch mechanism using
+ * ChannelMonitor::get_monitored_outpoints and ChannelMonitor::get_funding_txo().
+ * 4) Reconnect blocks on your ChannelMonitors.
+ * 5) Move the ChannelMonitors into your local ManyChannelMonitor.
+ * 6) Disconnect/connect blocks on the ChannelManager.
+ * 7) Register the new ChannelManager with your ChainWatchInterface.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelManagerReadArgs *inner;
+ bool is_owned;
+} LDKChannelManagerReadArgs;
+
+typedef struct LDKCVecTempl_ChannelMonitor {
+ LDKChannelMonitor *data;
+ uintptr_t datalen;
+} LDKCVecTempl_ChannelMonitor;
+
+typedef LDKCVecTempl_ChannelMonitor LDKCVec_ChannelMonitorZ;
+
+
+
+/**
+ * Simple structure send back by ManyChannelMonitor in case of HTLC detected onchain from a
+ * forward channel and from which info are needed to update HTLC in a backward channel.
+ */
+typedef struct MUST_USE_STRUCT LDKHTLCUpdate {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeHTLCUpdate *inner;
+ bool is_owned;
+} LDKHTLCUpdate;
+
+
+
+/**
+ * An error in decoding a message or struct.
+ */
+typedef struct MUST_USE_STRUCT LDKDecodeError {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeDecodeError *inner;
+ bool is_owned;
+} LDKDecodeError;
+
+
+
+/**
+ * A ping message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKPing {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativePing *inner;
+ bool is_owned;
+} LDKPing;
+
+
+
+/**
+ * A pong message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKPong {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativePong *inner;
+ bool is_owned;
+} LDKPong;
+
+
+
+/**
+ * Proof that the sender knows the per-commitment secret of the previous commitment transaction.
+ * This is used to convince the recipient that the channel is at a certain commitment
+ * number even if they lost that data due to a local failure. Of course, the peer may lie
+ * and even later commitments may have been revoked.
+ */
+typedef struct MUST_USE_STRUCT LDKDataLossProtect {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeDataLossProtect *inner;
+ bool is_owned;
+} LDKDataLossProtect;
+
+
+
+/**
+ * The unsigned part of a node_announcement
+ */
+typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUnsignedNodeAnnouncement *inner;
+ bool is_owned;
+} LDKUnsignedNodeAnnouncement;
+
+
+
+/**
+ * The unsigned part of a channel_update
+ */
+typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeUnsignedChannelUpdate *inner;
+ bool is_owned;
+} LDKUnsignedChannelUpdate;
+
+
+
+/**
+ * An Err type for failure to process messages.
+ */
+typedef struct MUST_USE_STRUCT LDKLightningError {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeLightningError *inner;
+ bool is_owned;
+} LDKLightningError;
+
+typedef struct LDKCVecTempl_UpdateAddHTLC {
+ LDKUpdateAddHTLC *data;
+ uintptr_t datalen;
+} LDKCVecTempl_UpdateAddHTLC;
+
+typedef LDKCVecTempl_UpdateAddHTLC LDKCVec_UpdateAddHTLCZ;
+
+typedef struct LDKCVecTempl_UpdateFulfillHTLC {
+ LDKUpdateFulfillHTLC *data;
+ uintptr_t datalen;
+} LDKCVecTempl_UpdateFulfillHTLC;
+
+typedef LDKCVecTempl_UpdateFulfillHTLC LDKCVec_UpdateFulfillHTLCZ;
+
+typedef struct LDKCVecTempl_UpdateFailHTLC {
+ LDKUpdateFailHTLC *data;
+ uintptr_t datalen;
+} LDKCVecTempl_UpdateFailHTLC;
+
+typedef LDKCVecTempl_UpdateFailHTLC LDKCVec_UpdateFailHTLCZ;
+
+typedef struct LDKCVecTempl_UpdateFailMalformedHTLC {
+ LDKUpdateFailMalformedHTLC *data;
+ uintptr_t datalen;
+} LDKCVecTempl_UpdateFailMalformedHTLC;
+
+typedef LDKCVecTempl_UpdateFailMalformedHTLC LDKCVec_UpdateFailMalformedHTLCZ;
+
+typedef union LDKCResultPtr_bool__LightningError {
+ bool *result;
+ LDKLightningError *err;
+} LDKCResultPtr_bool__LightningError;
+
+typedef struct LDKCResultTempl_bool__LightningError {
+ LDKCResultPtr_bool__LightningError contents;
+ bool result_ok;
+} LDKCResultTempl_bool__LightningError;
+
+typedef LDKCResultTempl_bool__LightningError LDKCResult_boolLightningErrorZ;
+
+typedef struct LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate {
+ LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *data;
+ uintptr_t datalen;
+} LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate;
+
+typedef LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ;
+
+typedef struct LDKCVecTempl_NodeAnnouncement {
+ LDKNodeAnnouncement *data;
+ uintptr_t datalen;
+} LDKCVecTempl_NodeAnnouncement;
+
+typedef LDKCVecTempl_NodeAnnouncement LDKCVec_NodeAnnouncementZ;
+
+/**
+ * A trait to describe an object which can receive routing messages.
+ */
+typedef struct LDKRoutingMessageHandler {
+ void *this_arg;
+ /**
+ * Handle an incoming node_announcement message, returning true if it should be forwarded on,
+ * false or returning an Err otherwise.
+ */
+ LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const LDKNodeAnnouncement *msg);
+ /**
+ * Handle a channel_announcement message, returning true if it should be forwarded on, false
+ * or returning an Err otherwise.
+ */
+ LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const LDKChannelAnnouncement *msg);
+ /**
+ * Handle an incoming channel_update message, returning true if it should be forwarded on,
+ * false or returning an Err otherwise.
+ */
+ LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const LDKChannelUpdate *msg);
+ /**
+ * Handle some updates to the route graph that we learned due to an outbound failed payment.
+ */
+ void (*handle_htlc_fail_channel_update)(const void *this_arg, const LDKHTLCFailChannelUpdate *update);
+ /**
+ * Gets a subset of the channel announcements and updates required to dump our routing table
+ * to a remote node, starting at the short_channel_id indicated by starting_point and
+ * including the batch_amount entries immediately higher in numerical value than starting_point.
+ */
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcements)(const void *this_arg, uint64_t starting_point, uint8_t batch_amount);
+ /**
+ * Gets a subset of the node announcements required to dump our routing table to a remote node,
+ * starting at the node *after* the provided publickey and including batch_amount entries
+ * immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
+ * If None is provided for starting_point, we start at the first node.
+ */
+ LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, LDKPublicKey starting_point, uint8_t batch_amount);
+ /**
+ * Returns whether a full sync should be requested from a peer.
+ */
+ bool (*should_request_full_sync)(const void *this_arg, LDKPublicKey node_id);
+ void (*free)(void *this_arg);
+} LDKRoutingMessageHandler;
+
+
+
+/**
+ * Provides references to trait impls which handle different types of messages.
+ */
+typedef struct MUST_USE_STRUCT LDKMessageHandler {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeMessageHandler *inner;
+ bool is_owned;
+} LDKMessageHandler;
+
+/**
+ * Provides an object which can be used to send data to and which uniquely identifies a connection
+ * to a remote host. You will need to be able to generate multiple of these which meet Eq and
+ * implement Hash to meet the PeerManager API.
+ *
+ * For efficiency, Clone should be relatively cheap for this type.
+ *
+ * You probably want to just extend an int and put a file descriptor in a struct and implement
+ * send_data. Note that if you are using a higher-level net library that may call close() itself,
+ * be careful to ensure you don't have races whereby you might register a new connection with an
+ * fd which is the same as a previous one which has yet to be removed via
+ * PeerManager::socket_disconnected().
+ */
+typedef struct LDKSocketDescriptor {
+ void *this_arg;
+ /**
+ * Attempts to send some data from the given slice to the peer.
+ *
+ * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected.
+ * Note that in the disconnected case, socket_disconnected must still fire and further write
+ * attempts may occur until that time.
+ *
+ * If the returned size is smaller than data.len(), a write_available event must
+ * trigger the next time more data can be written. Additionally, until the a send_data event
+ * completes fully, no further read_events should trigger on the same peer!
+ *
+ * If a read_event on this descriptor had previously returned true (indicating that read
+ * events should be paused to prevent DoS in the send buffer), resume_read may be set
+ * indicating that read events on this descriptor should resume. A resume_read of false does
+ * *not* imply that further read events should be paused.
+ */
+ uintptr_t (*send_data)(void *this_arg, LDKu8slice data, bool resume_read);
+ /**
+ * Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no
+ * more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with
+ * this descriptor. No socket_disconnected call should be generated as a result of this call,
+ * though races may occur whereby disconnect_socket is called after a call to
+ * socket_disconnected but prior to socket_disconnected returning.
+ */
+ void (*disconnect_socket)(void *this_arg);
+ bool (*eq)(const void *this_arg, const void *other_arg);
+ uint64_t (*hash)(const void *this_arg);
+ void *(*clone)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKSocketDescriptor;
+
+
+
+/**
+ * A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket
+ * events into messages which it passes on to its MessageHandlers.
+ *
+ * Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager
+ * a SimpleRefPeerManager, for conciseness. See their documentation for more details, but
+ * essentially you should default to using a SimpleRefPeerManager, and use a
+ * SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when
+ * you're using lightning-net-tokio.
+ */
+typedef struct MUST_USE_STRUCT LDKPeerManager {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativePeerManager *inner;
+ bool is_owned;
+} LDKPeerManager;
+
+typedef struct LDKCVecTempl_PublicKey {
+ LDKPublicKey *data;
+ uintptr_t datalen;
+} LDKCVecTempl_PublicKey;
+
+typedef LDKCVecTempl_PublicKey LDKCVec_PublicKeyZ;
+
+typedef union LDKCResultPtr_CVecTempl_u8_____PeerHandleError {
+ LDKCVecTempl_u8 *result;
+ LDKPeerHandleError *err;
+} LDKCResultPtr_CVecTempl_u8_____PeerHandleError;
+
+typedef struct LDKCResultTempl_CVecTempl_u8_____PeerHandleError {
+ LDKCResultPtr_CVecTempl_u8_____PeerHandleError contents;
+ bool result_ok;
+} LDKCResultTempl_CVecTempl_u8_____PeerHandleError;
+
+typedef LDKCResultTempl_CVecTempl_u8_____PeerHandleError LDKCResult_CVec_u8ZPeerHandleErrorZ;
+
+typedef union LDKCResultPtr_bool__PeerHandleError {
+ bool *result;
+ LDKPeerHandleError *err;
+} LDKCResultPtr_bool__PeerHandleError;
+
+typedef struct LDKCResultTempl_bool__PeerHandleError {
+ LDKCResultPtr_bool__PeerHandleError contents;
+ bool result_ok;
+} LDKCResultTempl_bool__PeerHandleError;
+
+typedef LDKCResultTempl_bool__PeerHandleError LDKCResult_boolPeerHandleErrorZ;
+
+typedef union LDKCResultPtr_SecretKey__Secp256k1Error {
+ LDKSecretKey *result;
+ LDKSecp256k1Error *err;
+} LDKCResultPtr_SecretKey__Secp256k1Error;
+
+typedef struct LDKCResultTempl_SecretKey__Secp256k1Error {
+ LDKCResultPtr_SecretKey__Secp256k1Error contents;
+ bool result_ok;
+} LDKCResultTempl_SecretKey__Secp256k1Error;
+
+typedef LDKCResultTempl_SecretKey__Secp256k1Error LDKCResult_SecretKeySecpErrorZ;
+
+typedef union LDKCResultPtr_PublicKey__Secp256k1Error {
+ LDKPublicKey *result;
+ LDKSecp256k1Error *err;
+} LDKCResultPtr_PublicKey__Secp256k1Error;
+
+typedef struct LDKCResultTempl_PublicKey__Secp256k1Error {
+ LDKCResultPtr_PublicKey__Secp256k1Error contents;
+ bool result_ok;
+} LDKCResultTempl_PublicKey__Secp256k1Error;
+
+typedef LDKCResultTempl_PublicKey__Secp256k1Error LDKCResult_PublicKeySecpErrorZ;
+
+
+
+/**
+ * The set of public keys which are used in the creation of one commitment transaction.
+ * These are derived from the channel base keys and per-commitment data.
+ *
+ * These keys are assumed to be good, either because the code derived them from
+ * channel basepoints via the new function, or they were obtained via
+ * PreCalculatedTxCreationKeys.trust_key_derivation because we trusted the source of the
+ * pre-calculated keys.
+ */
+typedef struct MUST_USE_STRUCT LDKTxCreationKeys {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeTxCreationKeys *inner;
+ bool is_owned;
+} LDKTxCreationKeys;
+
+typedef union LDKCResultPtr_TxCreationKeys__Secp256k1Error {
+ LDKTxCreationKeys *result;
+ LDKSecp256k1Error *err;
+} LDKCResultPtr_TxCreationKeys__Secp256k1Error;
+
+typedef struct LDKCResultTempl_TxCreationKeys__Secp256k1Error {
+ LDKCResultPtr_TxCreationKeys__Secp256k1Error contents;
+ bool result_ok;
+} LDKCResultTempl_TxCreationKeys__Secp256k1Error;
+
+typedef LDKCResultTempl_TxCreationKeys__Secp256k1Error LDKCResult_TxCreationKeysSecpErrorZ;
+
+typedef struct LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature {
+ LDKC2TupleTempl_HTLCOutputInCommitment__Signature *data;
+ uintptr_t datalen;
+} LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature;
+
+typedef LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ;
+
+
+
+/**
+ * Features used within a `node_announcement` message.
+ */
+typedef struct MUST_USE_STRUCT LDKNodeFeatures {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeNodeFeatures *inner;
+ bool is_owned;
+} LDKNodeFeatures;
+
+
+
+/**
+ * Features used within a `channel_announcement` message.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelFeatures {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelFeatures *inner;
+ bool is_owned;
+} LDKChannelFeatures;
+
+
+
+/**
+ * A hop in a route
+ */
+typedef struct MUST_USE_STRUCT LDKRouteHop {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeRouteHop *inner;
+ bool is_owned;
+} LDKRouteHop;
+
+typedef struct LDKCVecTempl_RouteHop {
+ LDKRouteHop *data;
+ uintptr_t datalen;
+} LDKCVecTempl_RouteHop;
+
+typedef struct LDKCVecTempl_CVecTempl_RouteHop {
+ LDKCVecTempl_RouteHop *data;
+ uintptr_t datalen;
+} LDKCVecTempl_CVecTempl_RouteHop;
+
+typedef LDKCVecTempl_CVecTempl_RouteHop LDKCVec_CVec_RouteHopZZ;
+
+
+
+/**
+ * A channel descriptor which provides a last-hop route to get_route
+ */
+typedef struct MUST_USE_STRUCT LDKRouteHint {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeRouteHint *inner;
+ bool is_owned;
+} LDKRouteHint;
+
+
+
+/**
+ * Fees for routing via a given channel or a node
+ */
+typedef struct MUST_USE_STRUCT LDKRoutingFees {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeRoutingFees *inner;
+ bool is_owned;
+} LDKRoutingFees;
+
+typedef union LDKCResultPtr_Route__LightningError {
+ LDKRoute *result;
+ LDKLightningError *err;
+} LDKCResultPtr_Route__LightningError;
+
+typedef struct LDKCResultTempl_Route__LightningError {
+ LDKCResultPtr_Route__LightningError contents;
+ bool result_ok;
+} LDKCResultTempl_Route__LightningError;
+
+typedef LDKCResultTempl_Route__LightningError LDKCResult_RouteLightningErrorZ;
+
+
+
+/**
+ * Represents the network as nodes and channels between them
+ */
+typedef struct MUST_USE_STRUCT LDKNetworkGraph {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeNetworkGraph *inner;
+ bool is_owned;
+} LDKNetworkGraph;
+
+typedef struct LDKCVecTempl_RouteHint {
+ LDKRouteHint *data;
+ uintptr_t datalen;
+} LDKCVecTempl_RouteHint;
+
+typedef LDKCVecTempl_RouteHint LDKCVec_RouteHintZ;
+
+
+
+/**
+ * A simple newtype for RwLockReadGuard<'a, NetworkGraph>.
+ * This exists only to make accessing a RwLock<NetworkGraph> possible from
+ * the C bindings, as it can be done directly in Rust code.
+ */
+typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeLockedNetworkGraph *inner;
+ bool is_owned;
+} LDKLockedNetworkGraph;
+
+
+
+/**
+ * Receives and validates network updates from peers,
+ * stores authentic and relevant data as a network graph.
+ * This network graph is then used for routing payments.
+ * Provides interface to help with initial routing sync by
+ * serving historical announcements.
+ */
+typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeNetGraphMsgHandler *inner;
+ bool is_owned;
+} LDKNetGraphMsgHandler;
+
+
+
+/**
+ * Details about one direction of a channel. Received
+ * within a channel update.
+ */
+typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeDirectionalChannelInfo *inner;
+ bool is_owned;
+} LDKDirectionalChannelInfo;
+
+
+
+/**
+ * Details about a channel (both directions).
+ * Received within a channel announcement.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelInfo {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelInfo *inner;
+ bool is_owned;
+} LDKChannelInfo;
+
+
+
+/**
+ * Information received in the latest node_announcement from this node.
+ */
+typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeNodeAnnouncementInfo *inner;
+ bool is_owned;
+} LDKNodeAnnouncementInfo;
+
+
+
+/**
+ * Details about a node in the network, known from the network announcement.
+ */
+typedef struct MUST_USE_STRUCT LDKNodeInfo {
+ /**
+ * Nearly everyhwere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeNodeInfo *inner;
+ bool is_owned;
+} LDKNodeInfo;
+
+typedef struct LDKCVecTempl_u64 {
+ uint64_t *data;
+ uintptr_t datalen;
+} LDKCVecTempl_u64;
+
+typedef LDKCVecTempl_u64 LDKCVec_u64Z;
+
+typedef LDKCVecTempl_RouteHop LDKCVec_RouteHopZ;
+
+extern const void (*C2Tuple_HTLCOutputInCommitmentSignatureZ_free)(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ);
+
+extern const void (*C2Tuple_OutPointScriptZ_free)(LDKC2Tuple_OutPointScriptZ);
+
+extern const void (*C2Tuple_Scriptu64Z_free)(LDKC2Tuple_Scriptu64Z);
+
+extern const void (*C2Tuple_SignatureCVec_SignatureZZ_free)(LDKC2Tuple_SignatureCVec_SignatureZZ);
+
+extern const void (*C2Tuple_Txidu32Z_free)(LDKC2Tuple_Txidu32Z);
+
+extern const void (*C2Tuple_u64u64Z_free)(LDKC2Tuple_u64u64Z);
+
+extern const void (*C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free)(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ);
+
+extern const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ (*CResult_C2Tuple_Scriptu64ZChainErrorZ_err)(LDKChainError);
+
+extern const void (*CResult_C2Tuple_Scriptu64ZChainErrorZ_free)(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ);
+
+extern const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ (*CResult_C2Tuple_Scriptu64ZChainErrorZ_ok)(LDKC2Tuple_Scriptu64Z);
+
+extern const void (*CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free)(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ);
+
+extern const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok)(LDKC2Tuple_SignatureCVec_SignatureZZ);
+
+extern const void (*CResult_CVec_SignatureZNoneZ_free)(LDKCResult_CVec_SignatureZNoneZ);
+
+extern const LDKCResult_CVec_SignatureZNoneZ (*CResult_CVec_SignatureZNoneZ_ok)(LDKCVec_SignatureZ);
+
+extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_err)(LDKPeerHandleError);
+
+extern const void (*CResult_CVec_u8ZPeerHandleErrorZ_free)(LDKCResult_CVec_u8ZPeerHandleErrorZ);
+
+extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_ok)(LDKCVec_u8Z);
+
+extern const LDKCResult_NoneAPIErrorZ (*CResult_NoneAPIErrorZ_err)(LDKAPIError);
+
+extern const void (*CResult_NoneAPIErrorZ_free)(LDKCResult_NoneAPIErrorZ);
+
+extern const LDKCResult_NoneChannelMonitorUpdateErrZ (*CResult_NoneChannelMonitorUpdateErrZ_err)(LDKChannelMonitorUpdateErr);
+
+extern const void (*CResult_NoneChannelMonitorUpdateErrZ_free)(LDKCResult_NoneChannelMonitorUpdateErrZ);
+
+extern const LDKCResult_NoneMonitorUpdateErrorZ (*CResult_NoneMonitorUpdateErrorZ_err)(LDKMonitorUpdateError);
+
+extern const void (*CResult_NoneMonitorUpdateErrorZ_free)(LDKCResult_NoneMonitorUpdateErrorZ);
+
+extern const LDKCResult_NonePaymentSendFailureZ (*CResult_NonePaymentSendFailureZ_err)(LDKPaymentSendFailure);
+
+extern const void (*CResult_NonePaymentSendFailureZ_free)(LDKCResult_NonePaymentSendFailureZ);
+
+extern const LDKCResult_NonePeerHandleErrorZ (*CResult_NonePeerHandleErrorZ_err)(LDKPeerHandleError);
+
+extern const void (*CResult_NonePeerHandleErrorZ_free)(LDKCResult_NonePeerHandleErrorZ);
+
+extern const LDKCResult_PublicKeySecpErrorZ (*CResult_PublicKeySecpErrorZ_err)(LDKSecp256k1Error);
+
+extern const void (*CResult_PublicKeySecpErrorZ_free)(LDKCResult_PublicKeySecpErrorZ);
+
+extern const LDKCResult_PublicKeySecpErrorZ (*CResult_PublicKeySecpErrorZ_ok)(LDKPublicKey);
+
+extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_err)(LDKLightningError);
+
+extern const void (*CResult_RouteLightningErrorZ_free)(LDKCResult_RouteLightningErrorZ);
+
+extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_ok)(LDKRoute);
+
+extern const LDKCResult_SecretKeySecpErrorZ (*CResult_SecretKeySecpErrorZ_err)(LDKSecp256k1Error);
+
+extern const void (*CResult_SecretKeySecpErrorZ_free)(LDKCResult_SecretKeySecpErrorZ);
+
+extern const LDKCResult_SecretKeySecpErrorZ (*CResult_SecretKeySecpErrorZ_ok)(LDKSecretKey);
+
+extern const void (*CResult_SignatureNoneZ_free)(LDKCResult_SignatureNoneZ);
+
+extern const LDKCResult_SignatureNoneZ (*CResult_SignatureNoneZ_ok)(LDKSignature);
+
+extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_err)(LDKSecp256k1Error);
+
+extern const void (*CResult_TxCreationKeysSecpErrorZ_free)(LDKCResult_TxCreationKeysSecpErrorZ);
+
+extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_ok)(LDKTxCreationKeys);
+
+extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_err)(LDKLightningError);
+
+extern const void (*CResult_boolLightningErrorZ_free)(LDKCResult_boolLightningErrorZ);
+
+extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_ok)(bool);
+
+extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_err)(LDKPeerHandleError);
+
+extern const void (*CResult_boolPeerHandleErrorZ_free)(LDKCResult_boolPeerHandleErrorZ);
+
+extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_ok)(bool);
+
+extern const void (*CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free)(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ);
+
+extern const void (*CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free)(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ);
+
+extern const void (*CVec_CVec_RouteHopZZ_free)(LDKCVec_CVec_RouteHopZZ);
+
+extern const void (*CVec_ChannelDetailsZ_free)(LDKCVec_ChannelDetailsZ);
+
+extern const void (*CVec_ChannelMonitorZ_free)(LDKCVec_ChannelMonitorZ);
+
+extern const void (*CVec_EventZ_free)(LDKCVec_EventZ);
+
+extern const void (*CVec_HTLCOutputInCommitmentZ_free)(LDKCVec_HTLCOutputInCommitmentZ);
+
+extern const void (*CVec_MessageSendEventZ_free)(LDKCVec_MessageSendEventZ);
+
+extern const void (*CVec_MonitorEventZ_free)(LDKCVec_MonitorEventZ);
+
+extern const void (*CVec_NetAddressZ_free)(LDKCVec_NetAddressZ);
+
+extern const void (*CVec_NodeAnnouncementZ_free)(LDKCVec_NodeAnnouncementZ);
+
+extern const void (*CVec_PublicKeyZ_free)(LDKCVec_PublicKeyZ);
+
+extern const void (*CVec_RouteHintZ_free)(LDKCVec_RouteHintZ);
+
+extern const void (*CVec_RouteHopZ_free)(LDKCVec_RouteHopZ);
+
+extern const void (*CVec_SignatureZ_free)(LDKCVec_SignatureZ);
+
+extern const void (*CVec_SpendableOutputDescriptorZ_free)(LDKCVec_SpendableOutputDescriptorZ);
+
+extern const void (*CVec_TransactionZ_free)(LDKCVec_TransactionZ);
+
+extern const void (*CVec_UpdateAddHTLCZ_free)(LDKCVec_UpdateAddHTLCZ);
+
+extern const void (*CVec_UpdateFailHTLCZ_free)(LDKCVec_UpdateFailHTLCZ);
+
+extern const void (*CVec_UpdateFailMalformedHTLCZ_free)(LDKCVec_UpdateFailMalformedHTLCZ);
+
+extern const void (*CVec_UpdateFulfillHTLCZ_free)(LDKCVec_UpdateFulfillHTLCZ);
+
+extern const void (*CVec_u64Z_free)(LDKCVec_u64Z);
+
+extern const void (*CVec_u8Z_free)(LDKCVec_u8Z);
+
+extern const void (*CVec_usizeZ_free)(LDKCVec_usizeZ);
+
+extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT;
+
+void TxOut_free(LDKTxOut _res);
+
+LDKC2Tuple_Txidu32Z C2Tuple_Txidu32Z_new(LDKThirtyTwoBytes a, uint32_t b);
+
+LDKC2Tuple_Scriptu64Z C2Tuple_Scriptu64Z_new(LDKCVec_u8Z a, uint64_t b);
+
+LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b);
+
+LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(LDKSignature a, LDKCVec_SignatureZ b);
+
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void);
+
+LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void);
+
+LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void);
+
+LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void);
+
+LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void);
+
+LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void);
+
+LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void);
+
+LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(LDKOutPoint a, LDKCVec_u8Z b);
+
+LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(LDKChannelAnnouncement a, LDKChannelUpdate b, LDKChannelUpdate c);
+
+LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void);
+
+LDKC2Tuple_HTLCOutputInCommitmentSignatureZ C2Tuple_HTLCOutputInCommitmentSignatureZ_new(LDKHTLCOutputInCommitment a, LDKSignature b);
+
+void Event_free(LDKEvent this_ptr);
+
+void MessageSendEvent_free(LDKMessageSendEvent this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void MessageSendEventsProvider_free(LDKMessageSendEventsProvider this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void EventsProvider_free(LDKEventsProvider this_ptr);
+
+void APIError_free(LDKAPIError this_ptr);
+
+/**
+ * Returns the most verbose logging level.
+ */
+MUST_USE_RES LDKLevel Level_max(void);
+
+/**
+ * Calls the free function if one is set
+ */
+void Logger_free(LDKLogger this_ptr);
+
+void ChannelHandshakeConfig_free(LDKChannelHandshakeConfig this_ptr);
+
+/**
+ * Confirmations we will wait for before considering the channel locked in.
+ * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
+ * equivalent limit applied to outbound channels).
+ *
+ * Default value: 6.
+ */
+uint32_t ChannelHandshakeConfig_get_minimum_depth(const LDKChannelHandshakeConfig *this_ptr);
+
+/**
+ * Confirmations we will wait for before considering the channel locked in.
+ * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
+ * equivalent limit applied to outbound channels).
+ *
+ * Default value: 6.
+ */
+void ChannelHandshakeConfig_set_minimum_depth(LDKChannelHandshakeConfig *this_ptr, uint32_t val);
+
+/**
+ * Set to the amount of time we require our counterparty to wait to claim their money.
+ *
+ * It's one of the main parameter of our security model. We (or one of our watchtowers) MUST
+ * be online to check for peer having broadcast a revoked transaction to steal our funds
+ * at least once every our_to_self_delay blocks.
+ *
+ * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
+ * case of an honest unilateral channel close, which implicitly decrease the economic value of
+ * our channel.
+ *
+ * Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel
+ * opening so you can tweak config to ask for more security, not less.
+ */
+uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const LDKChannelHandshakeConfig *this_ptr);
+
+/**
+ * Set to the amount of time we require our counterparty to wait to claim their money.
+ *
+ * It's one of the main parameter of our security model. We (or one of our watchtowers) MUST
+ * be online to check for peer having broadcast a revoked transaction to steal our funds
+ * at least once every our_to_self_delay blocks.
+ *
+ * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
+ * case of an honest unilateral channel close, which implicitly decrease the economic value of
+ * our channel.
+ *
+ * Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel
+ * opening so you can tweak config to ask for more security, not less.
+ */
+void ChannelHandshakeConfig_set_our_to_self_delay(LDKChannelHandshakeConfig *this_ptr, uint16_t val);
+
+/**
+ * Set to the smallest value HTLC we will accept to process.
+ *
+ * This value is sent to our counterparty on channel-open and we close the channel any time
+ * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
+ *
+ * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
+ * by the protocol.
+ */
+uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const LDKChannelHandshakeConfig *this_ptr);
+
+/**
+ * Set to the smallest value HTLC we will accept to process.
+ *
+ * This value is sent to our counterparty on channel-open and we close the channel any time
+ * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
+ *
+ * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
+ * by the protocol.
+ */
+void ChannelHandshakeConfig_set_our_htlc_minimum_msat(LDKChannelHandshakeConfig *this_ptr, uint64_t val);
+
+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);
+
+MUST_USE_RES LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void);
+
+void ChannelHandshakeLimits_free(LDKChannelHandshakeLimits this_ptr);
+
+/**
+ * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
+ * only applies to inbound channels.
+ *
+ * Default value: 0.
+ */
+uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
+ * only applies to inbound channels.
+ *
+ * Default value: 0.
+ */
+void ChannelHandshakeLimits_set_min_funding_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
+
+/**
+ * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
+ * you to limit the maximum minimum-size they can require.
+ *
+ * Default value: u64::max_value.
+ */
+uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
+ * you to limit the maximum minimum-size they can require.
+ *
+ * Default value: u64::max_value.
+ */
+void ChannelHandshakeLimits_set_max_htlc_minimum_msat(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
+
+/**
+ * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
+ * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
+ *
+ * Default value: 0.
+ */
+uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
+ * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
+ *
+ * Default value: 0.
+ */
+void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
+
+/**
+ * The remote node will require we keep a certain amount in direct payment to ourselves at all
+ * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
+ * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
+ *
+ * Default value: u64::max_value.
+ */
+uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * The remote node will require we keep a certain amount in direct payment to ourselves at all
+ * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
+ * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
+ *
+ * Default value: u64::max_value.
+ */
+void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
+
+/**
+ * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
+ * time. This allows you to set a minimum such value.
+ *
+ * Default value: 0.
+ */
+uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
+ * time. This allows you to set a minimum such value.
+ *
+ * Default value: 0.
+ */
+void ChannelHandshakeLimits_set_min_max_accepted_htlcs(LDKChannelHandshakeLimits *this_ptr, uint16_t val);
+
+/**
+ * Outputs below a certain value will not be added to on-chain transactions. The dust value is
+ * required to always be higher than this value so this only applies to HTLC outputs (and
+ * potentially to-self outputs before any payments have been made).
+ * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
+ * This setting allows you to set a minimum dust limit for their commitment transactions,
+ * reflecting the reality that tiny outputs are not considered standard transactions and will
+ * not propagate through the Bitcoin network.
+ *
+ * Default value: 546, the current dust limit on the Bitcoin network.
+ */
+uint64_t ChannelHandshakeLimits_get_min_dust_limit_satoshis(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * Outputs below a certain value will not be added to on-chain transactions. The dust value is
+ * required to always be higher than this value so this only applies to HTLC outputs (and
+ * potentially to-self outputs before any payments have been made).
+ * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
+ * This setting allows you to set a minimum dust limit for their commitment transactions,
+ * reflecting the reality that tiny outputs are not considered standard transactions and will
+ * not propagate through the Bitcoin network.
+ *
+ * Default value: 546, the current dust limit on the Bitcoin network.
+ */
+void ChannelHandshakeLimits_set_min_dust_limit_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
+
+/**
+ * Maximum allowed threshold above which outputs will not be generated in their commitment
+ * transactions.
+ * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
+ *
+ * Default value: u64::max_value.
+ */
+uint64_t ChannelHandshakeLimits_get_max_dust_limit_satoshis(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * Maximum allowed threshold above which outputs will not be generated in their commitment
+ * transactions.
+ * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
+ *
+ * Default value: u64::max_value.
+ */
+void ChannelHandshakeLimits_set_max_dust_limit_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val);
+
+/**
+ * Before a channel is usable the funding transaction will need to be confirmed by at least a
+ * certain number of blocks, specified by the node which is not the funder (as the funder can
+ * assume they aren't going to double-spend themselves).
+ * This config allows you to set a limit on the maximum amount of time to wait.
+ *
+ * Default value: 144, or roughly one day and only applies to outbound channels.
+ */
+uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * Before a channel is usable the funding transaction will need to be confirmed by at least a
+ * certain number of blocks, specified by the node which is not the funder (as the funder can
+ * assume they aren't going to double-spend themselves).
+ * This config allows you to set a limit on the maximum amount of time to wait.
+ *
+ * Default value: 144, or roughly one day and only applies to outbound channels.
+ */
+void ChannelHandshakeLimits_set_max_minimum_depth(LDKChannelHandshakeLimits *this_ptr, uint32_t val);
+
+/**
+ * Set to force the incoming channel to match our announced channel preference in
+ * ChannelConfig.
+ *
+ * Default value: true, to make the default that no announced channels are possible (which is
+ * appropriate for any nodes which are not online very reliably).
+ */
+bool ChannelHandshakeLimits_get_force_announced_channel_preference(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * Set to force the incoming channel to match our announced channel preference in
+ * ChannelConfig.
+ *
+ * Default value: true, to make the default that no announced channels are possible (which is
+ * appropriate for any nodes which are not online very reliably).
+ */
+void ChannelHandshakeLimits_set_force_announced_channel_preference(LDKChannelHandshakeLimits *this_ptr, bool val);
+
+/**
+ * Set to the amount of time we're willing to wait to claim money back to us.
+ *
+ * Not checking this value would be a security issue, as our peer would be able to set it to
+ * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
+ *
+ * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
+ * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
+ */
+uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const LDKChannelHandshakeLimits *this_ptr);
+
+/**
+ * Set to the amount of time we're willing to wait to claim money back to us.
+ *
+ * Not checking this value would be a security issue, as our peer would be able to set it to
+ * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
+ *
+ * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
+ * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
+ */
+void ChannelHandshakeLimits_set_their_to_self_delay(LDKChannelHandshakeLimits *this_ptr, uint16_t val);
+
+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);
+
+MUST_USE_RES LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void);
+
+void ChannelConfig_free(LDKChannelConfig this_ptr);
+
+/**
+ * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
+ * This may be allowed to change at runtime in a later update, however doing so must result in
+ * update messages sent to notify all nodes of our updated relay fee.
+ *
+ * Default value: 0.
+ */
+uint32_t ChannelConfig_get_fee_proportional_millionths(const LDKChannelConfig *this_ptr);
+
+/**
+ * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
+ * This may be allowed to change at runtime in a later update, however doing so must result in
+ * update messages sent to notify all nodes of our updated relay fee.
+ *
+ * Default value: 0.
+ */
+void ChannelConfig_set_fee_proportional_millionths(LDKChannelConfig *this_ptr, uint32_t val);
+
+/**
+ * Set to announce the channel publicly and notify all nodes that they can route via this
+ * channel.
+ *
+ * This should only be set to true for nodes which expect to be online reliably.
+ *
+ * As the node which funds a channel picks this value this will only apply for new outbound
+ * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
+ *
+ * This cannot be changed after the initial channel handshake.
+ *
+ * Default value: false.
+ */
+bool ChannelConfig_get_announced_channel(const LDKChannelConfig *this_ptr);
+
+/**
+ * Set to announce the channel publicly and notify all nodes that they can route via this
+ * channel.
+ *
+ * This should only be set to true for nodes which expect to be online reliably.
+ *
+ * As the node which funds a channel picks this value this will only apply for new outbound
+ * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
+ *
+ * This cannot be changed after the initial channel handshake.
+ *
+ * Default value: false.
+ */
+void ChannelConfig_set_announced_channel(LDKChannelConfig *this_ptr, bool val);
+
+/**
+ * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
+ * supports it, they will then enforce the mutual-close output to us matches what we provided
+ * at intialization, preventing us from closing to an alternate pubkey.
+ *
+ * This is set to true by default to provide a slight increase in security, though ultimately
+ * any attacker who is able to take control of a channel can just as easily send the funds via
+ * lightning payments, so we never require that our counterparties support this option.
+ *
+ * This cannot be changed after a channel has been initialized.
+ *
+ * Default value: true.
+ */
+bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const LDKChannelConfig *this_ptr);
+
+/**
+ * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
+ * supports it, they will then enforce the mutual-close output to us matches what we provided
+ * at intialization, preventing us from closing to an alternate pubkey.
+ *
+ * This is set to true by default to provide a slight increase in security, though ultimately
+ * any attacker who is able to take control of a channel can just as easily send the funds via
+ * lightning payments, so we never require that our counterparties support this option.
+ *
+ * This cannot be changed after a channel has been initialized.
+ *
+ * Default value: true.
+ */
+void ChannelConfig_set_commit_upfront_shutdown_pubkey(LDKChannelConfig *this_ptr, bool val);
+
+MUST_USE_RES LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg);
+
+MUST_USE_RES LDKChannelConfig ChannelConfig_default(void);
+
+LDKCVec_u8Z ChannelConfig_write(const LDKChannelConfig *obj);
+
+LDKChannelConfig ChannelConfig_read(LDKu8slice ser);
+
+void UserConfig_free(LDKUserConfig this_ptr);
+
+/**
+ * Channel config that we propose to our counterparty.
+ */
+LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const LDKUserConfig *this_ptr);
+
+/**
+ * Channel config that we propose to our counterparty.
+ */
+void UserConfig_set_own_channel_config(LDKUserConfig *this_ptr, LDKChannelHandshakeConfig val);
+
+/**
+ * Limits applied to our counterparty's proposed channel config settings.
+ */
+LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const LDKUserConfig *this_ptr);
+
+/**
+ * Limits applied to our counterparty's proposed channel config settings.
+ */
+void UserConfig_set_peer_channel_config_limits(LDKUserConfig *this_ptr, LDKChannelHandshakeLimits val);
+
+/**
+ * Channel config which affects behavior during channel lifetime.
+ */
+LDKChannelConfig UserConfig_get_channel_options(const LDKUserConfig *this_ptr);
+
+/**
+ * Channel config which affects behavior during channel lifetime.
+ */
+void UserConfig_set_channel_options(LDKUserConfig *this_ptr, LDKChannelConfig val);
+
+MUST_USE_RES LDKUserConfig UserConfig_new(LDKChannelHandshakeConfig own_channel_config_arg, LDKChannelHandshakeLimits peer_channel_config_limits_arg, LDKChannelConfig channel_options_arg);
+
+MUST_USE_RES LDKUserConfig UserConfig_default(void);
+
+/**
+ * Calls the free function if one is set
+ */
+void ChainWatchInterface_free(LDKChainWatchInterface this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void BroadcasterInterface_free(LDKBroadcasterInterface this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void ChainListener_free(LDKChainListener this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void FeeEstimator_free(LDKFeeEstimator this_ptr);
+
+void ChainWatchedUtil_free(LDKChainWatchedUtil this_ptr);
+
+/**
+ * Constructs an empty (watches nothing) ChainWatchedUtil
+ */
+MUST_USE_RES LDKChainWatchedUtil ChainWatchedUtil_new(void);
+
+/**
+ * Registers a tx for monitoring, returning true if it was a new tx and false if we'd already
+ * been watching for it.
+ */
+MUST_USE_RES bool ChainWatchedUtil_register_tx(LDKChainWatchedUtil *this_arg, const uint8_t (*txid)[32], LDKu8slice script_pub_key);
+
+/**
+ * Registers an outpoint for monitoring, returning true if it was a new outpoint and false if
+ * we'd already been watching for it
+ */
+MUST_USE_RES bool ChainWatchedUtil_register_outpoint(LDKChainWatchedUtil *this_arg, LDKC2Tuple_Txidu32Z outpoint, LDKu8slice _script_pub_key);
+
+/**
+ * Sets us to match all transactions, returning true if this is a new setting and false if
+ * we'd already been set to match everything.
+ */
+MUST_USE_RES bool ChainWatchedUtil_watch_all(LDKChainWatchedUtil *this_arg);
+
+/**
+ * Checks if a given transaction matches the current filter.
+ */
+MUST_USE_RES bool ChainWatchedUtil_does_match_tx(const LDKChainWatchedUtil *this_arg, LDKTransaction tx);
+
+void BlockNotifier_free(LDKBlockNotifier this_ptr);
+
+/**
+ * Constructs a new BlockNotifier without any listeners.
+ */
+MUST_USE_RES LDKBlockNotifier BlockNotifier_new(LDKChainWatchInterface chain_monitor);
+
+/**
+ * Register the given listener to receive events.
+ */
+void BlockNotifier_register_listener(const LDKBlockNotifier *this_arg, LDKChainListener listener);
+
+/**
+ * Notify listeners that a block was connected given a full, unfiltered block.
+ *
+ * Handles re-scanning the block and calling block_connected again if listeners register new
+ * watch data during the callbacks for you (see ChainListener::block_connected for more info).
+ */
+void BlockNotifier_block_connected(const LDKBlockNotifier *this_arg, LDKu8slice block, uint32_t height);
+
+/**
+ * Notify listeners that a block was connected, given pre-filtered list of transactions in the
+ * block which matched the filter (probably using does_match_tx).
+ *
+ * Returns true if notified listeners registered additional watch data (implying that the
+ * block must be re-scanned and this function called again prior to further block_connected
+ * calls, see ChainListener::block_connected for more info).
+ */
+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);
+
+/**
+ * Notify listeners that a block was disconnected.
+ */
+void BlockNotifier_block_disconnected(const LDKBlockNotifier *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height);
+
+void ChainWatchInterfaceUtil_free(LDKChainWatchInterfaceUtil this_ptr);
+
+LDKChainWatchInterface ChainWatchInterfaceUtil_as_ChainWatchInterface(const LDKChainWatchInterfaceUtil *this_arg);
+
+/**
+ * Creates a new ChainWatchInterfaceUtil for the given network
+ */
+MUST_USE_RES LDKChainWatchInterfaceUtil ChainWatchInterfaceUtil_new(LDKNetwork network);
+
+/**
+ * Checks if a given transaction matches the current filter.
+ */
+MUST_USE_RES bool ChainWatchInterfaceUtil_does_match_tx(const LDKChainWatchInterfaceUtil *this_arg, LDKTransaction tx);
+
+void OutPoint_free(LDKOutPoint this_ptr);
+
+/**
+ * The referenced transaction's txid.
+ */
+const uint8_t (*OutPoint_get_txid(const LDKOutPoint *this_ptr))[32];
+
+/**
+ * The referenced transaction's txid.
+ */
+void OutPoint_set_txid(LDKOutPoint *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The index of the referenced output in its transaction's vout.
+ */
+uint16_t OutPoint_get_index(const LDKOutPoint *this_ptr);
+
+/**
+ * The index of the referenced output in its transaction's vout.
+ */
+void OutPoint_set_index(LDKOutPoint *this_ptr, uint16_t val);
+
+MUST_USE_RES LDKOutPoint OutPoint_new(LDKThirtyTwoBytes txid_arg, uint16_t index_arg);
+
+/**
+ * Convert an `OutPoint` to a lightning channel id.
+ */
+MUST_USE_RES LDKThirtyTwoBytes OutPoint_to_channel_id(const LDKOutPoint *this_arg);
+
+LDKCVec_u8Z OutPoint_write(const LDKOutPoint *obj);
+
+LDKOutPoint OutPoint_read(LDKu8slice ser);
+
+void SpendableOutputDescriptor_free(LDKSpendableOutputDescriptor this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void ChannelKeys_free(LDKChannelKeys this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void KeysInterface_free(LDKKeysInterface this_ptr);
+
+void InMemoryChannelKeys_free(LDKInMemoryChannelKeys this_ptr);
+
+/**
+ * Private key of anchor tx
+ */
+const uint8_t (*InMemoryChannelKeys_get_funding_key(const LDKInMemoryChannelKeys *this_ptr))[32];
+
+/**
+ * Private key of anchor tx
+ */
+void InMemoryChannelKeys_set_funding_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
+
+/**
+ * Local secret key for blinded revocation pubkey
+ */
+const uint8_t (*InMemoryChannelKeys_get_revocation_base_key(const LDKInMemoryChannelKeys *this_ptr))[32];
+
+/**
+ * Local secret key for blinded revocation pubkey
+ */
+void InMemoryChannelKeys_set_revocation_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
+
+/**
+ * Local secret key used for our balance in remote-broadcasted commitment transactions
+ */
+const uint8_t (*InMemoryChannelKeys_get_payment_key(const LDKInMemoryChannelKeys *this_ptr))[32];
+
+/**
+ * Local secret key used for our balance in remote-broadcasted commitment transactions
+ */
+void InMemoryChannelKeys_set_payment_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
+
+/**
+ * Local secret key used in HTLC tx
+ */
+const uint8_t (*InMemoryChannelKeys_get_delayed_payment_base_key(const LDKInMemoryChannelKeys *this_ptr))[32];
+
+/**
+ * Local secret key used in HTLC tx
+ */
+void InMemoryChannelKeys_set_delayed_payment_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
+
+/**
+ * Local htlc secret key used in commitment tx htlc outputs
+ */
+const uint8_t (*InMemoryChannelKeys_get_htlc_base_key(const LDKInMemoryChannelKeys *this_ptr))[32];
+
+/**
+ * Local htlc secret key used in commitment tx htlc outputs
+ */
+void InMemoryChannelKeys_set_htlc_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val);
+
+/**
+ * Commitment seed
+ */
+const uint8_t (*InMemoryChannelKeys_get_commitment_seed(const LDKInMemoryChannelKeys *this_ptr))[32];
+
+/**
+ * Commitment seed
+ */
+void InMemoryChannelKeys_set_commitment_seed(LDKInMemoryChannelKeys *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * Create a new InMemoryChannelKeys
+ */
+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);
+
+/**
+ * Remote pubkeys.
+ * Will panic if on_accept wasn't called.
+ */
+MUST_USE_RES LDKChannelPublicKeys InMemoryChannelKeys_remote_pubkeys(const LDKInMemoryChannelKeys *this_arg);
+
+/**
+ * The to_self_delay value specified by our counterparty and applied on locally-broadcastable
+ * transactions, ie the amount of time that we have to wait to recover our funds if we
+ * broadcast a transaction. You'll likely want to pass this to the
+ * ln::chan_utils::build*_transaction functions when signing local transactions.
+ * Will panic if on_accept wasn't called.
+ */
+MUST_USE_RES uint16_t InMemoryChannelKeys_remote_to_self_delay(const LDKInMemoryChannelKeys *this_arg);
+
+/**
+ * The to_self_delay value specified by us and applied on transactions broadcastable
+ * by our counterparty, ie the amount of time that they have to wait to recover their funds
+ * if they broadcast a transaction.
+ * Will panic if on_accept wasn't called.
+ */
+MUST_USE_RES uint16_t InMemoryChannelKeys_local_to_self_delay(const LDKInMemoryChannelKeys *this_arg);
+
+LDKChannelKeys InMemoryChannelKeys_as_ChannelKeys(const LDKInMemoryChannelKeys *this_arg);
+
+LDKCVec_u8Z InMemoryChannelKeys_write(const LDKInMemoryChannelKeys *obj);
+
+LDKInMemoryChannelKeys InMemoryChannelKeys_read(LDKu8slice ser);
+
+void KeysManager_free(LDKKeysManager this_ptr);
+
+/**
+ * Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your
+ * CSRNG is busted) this may panic (but more importantly, you will possibly lose funds).
+ * starting_time isn't strictly required to actually be a time, but it must absolutely,
+ * without a doubt, be unique to this instance. ie if you start multiple times with the same
+ * seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to
+ * simply use the current time (with very high precision).
+ *
+ * The seed MUST be backed up safely prior to use so that the keys can be re-created, however,
+ * obviously, starting_time should be unique every time you reload the library - it is only
+ * used to generate new ephemeral key data (which will be stored by the individual channel if
+ * necessary).
+ *
+ * Note that the seed is required to recover certain on-chain funds independent of
+ * ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any
+ * channel, and some on-chain during-closing funds.
+ *
+ * Note that until the 0.1 release there is no guarantee of backward compatibility between
+ * versions. Once the library is more fully supported, the docs will be updated to include a
+ * detailed description of the guarantee.
+ */
+MUST_USE_RES LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], LDKNetwork network, uint64_t starting_time_secs, uint32_t starting_time_nanos);
+
+/**
+ * Derive an old set of ChannelKeys for per-channel secrets based on a key derivation
+ * parameters.
+ * Key derivation parameters are accessible through a per-channel secrets
+ * ChannelKeys::key_derivation_params and is provided inside DynamicOuputP2WSH in case of
+ * onchain output detection for which a corresponding delayed_payment_key must be derived.
+ */
+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);
+
+LDKKeysInterface KeysManager_as_KeysInterface(const LDKKeysManager *this_arg);
+
+void ChannelManager_free(LDKChannelManager this_ptr);
+
+void ChannelDetails_free(LDKChannelDetails this_ptr);
+
+/**
+ * The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
+ * thereafter this is the txid of the funding transaction xor the funding transaction output).
+ * Note that this means this value is *not* persistent - it can change once during the
+ * lifetime of the channel.
+ */
+const uint8_t (*ChannelDetails_get_channel_id(const LDKChannelDetails *this_ptr))[32];
+
+/**
+ * The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
+ * thereafter this is the txid of the funding transaction xor the funding transaction output).
+ * Note that this means this value is *not* persistent - it can change once during the
+ * lifetime of the channel.
+ */
+void ChannelDetails_set_channel_id(LDKChannelDetails *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The node_id of our counterparty
+ */
+LDKPublicKey ChannelDetails_get_remote_network_id(const LDKChannelDetails *this_ptr);
+
+/**
+ * The node_id of our counterparty
+ */
+void ChannelDetails_set_remote_network_id(LDKChannelDetails *this_ptr, LDKPublicKey val);
+
+/**
+ * The Features the channel counterparty provided upon last connection.
+ * Useful for routing as it is the most up-to-date copy of the counterparty's features and
+ * many routing-relevant features are present in the init context.
+ */
+LDKInitFeatures ChannelDetails_get_counterparty_features(const LDKChannelDetails *this_ptr);
+
+/**
+ * The Features the channel counterparty provided upon last connection.
+ * Useful for routing as it is the most up-to-date copy of the counterparty's features and
+ * many routing-relevant features are present in the init context.
+ */
+void ChannelDetails_set_counterparty_features(LDKChannelDetails *this_ptr, LDKInitFeatures val);
+
+/**
+ * The value, in satoshis, of this channel as appears in the funding output
+ */
+uint64_t ChannelDetails_get_channel_value_satoshis(const LDKChannelDetails *this_ptr);
+
+/**
+ * The value, in satoshis, of this channel as appears in the funding output
+ */
+void ChannelDetails_set_channel_value_satoshis(LDKChannelDetails *this_ptr, uint64_t val);
+
+/**
+ * The user_id passed in to create_channel, or 0 if the channel was inbound.
+ */
+uint64_t ChannelDetails_get_user_id(const LDKChannelDetails *this_ptr);
+
+/**
+ * The user_id passed in to create_channel, or 0 if the channel was inbound.
+ */
+void ChannelDetails_set_user_id(LDKChannelDetails *this_ptr, uint64_t val);
+
+/**
+ * The available outbound capacity for sending HTLCs to the remote peer. This does not include
+ * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+ * available for inclusion in new outbound HTLCs). This further does not include any pending
+ * outgoing HTLCs which are awaiting some other resolution to be sent.
+ */
+uint64_t ChannelDetails_get_outbound_capacity_msat(const LDKChannelDetails *this_ptr);
+
+/**
+ * The available outbound capacity for sending HTLCs to the remote peer. This does not include
+ * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+ * available for inclusion in new outbound HTLCs). This further does not include any pending
+ * outgoing HTLCs which are awaiting some other resolution to be sent.
+ */
+void ChannelDetails_set_outbound_capacity_msat(LDKChannelDetails *this_ptr, uint64_t val);
+
+/**
+ * The available inbound capacity for the remote peer to send HTLCs to us. This does not
+ * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+ * available for inclusion in new inbound HTLCs).
+ * Note that there are some corner cases not fully handled here, so the actual available
+ * inbound capacity may be slightly higher than this.
+ */
+uint64_t ChannelDetails_get_inbound_capacity_msat(const LDKChannelDetails *this_ptr);
+
+/**
+ * The available inbound capacity for the remote peer to send HTLCs to us. This does not
+ * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+ * available for inclusion in new inbound HTLCs).
+ * Note that there are some corner cases not fully handled here, so the actual available
+ * inbound capacity may be slightly higher than this.
+ */
+void ChannelDetails_set_inbound_capacity_msat(LDKChannelDetails *this_ptr, uint64_t val);
+
+/**
+ * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
+ * the peer is connected, and (c) no monitor update failure is pending resolution.
+ */
+bool ChannelDetails_get_is_live(const LDKChannelDetails *this_ptr);
+
+/**
+ * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
+ * the peer is connected, and (c) no monitor update failure is pending resolution.
+ */
+void ChannelDetails_set_is_live(LDKChannelDetails *this_ptr, bool val);
+
+void PaymentSendFailure_free(LDKPaymentSendFailure this_ptr);
+
+/**
+ * Constructs a new ChannelManager to hold several channels and route between them.
+ *
+ * This is the main \"logic hub\" for all channel-related actions, and implements
+ * ChannelMessageHandler.
+ *
+ * Non-proportional fees are fixed according to our risk using the provided fee estimator.
+ *
+ * panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
+ *
+ * Users must provide the current blockchain height from which to track onchain channel
+ * funding outpoints and send payments with reliable timelocks.
+ *
+ * Users need to notify the new ChannelManager when a new block is connected or
+ * disconnected using its `block_connected` and `block_disconnected` methods.
+ * However, rather than calling these methods directly, the user should register
+ * the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's
+ * `block_(dis)connected` methods, which will notify all registered listeners in one
+ * go.
+ */
+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);
+
+/**
+ * Creates a new outbound channel to the given remote node and with the given value.
+ *
+ * user_id will be provided back as user_channel_id in FundingGenerationReady and
+ * FundingBroadcastSafe events to allow tracking of which events correspond with which
+ * create_channel call. Note that user_channel_id defaults to 0 for inbound channels, so you
+ * may wish to avoid using 0 for user_id here.
+ *
+ * If successful, will generate a SendOpenChannel message event, so you should probably poll
+ * PeerManager::process_events afterwards.
+ *
+ * Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
+ * greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
+ */
+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);
+
+/**
+ * Gets the list of open channels, in random order. See ChannelDetail field documentation for
+ * more information.
+ */
+MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const LDKChannelManager *this_arg);
+
+/**
+ * Gets the list of usable channels, in random order. Useful as an argument to
+ * get_route to ensure non-announced channels are used.
+ *
+ * These are guaranteed to have their is_live value set to true, see the documentation for
+ * ChannelDetails::is_live for more info on exactly what the criteria are.
+ */
+MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const LDKChannelManager *this_arg);
+
+/**
+ * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
+ * will be accepted on the given channel, and after additional timeout/the closing of all
+ * pending HTLCs, the channel will be closed on chain.
+ *
+ * May generate a SendShutdown message event on success, which should be relayed.
+ */
+MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]);
+
+/**
+ * Force closes a channel, immediately broadcasting the latest local commitment transaction to
+ * the chain and rejecting new HTLCs on the given channel.
+ */
+void ChannelManager_force_close_channel(const LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]);
+
+/**
+ * Force close all channels, immediately broadcasting the latest local commitment transaction
+ * for each to the chain and rejecting new HTLCs on each.
+ */
+void ChannelManager_force_close_all_channels(const LDKChannelManager *this_arg);
+
+/**
+ * Sends a payment along a given route.
+ *
+ * Value parameters are provided via the last hop in route, see documentation for RouteHop
+ * fields for more info.
+ *
+ * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
+ * payment), we don't do anything to stop you! We always try to ensure that if the provided
+ * next hop knows the preimage to payment_hash they can claim an additional amount as
+ * specified in the last hop in the route! Thus, you should probably do your own
+ * payment_preimage tracking (which you should already be doing as they represent \"proof of
+ * payment\") and prevent double-sends yourself.
+ *
+ * May generate SendHTLCs message(s) event on success, which should be relayed.
+ *
+ * Each path may have a different return value, and PaymentSendValue may return a Vec with
+ * each entry matching the corresponding-index entry in the route paths, see
+ * PaymentSendFailure for more info.
+ *
+ * In general, a path may raise:
+ * * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
+ * node public key) is specified.
+ * * APIError::ChannelUnavailable if the next-hop channel is not available for updates
+ * (including due to previous monitor update failure or new permanent monitor update
+ * failure).
+ * * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
+ * relevant updates.
+ *
+ * Note that depending on the type of the PaymentSendFailure the HTLC may have been
+ * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
+ * different route unless you intend to pay twice!
+ *
+ * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
+ * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
+ * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
+ * must not contain multiple paths as multi-path payments require a recipient-provided
+ * payment_secret.
+ * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
+ * bit set (either as required or as available). If multiple paths are present in the Route,
+ * we assume the invoice had the basic_mpp feature set.
+ */
+MUST_USE_RES LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(const LDKChannelManager *this_arg, const LDKRoute *route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret);
+
+/**
+ * Call this upon creation of a funding transaction for the given channel.
+ *
+ * Note that ALL inputs in the transaction pointed to by funding_txo MUST spend SegWit outputs
+ * or your counterparty can steal your funds!
+ *
+ * Panics if a funding transaction has already been provided for this channel.
+ *
+ * May panic if the funding_txo is duplicative with some other channel (note that this should
+ * be trivially prevented by using unique funding transaction keys per-channel).
+ */
+void ChannelManager_funding_transaction_generated(const LDKChannelManager *this_arg, const uint8_t (*temporary_channel_id)[32], LDKOutPoint funding_txo);
+
+/**
+ * Generates a signed node_announcement from the given arguments and creates a
+ * BroadcastNodeAnnouncement event. Note that such messages will be ignored unless peers have
+ * seen a channel_announcement from us (ie unless we have public channels open).
+ *
+ * RGB is a node \"color\" and alias is a printable human-readable string to describe this node
+ * to humans. They carry no in-protocol meaning.
+ *
+ * addresses represent the set (possibly empty) of socket addresses on which this node accepts
+ * incoming connections. These will be broadcast to the network, publicly tying these
+ * addresses together. If you wish to preserve user privacy, addresses should likely contain
+ * only Tor Onion addresses.
+ *
+ * Panics if addresses is absurdly large (more than 500).
+ */
+void ChannelManager_broadcast_node_announcement(const LDKChannelManager *this_arg, LDKThreeBytes rgb, LDKThirtyTwoBytes alias, LDKCVec_NetAddressZ addresses);
+
+/**
+ * Processes HTLCs which are pending waiting on random forward delay.
+ *
+ * Should only really ever be called in response to a PendingHTLCsForwardable event.
+ * Will likely generate further events.
+ */
+void ChannelManager_process_pending_htlc_forwards(const LDKChannelManager *this_arg);
+
+/**
+ * If a peer is disconnected we mark any channels with that peer as 'disabled'.
+ * After some time, if channels are still disabled we need to broadcast a ChannelUpdate
+ * to inform the network about the uselessness of these channels.
+ *
+ * This method handles all the details, and must be called roughly once per minute.
+ */
+void ChannelManager_timer_chan_freshness_every_min(const LDKChannelManager *this_arg);
+
+/**
+ * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
+ * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources
+ * along the path (including in our own channel on which we received it).
+ * Returns false if no payment was found to fail backwards, true if the process of failing the
+ * HTLC backwards has been started.
+ */
+MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const LDKChannelManager *this_arg, const uint8_t (*payment_hash)[32], LDKThirtyTwoBytes payment_secret);
+
+/**
+ * Provides a payment preimage in response to a PaymentReceived event, returning true and
+ * generating message events for the net layer to claim the payment, if possible. Thus, you
+ * should probably kick the net layer to go send messages if this returns true!
+ *
+ * You must specify the expected amounts for this HTLC, and we will only claim HTLCs
+ * available within a few percent of the expected amount. This is critical for several
+ * reasons : a) it avoids providing senders with `proof-of-payment` (in the form of the
+ * payment_preimage without having provided the full value and b) it avoids certain
+ * privacy-breaking recipient-probing attacks which may reveal payment activity to
+ * motivated attackers.
+ *
+ * Note that the privacy concerns in (b) are not relevant in payments with a payment_secret
+ * set. Thus, for such payments we will claim any payments which do not under-pay.
+ *
+ * May panic if called except in response to a PaymentReceived event.
+ */
+MUST_USE_RES bool ChannelManager_claim_funds(const LDKChannelManager *this_arg, LDKThirtyTwoBytes payment_preimage, LDKThirtyTwoBytes payment_secret, uint64_t expected_amount);
+
+/**
+ * Gets the node_id held by this ChannelManager
+ */
+MUST_USE_RES LDKPublicKey ChannelManager_get_our_node_id(const LDKChannelManager *this_arg);
+
+/**
+ * Restores a single, given channel to normal operation after a
+ * ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update
+ * operation.
+ *
+ * All ChannelMonitor updates up to and including highest_applied_update_id must have been
+ * fully committed in every copy of the given channels' ChannelMonitors.
+ *
+ * Note that there is no effect to calling with a highest_applied_update_id other than the
+ * current latest ChannelMonitorUpdate and one call to this function after multiple
+ * ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field
+ * exists largely only to prevent races between this and concurrent update_monitor calls.
+ *
+ * Thus, the anticipated use is, at a high level:
+ * 1) You register a ManyChannelMonitor with this ChannelManager,
+ * 2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
+ * said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
+ * any time it cannot do so instantly,
+ * 3) update(s) are applied to each remote copy of a ChannelMonitor,
+ * 4) once all remote copies are updated, you call this function with the update_id that
+ * completed, and once it is the latest the Channel will be re-enabled.
+ */
+void ChannelManager_channel_monitor_updated(const LDKChannelManager *this_arg, const LDKOutPoint *funding_txo, uint64_t highest_applied_update_id);
+
+LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const LDKChannelManager *this_arg);
+
+LDKEventsProvider ChannelManager_as_EventsProvider(const LDKChannelManager *this_arg);
+
+LDKChainListener ChannelManager_as_ChainListener(const LDKChannelManager *this_arg);
+
+LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const LDKChannelManager *this_arg);
+
+void ChannelManagerReadArgs_free(LDKChannelManagerReadArgs this_ptr);
+
+/**
+ * The keys provider which will give us relevant keys. Some keys will be loaded during
+ * deserialization.
+ */
+const LDKKeysInterface *ChannelManagerReadArgs_get_keys_manager(const LDKChannelManagerReadArgs *this_ptr);
+
+/**
+ * The keys provider which will give us relevant keys. Some keys will be loaded during
+ * deserialization.
+ */
+void ChannelManagerReadArgs_set_keys_manager(LDKChannelManagerReadArgs *this_ptr, LDKKeysInterface val);
+
+/**
+ * The fee_estimator for use in the ChannelManager in the future.
+ *
+ * No calls to the FeeEstimator will be made during deserialization.
+ */
+const LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const LDKChannelManagerReadArgs *this_ptr);
+
+/**
+ * The fee_estimator for use in the ChannelManager in the future.
+ *
+ * No calls to the FeeEstimator will be made during deserialization.
+ */
+void ChannelManagerReadArgs_set_fee_estimator(LDKChannelManagerReadArgs *this_ptr, LDKFeeEstimator val);
+
+/**
+ * The ManyChannelMonitor for use in the ChannelManager in the future.
+ *
+ * No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
+ * you have deserialized ChannelMonitors separately and will add them to your
+ * ManyChannelMonitor after deserializing this ChannelManager.
+ */
+const LDKManyChannelMonitor *ChannelManagerReadArgs_get_monitor(const LDKChannelManagerReadArgs *this_ptr);
+
+/**
+ * The ManyChannelMonitor for use in the ChannelManager in the future.
+ *
+ * No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
+ * you have deserialized ChannelMonitors separately and will add them to your
+ * ManyChannelMonitor after deserializing this ChannelManager.
+ */
+void ChannelManagerReadArgs_set_monitor(LDKChannelManagerReadArgs *this_ptr, LDKManyChannelMonitor val);
+
+/**
+ * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
+ * used to broadcast the latest local commitment transactions of channels which must be
+ * force-closed during deserialization.
+ */
+const LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const LDKChannelManagerReadArgs *this_ptr);
+
+/**
+ * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
+ * used to broadcast the latest local commitment transactions of channels which must be
+ * force-closed during deserialization.
+ */
+void ChannelManagerReadArgs_set_tx_broadcaster(LDKChannelManagerReadArgs *this_ptr, LDKBroadcasterInterface val);
+
+/**
+ * The Logger for use in the ChannelManager and which may be used to log information during
+ * deserialization.
+ */
+const LDKLogger *ChannelManagerReadArgs_get_logger(const LDKChannelManagerReadArgs *this_ptr);
+
+/**
+ * The Logger for use in the ChannelManager and which may be used to log information during
+ * deserialization.
+ */
+void ChannelManagerReadArgs_set_logger(LDKChannelManagerReadArgs *this_ptr, LDKLogger val);
+
+/**
+ * Default settings used for new channels. Any existing channels will continue to use the
+ * runtime settings which were stored when the ChannelManager was serialized.
+ */
+LDKUserConfig ChannelManagerReadArgs_get_default_config(const LDKChannelManagerReadArgs *this_ptr);
+
+/**
+ * Default settings used for new channels. Any existing channels will continue to use the
+ * runtime settings which were stored when the ChannelManager was serialized.
+ */
+void ChannelManagerReadArgs_set_default_config(LDKChannelManagerReadArgs *this_ptr, LDKUserConfig val);
+
+/**
+ * Simple utility function to create a ChannelManagerReadArgs which creates the monitor
+ * HashMap for you. This is primarily useful for C bindings where it is not practical to
+ * populate a HashMap directly from C.
+ */
+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);
+
+void ChannelMonitorUpdate_free(LDKChannelMonitorUpdate this_ptr);
+
+/**
+ * The sequence number of this update. Updates *must* be replayed in-order according to this
+ * sequence number (and updates may panic if they are not). The update_id values are strictly
+ * increasing and increase by one for each new update.
+ *
+ * This sequence number is also used to track up to which points updates which returned
+ * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
+ * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
+ */
+uint64_t ChannelMonitorUpdate_get_update_id(const LDKChannelMonitorUpdate *this_ptr);
+
+/**
+ * The sequence number of this update. Updates *must* be replayed in-order according to this
+ * sequence number (and updates may panic if they are not). The update_id values are strictly
+ * increasing and increase by one for each new update.
+ *
+ * This sequence number is also used to track up to which points updates which returned
+ * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
+ * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
+ */
+void ChannelMonitorUpdate_set_update_id(LDKChannelMonitorUpdate *this_ptr, uint64_t val);
+
+LDKCVec_u8Z ChannelMonitorUpdate_write(const LDKChannelMonitorUpdate *obj);
+
+LDKChannelMonitorUpdate ChannelMonitorUpdate_read(LDKu8slice ser);
+
+void MonitorUpdateError_free(LDKMonitorUpdateError this_ptr);
+
+void MonitorEvent_free(LDKMonitorEvent this_ptr);
+
+void HTLCUpdate_free(LDKHTLCUpdate this_ptr);
+
+LDKCVec_u8Z HTLCUpdate_write(const LDKHTLCUpdate *obj);
+
+LDKHTLCUpdate HTLCUpdate_read(LDKu8slice ser);
+
+void ChannelMonitor_free(LDKChannelMonitor this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void ManyChannelMonitor_free(LDKManyChannelMonitor this_ptr);
+
+/**
+ * Updates a ChannelMonitor on the basis of some new information provided by the Channel
+ * itself.
+ *
+ * panics if the given update is not the next update by update_id.
+ */
+MUST_USE_RES LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(LDKChannelMonitor *this_arg, LDKChannelMonitorUpdate updates, const LDKBroadcasterInterface *broadcaster, const LDKLogger *logger);
+
+/**
+ * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
+ * ChannelMonitor.
+ */
+MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const LDKChannelMonitor *this_arg);
+
+/**
+ * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
+ */
+MUST_USE_RES LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const LDKChannelMonitor *this_arg);
+
+/**
+ * Get the list of HTLCs who's status has been updated on chain. This should be called by
+ * ChannelManager via ManyChannelMonitor::get_and_clear_pending_monitor_events().
+ */
+MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(LDKChannelMonitor *this_arg);
+
+/**
+ * Gets the list of pending events which were generated by previous actions, clearing the list
+ * in the process.
+ *
+ * This is called by ManyChannelMonitor::get_and_clear_pending_events() and is equivalent to
+ * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
+ * no internal locking in ChannelMonitors.
+ */
+MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(LDKChannelMonitor *this_arg);
+
+/**
+ * Used by ChannelManager deserialization to broadcast the latest local state if its copy of
+ * the Channel was out-of-date. You may use it to get a broadcastable local toxic tx in case of
+ * fallen-behind, i.e when receiving a channel_reestablish with a proof that our remote side knows
+ * a higher revocation secret than the local commitment number we are aware of. Broadcasting these
+ * transactions are UNSAFE, as they allow remote side to punish you. Nevertheless you may want to
+ * broadcast them if remote don't close channel with his higher commitment transaction after a
+ * substantial amount of time (a month or even a year) to get back funds. Best may be to contact
+ * out-of-band the other node operator to coordinate with him if option is available to you.
+ * In any-case, choice is up to the user.
+ */
+MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_local_commitment_txn(LDKChannelMonitor *this_arg, const LDKLogger *logger);
+
+void DecodeError_free(LDKDecodeError this_ptr);
+
+void Init_free(LDKInit this_ptr);
+
+void ErrorMessage_free(LDKErrorMessage this_ptr);
+
+/**
+ * The channel ID involved in the error
+ */
+const uint8_t (*ErrorMessage_get_channel_id(const LDKErrorMessage *this_ptr))[32];
+
+/**
+ * The channel ID involved in the error
+ */
+void ErrorMessage_set_channel_id(LDKErrorMessage *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * A possibly human-readable error description.
+ * The string should be sanitized before it is used (e.g. emitted to logs
+ * or printed to stdout). Otherwise, a well crafted error message may trigger a security
+ * vulnerability in the terminal emulator or the logging subsystem.
+ */
+LDKStr ErrorMessage_get_data(const LDKErrorMessage *this_ptr);
+
+/**
+ * A possibly human-readable error description.
+ * The string should be sanitized before it is used (e.g. emitted to logs
+ * or printed to stdout). Otherwise, a well crafted error message may trigger a security
+ * vulnerability in the terminal emulator or the logging subsystem.
+ */
+void ErrorMessage_set_data(LDKErrorMessage *this_ptr, LDKCVec_u8Z val);
+
+MUST_USE_RES LDKErrorMessage ErrorMessage_new(LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z data_arg);
+
+void Ping_free(LDKPing this_ptr);
+
+/**
+ * The desired response length
+ */
+uint16_t Ping_get_ponglen(const LDKPing *this_ptr);
+
+/**
+ * The desired response length
+ */
+void Ping_set_ponglen(LDKPing *this_ptr, uint16_t val);
+
+/**
+ * The ping packet size.
+ * This field is not sent on the wire. byteslen zeros are sent.
+ */
+uint16_t Ping_get_byteslen(const LDKPing *this_ptr);
+
+/**
+ * The ping packet size.
+ * This field is not sent on the wire. byteslen zeros are sent.
+ */
+void Ping_set_byteslen(LDKPing *this_ptr, uint16_t val);
+
+MUST_USE_RES LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg);
+
+void Pong_free(LDKPong this_ptr);
+
+/**
+ * The pong packet size.
+ * This field is not sent on the wire. byteslen zeros are sent.
+ */
+uint16_t Pong_get_byteslen(const LDKPong *this_ptr);
+
+/**
+ * The pong packet size.
+ * This field is not sent on the wire. byteslen zeros are sent.
+ */
+void Pong_set_byteslen(LDKPong *this_ptr, uint16_t val);
+
+MUST_USE_RES LDKPong Pong_new(uint16_t byteslen_arg);
+
+void OpenChannel_free(LDKOpenChannel this_ptr);
+
+/**
+ * The genesis hash of the blockchain where the channel is to be opened
+ */
+const uint8_t (*OpenChannel_get_chain_hash(const LDKOpenChannel *this_ptr))[32];
+
+/**
+ * The genesis hash of the blockchain where the channel is to be opened
+ */
+void OpenChannel_set_chain_hash(LDKOpenChannel *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * A temporary channel ID, until the funding outpoint is announced
+ */
+const uint8_t (*OpenChannel_get_temporary_channel_id(const LDKOpenChannel *this_ptr))[32];
+
+/**
+ * A temporary channel ID, until the funding outpoint is announced
+ */
+void OpenChannel_set_temporary_channel_id(LDKOpenChannel *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The channel value
+ */
+uint64_t OpenChannel_get_funding_satoshis(const LDKOpenChannel *this_ptr);
+
+/**
+ * The channel value
+ */
+void OpenChannel_set_funding_satoshis(LDKOpenChannel *this_ptr, uint64_t val);
+
+/**
+ * The amount to push to the counterparty as part of the open, in milli-satoshi
+ */
+uint64_t OpenChannel_get_push_msat(const LDKOpenChannel *this_ptr);
+
+/**
+ * The amount to push to the counterparty as part of the open, in milli-satoshi
+ */
+void OpenChannel_set_push_msat(LDKOpenChannel *this_ptr, uint64_t val);
+
+/**
+ * The threshold below which outputs on transactions broadcast by sender will be omitted
+ */
+uint64_t OpenChannel_get_dust_limit_satoshis(const LDKOpenChannel *this_ptr);
+
+/**
+ * The threshold below which outputs on transactions broadcast by sender will be omitted
+ */
+void OpenChannel_set_dust_limit_satoshis(LDKOpenChannel *this_ptr, uint64_t val);
+
+/**
+ * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
+ */
+uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const LDKOpenChannel *this_ptr);
+
+/**
+ * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
+ */
+void OpenChannel_set_max_htlc_value_in_flight_msat(LDKOpenChannel *this_ptr, uint64_t val);
+
+/**
+ * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
+ */
+uint64_t OpenChannel_get_channel_reserve_satoshis(const LDKOpenChannel *this_ptr);
+
+/**
+ * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
+ */
+void OpenChannel_set_channel_reserve_satoshis(LDKOpenChannel *this_ptr, uint64_t val);
+
+/**
+ * The minimum HTLC size incoming to sender, in milli-satoshi
+ */
+uint64_t OpenChannel_get_htlc_minimum_msat(const LDKOpenChannel *this_ptr);
+
+/**
+ * The minimum HTLC size incoming to sender, in milli-satoshi
+ */
+void OpenChannel_set_htlc_minimum_msat(LDKOpenChannel *this_ptr, uint64_t val);
+
+/**
+ * The feerate per 1000-weight of sender generated transactions, until updated by update_fee
+ */
+uint32_t OpenChannel_get_feerate_per_kw(const LDKOpenChannel *this_ptr);
+
+/**
+ * The feerate per 1000-weight of sender generated transactions, until updated by update_fee
+ */
+void OpenChannel_set_feerate_per_kw(LDKOpenChannel *this_ptr, uint32_t val);
+
+/**
+ * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
+ */
+uint16_t OpenChannel_get_to_self_delay(const LDKOpenChannel *this_ptr);
+
+/**
+ * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
+ */
+void OpenChannel_set_to_self_delay(LDKOpenChannel *this_ptr, uint16_t val);
+
+/**
+ * The maximum number of inbound HTLCs towards sender
+ */
+uint16_t OpenChannel_get_max_accepted_htlcs(const LDKOpenChannel *this_ptr);
+
+/**
+ * The maximum number of inbound HTLCs towards sender
+ */
+void OpenChannel_set_max_accepted_htlcs(LDKOpenChannel *this_ptr, uint16_t val);
+
+/**
+ * The sender's key controlling the funding transaction
+ */
+LDKPublicKey OpenChannel_get_funding_pubkey(const LDKOpenChannel *this_ptr);
+
+/**
+ * The sender's key controlling the funding transaction
+ */
+void OpenChannel_set_funding_pubkey(LDKOpenChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * Used to derive a revocation key for transactions broadcast by counterparty
+ */
+LDKPublicKey OpenChannel_get_revocation_basepoint(const LDKOpenChannel *this_ptr);
+
+/**
+ * Used to derive a revocation key for transactions broadcast by counterparty
+ */
+void OpenChannel_set_revocation_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * A payment key to sender for transactions broadcast by counterparty
+ */
+LDKPublicKey OpenChannel_get_payment_point(const LDKOpenChannel *this_ptr);
+
+/**
+ * A payment key to sender for transactions broadcast by counterparty
+ */
+void OpenChannel_set_payment_point(LDKOpenChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * Used to derive a payment key to sender for transactions broadcast by sender
+ */
+LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const LDKOpenChannel *this_ptr);
+
+/**
+ * Used to derive a payment key to sender for transactions broadcast by sender
+ */
+void OpenChannel_set_delayed_payment_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * Used to derive an HTLC payment key to sender
+ */
+LDKPublicKey OpenChannel_get_htlc_basepoint(const LDKOpenChannel *this_ptr);
+
+/**
+ * Used to derive an HTLC payment key to sender
+ */
+void OpenChannel_set_htlc_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * The first to-be-broadcast-by-sender transaction's per commitment point
+ */
+LDKPublicKey OpenChannel_get_first_per_commitment_point(const LDKOpenChannel *this_ptr);
+
+/**
+ * The first to-be-broadcast-by-sender transaction's per commitment point
+ */
+void OpenChannel_set_first_per_commitment_point(LDKOpenChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * Channel flags
+ */
+uint8_t OpenChannel_get_channel_flags(const LDKOpenChannel *this_ptr);
+
+/**
+ * Channel flags
+ */
+void OpenChannel_set_channel_flags(LDKOpenChannel *this_ptr, uint8_t val);
+
+void AcceptChannel_free(LDKAcceptChannel this_ptr);
+
+/**
+ * A temporary channel ID, until the funding outpoint is announced
+ */
+const uint8_t (*AcceptChannel_get_temporary_channel_id(const LDKAcceptChannel *this_ptr))[32];
+
+/**
+ * A temporary channel ID, until the funding outpoint is announced
+ */
+void AcceptChannel_set_temporary_channel_id(LDKAcceptChannel *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The threshold below which outputs on transactions broadcast by sender will be omitted
+ */
+uint64_t AcceptChannel_get_dust_limit_satoshis(const LDKAcceptChannel *this_ptr);
+
+/**
+ * The threshold below which outputs on transactions broadcast by sender will be omitted
+ */
+void AcceptChannel_set_dust_limit_satoshis(LDKAcceptChannel *this_ptr, uint64_t val);
+
+/**
+ * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
+ */
+uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const LDKAcceptChannel *this_ptr);
+
+/**
+ * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
+ */
+void AcceptChannel_set_max_htlc_value_in_flight_msat(LDKAcceptChannel *this_ptr, uint64_t val);
+
+/**
+ * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
+ */
+uint64_t AcceptChannel_get_channel_reserve_satoshis(const LDKAcceptChannel *this_ptr);
+
+/**
+ * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
+ */
+void AcceptChannel_set_channel_reserve_satoshis(LDKAcceptChannel *this_ptr, uint64_t val);
+
+/**
+ * The minimum HTLC size incoming to sender, in milli-satoshi
+ */
+uint64_t AcceptChannel_get_htlc_minimum_msat(const LDKAcceptChannel *this_ptr);
+
+/**
+ * The minimum HTLC size incoming to sender, in milli-satoshi
+ */
+void AcceptChannel_set_htlc_minimum_msat(LDKAcceptChannel *this_ptr, uint64_t val);
+
+/**
+ * Minimum depth of the funding transaction before the channel is considered open
+ */
+uint32_t AcceptChannel_get_minimum_depth(const LDKAcceptChannel *this_ptr);
+
+/**
+ * Minimum depth of the funding transaction before the channel is considered open
+ */
+void AcceptChannel_set_minimum_depth(LDKAcceptChannel *this_ptr, uint32_t val);
+
+/**
+ * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
+ */
+uint16_t AcceptChannel_get_to_self_delay(const LDKAcceptChannel *this_ptr);
+
+/**
+ * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
+ */
+void AcceptChannel_set_to_self_delay(LDKAcceptChannel *this_ptr, uint16_t val);
+
+/**
+ * The maximum number of inbound HTLCs towards sender
+ */
+uint16_t AcceptChannel_get_max_accepted_htlcs(const LDKAcceptChannel *this_ptr);
+
+/**
+ * The maximum number of inbound HTLCs towards sender
+ */
+void AcceptChannel_set_max_accepted_htlcs(LDKAcceptChannel *this_ptr, uint16_t val);
+
+/**
+ * The sender's key controlling the funding transaction
+ */
+LDKPublicKey AcceptChannel_get_funding_pubkey(const LDKAcceptChannel *this_ptr);
+
+/**
+ * The sender's key controlling the funding transaction
+ */
+void AcceptChannel_set_funding_pubkey(LDKAcceptChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * Used to derive a revocation key for transactions broadcast by counterparty
+ */
+LDKPublicKey AcceptChannel_get_revocation_basepoint(const LDKAcceptChannel *this_ptr);
+
+/**
+ * Used to derive a revocation key for transactions broadcast by counterparty
+ */
+void AcceptChannel_set_revocation_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * A payment key to sender for transactions broadcast by counterparty
+ */
+LDKPublicKey AcceptChannel_get_payment_point(const LDKAcceptChannel *this_ptr);
+
+/**
+ * A payment key to sender for transactions broadcast by counterparty
+ */
+void AcceptChannel_set_payment_point(LDKAcceptChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * Used to derive a payment key to sender for transactions broadcast by sender
+ */
+LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const LDKAcceptChannel *this_ptr);
+
+/**
+ * Used to derive a payment key to sender for transactions broadcast by sender
+ */
+void AcceptChannel_set_delayed_payment_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
+ */
+LDKPublicKey AcceptChannel_get_htlc_basepoint(const LDKAcceptChannel *this_ptr);
+
+/**
+ * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
+ */
+void AcceptChannel_set_htlc_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val);
+
+/**
+ * The first to-be-broadcast-by-sender transaction's per commitment point
+ */
+LDKPublicKey AcceptChannel_get_first_per_commitment_point(const LDKAcceptChannel *this_ptr);
+
+/**
+ * The first to-be-broadcast-by-sender transaction's per commitment point
+ */
+void AcceptChannel_set_first_per_commitment_point(LDKAcceptChannel *this_ptr, LDKPublicKey val);
+
+void FundingCreated_free(LDKFundingCreated this_ptr);
+
+/**
+ * A temporary channel ID, until the funding is established
+ */
+const uint8_t (*FundingCreated_get_temporary_channel_id(const LDKFundingCreated *this_ptr))[32];
+
+/**
+ * A temporary channel ID, until the funding is established
+ */
+void FundingCreated_set_temporary_channel_id(LDKFundingCreated *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The funding transaction ID
+ */
+const uint8_t (*FundingCreated_get_funding_txid(const LDKFundingCreated *this_ptr))[32];
+
+/**
+ * The funding transaction ID
+ */
+void FundingCreated_set_funding_txid(LDKFundingCreated *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The specific output index funding this channel
+ */
+uint16_t FundingCreated_get_funding_output_index(const LDKFundingCreated *this_ptr);
+
+/**
+ * The specific output index funding this channel
+ */
+void FundingCreated_set_funding_output_index(LDKFundingCreated *this_ptr, uint16_t val);
+
+/**
+ * The signature of the channel initiator (funder) on the funding transaction
+ */
+LDKSignature FundingCreated_get_signature(const LDKFundingCreated *this_ptr);
+
+/**
+ * The signature of the channel initiator (funder) on the funding transaction
+ */
+void FundingCreated_set_signature(LDKFundingCreated *this_ptr, LDKSignature val);
+
+MUST_USE_RES LDKFundingCreated FundingCreated_new(LDKThirtyTwoBytes temporary_channel_id_arg, LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, LDKSignature signature_arg);
+
+void FundingSigned_free(LDKFundingSigned this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*FundingSigned_get_channel_id(const LDKFundingSigned *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void FundingSigned_set_channel_id(LDKFundingSigned *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The signature of the channel acceptor (fundee) on the funding transaction
+ */
+LDKSignature FundingSigned_get_signature(const LDKFundingSigned *this_ptr);
+
+/**
+ * The signature of the channel acceptor (fundee) on the funding transaction
+ */
+void FundingSigned_set_signature(LDKFundingSigned *this_ptr, LDKSignature val);
+
+MUST_USE_RES LDKFundingSigned FundingSigned_new(LDKThirtyTwoBytes channel_id_arg, LDKSignature signature_arg);
+
+void FundingLocked_free(LDKFundingLocked this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*FundingLocked_get_channel_id(const LDKFundingLocked *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void FundingLocked_set_channel_id(LDKFundingLocked *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The per-commitment point of the second commitment transaction
+ */
+LDKPublicKey FundingLocked_get_next_per_commitment_point(const LDKFundingLocked *this_ptr);
+
+/**
+ * The per-commitment point of the second commitment transaction
+ */
+void FundingLocked_set_next_per_commitment_point(LDKFundingLocked *this_ptr, LDKPublicKey val);
+
+MUST_USE_RES LDKFundingLocked FundingLocked_new(LDKThirtyTwoBytes channel_id_arg, LDKPublicKey next_per_commitment_point_arg);
+
+void Shutdown_free(LDKShutdown this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*Shutdown_get_channel_id(const LDKShutdown *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void Shutdown_set_channel_id(LDKShutdown *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The destination of this peer's funds on closing.
+ * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
+ */
+LDKu8slice Shutdown_get_scriptpubkey(const LDKShutdown *this_ptr);
+
+/**
+ * The destination of this peer's funds on closing.
+ * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
+ */
+void Shutdown_set_scriptpubkey(LDKShutdown *this_ptr, LDKCVec_u8Z val);
+
+MUST_USE_RES LDKShutdown Shutdown_new(LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z scriptpubkey_arg);
+
+void ClosingSigned_free(LDKClosingSigned this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*ClosingSigned_get_channel_id(const LDKClosingSigned *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void ClosingSigned_set_channel_id(LDKClosingSigned *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The proposed total fee for the closing transaction
+ */
+uint64_t ClosingSigned_get_fee_satoshis(const LDKClosingSigned *this_ptr);
+
+/**
+ * The proposed total fee for the closing transaction
+ */
+void ClosingSigned_set_fee_satoshis(LDKClosingSigned *this_ptr, uint64_t val);
+
+/**
+ * A signature on the closing transaction
+ */
+LDKSignature ClosingSigned_get_signature(const LDKClosingSigned *this_ptr);
+
+/**
+ * A signature on the closing transaction
+ */
+void ClosingSigned_set_signature(LDKClosingSigned *this_ptr, LDKSignature val);
+
+MUST_USE_RES LDKClosingSigned ClosingSigned_new(LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, LDKSignature signature_arg);
+
+void UpdateAddHTLC_free(LDKUpdateAddHTLC this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*UpdateAddHTLC_get_channel_id(const LDKUpdateAddHTLC *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void UpdateAddHTLC_set_channel_id(LDKUpdateAddHTLC *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The HTLC ID
+ */
+uint64_t UpdateAddHTLC_get_htlc_id(const LDKUpdateAddHTLC *this_ptr);
+
+/**
+ * The HTLC ID
+ */
+void UpdateAddHTLC_set_htlc_id(LDKUpdateAddHTLC *this_ptr, uint64_t val);
+
+/**
+ * The HTLC value in milli-satoshi
+ */
+uint64_t UpdateAddHTLC_get_amount_msat(const LDKUpdateAddHTLC *this_ptr);
+
+/**
+ * The HTLC value in milli-satoshi
+ */
+void UpdateAddHTLC_set_amount_msat(LDKUpdateAddHTLC *this_ptr, uint64_t val);
+
+/**
+ * The payment hash, the pre-image of which controls HTLC redemption
+ */
+const uint8_t (*UpdateAddHTLC_get_payment_hash(const LDKUpdateAddHTLC *this_ptr))[32];
+
+/**
+ * The payment hash, the pre-image of which controls HTLC redemption
+ */
+void UpdateAddHTLC_set_payment_hash(LDKUpdateAddHTLC *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The expiry height of the HTLC
+ */
+uint32_t UpdateAddHTLC_get_cltv_expiry(const LDKUpdateAddHTLC *this_ptr);
+
+/**
+ * The expiry height of the HTLC
+ */
+void UpdateAddHTLC_set_cltv_expiry(LDKUpdateAddHTLC *this_ptr, uint32_t val);
+
+void UpdateFulfillHTLC_free(LDKUpdateFulfillHTLC this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*UpdateFulfillHTLC_get_channel_id(const LDKUpdateFulfillHTLC *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void UpdateFulfillHTLC_set_channel_id(LDKUpdateFulfillHTLC *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The HTLC ID
+ */
+uint64_t UpdateFulfillHTLC_get_htlc_id(const LDKUpdateFulfillHTLC *this_ptr);
+
+/**
+ * The HTLC ID
+ */
+void UpdateFulfillHTLC_set_htlc_id(LDKUpdateFulfillHTLC *this_ptr, uint64_t val);
+
+/**
+ * The pre-image of the payment hash, allowing HTLC redemption
+ */
+const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const LDKUpdateFulfillHTLC *this_ptr))[32];
+
+/**
+ * The pre-image of the payment hash, allowing HTLC redemption
+ */
+void UpdateFulfillHTLC_set_payment_preimage(LDKUpdateFulfillHTLC *this_ptr, LDKThirtyTwoBytes val);
+
+MUST_USE_RES LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, LDKThirtyTwoBytes payment_preimage_arg);
+
+void UpdateFailHTLC_free(LDKUpdateFailHTLC this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*UpdateFailHTLC_get_channel_id(const LDKUpdateFailHTLC *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void UpdateFailHTLC_set_channel_id(LDKUpdateFailHTLC *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The HTLC ID
+ */
+uint64_t UpdateFailHTLC_get_htlc_id(const LDKUpdateFailHTLC *this_ptr);
+
+/**
+ * The HTLC ID
+ */
+void UpdateFailHTLC_set_htlc_id(LDKUpdateFailHTLC *this_ptr, uint64_t val);
+
+void UpdateFailMalformedHTLC_free(LDKUpdateFailMalformedHTLC this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const LDKUpdateFailMalformedHTLC *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void UpdateFailMalformedHTLC_set_channel_id(LDKUpdateFailMalformedHTLC *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The HTLC ID
+ */
+uint64_t UpdateFailMalformedHTLC_get_htlc_id(const LDKUpdateFailMalformedHTLC *this_ptr);
+
+/**
+ * The HTLC ID
+ */
+void UpdateFailMalformedHTLC_set_htlc_id(LDKUpdateFailMalformedHTLC *this_ptr, uint64_t val);
+
+/**
+ * The failure code
+ */
+uint16_t UpdateFailMalformedHTLC_get_failure_code(const LDKUpdateFailMalformedHTLC *this_ptr);
+
+/**
+ * The failure code
+ */
+void UpdateFailMalformedHTLC_set_failure_code(LDKUpdateFailMalformedHTLC *this_ptr, uint16_t val);
+
+void CommitmentSigned_free(LDKCommitmentSigned this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*CommitmentSigned_get_channel_id(const LDKCommitmentSigned *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void CommitmentSigned_set_channel_id(LDKCommitmentSigned *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * A signature on the commitment transaction
+ */
+LDKSignature CommitmentSigned_get_signature(const LDKCommitmentSigned *this_ptr);
+
+/**
+ * A signature on the commitment transaction
+ */
+void CommitmentSigned_set_signature(LDKCommitmentSigned *this_ptr, LDKSignature val);
+
+/**
+ * Signatures on the HTLC transactions
+ */
+void CommitmentSigned_set_htlc_signatures(LDKCommitmentSigned *this_ptr, LDKCVec_SignatureZ val);
+
+MUST_USE_RES LDKCommitmentSigned CommitmentSigned_new(LDKThirtyTwoBytes channel_id_arg, LDKSignature signature_arg, LDKCVec_SignatureZ htlc_signatures_arg);
+
+void RevokeAndACK_free(LDKRevokeAndACK this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*RevokeAndACK_get_channel_id(const LDKRevokeAndACK *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void RevokeAndACK_set_channel_id(LDKRevokeAndACK *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The secret corresponding to the per-commitment point
+ */
+const uint8_t (*RevokeAndACK_get_per_commitment_secret(const LDKRevokeAndACK *this_ptr))[32];
+
+/**
+ * The secret corresponding to the per-commitment point
+ */
+void RevokeAndACK_set_per_commitment_secret(LDKRevokeAndACK *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The next sender-broadcast commitment transaction's per-commitment point
+ */
+LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const LDKRevokeAndACK *this_ptr);
+
+/**
+ * The next sender-broadcast commitment transaction's per-commitment point
+ */
+void RevokeAndACK_set_next_per_commitment_point(LDKRevokeAndACK *this_ptr, LDKPublicKey val);
+
+MUST_USE_RES LDKRevokeAndACK RevokeAndACK_new(LDKThirtyTwoBytes channel_id_arg, LDKThirtyTwoBytes per_commitment_secret_arg, LDKPublicKey next_per_commitment_point_arg);
+
+void UpdateFee_free(LDKUpdateFee this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*UpdateFee_get_channel_id(const LDKUpdateFee *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void UpdateFee_set_channel_id(LDKUpdateFee *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * Fee rate per 1000-weight of the transaction
+ */
+uint32_t UpdateFee_get_feerate_per_kw(const LDKUpdateFee *this_ptr);
+
+/**
+ * Fee rate per 1000-weight of the transaction
+ */
+void UpdateFee_set_feerate_per_kw(LDKUpdateFee *this_ptr, uint32_t val);
+
+MUST_USE_RES LDKUpdateFee UpdateFee_new(LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg);
+
+void DataLossProtect_free(LDKDataLossProtect this_ptr);
+
+/**
+ * Proof that the sender knows the per-commitment secret of a specific commitment transaction
+ * belonging to the recipient
+ */
+const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const LDKDataLossProtect *this_ptr))[32];
+
+/**
+ * Proof that the sender knows the per-commitment secret of a specific commitment transaction
+ * belonging to the recipient
+ */
+void DataLossProtect_set_your_last_per_commitment_secret(LDKDataLossProtect *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The sender's per-commitment point for their current commitment transaction
+ */
+LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const LDKDataLossProtect *this_ptr);
+
+/**
+ * The sender's per-commitment point for their current commitment transaction
+ */
+void DataLossProtect_set_my_current_per_commitment_point(LDKDataLossProtect *this_ptr, LDKPublicKey val);
+
+MUST_USE_RES LDKDataLossProtect DataLossProtect_new(LDKThirtyTwoBytes your_last_per_commitment_secret_arg, LDKPublicKey my_current_per_commitment_point_arg);
+
+void ChannelReestablish_free(LDKChannelReestablish this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*ChannelReestablish_get_channel_id(const LDKChannelReestablish *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void ChannelReestablish_set_channel_id(LDKChannelReestablish *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The next commitment number for the sender
+ */
+uint64_t ChannelReestablish_get_next_local_commitment_number(const LDKChannelReestablish *this_ptr);
+
+/**
+ * The next commitment number for the sender
+ */
+void ChannelReestablish_set_next_local_commitment_number(LDKChannelReestablish *this_ptr, uint64_t val);
+
+/**
+ * The next commitment number for the recipient
+ */
+uint64_t ChannelReestablish_get_next_remote_commitment_number(const LDKChannelReestablish *this_ptr);
+
+/**
+ * The next commitment number for the recipient
+ */
+void ChannelReestablish_set_next_remote_commitment_number(LDKChannelReestablish *this_ptr, uint64_t val);
+
+void AnnouncementSignatures_free(LDKAnnouncementSignatures this_ptr);
+
+/**
+ * The channel ID
+ */
+const uint8_t (*AnnouncementSignatures_get_channel_id(const LDKAnnouncementSignatures *this_ptr))[32];
+
+/**
+ * The channel ID
+ */
+void AnnouncementSignatures_set_channel_id(LDKAnnouncementSignatures *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The short channel ID
+ */
+uint64_t AnnouncementSignatures_get_short_channel_id(const LDKAnnouncementSignatures *this_ptr);
+
+/**
+ * The short channel ID
+ */
+void AnnouncementSignatures_set_short_channel_id(LDKAnnouncementSignatures *this_ptr, uint64_t val);
+
+/**
+ * A signature by the node key
+ */
+LDKSignature AnnouncementSignatures_get_node_signature(const LDKAnnouncementSignatures *this_ptr);
+
+/**
+ * A signature by the node key
+ */
+void AnnouncementSignatures_set_node_signature(LDKAnnouncementSignatures *this_ptr, LDKSignature val);
+
+/**
+ * A signature by the funding key
+ */
+LDKSignature AnnouncementSignatures_get_bitcoin_signature(const LDKAnnouncementSignatures *this_ptr);
+
+/**
+ * A signature by the funding key
+ */
+void AnnouncementSignatures_set_bitcoin_signature(LDKAnnouncementSignatures *this_ptr, LDKSignature val);
+
+MUST_USE_RES LDKAnnouncementSignatures AnnouncementSignatures_new(LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, LDKSignature node_signature_arg, LDKSignature bitcoin_signature_arg);
+
+void NetAddress_free(LDKNetAddress this_ptr);
+
+void UnsignedNodeAnnouncement_free(LDKUnsignedNodeAnnouncement this_ptr);
+
+/**
+ * A strictly monotonic announcement counter, with gaps allowed
+ */
+uint32_t UnsignedNodeAnnouncement_get_timestamp(const LDKUnsignedNodeAnnouncement *this_ptr);
+
+/**
+ * A strictly monotonic announcement counter, with gaps allowed
+ */
+void UnsignedNodeAnnouncement_set_timestamp(LDKUnsignedNodeAnnouncement *this_ptr, uint32_t val);
+
+/**
+ * The node_id this announcement originated from (don't rebroadcast the node_announcement back
+ * to this node).
+ */
+LDKPublicKey UnsignedNodeAnnouncement_get_node_id(const LDKUnsignedNodeAnnouncement *this_ptr);
+
+/**
+ * The node_id this announcement originated from (don't rebroadcast the node_announcement back
+ * to this node).
+ */
+void UnsignedNodeAnnouncement_set_node_id(LDKUnsignedNodeAnnouncement *this_ptr, LDKPublicKey val);
+
+/**
+ * An RGB color for UI purposes
+ */
+const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const LDKUnsignedNodeAnnouncement *this_ptr))[3];
+
+/**
+ * An RGB color for UI purposes
+ */
+void UnsignedNodeAnnouncement_set_rgb(LDKUnsignedNodeAnnouncement *this_ptr, LDKThreeBytes val);
+
+/**
+ * An alias, for UI purposes. This should be sanitized before use. There is no guarantee
+ * of uniqueness.
+ */
+const uint8_t (*UnsignedNodeAnnouncement_get_alias(const LDKUnsignedNodeAnnouncement *this_ptr))[32];
+
+/**
+ * An alias, for UI purposes. This should be sanitized before use. There is no guarantee
+ * of uniqueness.
+ */
+void UnsignedNodeAnnouncement_set_alias(LDKUnsignedNodeAnnouncement *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * List of addresses on which this node is reachable
+ */
+void UnsignedNodeAnnouncement_set_addresses(LDKUnsignedNodeAnnouncement *this_ptr, LDKCVec_NetAddressZ val);
+
+void NodeAnnouncement_free(LDKNodeAnnouncement this_ptr);
+
+/**
+ * The signature by the node key
+ */
+LDKSignature NodeAnnouncement_get_signature(const LDKNodeAnnouncement *this_ptr);
+
+/**
+ * The signature by the node key
+ */
+void NodeAnnouncement_set_signature(LDKNodeAnnouncement *this_ptr, LDKSignature val);
+
+/**
+ * The actual content of the announcement
+ */
+LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const LDKNodeAnnouncement *this_ptr);
+
+/**
+ * The actual content of the announcement
+ */
+void NodeAnnouncement_set_contents(LDKNodeAnnouncement *this_ptr, LDKUnsignedNodeAnnouncement val);
+
+MUST_USE_RES LDKNodeAnnouncement NodeAnnouncement_new(LDKSignature signature_arg, LDKUnsignedNodeAnnouncement contents_arg);
+
+void UnsignedChannelAnnouncement_free(LDKUnsignedChannelAnnouncement this_ptr);
+
+/**
+ * The genesis hash of the blockchain where the channel is to be opened
+ */
+const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const LDKUnsignedChannelAnnouncement *this_ptr))[32];
+
+/**
+ * The genesis hash of the blockchain where the channel is to be opened
+ */
+void UnsignedChannelAnnouncement_set_chain_hash(LDKUnsignedChannelAnnouncement *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The short channel ID
+ */
+uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const LDKUnsignedChannelAnnouncement *this_ptr);
+
+/**
+ * The short channel ID
+ */
+void UnsignedChannelAnnouncement_set_short_channel_id(LDKUnsignedChannelAnnouncement *this_ptr, uint64_t val);
+
+/**
+ * One of the two node_ids which are endpoints of this channel
+ */
+LDKPublicKey UnsignedChannelAnnouncement_get_node_id_1(const LDKUnsignedChannelAnnouncement *this_ptr);
+
+/**
+ * One of the two node_ids which are endpoints of this channel
+ */
+void UnsignedChannelAnnouncement_set_node_id_1(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val);
+
+/**
+ * The other of the two node_ids which are endpoints of this channel
+ */
+LDKPublicKey UnsignedChannelAnnouncement_get_node_id_2(const LDKUnsignedChannelAnnouncement *this_ptr);
+
+/**
+ * The other of the two node_ids which are endpoints of this channel
+ */
+void UnsignedChannelAnnouncement_set_node_id_2(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val);
+
+/**
+ * The funding key for the first node
+ */
+LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_1(const LDKUnsignedChannelAnnouncement *this_ptr);
+
+/**
+ * The funding key for the first node
+ */
+void UnsignedChannelAnnouncement_set_bitcoin_key_1(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val);
+
+/**
+ * The funding key for the second node
+ */
+LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const LDKUnsignedChannelAnnouncement *this_ptr);
+
+/**
+ * The funding key for the second node
+ */
+void UnsignedChannelAnnouncement_set_bitcoin_key_2(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val);
+
+void ChannelAnnouncement_free(LDKChannelAnnouncement this_ptr);
+
+/**
+ * Authentication of the announcement by the first public node
+ */
+LDKSignature ChannelAnnouncement_get_node_signature_1(const LDKChannelAnnouncement *this_ptr);
+
+/**
+ * Authentication of the announcement by the first public node
+ */
+void ChannelAnnouncement_set_node_signature_1(LDKChannelAnnouncement *this_ptr, LDKSignature val);
+
+/**
+ * Authentication of the announcement by the second public node
+ */
+LDKSignature ChannelAnnouncement_get_node_signature_2(const LDKChannelAnnouncement *this_ptr);
+
+/**
+ * Authentication of the announcement by the second public node
+ */
+void ChannelAnnouncement_set_node_signature_2(LDKChannelAnnouncement *this_ptr, LDKSignature val);
+
+/**
+ * Proof of funding UTXO ownership by the first public node
+ */
+LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const LDKChannelAnnouncement *this_ptr);
+
+/**
+ * Proof of funding UTXO ownership by the first public node
+ */
+void ChannelAnnouncement_set_bitcoin_signature_1(LDKChannelAnnouncement *this_ptr, LDKSignature val);
+
+/**
+ * Proof of funding UTXO ownership by the second public node
+ */
+LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const LDKChannelAnnouncement *this_ptr);
+
+/**
+ * Proof of funding UTXO ownership by the second public node
+ */
+void ChannelAnnouncement_set_bitcoin_signature_2(LDKChannelAnnouncement *this_ptr, LDKSignature val);
+
+/**
+ * The actual announcement
+ */
+LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const LDKChannelAnnouncement *this_ptr);
+
+/**
+ * The actual announcement
+ */
+void ChannelAnnouncement_set_contents(LDKChannelAnnouncement *this_ptr, LDKUnsignedChannelAnnouncement val);
+
+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);
+
+void UnsignedChannelUpdate_free(LDKUnsignedChannelUpdate this_ptr);
+
+/**
+ * The genesis hash of the blockchain where the channel is to be opened
+ */
+const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const LDKUnsignedChannelUpdate *this_ptr))[32];
+
+/**
+ * The genesis hash of the blockchain where the channel is to be opened
+ */
+void UnsignedChannelUpdate_set_chain_hash(LDKUnsignedChannelUpdate *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * The short channel ID
+ */
+uint64_t UnsignedChannelUpdate_get_short_channel_id(const LDKUnsignedChannelUpdate *this_ptr);
+
+/**
+ * The short channel ID
+ */
+void UnsignedChannelUpdate_set_short_channel_id(LDKUnsignedChannelUpdate *this_ptr, uint64_t val);
+
+/**
+ * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
+ */
+uint32_t UnsignedChannelUpdate_get_timestamp(const LDKUnsignedChannelUpdate *this_ptr);
+
+/**
+ * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
+ */
+void UnsignedChannelUpdate_set_timestamp(LDKUnsignedChannelUpdate *this_ptr, uint32_t val);
+
+/**
+ * Channel flags
+ */
+uint8_t UnsignedChannelUpdate_get_flags(const LDKUnsignedChannelUpdate *this_ptr);
+
+/**
+ * Channel flags
+ */
+void UnsignedChannelUpdate_set_flags(LDKUnsignedChannelUpdate *this_ptr, uint8_t val);
+
+/**
+ * The number of blocks to subtract from incoming HTLC cltv_expiry values
+ */
+uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const LDKUnsignedChannelUpdate *this_ptr);
+
+/**
+ * The number of blocks to subtract from incoming HTLC cltv_expiry values
+ */
+void UnsignedChannelUpdate_set_cltv_expiry_delta(LDKUnsignedChannelUpdate *this_ptr, uint16_t val);
+
+/**
+ * The minimum HTLC size incoming to sender, in milli-satoshi
+ */
+uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const LDKUnsignedChannelUpdate *this_ptr);
+
+/**
+ * The minimum HTLC size incoming to sender, in milli-satoshi
+ */
+void UnsignedChannelUpdate_set_htlc_minimum_msat(LDKUnsignedChannelUpdate *this_ptr, uint64_t val);
+
+/**
+ * The base HTLC fee charged by sender, in milli-satoshi
+ */
+uint32_t UnsignedChannelUpdate_get_fee_base_msat(const LDKUnsignedChannelUpdate *this_ptr);
+
+/**
+ * The base HTLC fee charged by sender, in milli-satoshi
+ */
+void UnsignedChannelUpdate_set_fee_base_msat(LDKUnsignedChannelUpdate *this_ptr, uint32_t val);
+
+/**
+ * The amount to fee multiplier, in micro-satoshi
+ */
+uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const LDKUnsignedChannelUpdate *this_ptr);
+
+/**
+ * The amount to fee multiplier, in micro-satoshi
+ */
+void UnsignedChannelUpdate_set_fee_proportional_millionths(LDKUnsignedChannelUpdate *this_ptr, uint32_t val);
+
+void ChannelUpdate_free(LDKChannelUpdate this_ptr);
+
+/**
+ * A signature of the channel update
+ */
+LDKSignature ChannelUpdate_get_signature(const LDKChannelUpdate *this_ptr);
+
+/**
+ * A signature of the channel update
+ */
+void ChannelUpdate_set_signature(LDKChannelUpdate *this_ptr, LDKSignature val);
+
+/**
+ * The actual channel update
+ */
+LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const LDKChannelUpdate *this_ptr);
+
+/**
+ * The actual channel update
+ */
+void ChannelUpdate_set_contents(LDKChannelUpdate *this_ptr, LDKUnsignedChannelUpdate val);
+
+MUST_USE_RES LDKChannelUpdate ChannelUpdate_new(LDKSignature signature_arg, LDKUnsignedChannelUpdate contents_arg);
+
+void ErrorAction_free(LDKErrorAction this_ptr);
+
+void LightningError_free(LDKLightningError this_ptr);
+
+/**
+ * A human-readable message describing the error
+ */
+LDKStr LightningError_get_err(const LDKLightningError *this_ptr);
+
+/**
+ * A human-readable message describing the error
+ */
+void LightningError_set_err(LDKLightningError *this_ptr, LDKCVec_u8Z val);
+
+/**
+ * The action which should be taken against the offending peer.
+ */
+LDKErrorAction LightningError_get_action(const LDKLightningError *this_ptr);
+
+/**
+ * The action which should be taken against the offending peer.
+ */
+void LightningError_set_action(LDKLightningError *this_ptr, LDKErrorAction val);
+
+MUST_USE_RES LDKLightningError LightningError_new(LDKCVec_u8Z err_arg, LDKErrorAction action_arg);
+
+void CommitmentUpdate_free(LDKCommitmentUpdate this_ptr);
+
+/**
+ * update_add_htlc messages which should be sent
+ */
+void CommitmentUpdate_set_update_add_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateAddHTLCZ val);
+
+/**
+ * update_fulfill_htlc messages which should be sent
+ */
+void CommitmentUpdate_set_update_fulfill_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFulfillHTLCZ val);
+
+/**
+ * update_fail_htlc messages which should be sent
+ */
+void CommitmentUpdate_set_update_fail_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailHTLCZ val);
+
+/**
+ * update_fail_malformed_htlc messages which should be sent
+ */
+void CommitmentUpdate_set_update_fail_malformed_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailMalformedHTLCZ val);
+
+/**
+ * An update_fee message which should be sent
+ */
+LDKUpdateFee CommitmentUpdate_get_update_fee(const LDKCommitmentUpdate *this_ptr);
+
+/**
+ * An update_fee message which should be sent
+ */
+void CommitmentUpdate_set_update_fee(LDKCommitmentUpdate *this_ptr, LDKUpdateFee val);
+
+/**
+ * Finally, the commitment_signed message which should be sent
+ */
+LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const LDKCommitmentUpdate *this_ptr);
+
+/**
+ * Finally, the commitment_signed message which should be sent
+ */
+void CommitmentUpdate_set_commitment_signed(LDKCommitmentUpdate *this_ptr, LDKCommitmentSigned val);
+
+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);
+
+void HTLCFailChannelUpdate_free(LDKHTLCFailChannelUpdate this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void ChannelMessageHandler_free(LDKChannelMessageHandler this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void RoutingMessageHandler_free(LDKRoutingMessageHandler this_ptr);
+
+LDKCVec_u8Z AcceptChannel_write(const LDKAcceptChannel *obj);
+
+LDKAcceptChannel AcceptChannel_read(LDKu8slice ser);
+
+LDKCVec_u8Z AnnouncementSignatures_write(const LDKAnnouncementSignatures *obj);
+
+LDKAnnouncementSignatures AnnouncementSignatures_read(LDKu8slice ser);
+
+LDKCVec_u8Z ChannelReestablish_write(const LDKChannelReestablish *obj);
+
+LDKChannelReestablish ChannelReestablish_read(LDKu8slice ser);
+
+LDKCVec_u8Z ClosingSigned_write(const LDKClosingSigned *obj);
+
+LDKClosingSigned ClosingSigned_read(LDKu8slice ser);
+
+LDKCVec_u8Z CommitmentSigned_write(const LDKCommitmentSigned *obj);
+
+LDKCommitmentSigned CommitmentSigned_read(LDKu8slice ser);
+
+LDKCVec_u8Z FundingCreated_write(const LDKFundingCreated *obj);
+
+LDKFundingCreated FundingCreated_read(LDKu8slice ser);
+
+LDKCVec_u8Z FundingSigned_write(const LDKFundingSigned *obj);
+
+LDKFundingSigned FundingSigned_read(LDKu8slice ser);
+
+LDKCVec_u8Z FundingLocked_write(const LDKFundingLocked *obj);
+
+LDKFundingLocked FundingLocked_read(LDKu8slice ser);
+
+LDKCVec_u8Z Init_write(const LDKInit *obj);
+
+LDKInit Init_read(LDKu8slice ser);
+
+LDKCVec_u8Z OpenChannel_write(const LDKOpenChannel *obj);
+
+LDKOpenChannel OpenChannel_read(LDKu8slice ser);
+
+LDKCVec_u8Z RevokeAndACK_write(const LDKRevokeAndACK *obj);
+
+LDKRevokeAndACK RevokeAndACK_read(LDKu8slice ser);
+
+LDKCVec_u8Z Shutdown_write(const LDKShutdown *obj);
+
+LDKShutdown Shutdown_read(LDKu8slice ser);
+
+LDKCVec_u8Z UpdateFailHTLC_write(const LDKUpdateFailHTLC *obj);
+
+LDKUpdateFailHTLC UpdateFailHTLC_read(LDKu8slice ser);
+
+LDKCVec_u8Z UpdateFailMalformedHTLC_write(const LDKUpdateFailMalformedHTLC *obj);
+
+LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_read(LDKu8slice ser);
+
+LDKCVec_u8Z UpdateFee_write(const LDKUpdateFee *obj);
+
+LDKUpdateFee UpdateFee_read(LDKu8slice ser);
+
+LDKCVec_u8Z UpdateFulfillHTLC_write(const LDKUpdateFulfillHTLC *obj);
+
+LDKUpdateFulfillHTLC UpdateFulfillHTLC_read(LDKu8slice ser);
+
+LDKCVec_u8Z UpdateAddHTLC_write(const LDKUpdateAddHTLC *obj);
+
+LDKUpdateAddHTLC UpdateAddHTLC_read(LDKu8slice ser);
+
+LDKCVec_u8Z Ping_write(const LDKPing *obj);
+
+LDKPing Ping_read(LDKu8slice ser);
+
+LDKCVec_u8Z Pong_write(const LDKPong *obj);
+
+LDKPong Pong_read(LDKu8slice ser);
+
+LDKCVec_u8Z UnsignedChannelAnnouncement_write(const LDKUnsignedChannelAnnouncement *obj);
+
+LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_read(LDKu8slice ser);
+
+LDKCVec_u8Z ChannelAnnouncement_write(const LDKChannelAnnouncement *obj);
+
+LDKChannelAnnouncement ChannelAnnouncement_read(LDKu8slice ser);
+
+LDKCVec_u8Z UnsignedChannelUpdate_write(const LDKUnsignedChannelUpdate *obj);
+
+LDKUnsignedChannelUpdate UnsignedChannelUpdate_read(LDKu8slice ser);
+
+LDKCVec_u8Z ChannelUpdate_write(const LDKChannelUpdate *obj);
+
+LDKChannelUpdate ChannelUpdate_read(LDKu8slice ser);
+
+LDKCVec_u8Z ErrorMessage_write(const LDKErrorMessage *obj);
+
+LDKErrorMessage ErrorMessage_read(LDKu8slice ser);
+
+LDKCVec_u8Z UnsignedNodeAnnouncement_write(const LDKUnsignedNodeAnnouncement *obj);
+
+LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_read(LDKu8slice ser);
+
+LDKCVec_u8Z NodeAnnouncement_write(const LDKNodeAnnouncement *obj);
+
+LDKNodeAnnouncement NodeAnnouncement_read(LDKu8slice ser);
+
+void MessageHandler_free(LDKMessageHandler this_ptr);
+
+/**
+ * A message handler which handles messages specific to channels. Usually this is just a
+ * ChannelManager object.
+ */
+const LDKChannelMessageHandler *MessageHandler_get_chan_handler(const LDKMessageHandler *this_ptr);
+
+/**
+ * A message handler which handles messages specific to channels. Usually this is just a
+ * ChannelManager object.
+ */
+void MessageHandler_set_chan_handler(LDKMessageHandler *this_ptr, LDKChannelMessageHandler val);
+
+/**
+ * A message handler which handles messages updating our knowledge of the network channel
+ * graph. Usually this is just a NetGraphMsgHandlerMonitor object.
+ */
+const LDKRoutingMessageHandler *MessageHandler_get_route_handler(const LDKMessageHandler *this_ptr);
+
+/**
+ * A message handler which handles messages updating our knowledge of the network channel
+ * graph. Usually this is just a NetGraphMsgHandlerMonitor object.
+ */
+void MessageHandler_set_route_handler(LDKMessageHandler *this_ptr, LDKRoutingMessageHandler val);
+
+MUST_USE_RES LDKMessageHandler MessageHandler_new(LDKChannelMessageHandler chan_handler_arg, LDKRoutingMessageHandler route_handler_arg);
+
+/**
+ * Calls the free function if one is set
+ */
+void SocketDescriptor_free(LDKSocketDescriptor this_ptr);
+
+void PeerHandleError_free(LDKPeerHandleError this_ptr);
+
+/**
+ * Used to indicate that we probably can't make any future connections to this peer, implying
+ * we should go ahead and force-close any channels we have with it.
+ */
+bool PeerHandleError_get_no_connection_possible(const LDKPeerHandleError *this_ptr);
+
+/**
+ * Used to indicate that we probably can't make any future connections to this peer, implying
+ * we should go ahead and force-close any channels we have with it.
+ */
+void PeerHandleError_set_no_connection_possible(LDKPeerHandleError *this_ptr, bool val);
+
+MUST_USE_RES LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg);
+
+void PeerManager_free(LDKPeerManager this_ptr);
+
+/**
+ * Constructs a new PeerManager with the given message handlers and node_id secret key
+ * ephemeral_random_data is used to derive per-connection ephemeral keys and must be
+ * cryptographically secure random bytes.
+ */
+MUST_USE_RES LDKPeerManager PeerManager_new(LDKMessageHandler message_handler, LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], LDKLogger logger);
+
+/**
+ * Get the list of node ids for peers which have completed the initial handshake.
+ *
+ * For outbound connections, this will be the same as the their_node_id parameter passed in to
+ * new_outbound_connection, however entries will only appear once the initial handshake has
+ * completed and we are sure the remote peer has the private key for the given node_id.
+ */
+MUST_USE_RES LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const LDKPeerManager *this_arg);
+
+/**
+ * Indicates a new outbound connection has been established to a node with the given node_id.
+ * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new
+ * descriptor but must disconnect the connection immediately.
+ *
+ * Returns a small number of bytes to send to the remote node (currently always 50).
+ *
+ * Panics if descriptor is duplicative with some other descriptor which has not yet had a
+ * socket_disconnected().
+ */
+MUST_USE_RES LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const LDKPeerManager *this_arg, LDKPublicKey their_node_id, LDKSocketDescriptor descriptor);
+
+/**
+ * Indicates a new inbound connection has been established.
+ *
+ * May refuse the connection by returning an Err, but will never write bytes to the remote end
+ * (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT
+ * call socket_disconnected for the new descriptor but must disconnect the connection
+ * immediately.
+ *
+ * Panics if descriptor is duplicative with some other descriptor which has not yet had
+ * socket_disconnected called.
+ */
+MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const LDKPeerManager *this_arg, LDKSocketDescriptor descriptor);
+
+/**
+ * Indicates that there is room to write data to the given socket descriptor.
+ *
+ * May return an Err to indicate that the connection should be closed.
+ *
+ * Will most likely call send_data on the descriptor passed in (or the descriptor handed into
+ * new_*\\_connection) before returning. Thus, be very careful with reentrancy issues! The
+ * invariants around calling write_buffer_space_avail in case a write did not fully complete
+ * must still hold - be ready to call write_buffer_space_avail again if a write call generated
+ * here isn't sufficient! Panics if the descriptor was not previously registered in a
+ * new_\\*_connection event.
+ */
+MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const LDKPeerManager *this_arg, LDKSocketDescriptor *descriptor);
+
+/**
+ * Indicates that data was read from the given socket descriptor.
+ *
+ * May return an Err to indicate that the connection should be closed.
+ *
+ * Will *not* call back into send_data on any descriptors to avoid reentrancy complexity.
+ * Thus, however, you almost certainly want to call process_events() after any read_event to
+ * generate send_data calls to handle responses.
+ *
+ * If Ok(true) is returned, further read_events should not be triggered until a send_data call
+ * on this file descriptor has resume_read set (preventing DoS issues in the send buffer).
+ *
+ * Panics if the descriptor was not previously registered in a new_*_connection event.
+ */
+MUST_USE_RES LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const LDKPeerManager *this_arg, LDKSocketDescriptor *peer_descriptor, LDKu8slice data);
+
+/**
+ * Checks for any events generated by our handlers and processes them. Includes sending most
+ * response messages as well as messages generated by calls to handler functions directly (eg
+ * functions like ChannelManager::process_pending_htlc_forward or send_payment).
+ */
+void PeerManager_process_events(const LDKPeerManager *this_arg);
+
+/**
+ * Indicates that the given socket descriptor's connection is now closed.
+ *
+ * This must only be called if the socket has been disconnected by the peer or your own
+ * decision to disconnect it and must NOT be called in any case where other parts of this
+ * library (eg PeerHandleError, explicit disconnect_socket calls) instruct you to disconnect
+ * the peer.
+ *
+ * Panics if the descriptor was not previously registered in a successful new_*_connection event.
+ */
+void PeerManager_socket_disconnected(const LDKPeerManager *this_arg, const LDKSocketDescriptor *descriptor);
+
+/**
+ * This function should be called roughly once every 30 seconds.
+ * It will send pings to each peer and disconnect those which did not respond to the last round of pings.
+ * Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues!
+ */
+void PeerManager_timer_tick_occured(const LDKPeerManager *this_arg);
+
+/**
+ * Build the commitment secret from the seed and the commitment number
+ */
+LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx);
+
+/**
+ * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
+ * from the base secret and the per_commitment_point.
+ *
+ * Note that this is infallible iff we trust that at least one of the two input keys are randomly
+ * generated (ie our own).
+ */
+LDKCResult_SecretKeySecpErrorZ derive_private_key(LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]);
+
+/**
+ * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
+ * from the base point and the per_commitment_key. This is the public equivalent of
+ * derive_private_key - using only public keys to derive a public key instead of private keys.
+ *
+ * Note that this is infallible iff we trust that at least one of the two input keys are randomly
+ * generated (ie our own).
+ */
+LDKCResult_PublicKeySecpErrorZ derive_public_key(LDKPublicKey per_commitment_point, LDKPublicKey base_point);
+
+/**
+ * Derives a per-commitment-transaction revocation key from its constituent parts.
+ *
+ * Note that this is infallible iff we trust that at least one of the two input keys are randomly
+ * generated (ie our own).
+ */
+LDKCResult_SecretKeySecpErrorZ derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*revocation_base_secret)[32]);
+
+/**
+ * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
+ * the public equivalend of derive_private_revocation_key - using only public keys to derive a
+ * public key instead of private keys.
+ *
+ * Note that this is infallible iff we trust that at least one of the two input keys are randomly
+ * generated (ie our own).
+ */
+LDKCResult_PublicKeySecpErrorZ derive_public_revocation_key(LDKPublicKey per_commitment_point, LDKPublicKey revocation_base_point);
+
+void TxCreationKeys_free(LDKTxCreationKeys this_ptr);
+
+/**
+ * The per-commitment public key which was used to derive the other keys.
+ */
+LDKPublicKey TxCreationKeys_get_per_commitment_point(const LDKTxCreationKeys *this_ptr);
+
+/**
+ * The per-commitment public key which was used to derive the other keys.
+ */
+void TxCreationKeys_set_per_commitment_point(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
+
+/**
+ * The revocation key which is used to allow the owner of the commitment transaction to
+ * provide their counterparty the ability to punish them if they broadcast an old state.
+ */
+LDKPublicKey TxCreationKeys_get_revocation_key(const LDKTxCreationKeys *this_ptr);
+
+/**
+ * The revocation key which is used to allow the owner of the commitment transaction to
+ * provide their counterparty the ability to punish them if they broadcast an old state.
+ */
+void TxCreationKeys_set_revocation_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
+
+/**
+ * A's HTLC Key
+ */
+LDKPublicKey TxCreationKeys_get_a_htlc_key(const LDKTxCreationKeys *this_ptr);
+
+/**
+ * A's HTLC Key
+ */
+void TxCreationKeys_set_a_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
+
+/**
+ * B's HTLC Key
+ */
+LDKPublicKey TxCreationKeys_get_b_htlc_key(const LDKTxCreationKeys *this_ptr);
+
+/**
+ * B's HTLC Key
+ */
+void TxCreationKeys_set_b_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
+
+/**
+ * A's Payment Key (which isn't allowed to be spent from for some delay)
+ */
+LDKPublicKey TxCreationKeys_get_a_delayed_payment_key(const LDKTxCreationKeys *this_ptr);
+
+/**
+ * A's Payment Key (which isn't allowed to be spent from for some delay)
+ */
+void TxCreationKeys_set_a_delayed_payment_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val);
+
+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);
+
+LDKCVec_u8Z TxCreationKeys_write(const LDKTxCreationKeys *obj);
+
+LDKTxCreationKeys TxCreationKeys_read(LDKu8slice ser);
+
+void PreCalculatedTxCreationKeys_free(LDKPreCalculatedTxCreationKeys this_ptr);
+
+/**
+ * Create a new PreCalculatedTxCreationKeys from TxCreationKeys
+ */
+MUST_USE_RES LDKPreCalculatedTxCreationKeys PreCalculatedTxCreationKeys_new(LDKTxCreationKeys keys);
+
+/**
+ * The pre-calculated transaction creation public keys.
+ * An external validating signer should not trust these keys.
+ */
+MUST_USE_RES LDKTxCreationKeys PreCalculatedTxCreationKeys_trust_key_derivation(const LDKPreCalculatedTxCreationKeys *this_arg);
+
+/**
+ * The transaction per-commitment point
+ */
+MUST_USE_RES LDKPublicKey PreCalculatedTxCreationKeys_per_commitment_point(const LDKPreCalculatedTxCreationKeys *this_arg);
+
+void ChannelPublicKeys_free(LDKChannelPublicKeys this_ptr);
+
+/**
+ * The public key which is used to sign all commitment transactions, as it appears in the
+ * on-chain channel lock-in 2-of-2 multisig output.
+ */
+LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const LDKChannelPublicKeys *this_ptr);
+
+/**
+ * The public key which is used to sign all commitment transactions, as it appears in the
+ * on-chain channel lock-in 2-of-2 multisig output.
+ */
+void ChannelPublicKeys_set_funding_pubkey(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
+
+/**
+ * The base point which is used (with derive_public_revocation_key) to derive per-commitment
+ * revocation keys. This is combined with the per-commitment-secret generated by the
+ * counterparty to create a secret which the counterparty can reveal to revoke previous
+ * states.
+ */
+LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const LDKChannelPublicKeys *this_ptr);
+
+/**
+ * The base point which is used (with derive_public_revocation_key) to derive per-commitment
+ * revocation keys. This is combined with the per-commitment-secret generated by the
+ * counterparty to create a secret which the counterparty can reveal to revoke previous
+ * states.
+ */
+void ChannelPublicKeys_set_revocation_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
+
+/**
+ * The public key which receives our immediately spendable primary channel balance in
+ * remote-broadcasted commitment transactions. This key is static across every commitment
+ * transaction.
+ */
+LDKPublicKey ChannelPublicKeys_get_payment_point(const LDKChannelPublicKeys *this_ptr);
+
+/**
+ * The public key which receives our immediately spendable primary channel balance in
+ * remote-broadcasted commitment transactions. This key is static across every commitment
+ * transaction.
+ */
+void ChannelPublicKeys_set_payment_point(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
+
+/**
+ * The base point which is used (with derive_public_key) to derive a per-commitment payment
+ * public key which receives non-HTLC-encumbered funds which are only available for spending
+ * after some delay (or can be claimed via the revocation path).
+ */
+LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const LDKChannelPublicKeys *this_ptr);
+
+/**
+ * The base point which is used (with derive_public_key) to derive a per-commitment payment
+ * public key which receives non-HTLC-encumbered funds which are only available for spending
+ * after some delay (or can be claimed via the revocation path).
+ */
+void ChannelPublicKeys_set_delayed_payment_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
+
+/**
+ * The base point which is used (with derive_public_key) to derive a per-commitment public key
+ * which is used to encumber HTLC-in-flight outputs.
+ */
+LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const LDKChannelPublicKeys *this_ptr);
+
+/**
+ * The base point which is used (with derive_public_key) to derive a per-commitment public key
+ * which is used to encumber HTLC-in-flight outputs.
+ */
+void ChannelPublicKeys_set_htlc_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val);
+
+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);
+
+LDKCVec_u8Z ChannelPublicKeys_write(const LDKChannelPublicKeys *obj);
+
+LDKChannelPublicKeys ChannelPublicKeys_read(LDKu8slice ser);
+
+/**
+ * Create a new TxCreationKeys from channel base points and the per-commitment point
+ */
+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);
+
+/**
+ * A script either spendable by the revocation
+ * key or the delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
+ * Encumbering a `to_local` output on a commitment transaction or 2nd-stage HTLC transactions.
+ */
+LDKCVec_u8Z get_revokeable_redeemscript(LDKPublicKey revocation_key, uint16_t to_self_delay, LDKPublicKey delayed_payment_key);
+
+void HTLCOutputInCommitment_free(LDKHTLCOutputInCommitment this_ptr);
+
+/**
+ * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
+ * Note that this is not the same as whether it is ountbound *from us*. To determine that you
+ * need to compare this value to whether the commitment transaction in question is that of
+ * the remote party or our own.
+ */
+bool HTLCOutputInCommitment_get_offered(const LDKHTLCOutputInCommitment *this_ptr);
+
+/**
+ * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
+ * Note that this is not the same as whether it is ountbound *from us*. To determine that you
+ * need to compare this value to whether the commitment transaction in question is that of
+ * the remote party or our own.
+ */
+void HTLCOutputInCommitment_set_offered(LDKHTLCOutputInCommitment *this_ptr, bool val);
+
+/**
+ * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
+ * this divided by 1000.
+ */
+uint64_t HTLCOutputInCommitment_get_amount_msat(const LDKHTLCOutputInCommitment *this_ptr);
+
+/**
+ * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
+ * this divided by 1000.
+ */
+void HTLCOutputInCommitment_set_amount_msat(LDKHTLCOutputInCommitment *this_ptr, uint64_t val);
+
+/**
+ * The CLTV lock-time at which this HTLC expires.
+ */
+uint32_t HTLCOutputInCommitment_get_cltv_expiry(const LDKHTLCOutputInCommitment *this_ptr);
+
+/**
+ * The CLTV lock-time at which this HTLC expires.
+ */
+void HTLCOutputInCommitment_set_cltv_expiry(LDKHTLCOutputInCommitment *this_ptr, uint32_t val);
+
+/**
+ * The hash of the preimage which unlocks this HTLC.
+ */
+const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const LDKHTLCOutputInCommitment *this_ptr))[32];
+
+/**
+ * The hash of the preimage which unlocks this HTLC.
+ */
+void HTLCOutputInCommitment_set_payment_hash(LDKHTLCOutputInCommitment *this_ptr, LDKThirtyTwoBytes val);
+
+LDKCVec_u8Z HTLCOutputInCommitment_write(const LDKHTLCOutputInCommitment *obj);
+
+LDKHTLCOutputInCommitment HTLCOutputInCommitment_read(LDKu8slice ser);
+
+/**
+ * note here that 'a_revocation_key' is generated using b_revocation_basepoint and a's
+ * commitment secret. 'htlc' does *not* need to have its previous_output_index filled.
+ */
+LDKCVec_u8Z get_htlc_redeemscript(const LDKHTLCOutputInCommitment *htlc, const LDKTxCreationKeys *keys);
+
+/**
+ * Gets the redeemscript for a funding output from the two funding public keys.
+ * Note that the order of funding public keys does not matter.
+ */
+LDKCVec_u8Z make_funding_redeemscript(LDKPublicKey a, LDKPublicKey b);
+
+/**
+ * panics if htlc.transaction_output_index.is_none()!
+ */
+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);
+
+void LocalCommitmentTransaction_free(LDKLocalCommitmentTransaction this_ptr);
+
+/**
+ * The commitment transaction itself, in unsigned form.
+ */
+LDKCVec_u8Z LocalCommitmentTransaction_get_unsigned_tx(const LDKLocalCommitmentTransaction *this_ptr);
+
+/**
+ * The commitment transaction itself, in unsigned form.
+ */
+void LocalCommitmentTransaction_set_unsigned_tx(LDKLocalCommitmentTransaction *this_ptr, LDKCVec_u8Z val);
+
+/**
+ * Our counterparty's signature for the transaction, above.
+ */
+LDKSignature LocalCommitmentTransaction_get_their_sig(const LDKLocalCommitmentTransaction *this_ptr);
+
+/**
+ * Our counterparty's signature for the transaction, above.
+ */
+void LocalCommitmentTransaction_set_their_sig(LDKLocalCommitmentTransaction *this_ptr, LDKSignature val);
+
+/**
+ * The feerate paid per 1000-weight-unit in this commitment transaction. This value is
+ * controlled by the channel initiator.
+ */
+uint32_t LocalCommitmentTransaction_get_feerate_per_kw(const LDKLocalCommitmentTransaction *this_ptr);
+
+/**
+ * The feerate paid per 1000-weight-unit in this commitment transaction. This value is
+ * controlled by the channel initiator.
+ */
+void LocalCommitmentTransaction_set_feerate_per_kw(LDKLocalCommitmentTransaction *this_ptr, uint32_t val);
+
+/**
+ * The HTLCs and remote htlc signatures which were included in this commitment transaction.
+ *
+ * Note that this includes all HTLCs, including ones which were considered dust and not
+ * actually included in the transaction as it appears on-chain, but who's value is burned as
+ * fees and not included in the to_local or to_remote outputs.
+ *
+ * The remote HTLC signatures in the second element will always be set for non-dust HTLCs, ie
+ * those for which transaction_output_index.is_some().
+ */
+void LocalCommitmentTransaction_set_per_htlc(LDKLocalCommitmentTransaction *this_ptr, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val);
+
+/**
+ * Generate a new LocalCommitmentTransaction based on a raw commitment transaction,
+ * remote signature and both parties keys.
+ *
+ * The unsigned transaction outputs must be consistent with htlc_data. This function
+ * only checks that the shape and amounts are consistent, but does not check the scriptPubkey.
+ */
+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);
+
+/**
+ * The pre-calculated transaction creation public keys.
+ * An external validating signer should not trust these keys.
+ */
+MUST_USE_RES LDKTxCreationKeys LocalCommitmentTransaction_trust_key_derivation(const LDKLocalCommitmentTransaction *this_arg);
+
+/**
+ * Get the txid of the local commitment transaction contained in this
+ * LocalCommitmentTransaction
+ */
+MUST_USE_RES LDKThirtyTwoBytes LocalCommitmentTransaction_txid(const LDKLocalCommitmentTransaction *this_arg);
+
+/**
+ * Gets our signature for the contained commitment transaction given our funding private key.
+ *
+ * Funding key is your key included in the 2-2 funding_outpoint lock. Should be provided
+ * by your ChannelKeys.
+ * Funding redeemscript is script locking funding_outpoint. This is the mutlsig script
+ * between your own funding key and your counterparty's. Currently, this is provided in
+ * ChannelKeys::sign_local_commitment() calls directly.
+ * Channel value is amount locked in funding_outpoint.
+ */
+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);
+
+/**
+ * Get a signature for each HTLC which was included in the commitment transaction (ie for
+ * which HTLCOutputInCommitment::transaction_output_index.is_some()).
+ *
+ * The returned Vec has one entry for each HTLC, and in the same order. For HTLCs which were
+ * considered dust and not included, a None entry exists, for all others a signature is
+ * included.
+ */
+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);
+
+LDKCVec_u8Z LocalCommitmentTransaction_write(const LDKLocalCommitmentTransaction *obj);
+
+LDKLocalCommitmentTransaction LocalCommitmentTransaction_read(LDKu8slice ser);
+
+void InitFeatures_free(LDKInitFeatures this_ptr);
+
+void NodeFeatures_free(LDKNodeFeatures this_ptr);
+
+void ChannelFeatures_free(LDKChannelFeatures this_ptr);
+
+void RouteHop_free(LDKRouteHop this_ptr);
+
+/**
+ * The node_id of the node at this hop.
+ */
+LDKPublicKey RouteHop_get_pubkey(const LDKRouteHop *this_ptr);
+
+/**
+ * The node_id of the node at this hop.
+ */
+void RouteHop_set_pubkey(LDKRouteHop *this_ptr, LDKPublicKey val);
+
+/**
+ * The channel that should be used from the previous hop to reach this node.
+ */
+uint64_t RouteHop_get_short_channel_id(const LDKRouteHop *this_ptr);
+
+/**
+ * The channel that should be used from the previous hop to reach this node.
+ */
+void RouteHop_set_short_channel_id(LDKRouteHop *this_ptr, uint64_t val);
+
+/**
+ * The fee taken on this hop. For the last hop, this should be the full value of the payment.
+ */
+uint64_t RouteHop_get_fee_msat(const LDKRouteHop *this_ptr);
+
+/**
+ * The fee taken on this hop. For the last hop, this should be the full value of the payment.
+ */
+void RouteHop_set_fee_msat(LDKRouteHop *this_ptr, uint64_t val);
+
+/**
+ * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
+ * expected at the destination, in excess of the current block height.
+ */
+uint32_t RouteHop_get_cltv_expiry_delta(const LDKRouteHop *this_ptr);
+
+/**
+ * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
+ * expected at the destination, in excess of the current block height.
+ */
+void RouteHop_set_cltv_expiry_delta(LDKRouteHop *this_ptr, uint32_t val);
+
+void Route_free(LDKRoute this_ptr);
+
+/**
+ * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
+ * last RouteHop in each path must be the same.
+ * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the
+ * destination. Thus, this must always be at least length one. While the maximum length of any
+ * given path is variable, keeping the length of any path to less than 20 should currently
+ * ensure it is viable.
+ */
+void Route_set_paths(LDKRoute *this_ptr, LDKCVec_CVec_RouteHopZZ val);
+
+MUST_USE_RES LDKRoute Route_new(LDKCVec_CVec_RouteHopZZ paths_arg);
+
+LDKCVec_u8Z Route_write(const LDKRoute *obj);
+
+LDKRoute Route_read(LDKu8slice ser);
+
+void RouteHint_free(LDKRouteHint this_ptr);
+
+/**
+ * The node_id of the non-target end of the route
+ */
+LDKPublicKey RouteHint_get_src_node_id(const LDKRouteHint *this_ptr);
+
+/**
+ * The node_id of the non-target end of the route
+ */
+void RouteHint_set_src_node_id(LDKRouteHint *this_ptr, LDKPublicKey val);
+
+/**
+ * The short_channel_id of this channel
+ */
+uint64_t RouteHint_get_short_channel_id(const LDKRouteHint *this_ptr);
+
+/**
+ * The short_channel_id of this channel
+ */
+void RouteHint_set_short_channel_id(LDKRouteHint *this_ptr, uint64_t val);
+
+/**
+ * The fees which must be paid to use this channel
+ */
+LDKRoutingFees RouteHint_get_fees(const LDKRouteHint *this_ptr);
+
+/**
+ * The fees which must be paid to use this channel
+ */
+void RouteHint_set_fees(LDKRouteHint *this_ptr, LDKRoutingFees val);
+
+/**
+ * The difference in CLTV values between this node and the next node.
+ */
+uint16_t RouteHint_get_cltv_expiry_delta(const LDKRouteHint *this_ptr);
+
+/**
+ * The difference in CLTV values between this node and the next node.
+ */
+void RouteHint_set_cltv_expiry_delta(LDKRouteHint *this_ptr, uint16_t val);
+
+/**
+ * The minimum value, in msat, which must be relayed to the next hop.
+ */
+uint64_t RouteHint_get_htlc_minimum_msat(const LDKRouteHint *this_ptr);
+
+/**
+ * The minimum value, in msat, which must be relayed to the next hop.
+ */
+void RouteHint_set_htlc_minimum_msat(LDKRouteHint *this_ptr, uint64_t val);
+
+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);
+
+/**
+ * Gets a route from us to the given target node.
+ *
+ * Extra routing hops between known nodes and the target will be used if they are included in
+ * last_hops.
+ *
+ * If some channels aren't announced, it may be useful to fill in a first_hops with the
+ * results from a local ChannelManager::list_usable_channels() call. If it is filled in, our
+ * view of our local channels (from net_graph_msg_handler) will be ignored, and only those in first_hops
+ * will be used.
+ *
+ * Panics if first_hops contains channels without short_channel_ids
+ * (ChannelManager::list_usable_channels will never include such channels).
+ *
+ * The fees on channels from us to next-hops are ignored (as they are assumed to all be
+ * equal), however the enabled/disabled bit on such channels as well as the htlc_minimum_msat
+ * *is* checked as they may change based on the receiving node.
+ */
+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);
+
+void NetworkGraph_free(LDKNetworkGraph this_ptr);
+
+void LockedNetworkGraph_free(LDKLockedNetworkGraph this_ptr);
+
+void NetGraphMsgHandler_free(LDKNetGraphMsgHandler this_ptr);
+
+/**
+ * Creates a new tracker of the actual state of the network of channels and nodes,
+ * assuming a fresh network graph.
+ * Chain monitor is used to make sure announced channels exist on-chain,
+ * channel data is correct, and that the announcement is signed with
+ * channel owners' keys.
+ */
+MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_new(LDKChainWatchInterface chain_monitor, LDKLogger logger);
+
+/**
+ * Creates a new tracker of the actual state of the network of channels and nodes,
+ * assuming an existing Network Graph.
+ */
+MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(LDKChainWatchInterface chain_monitor, LDKLogger logger, LDKNetworkGraph network_graph);
+
+/**
+ * Take a read lock on the network_graph and return it in the C-bindings
+ * newtype helper. This is likely only useful when called via the C
+ * bindings as you can call `self.network_graph.read().unwrap()` in Rust
+ * yourself.
+ */
+MUST_USE_RES LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const LDKNetGraphMsgHandler *this_arg);
+
+/**
+ * Get a reference to the NetworkGraph which this read-lock contains.
+ */
+MUST_USE_RES LDKNetworkGraph LockedNetworkGraph_graph(const LDKLockedNetworkGraph *this_arg);
+
+LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const LDKNetGraphMsgHandler *this_arg);
+
+void DirectionalChannelInfo_free(LDKDirectionalChannelInfo this_ptr);
+
+/**
+ * When the last update to the channel direction was issued.
+ * Value is opaque, as set in the announcement.
+ */
+uint32_t DirectionalChannelInfo_get_last_update(const LDKDirectionalChannelInfo *this_ptr);
+
+/**
+ * When the last update to the channel direction was issued.
+ * Value is opaque, as set in the announcement.
+ */
+void DirectionalChannelInfo_set_last_update(LDKDirectionalChannelInfo *this_ptr, uint32_t val);
+
+/**
+ * Whether the channel can be currently used for payments (in this one direction).
+ */
+bool DirectionalChannelInfo_get_enabled(const LDKDirectionalChannelInfo *this_ptr);
+
+/**
+ * Whether the channel can be currently used for payments (in this one direction).
+ */
+void DirectionalChannelInfo_set_enabled(LDKDirectionalChannelInfo *this_ptr, bool val);
+
+/**
+ * The difference in CLTV values that you must have when routing through this channel.
+ */
+uint16_t DirectionalChannelInfo_get_cltv_expiry_delta(const LDKDirectionalChannelInfo *this_ptr);
+
+/**
+ * The difference in CLTV values that you must have when routing through this channel.
+ */
+void DirectionalChannelInfo_set_cltv_expiry_delta(LDKDirectionalChannelInfo *this_ptr, uint16_t val);
+
+/**
+ * The minimum value, which must be relayed to the next hop via the channel
+ */
+uint64_t DirectionalChannelInfo_get_htlc_minimum_msat(const LDKDirectionalChannelInfo *this_ptr);
+
+/**
+ * The minimum value, which must be relayed to the next hop via the channel
+ */
+void DirectionalChannelInfo_set_htlc_minimum_msat(LDKDirectionalChannelInfo *this_ptr, uint64_t val);
+
+/**
+ * Most recent update for the channel received from the network
+ * Mostly redundant with the data we store in fields explicitly.
+ * Everything else is useful only for sending out for initial routing sync.
+ * Not stored if contains excess data to prevent DoS.
+ */
+LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const LDKDirectionalChannelInfo *this_ptr);
+
+/**
+ * Most recent update for the channel received from the network
+ * Mostly redundant with the data we store in fields explicitly.
+ * Everything else is useful only for sending out for initial routing sync.
+ * Not stored if contains excess data to prevent DoS.
+ */
+void DirectionalChannelInfo_set_last_update_message(LDKDirectionalChannelInfo *this_ptr, LDKChannelUpdate val);
+
+LDKCVec_u8Z DirectionalChannelInfo_write(const LDKDirectionalChannelInfo *obj);
+
+LDKDirectionalChannelInfo DirectionalChannelInfo_read(LDKu8slice ser);
+
+void ChannelInfo_free(LDKChannelInfo this_ptr);
+
+/**
+ * Source node of the first direction of a channel
+ */
+LDKPublicKey ChannelInfo_get_node_one(const LDKChannelInfo *this_ptr);
+
+/**
+ * Source node of the first direction of a channel
+ */
+void ChannelInfo_set_node_one(LDKChannelInfo *this_ptr, LDKPublicKey val);
+
+/**
+ * Details about the first direction of a channel
+ */
+LDKDirectionalChannelInfo ChannelInfo_get_one_to_two(const LDKChannelInfo *this_ptr);
+
+/**
+ * Details about the first direction of a channel
+ */
+void ChannelInfo_set_one_to_two(LDKChannelInfo *this_ptr, LDKDirectionalChannelInfo val);
+
+/**
+ * Source node of the second direction of a channel
+ */
+LDKPublicKey ChannelInfo_get_node_two(const LDKChannelInfo *this_ptr);
+
+/**
+ * Source node of the second direction of a channel
+ */
+void ChannelInfo_set_node_two(LDKChannelInfo *this_ptr, LDKPublicKey val);
+
+/**
+ * Details about the second direction of a channel
+ */
+LDKDirectionalChannelInfo ChannelInfo_get_two_to_one(const LDKChannelInfo *this_ptr);
+
+/**
+ * Details about the second direction of a channel
+ */
+void ChannelInfo_set_two_to_one(LDKChannelInfo *this_ptr, LDKDirectionalChannelInfo val);
+
+/**
+ * An initial announcement of the channel
+ * Mostly redundant with the data we store in fields explicitly.
+ * Everything else is useful only for sending out for initial routing sync.
+ * Not stored if contains excess data to prevent DoS.
+ */
+LDKChannelAnnouncement ChannelInfo_get_announcement_message(const LDKChannelInfo *this_ptr);
+
+/**
+ * An initial announcement of the channel
+ * Mostly redundant with the data we store in fields explicitly.
+ * Everything else is useful only for sending out for initial routing sync.
+ * Not stored if contains excess data to prevent DoS.
+ */
+void ChannelInfo_set_announcement_message(LDKChannelInfo *this_ptr, LDKChannelAnnouncement val);
+
+LDKCVec_u8Z ChannelInfo_write(const LDKChannelInfo *obj);
+
+LDKChannelInfo ChannelInfo_read(LDKu8slice ser);
+
+void RoutingFees_free(LDKRoutingFees this_ptr);
+
+/**
+ * Flat routing fee in satoshis
+ */
+uint32_t RoutingFees_get_base_msat(const LDKRoutingFees *this_ptr);
+
+/**
+ * Flat routing fee in satoshis
+ */
+void RoutingFees_set_base_msat(LDKRoutingFees *this_ptr, uint32_t val);
+
+/**
+ * Liquidity-based routing fee in millionths of a routed amount.
+ * In other words, 10000 is 1%.
+ */
+uint32_t RoutingFees_get_proportional_millionths(const LDKRoutingFees *this_ptr);
+
+/**
+ * Liquidity-based routing fee in millionths of a routed amount.
+ * In other words, 10000 is 1%.
+ */
+void RoutingFees_set_proportional_millionths(LDKRoutingFees *this_ptr, uint32_t val);
+
+MUST_USE_RES LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg);
+
+LDKRoutingFees RoutingFees_read(LDKu8slice ser);
+
+LDKCVec_u8Z RoutingFees_write(const LDKRoutingFees *obj);
+
+void NodeAnnouncementInfo_free(LDKNodeAnnouncementInfo this_ptr);
+
+/**
+ * When the last known update to the node state was issued.
+ * Value is opaque, as set in the announcement.
+ */
+uint32_t NodeAnnouncementInfo_get_last_update(const LDKNodeAnnouncementInfo *this_ptr);
+
+/**
+ * When the last known update to the node state was issued.
+ * Value is opaque, as set in the announcement.
+ */
+void NodeAnnouncementInfo_set_last_update(LDKNodeAnnouncementInfo *this_ptr, uint32_t val);
+
+/**
+ * Color assigned to the node
+ */
+const uint8_t (*NodeAnnouncementInfo_get_rgb(const LDKNodeAnnouncementInfo *this_ptr))[3];
+
+/**
+ * Color assigned to the node
+ */
+void NodeAnnouncementInfo_set_rgb(LDKNodeAnnouncementInfo *this_ptr, LDKThreeBytes val);
+
+/**
+ * Moniker assigned to the node.
+ * May be invalid or malicious (eg control chars),
+ * should not be exposed to the user.
+ */
+const uint8_t (*NodeAnnouncementInfo_get_alias(const LDKNodeAnnouncementInfo *this_ptr))[32];
+
+/**
+ * Moniker assigned to the node.
+ * May be invalid or malicious (eg control chars),
+ * should not be exposed to the user.
+ */
+void NodeAnnouncementInfo_set_alias(LDKNodeAnnouncementInfo *this_ptr, LDKThirtyTwoBytes val);
+
+/**
+ * Internet-level addresses via which one can connect to the node
+ */
+void NodeAnnouncementInfo_set_addresses(LDKNodeAnnouncementInfo *this_ptr, LDKCVec_NetAddressZ val);
+
+/**
+ * An initial announcement of the node
+ * Mostly redundant with the data we store in fields explicitly.
+ * Everything else is useful only for sending out for initial routing sync.
+ * Not stored if contains excess data to prevent DoS.
+ */
+LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const LDKNodeAnnouncementInfo *this_ptr);
+
+/**
+ * An initial announcement of the node
+ * Mostly redundant with the data we store in fields explicitly.
+ * Everything else is useful only for sending out for initial routing sync.
+ * Not stored if contains excess data to prevent DoS.
+ */
+void NodeAnnouncementInfo_set_announcement_message(LDKNodeAnnouncementInfo *this_ptr, LDKNodeAnnouncement val);
+
+LDKCVec_u8Z NodeAnnouncementInfo_write(const LDKNodeAnnouncementInfo *obj);
+
+LDKNodeAnnouncementInfo NodeAnnouncementInfo_read(LDKu8slice ser);
+
+void NodeInfo_free(LDKNodeInfo this_ptr);
+
+/**
+ * All valid channels a node has announced
+ */
+void NodeInfo_set_channels(LDKNodeInfo *this_ptr, LDKCVec_u64Z val);
+
+/**
+ * Lowest fees enabling routing via any of the enabled, known channels to a node.
+ * The two fields (flat and proportional fee) are independent,
+ * meaning they don't have to refer to the same channel.
+ */
+LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const LDKNodeInfo *this_ptr);
+
+/**
+ * Lowest fees enabling routing via any of the enabled, known channels to a node.
+ * The two fields (flat and proportional fee) are independent,
+ * meaning they don't have to refer to the same channel.
+ */
+void NodeInfo_set_lowest_inbound_channel_fees(LDKNodeInfo *this_ptr, LDKRoutingFees val);
+
+/**
+ * More information about a node from node_announcement.
+ * Optional because we store a Node entry after learning about it from
+ * a channel announcement, but before receiving a node announcement.
+ */
+LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const LDKNodeInfo *this_ptr);
+
+/**
+ * More information about a node from node_announcement.
+ * Optional because we store a Node entry after learning about it from
+ * a channel announcement, but before receiving a node announcement.
+ */
+void NodeInfo_set_announcement_info(LDKNodeInfo *this_ptr, LDKNodeAnnouncementInfo val);
+
+MUST_USE_RES LDKNodeInfo NodeInfo_new(LDKCVec_u64Z channels_arg, LDKRoutingFees lowest_inbound_channel_fees_arg, LDKNodeAnnouncementInfo announcement_info_arg);
+
+LDKCVec_u8Z NodeInfo_write(const LDKNodeInfo *obj);
+
+LDKNodeInfo NodeInfo_read(LDKu8slice ser);
+
+LDKCVec_u8Z NetworkGraph_write(const LDKNetworkGraph *obj);
+
+LDKNetworkGraph NetworkGraph_read(LDKu8slice ser);
+
+/**
+ * Creates a new, empty, network graph.
+ */
+MUST_USE_RES LDKNetworkGraph NetworkGraph_new(void);
+
+/**
+ * Close a channel if a corresponding HTLC fail was sent.
+ * If permanent, removes a channel from the local storage.
+ * May cause the removal of nodes too, if this was their last channel.
+ * If not permanent, makes channels unavailable for routing.
+ */
+void NetworkGraph_close_channel_from_update(LDKNetworkGraph *this_arg, uint64_t short_channel_id, bool is_permanent);
+
+/* Text to put at the end of the generated file */
--- /dev/null
+#include <string.h>
+namespace LDK {
+class Event {
+private:
+ LDKEvent self;
+public:
+ Event(const Event&) = delete;
+ ~Event() { Event_free(self); }
+ Event(Event&& o) : self(o.self) { memset(&o, 0, sizeof(Event)); }
+ Event(LDKEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEvent)); }
+ operator LDKEvent() { LDKEvent res = self; memset(&self, 0, sizeof(LDKEvent)); return res; }
+ LDKEvent* operator &() { return &self; }
+ LDKEvent* operator ->() { return &self; }
+ const LDKEvent* operator &() const { return &self; }
+ const LDKEvent* operator ->() const { return &self; }
+};
+class MessageSendEvent {
+private:
+ LDKMessageSendEvent self;
+public:
+ MessageSendEvent(const MessageSendEvent&) = delete;
+ ~MessageSendEvent() { MessageSendEvent_free(self); }
+ MessageSendEvent(MessageSendEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEvent)); }
+ MessageSendEvent(LDKMessageSendEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEvent)); }
+ operator LDKMessageSendEvent() { LDKMessageSendEvent res = self; memset(&self, 0, sizeof(LDKMessageSendEvent)); return res; }
+ LDKMessageSendEvent* operator &() { return &self; }
+ LDKMessageSendEvent* operator ->() { return &self; }
+ const LDKMessageSendEvent* operator &() const { return &self; }
+ const LDKMessageSendEvent* operator ->() const { return &self; }
+};
+class MessageSendEventsProvider {
+private:
+ LDKMessageSendEventsProvider self;
+public:
+ MessageSendEventsProvider(const MessageSendEventsProvider&) = delete;
+ ~MessageSendEventsProvider() { MessageSendEventsProvider_free(self); }
+ MessageSendEventsProvider(MessageSendEventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEventsProvider)); }
+ MessageSendEventsProvider(LDKMessageSendEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEventsProvider)); }
+ operator LDKMessageSendEventsProvider() { LDKMessageSendEventsProvider res = self; memset(&self, 0, sizeof(LDKMessageSendEventsProvider)); return res; }
+ LDKMessageSendEventsProvider* operator &() { return &self; }
+ LDKMessageSendEventsProvider* operator ->() { return &self; }
+ const LDKMessageSendEventsProvider* operator &() const { return &self; }
+ const LDKMessageSendEventsProvider* operator ->() const { return &self; }
+};
+class EventsProvider {
+private:
+ LDKEventsProvider self;
+public:
+ EventsProvider(const EventsProvider&) = delete;
+ ~EventsProvider() { EventsProvider_free(self); }
+ EventsProvider(EventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(EventsProvider)); }
+ EventsProvider(LDKEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventsProvider)); }
+ operator LDKEventsProvider() { LDKEventsProvider res = self; memset(&self, 0, sizeof(LDKEventsProvider)); return res; }
+ LDKEventsProvider* operator &() { return &self; }
+ LDKEventsProvider* operator ->() { return &self; }
+ const LDKEventsProvider* operator &() const { return &self; }
+ const LDKEventsProvider* operator ->() const { return &self; }
+};
+class APIError {
+private:
+ LDKAPIError self;
+public:
+ APIError(const APIError&) = delete;
+ ~APIError() { APIError_free(self); }
+ APIError(APIError&& o) : self(o.self) { memset(&o, 0, sizeof(APIError)); }
+ APIError(LDKAPIError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAPIError)); }
+ operator LDKAPIError() { LDKAPIError res = self; memset(&self, 0, sizeof(LDKAPIError)); return res; }
+ LDKAPIError* operator &() { return &self; }
+ LDKAPIError* operator ->() { return &self; }
+ const LDKAPIError* operator &() const { return &self; }
+ const LDKAPIError* operator ->() const { return &self; }
+};
+class Level {
+private:
+ LDKLevel self;
+public:
+ Level(const Level&) = delete;
+ Level(Level&& o) : self(o.self) { memset(&o, 0, sizeof(Level)); }
+ Level(LDKLevel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLevel)); }
+ operator LDKLevel() { LDKLevel res = self; memset(&self, 0, sizeof(LDKLevel)); return res; }
+ LDKLevel* operator &() { return &self; }
+ LDKLevel* operator ->() { return &self; }
+ const LDKLevel* operator &() const { return &self; }
+ const LDKLevel* operator ->() const { return &self; }
+};
+class Logger {
+private:
+ LDKLogger self;
+public:
+ Logger(const Logger&) = delete;
+ ~Logger() { Logger_free(self); }
+ Logger(Logger&& o) : self(o.self) { memset(&o, 0, sizeof(Logger)); }
+ Logger(LDKLogger&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLogger)); }
+ operator LDKLogger() { LDKLogger res = self; memset(&self, 0, sizeof(LDKLogger)); return res; }
+ LDKLogger* operator &() { return &self; }
+ LDKLogger* operator ->() { return &self; }
+ const LDKLogger* operator &() const { return &self; }
+ const LDKLogger* operator ->() const { return &self; }
+};
+class ChannelHandshakeConfig {
+private:
+ LDKChannelHandshakeConfig self;
+public:
+ ChannelHandshakeConfig(const ChannelHandshakeConfig&) = delete;
+ ~ChannelHandshakeConfig() { ChannelHandshakeConfig_free(self); }
+ ChannelHandshakeConfig(ChannelHandshakeConfig&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelHandshakeConfig)); }
+ ChannelHandshakeConfig(LDKChannelHandshakeConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelHandshakeConfig)); }
+ operator LDKChannelHandshakeConfig() { LDKChannelHandshakeConfig res = self; memset(&self, 0, sizeof(LDKChannelHandshakeConfig)); return res; }
+ LDKChannelHandshakeConfig* operator &() { return &self; }
+ LDKChannelHandshakeConfig* operator ->() { return &self; }
+ const LDKChannelHandshakeConfig* operator &() const { return &self; }
+ const LDKChannelHandshakeConfig* operator ->() const { return &self; }
+};
+class ChannelHandshakeLimits {
+private:
+ LDKChannelHandshakeLimits self;
+public:
+ ChannelHandshakeLimits(const ChannelHandshakeLimits&) = delete;
+ ~ChannelHandshakeLimits() { ChannelHandshakeLimits_free(self); }
+ ChannelHandshakeLimits(ChannelHandshakeLimits&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelHandshakeLimits)); }
+ ChannelHandshakeLimits(LDKChannelHandshakeLimits&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelHandshakeLimits)); }
+ operator LDKChannelHandshakeLimits() { LDKChannelHandshakeLimits res = self; memset(&self, 0, sizeof(LDKChannelHandshakeLimits)); return res; }
+ LDKChannelHandshakeLimits* operator &() { return &self; }
+ LDKChannelHandshakeLimits* operator ->() { return &self; }
+ const LDKChannelHandshakeLimits* operator &() const { return &self; }
+ const LDKChannelHandshakeLimits* operator ->() const { return &self; }
+};
+class ChannelConfig {
+private:
+ LDKChannelConfig self;
+public:
+ ChannelConfig(const ChannelConfig&) = delete;
+ ~ChannelConfig() { ChannelConfig_free(self); }
+ ChannelConfig(ChannelConfig&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelConfig)); }
+ ChannelConfig(LDKChannelConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelConfig)); }
+ operator LDKChannelConfig() { LDKChannelConfig res = self; memset(&self, 0, sizeof(LDKChannelConfig)); return res; }
+ LDKChannelConfig* operator &() { return &self; }
+ LDKChannelConfig* operator ->() { return &self; }
+ const LDKChannelConfig* operator &() const { return &self; }
+ const LDKChannelConfig* operator ->() const { return &self; }
+};
+class UserConfig {
+private:
+ LDKUserConfig self;
+public:
+ UserConfig(const UserConfig&) = delete;
+ ~UserConfig() { UserConfig_free(self); }
+ UserConfig(UserConfig&& o) : self(o.self) { memset(&o, 0, sizeof(UserConfig)); }
+ UserConfig(LDKUserConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUserConfig)); }
+ operator LDKUserConfig() { LDKUserConfig res = self; memset(&self, 0, sizeof(LDKUserConfig)); return res; }
+ LDKUserConfig* operator &() { return &self; }
+ LDKUserConfig* operator ->() { return &self; }
+ const LDKUserConfig* operator &() const { return &self; }
+ const LDKUserConfig* operator ->() const { return &self; }
+};
+class ChainError {
+private:
+ LDKChainError self;
+public:
+ ChainError(const ChainError&) = delete;
+ ChainError(ChainError&& o) : self(o.self) { memset(&o, 0, sizeof(ChainError)); }
+ ChainError(LDKChainError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainError)); }
+ operator LDKChainError() { LDKChainError res = self; memset(&self, 0, sizeof(LDKChainError)); return res; }
+ LDKChainError* operator &() { return &self; }
+ LDKChainError* operator ->() { return &self; }
+ const LDKChainError* operator &() const { return &self; }
+ const LDKChainError* operator ->() const { return &self; }
+};
+class ChainWatchInterface {
+private:
+ LDKChainWatchInterface self;
+public:
+ ChainWatchInterface(const ChainWatchInterface&) = delete;
+ ~ChainWatchInterface() { ChainWatchInterface_free(self); }
+ ChainWatchInterface(ChainWatchInterface&& o) : self(o.self) { memset(&o, 0, sizeof(ChainWatchInterface)); }
+ ChainWatchInterface(LDKChainWatchInterface&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainWatchInterface)); }
+ operator LDKChainWatchInterface() { LDKChainWatchInterface res = self; memset(&self, 0, sizeof(LDKChainWatchInterface)); return res; }
+ LDKChainWatchInterface* operator &() { return &self; }
+ LDKChainWatchInterface* operator ->() { return &self; }
+ const LDKChainWatchInterface* operator &() const { return &self; }
+ const LDKChainWatchInterface* operator ->() const { return &self; }
+};
+class BroadcasterInterface {
+private:
+ LDKBroadcasterInterface self;
+public:
+ BroadcasterInterface(const BroadcasterInterface&) = delete;
+ ~BroadcasterInterface() { BroadcasterInterface_free(self); }
+ BroadcasterInterface(BroadcasterInterface&& o) : self(o.self) { memset(&o, 0, sizeof(BroadcasterInterface)); }
+ BroadcasterInterface(LDKBroadcasterInterface&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBroadcasterInterface)); }
+ operator LDKBroadcasterInterface() { LDKBroadcasterInterface res = self; memset(&self, 0, sizeof(LDKBroadcasterInterface)); return res; }
+ LDKBroadcasterInterface* operator &() { return &self; }
+ LDKBroadcasterInterface* operator ->() { return &self; }
+ const LDKBroadcasterInterface* operator &() const { return &self; }
+ const LDKBroadcasterInterface* operator ->() const { return &self; }
+};
+class ChainListener {
+private:
+ LDKChainListener self;
+public:
+ ChainListener(const ChainListener&) = delete;
+ ~ChainListener() { ChainListener_free(self); }
+ ChainListener(ChainListener&& o) : self(o.self) { memset(&o, 0, sizeof(ChainListener)); }
+ ChainListener(LDKChainListener&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainListener)); }
+ operator LDKChainListener() { LDKChainListener res = self; memset(&self, 0, sizeof(LDKChainListener)); return res; }
+ LDKChainListener* operator &() { return &self; }
+ LDKChainListener* operator ->() { return &self; }
+ const LDKChainListener* operator &() const { return &self; }
+ const LDKChainListener* operator ->() const { return &self; }
+};
+class ConfirmationTarget {
+private:
+ LDKConfirmationTarget self;
+public:
+ ConfirmationTarget(const ConfirmationTarget&) = delete;
+ ConfirmationTarget(ConfirmationTarget&& o) : self(o.self) { memset(&o, 0, sizeof(ConfirmationTarget)); }
+ ConfirmationTarget(LDKConfirmationTarget&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKConfirmationTarget)); }
+ operator LDKConfirmationTarget() { LDKConfirmationTarget res = self; memset(&self, 0, sizeof(LDKConfirmationTarget)); return res; }
+ LDKConfirmationTarget* operator &() { return &self; }
+ LDKConfirmationTarget* operator ->() { return &self; }
+ const LDKConfirmationTarget* operator &() const { return &self; }
+ const LDKConfirmationTarget* operator ->() const { return &self; }
+};
+class FeeEstimator {
+private:
+ LDKFeeEstimator self;
+public:
+ FeeEstimator(const FeeEstimator&) = delete;
+ ~FeeEstimator() { FeeEstimator_free(self); }
+ FeeEstimator(FeeEstimator&& o) : self(o.self) { memset(&o, 0, sizeof(FeeEstimator)); }
+ FeeEstimator(LDKFeeEstimator&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFeeEstimator)); }
+ operator LDKFeeEstimator() { LDKFeeEstimator res = self; memset(&self, 0, sizeof(LDKFeeEstimator)); return res; }
+ LDKFeeEstimator* operator &() { return &self; }
+ LDKFeeEstimator* operator ->() { return &self; }
+ const LDKFeeEstimator* operator &() const { return &self; }
+ const LDKFeeEstimator* operator ->() const { return &self; }
+};
+class ChainWatchedUtil {
+private:
+ LDKChainWatchedUtil self;
+public:
+ ChainWatchedUtil(const ChainWatchedUtil&) = delete;
+ ~ChainWatchedUtil() { ChainWatchedUtil_free(self); }
+ ChainWatchedUtil(ChainWatchedUtil&& o) : self(o.self) { memset(&o, 0, sizeof(ChainWatchedUtil)); }
+ ChainWatchedUtil(LDKChainWatchedUtil&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainWatchedUtil)); }
+ operator LDKChainWatchedUtil() { LDKChainWatchedUtil res = self; memset(&self, 0, sizeof(LDKChainWatchedUtil)); return res; }
+ LDKChainWatchedUtil* operator &() { return &self; }
+ LDKChainWatchedUtil* operator ->() { return &self; }
+ const LDKChainWatchedUtil* operator &() const { return &self; }
+ const LDKChainWatchedUtil* operator ->() const { return &self; }
+};
+class BlockNotifier {
+private:
+ LDKBlockNotifier self;
+public:
+ BlockNotifier(const BlockNotifier&) = delete;
+ ~BlockNotifier() { BlockNotifier_free(self); }
+ BlockNotifier(BlockNotifier&& o) : self(o.self) { memset(&o, 0, sizeof(BlockNotifier)); }
+ BlockNotifier(LDKBlockNotifier&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlockNotifier)); }
+ operator LDKBlockNotifier() { LDKBlockNotifier res = self; memset(&self, 0, sizeof(LDKBlockNotifier)); return res; }
+ LDKBlockNotifier* operator &() { return &self; }
+ LDKBlockNotifier* operator ->() { return &self; }
+ const LDKBlockNotifier* operator &() const { return &self; }
+ const LDKBlockNotifier* operator ->() const { return &self; }
+};
+class ChainWatchInterfaceUtil {
+private:
+ LDKChainWatchInterfaceUtil self;
+public:
+ ChainWatchInterfaceUtil(const ChainWatchInterfaceUtil&) = delete;
+ ~ChainWatchInterfaceUtil() { ChainWatchInterfaceUtil_free(self); }
+ ChainWatchInterfaceUtil(ChainWatchInterfaceUtil&& o) : self(o.self) { memset(&o, 0, sizeof(ChainWatchInterfaceUtil)); }
+ ChainWatchInterfaceUtil(LDKChainWatchInterfaceUtil&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainWatchInterfaceUtil)); }
+ operator LDKChainWatchInterfaceUtil() { LDKChainWatchInterfaceUtil res = self; memset(&self, 0, sizeof(LDKChainWatchInterfaceUtil)); return res; }
+ LDKChainWatchInterfaceUtil* operator &() { return &self; }
+ LDKChainWatchInterfaceUtil* operator ->() { return &self; }
+ const LDKChainWatchInterfaceUtil* operator &() const { return &self; }
+ const LDKChainWatchInterfaceUtil* operator ->() const { return &self; }
+};
+class OutPoint {
+private:
+ LDKOutPoint self;
+public:
+ OutPoint(const OutPoint&) = delete;
+ ~OutPoint() { OutPoint_free(self); }
+ OutPoint(OutPoint&& o) : self(o.self) { memset(&o, 0, sizeof(OutPoint)); }
+ OutPoint(LDKOutPoint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOutPoint)); }
+ operator LDKOutPoint() { LDKOutPoint res = self; memset(&self, 0, sizeof(LDKOutPoint)); return res; }
+ LDKOutPoint* operator &() { return &self; }
+ LDKOutPoint* operator ->() { return &self; }
+ const LDKOutPoint* operator &() const { return &self; }
+ const LDKOutPoint* operator ->() const { return &self; }
+};
+class SpendableOutputDescriptor {
+private:
+ LDKSpendableOutputDescriptor self;
+public:
+ SpendableOutputDescriptor(const SpendableOutputDescriptor&) = delete;
+ ~SpendableOutputDescriptor() { SpendableOutputDescriptor_free(self); }
+ SpendableOutputDescriptor(SpendableOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(SpendableOutputDescriptor)); }
+ SpendableOutputDescriptor(LDKSpendableOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSpendableOutputDescriptor)); }
+ operator LDKSpendableOutputDescriptor() { LDKSpendableOutputDescriptor res = self; memset(&self, 0, sizeof(LDKSpendableOutputDescriptor)); return res; }
+ LDKSpendableOutputDescriptor* operator &() { return &self; }
+ LDKSpendableOutputDescriptor* operator ->() { return &self; }
+ const LDKSpendableOutputDescriptor* operator &() const { return &self; }
+ const LDKSpendableOutputDescriptor* operator ->() const { return &self; }
+};
+class ChannelKeys {
+private:
+ LDKChannelKeys self;
+public:
+ ChannelKeys(const ChannelKeys&) = delete;
+ ~ChannelKeys() { ChannelKeys_free(self); }
+ ChannelKeys(ChannelKeys&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelKeys)); }
+ ChannelKeys(LDKChannelKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelKeys)); }
+ operator LDKChannelKeys() { LDKChannelKeys res = self; memset(&self, 0, sizeof(LDKChannelKeys)); return res; }
+ LDKChannelKeys* operator &() { return &self; }
+ LDKChannelKeys* operator ->() { return &self; }
+ const LDKChannelKeys* operator &() const { return &self; }
+ const LDKChannelKeys* operator ->() const { return &self; }
+};
+class KeysInterface {
+private:
+ LDKKeysInterface self;
+public:
+ KeysInterface(const KeysInterface&) = delete;
+ ~KeysInterface() { KeysInterface_free(self); }
+ KeysInterface(KeysInterface&& o) : self(o.self) { memset(&o, 0, sizeof(KeysInterface)); }
+ KeysInterface(LDKKeysInterface&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKKeysInterface)); }
+ operator LDKKeysInterface() { LDKKeysInterface res = self; memset(&self, 0, sizeof(LDKKeysInterface)); return res; }
+ LDKKeysInterface* operator &() { return &self; }
+ LDKKeysInterface* operator ->() { return &self; }
+ const LDKKeysInterface* operator &() const { return &self; }
+ const LDKKeysInterface* operator ->() const { return &self; }
+};
+class InMemoryChannelKeys {
+private:
+ LDKInMemoryChannelKeys self;
+public:
+ InMemoryChannelKeys(const InMemoryChannelKeys&) = delete;
+ ~InMemoryChannelKeys() { InMemoryChannelKeys_free(self); }
+ InMemoryChannelKeys(InMemoryChannelKeys&& o) : self(o.self) { memset(&o, 0, sizeof(InMemoryChannelKeys)); }
+ InMemoryChannelKeys(LDKInMemoryChannelKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInMemoryChannelKeys)); }
+ operator LDKInMemoryChannelKeys() { LDKInMemoryChannelKeys res = self; memset(&self, 0, sizeof(LDKInMemoryChannelKeys)); return res; }
+ LDKInMemoryChannelKeys* operator &() { return &self; }
+ LDKInMemoryChannelKeys* operator ->() { return &self; }
+ const LDKInMemoryChannelKeys* operator &() const { return &self; }
+ const LDKInMemoryChannelKeys* operator ->() const { return &self; }
+};
+class KeysManager {
+private:
+ LDKKeysManager self;
+public:
+ KeysManager(const KeysManager&) = delete;
+ ~KeysManager() { KeysManager_free(self); }
+ KeysManager(KeysManager&& o) : self(o.self) { memset(&o, 0, sizeof(KeysManager)); }
+ KeysManager(LDKKeysManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKKeysManager)); }
+ operator LDKKeysManager() { LDKKeysManager res = self; memset(&self, 0, sizeof(LDKKeysManager)); return res; }
+ LDKKeysManager* operator &() { return &self; }
+ LDKKeysManager* operator ->() { return &self; }
+ const LDKKeysManager* operator &() const { return &self; }
+ const LDKKeysManager* operator ->() const { return &self; }
+};
+class ChannelManager {
+private:
+ LDKChannelManager self;
+public:
+ ChannelManager(const ChannelManager&) = delete;
+ ~ChannelManager() { ChannelManager_free(self); }
+ ChannelManager(ChannelManager&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelManager)); }
+ ChannelManager(LDKChannelManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelManager)); }
+ operator LDKChannelManager() { LDKChannelManager res = self; memset(&self, 0, sizeof(LDKChannelManager)); return res; }
+ LDKChannelManager* operator &() { return &self; }
+ LDKChannelManager* operator ->() { return &self; }
+ const LDKChannelManager* operator &() const { return &self; }
+ const LDKChannelManager* operator ->() const { return &self; }
+};
+class ChannelDetails {
+private:
+ LDKChannelDetails self;
+public:
+ ChannelDetails(const ChannelDetails&) = delete;
+ ~ChannelDetails() { ChannelDetails_free(self); }
+ ChannelDetails(ChannelDetails&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelDetails)); }
+ ChannelDetails(LDKChannelDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelDetails)); }
+ operator LDKChannelDetails() { LDKChannelDetails res = self; memset(&self, 0, sizeof(LDKChannelDetails)); return res; }
+ LDKChannelDetails* operator &() { return &self; }
+ LDKChannelDetails* operator ->() { return &self; }
+ const LDKChannelDetails* operator &() const { return &self; }
+ const LDKChannelDetails* operator ->() const { return &self; }
+};
+class PaymentSendFailure {
+private:
+ LDKPaymentSendFailure self;
+public:
+ PaymentSendFailure(const PaymentSendFailure&) = delete;
+ ~PaymentSendFailure() { PaymentSendFailure_free(self); }
+ PaymentSendFailure(PaymentSendFailure&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentSendFailure)); }
+ PaymentSendFailure(LDKPaymentSendFailure&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentSendFailure)); }
+ operator LDKPaymentSendFailure() { LDKPaymentSendFailure res = self; memset(&self, 0, sizeof(LDKPaymentSendFailure)); return res; }
+ LDKPaymentSendFailure* operator &() { return &self; }
+ LDKPaymentSendFailure* operator ->() { return &self; }
+ const LDKPaymentSendFailure* operator &() const { return &self; }
+ const LDKPaymentSendFailure* operator ->() const { return &self; }
+};
+class ChannelManagerReadArgs {
+private:
+ LDKChannelManagerReadArgs self;
+public:
+ ChannelManagerReadArgs(const ChannelManagerReadArgs&) = delete;
+ ~ChannelManagerReadArgs() { ChannelManagerReadArgs_free(self); }
+ ChannelManagerReadArgs(ChannelManagerReadArgs&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelManagerReadArgs)); }
+ ChannelManagerReadArgs(LDKChannelManagerReadArgs&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelManagerReadArgs)); }
+ operator LDKChannelManagerReadArgs() { LDKChannelManagerReadArgs res = self; memset(&self, 0, sizeof(LDKChannelManagerReadArgs)); return res; }
+ LDKChannelManagerReadArgs* operator &() { return &self; }
+ LDKChannelManagerReadArgs* operator ->() { return &self; }
+ const LDKChannelManagerReadArgs* operator &() const { return &self; }
+ const LDKChannelManagerReadArgs* operator ->() const { return &self; }
+};
+class ChannelMonitorUpdate {
+private:
+ LDKChannelMonitorUpdate self;
+public:
+ ChannelMonitorUpdate(const ChannelMonitorUpdate&) = delete;
+ ~ChannelMonitorUpdate() { ChannelMonitorUpdate_free(self); }
+ ChannelMonitorUpdate(ChannelMonitorUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdate)); }
+ ChannelMonitorUpdate(LDKChannelMonitorUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdate)); }
+ operator LDKChannelMonitorUpdate() { LDKChannelMonitorUpdate res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdate)); return res; }
+ LDKChannelMonitorUpdate* operator &() { return &self; }
+ LDKChannelMonitorUpdate* operator ->() { return &self; }
+ const LDKChannelMonitorUpdate* operator &() const { return &self; }
+ const LDKChannelMonitorUpdate* operator ->() const { return &self; }
+};
+class ChannelMonitorUpdateErr {
+private:
+ LDKChannelMonitorUpdateErr self;
+public:
+ ChannelMonitorUpdateErr(const ChannelMonitorUpdateErr&) = delete;
+ ChannelMonitorUpdateErr(ChannelMonitorUpdateErr&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdateErr)); }
+ ChannelMonitorUpdateErr(LDKChannelMonitorUpdateErr&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdateErr)); }
+ operator LDKChannelMonitorUpdateErr() { LDKChannelMonitorUpdateErr res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdateErr)); return res; }
+ LDKChannelMonitorUpdateErr* operator &() { return &self; }
+ LDKChannelMonitorUpdateErr* operator ->() { return &self; }
+ const LDKChannelMonitorUpdateErr* operator &() const { return &self; }
+ const LDKChannelMonitorUpdateErr* operator ->() const { return &self; }
+};
+class MonitorUpdateError {
+private:
+ LDKMonitorUpdateError self;
+public:
+ MonitorUpdateError(const MonitorUpdateError&) = delete;
+ ~MonitorUpdateError() { MonitorUpdateError_free(self); }
+ MonitorUpdateError(MonitorUpdateError&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorUpdateError)); }
+ MonitorUpdateError(LDKMonitorUpdateError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorUpdateError)); }
+ operator LDKMonitorUpdateError() { LDKMonitorUpdateError res = self; memset(&self, 0, sizeof(LDKMonitorUpdateError)); return res; }
+ LDKMonitorUpdateError* operator &() { return &self; }
+ LDKMonitorUpdateError* operator ->() { return &self; }
+ const LDKMonitorUpdateError* operator &() const { return &self; }
+ const LDKMonitorUpdateError* operator ->() const { return &self; }
+};
+class MonitorEvent {
+private:
+ LDKMonitorEvent self;
+public:
+ MonitorEvent(const MonitorEvent&) = delete;
+ ~MonitorEvent() { MonitorEvent_free(self); }
+ MonitorEvent(MonitorEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorEvent)); }
+ MonitorEvent(LDKMonitorEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorEvent)); }
+ operator LDKMonitorEvent() { LDKMonitorEvent res = self; memset(&self, 0, sizeof(LDKMonitorEvent)); return res; }
+ LDKMonitorEvent* operator &() { return &self; }
+ LDKMonitorEvent* operator ->() { return &self; }
+ const LDKMonitorEvent* operator &() const { return &self; }
+ const LDKMonitorEvent* operator ->() const { return &self; }
+};
+class HTLCUpdate {
+private:
+ LDKHTLCUpdate self;
+public:
+ HTLCUpdate(const HTLCUpdate&) = delete;
+ ~HTLCUpdate() { HTLCUpdate_free(self); }
+ HTLCUpdate(HTLCUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCUpdate)); }
+ HTLCUpdate(LDKHTLCUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCUpdate)); }
+ operator LDKHTLCUpdate() { LDKHTLCUpdate res = self; memset(&self, 0, sizeof(LDKHTLCUpdate)); return res; }
+ LDKHTLCUpdate* operator &() { return &self; }
+ LDKHTLCUpdate* operator ->() { return &self; }
+ const LDKHTLCUpdate* operator &() const { return &self; }
+ const LDKHTLCUpdate* operator ->() const { return &self; }
+};
+class ChannelMonitor {
+private:
+ LDKChannelMonitor self;
+public:
+ ChannelMonitor(const ChannelMonitor&) = delete;
+ ~ChannelMonitor() { ChannelMonitor_free(self); }
+ ChannelMonitor(ChannelMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitor)); }
+ ChannelMonitor(LDKChannelMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitor)); }
+ operator LDKChannelMonitor() { LDKChannelMonitor res = self; memset(&self, 0, sizeof(LDKChannelMonitor)); return res; }
+ LDKChannelMonitor* operator &() { return &self; }
+ LDKChannelMonitor* operator ->() { return &self; }
+ const LDKChannelMonitor* operator &() const { return &self; }
+ const LDKChannelMonitor* operator ->() const { return &self; }
+};
+class ManyChannelMonitor {
+private:
+ LDKManyChannelMonitor self;
+public:
+ ManyChannelMonitor(const ManyChannelMonitor&) = delete;
+ ~ManyChannelMonitor() { ManyChannelMonitor_free(self); }
+ ManyChannelMonitor(ManyChannelMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ManyChannelMonitor)); }
+ ManyChannelMonitor(LDKManyChannelMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKManyChannelMonitor)); }
+ operator LDKManyChannelMonitor() { LDKManyChannelMonitor res = self; memset(&self, 0, sizeof(LDKManyChannelMonitor)); return res; }
+ LDKManyChannelMonitor* operator &() { return &self; }
+ LDKManyChannelMonitor* operator ->() { return &self; }
+ const LDKManyChannelMonitor* operator &() const { return &self; }
+ const LDKManyChannelMonitor* operator ->() const { return &self; }
+};
+class DecodeError {
+private:
+ LDKDecodeError self;
+public:
+ DecodeError(const DecodeError&) = delete;
+ ~DecodeError() { DecodeError_free(self); }
+ DecodeError(DecodeError&& o) : self(o.self) { memset(&o, 0, sizeof(DecodeError)); }
+ DecodeError(LDKDecodeError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDecodeError)); }
+ operator LDKDecodeError() { LDKDecodeError res = self; memset(&self, 0, sizeof(LDKDecodeError)); return res; }
+ LDKDecodeError* operator &() { return &self; }
+ LDKDecodeError* operator ->() { return &self; }
+ const LDKDecodeError* operator &() const { return &self; }
+ const LDKDecodeError* operator ->() const { return &self; }
+};
+class Init {
+private:
+ LDKInit self;
+public:
+ Init(const Init&) = delete;
+ ~Init() { Init_free(self); }
+ Init(Init&& o) : self(o.self) { memset(&o, 0, sizeof(Init)); }
+ Init(LDKInit&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInit)); }
+ operator LDKInit() { LDKInit res = self; memset(&self, 0, sizeof(LDKInit)); return res; }
+ LDKInit* operator &() { return &self; }
+ LDKInit* operator ->() { return &self; }
+ const LDKInit* operator &() const { return &self; }
+ const LDKInit* operator ->() const { return &self; }
+};
+class ErrorMessage {
+private:
+ LDKErrorMessage self;
+public:
+ ErrorMessage(const ErrorMessage&) = delete;
+ ~ErrorMessage() { ErrorMessage_free(self); }
+ ErrorMessage(ErrorMessage&& o) : self(o.self) { memset(&o, 0, sizeof(ErrorMessage)); }
+ ErrorMessage(LDKErrorMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErrorMessage)); }
+ operator LDKErrorMessage() { LDKErrorMessage res = self; memset(&self, 0, sizeof(LDKErrorMessage)); return res; }
+ LDKErrorMessage* operator &() { return &self; }
+ LDKErrorMessage* operator ->() { return &self; }
+ const LDKErrorMessage* operator &() const { return &self; }
+ const LDKErrorMessage* operator ->() const { return &self; }
+};
+class Ping {
+private:
+ LDKPing self;
+public:
+ Ping(const Ping&) = delete;
+ ~Ping() { Ping_free(self); }
+ Ping(Ping&& o) : self(o.self) { memset(&o, 0, sizeof(Ping)); }
+ Ping(LDKPing&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPing)); }
+ operator LDKPing() { LDKPing res = self; memset(&self, 0, sizeof(LDKPing)); return res; }
+ LDKPing* operator &() { return &self; }
+ LDKPing* operator ->() { return &self; }
+ const LDKPing* operator &() const { return &self; }
+ const LDKPing* operator ->() const { return &self; }
+};
+class Pong {
+private:
+ LDKPong self;
+public:
+ Pong(const Pong&) = delete;
+ ~Pong() { Pong_free(self); }
+ Pong(Pong&& o) : self(o.self) { memset(&o, 0, sizeof(Pong)); }
+ Pong(LDKPong&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPong)); }
+ operator LDKPong() { LDKPong res = self; memset(&self, 0, sizeof(LDKPong)); return res; }
+ LDKPong* operator &() { return &self; }
+ LDKPong* operator ->() { return &self; }
+ const LDKPong* operator &() const { return &self; }
+ const LDKPong* operator ->() const { return &self; }
+};
+class OpenChannel {
+private:
+ LDKOpenChannel self;
+public:
+ OpenChannel(const OpenChannel&) = delete;
+ ~OpenChannel() { OpenChannel_free(self); }
+ OpenChannel(OpenChannel&& o) : self(o.self) { memset(&o, 0, sizeof(OpenChannel)); }
+ OpenChannel(LDKOpenChannel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOpenChannel)); }
+ operator LDKOpenChannel() { LDKOpenChannel res = self; memset(&self, 0, sizeof(LDKOpenChannel)); return res; }
+ LDKOpenChannel* operator &() { return &self; }
+ LDKOpenChannel* operator ->() { return &self; }
+ const LDKOpenChannel* operator &() const { return &self; }
+ const LDKOpenChannel* operator ->() const { return &self; }
+};
+class AcceptChannel {
+private:
+ LDKAcceptChannel self;
+public:
+ AcceptChannel(const AcceptChannel&) = delete;
+ ~AcceptChannel() { AcceptChannel_free(self); }
+ AcceptChannel(AcceptChannel&& o) : self(o.self) { memset(&o, 0, sizeof(AcceptChannel)); }
+ AcceptChannel(LDKAcceptChannel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAcceptChannel)); }
+ operator LDKAcceptChannel() { LDKAcceptChannel res = self; memset(&self, 0, sizeof(LDKAcceptChannel)); return res; }
+ LDKAcceptChannel* operator &() { return &self; }
+ LDKAcceptChannel* operator ->() { return &self; }
+ const LDKAcceptChannel* operator &() const { return &self; }
+ const LDKAcceptChannel* operator ->() const { return &self; }
+};
+class FundingCreated {
+private:
+ LDKFundingCreated self;
+public:
+ FundingCreated(const FundingCreated&) = delete;
+ ~FundingCreated() { FundingCreated_free(self); }
+ FundingCreated(FundingCreated&& o) : self(o.self) { memset(&o, 0, sizeof(FundingCreated)); }
+ FundingCreated(LDKFundingCreated&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingCreated)); }
+ operator LDKFundingCreated() { LDKFundingCreated res = self; memset(&self, 0, sizeof(LDKFundingCreated)); return res; }
+ LDKFundingCreated* operator &() { return &self; }
+ LDKFundingCreated* operator ->() { return &self; }
+ const LDKFundingCreated* operator &() const { return &self; }
+ const LDKFundingCreated* operator ->() const { return &self; }
+};
+class FundingSigned {
+private:
+ LDKFundingSigned self;
+public:
+ FundingSigned(const FundingSigned&) = delete;
+ ~FundingSigned() { FundingSigned_free(self); }
+ FundingSigned(FundingSigned&& o) : self(o.self) { memset(&o, 0, sizeof(FundingSigned)); }
+ FundingSigned(LDKFundingSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingSigned)); }
+ operator LDKFundingSigned() { LDKFundingSigned res = self; memset(&self, 0, sizeof(LDKFundingSigned)); return res; }
+ LDKFundingSigned* operator &() { return &self; }
+ LDKFundingSigned* operator ->() { return &self; }
+ const LDKFundingSigned* operator &() const { return &self; }
+ const LDKFundingSigned* operator ->() const { return &self; }
+};
+class FundingLocked {
+private:
+ LDKFundingLocked self;
+public:
+ FundingLocked(const FundingLocked&) = delete;
+ ~FundingLocked() { FundingLocked_free(self); }
+ FundingLocked(FundingLocked&& o) : self(o.self) { memset(&o, 0, sizeof(FundingLocked)); }
+ FundingLocked(LDKFundingLocked&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingLocked)); }
+ operator LDKFundingLocked() { LDKFundingLocked res = self; memset(&self, 0, sizeof(LDKFundingLocked)); return res; }
+ LDKFundingLocked* operator &() { return &self; }
+ LDKFundingLocked* operator ->() { return &self; }
+ const LDKFundingLocked* operator &() const { return &self; }
+ const LDKFundingLocked* operator ->() const { return &self; }
+};
+class Shutdown {
+private:
+ LDKShutdown self;
+public:
+ Shutdown(const Shutdown&) = delete;
+ ~Shutdown() { Shutdown_free(self); }
+ Shutdown(Shutdown&& o) : self(o.self) { memset(&o, 0, sizeof(Shutdown)); }
+ Shutdown(LDKShutdown&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKShutdown)); }
+ operator LDKShutdown() { LDKShutdown res = self; memset(&self, 0, sizeof(LDKShutdown)); return res; }
+ LDKShutdown* operator &() { return &self; }
+ LDKShutdown* operator ->() { return &self; }
+ const LDKShutdown* operator &() const { return &self; }
+ const LDKShutdown* operator ->() const { return &self; }
+};
+class ClosingSigned {
+private:
+ LDKClosingSigned self;
+public:
+ ClosingSigned(const ClosingSigned&) = delete;
+ ~ClosingSigned() { ClosingSigned_free(self); }
+ ClosingSigned(ClosingSigned&& o) : self(o.self) { memset(&o, 0, sizeof(ClosingSigned)); }
+ ClosingSigned(LDKClosingSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosingSigned)); }
+ operator LDKClosingSigned() { LDKClosingSigned res = self; memset(&self, 0, sizeof(LDKClosingSigned)); return res; }
+ LDKClosingSigned* operator &() { return &self; }
+ LDKClosingSigned* operator ->() { return &self; }
+ const LDKClosingSigned* operator &() const { return &self; }
+ const LDKClosingSigned* operator ->() const { return &self; }
+};
+class UpdateAddHTLC {
+private:
+ LDKUpdateAddHTLC self;
+public:
+ UpdateAddHTLC(const UpdateAddHTLC&) = delete;
+ ~UpdateAddHTLC() { UpdateAddHTLC_free(self); }
+ UpdateAddHTLC(UpdateAddHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateAddHTLC)); }
+ UpdateAddHTLC(LDKUpdateAddHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateAddHTLC)); }
+ operator LDKUpdateAddHTLC() { LDKUpdateAddHTLC res = self; memset(&self, 0, sizeof(LDKUpdateAddHTLC)); return res; }
+ LDKUpdateAddHTLC* operator &() { return &self; }
+ LDKUpdateAddHTLC* operator ->() { return &self; }
+ const LDKUpdateAddHTLC* operator &() const { return &self; }
+ const LDKUpdateAddHTLC* operator ->() const { return &self; }
+};
+class UpdateFulfillHTLC {
+private:
+ LDKUpdateFulfillHTLC self;
+public:
+ UpdateFulfillHTLC(const UpdateFulfillHTLC&) = delete;
+ ~UpdateFulfillHTLC() { UpdateFulfillHTLC_free(self); }
+ UpdateFulfillHTLC(UpdateFulfillHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFulfillHTLC)); }
+ UpdateFulfillHTLC(LDKUpdateFulfillHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFulfillHTLC)); }
+ operator LDKUpdateFulfillHTLC() { LDKUpdateFulfillHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFulfillHTLC)); return res; }
+ LDKUpdateFulfillHTLC* operator &() { return &self; }
+ LDKUpdateFulfillHTLC* operator ->() { return &self; }
+ const LDKUpdateFulfillHTLC* operator &() const { return &self; }
+ const LDKUpdateFulfillHTLC* operator ->() const { return &self; }
+};
+class UpdateFailHTLC {
+private:
+ LDKUpdateFailHTLC self;
+public:
+ UpdateFailHTLC(const UpdateFailHTLC&) = delete;
+ ~UpdateFailHTLC() { UpdateFailHTLC_free(self); }
+ UpdateFailHTLC(UpdateFailHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFailHTLC)); }
+ UpdateFailHTLC(LDKUpdateFailHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFailHTLC)); }
+ operator LDKUpdateFailHTLC() { LDKUpdateFailHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFailHTLC)); return res; }
+ LDKUpdateFailHTLC* operator &() { return &self; }
+ LDKUpdateFailHTLC* operator ->() { return &self; }
+ const LDKUpdateFailHTLC* operator &() const { return &self; }
+ const LDKUpdateFailHTLC* operator ->() const { return &self; }
+};
+class UpdateFailMalformedHTLC {
+private:
+ LDKUpdateFailMalformedHTLC self;
+public:
+ UpdateFailMalformedHTLC(const UpdateFailMalformedHTLC&) = delete;
+ ~UpdateFailMalformedHTLC() { UpdateFailMalformedHTLC_free(self); }
+ UpdateFailMalformedHTLC(UpdateFailMalformedHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFailMalformedHTLC)); }
+ UpdateFailMalformedHTLC(LDKUpdateFailMalformedHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFailMalformedHTLC)); }
+ operator LDKUpdateFailMalformedHTLC() { LDKUpdateFailMalformedHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFailMalformedHTLC)); return res; }
+ LDKUpdateFailMalformedHTLC* operator &() { return &self; }
+ LDKUpdateFailMalformedHTLC* operator ->() { return &self; }
+ const LDKUpdateFailMalformedHTLC* operator &() const { return &self; }
+ const LDKUpdateFailMalformedHTLC* operator ->() const { return &self; }
+};
+class CommitmentSigned {
+private:
+ LDKCommitmentSigned self;
+public:
+ CommitmentSigned(const CommitmentSigned&) = delete;
+ ~CommitmentSigned() { CommitmentSigned_free(self); }
+ CommitmentSigned(CommitmentSigned&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentSigned)); }
+ CommitmentSigned(LDKCommitmentSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentSigned)); }
+ operator LDKCommitmentSigned() { LDKCommitmentSigned res = self; memset(&self, 0, sizeof(LDKCommitmentSigned)); return res; }
+ LDKCommitmentSigned* operator &() { return &self; }
+ LDKCommitmentSigned* operator ->() { return &self; }
+ const LDKCommitmentSigned* operator &() const { return &self; }
+ const LDKCommitmentSigned* operator ->() const { return &self; }
+};
+class RevokeAndACK {
+private:
+ LDKRevokeAndACK self;
+public:
+ RevokeAndACK(const RevokeAndACK&) = delete;
+ ~RevokeAndACK() { RevokeAndACK_free(self); }
+ RevokeAndACK(RevokeAndACK&& o) : self(o.self) { memset(&o, 0, sizeof(RevokeAndACK)); }
+ RevokeAndACK(LDKRevokeAndACK&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRevokeAndACK)); }
+ operator LDKRevokeAndACK() { LDKRevokeAndACK res = self; memset(&self, 0, sizeof(LDKRevokeAndACK)); return res; }
+ LDKRevokeAndACK* operator &() { return &self; }
+ LDKRevokeAndACK* operator ->() { return &self; }
+ const LDKRevokeAndACK* operator &() const { return &self; }
+ const LDKRevokeAndACK* operator ->() const { return &self; }
+};
+class UpdateFee {
+private:
+ LDKUpdateFee self;
+public:
+ UpdateFee(const UpdateFee&) = delete;
+ ~UpdateFee() { UpdateFee_free(self); }
+ UpdateFee(UpdateFee&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFee)); }
+ UpdateFee(LDKUpdateFee&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFee)); }
+ operator LDKUpdateFee() { LDKUpdateFee res = self; memset(&self, 0, sizeof(LDKUpdateFee)); return res; }
+ LDKUpdateFee* operator &() { return &self; }
+ LDKUpdateFee* operator ->() { return &self; }
+ const LDKUpdateFee* operator &() const { return &self; }
+ const LDKUpdateFee* operator ->() const { return &self; }
+};
+class DataLossProtect {
+private:
+ LDKDataLossProtect self;
+public:
+ DataLossProtect(const DataLossProtect&) = delete;
+ ~DataLossProtect() { DataLossProtect_free(self); }
+ DataLossProtect(DataLossProtect&& o) : self(o.self) { memset(&o, 0, sizeof(DataLossProtect)); }
+ DataLossProtect(LDKDataLossProtect&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDataLossProtect)); }
+ operator LDKDataLossProtect() { LDKDataLossProtect res = self; memset(&self, 0, sizeof(LDKDataLossProtect)); return res; }
+ LDKDataLossProtect* operator &() { return &self; }
+ LDKDataLossProtect* operator ->() { return &self; }
+ const LDKDataLossProtect* operator &() const { return &self; }
+ const LDKDataLossProtect* operator ->() const { return &self; }
+};
+class ChannelReestablish {
+private:
+ LDKChannelReestablish self;
+public:
+ ChannelReestablish(const ChannelReestablish&) = delete;
+ ~ChannelReestablish() { ChannelReestablish_free(self); }
+ ChannelReestablish(ChannelReestablish&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelReestablish)); }
+ ChannelReestablish(LDKChannelReestablish&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelReestablish)); }
+ operator LDKChannelReestablish() { LDKChannelReestablish res = self; memset(&self, 0, sizeof(LDKChannelReestablish)); return res; }
+ LDKChannelReestablish* operator &() { return &self; }
+ LDKChannelReestablish* operator ->() { return &self; }
+ const LDKChannelReestablish* operator &() const { return &self; }
+ const LDKChannelReestablish* operator ->() const { return &self; }
+};
+class AnnouncementSignatures {
+private:
+ LDKAnnouncementSignatures self;
+public:
+ AnnouncementSignatures(const AnnouncementSignatures&) = delete;
+ ~AnnouncementSignatures() { AnnouncementSignatures_free(self); }
+ AnnouncementSignatures(AnnouncementSignatures&& o) : self(o.self) { memset(&o, 0, sizeof(AnnouncementSignatures)); }
+ AnnouncementSignatures(LDKAnnouncementSignatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAnnouncementSignatures)); }
+ operator LDKAnnouncementSignatures() { LDKAnnouncementSignatures res = self; memset(&self, 0, sizeof(LDKAnnouncementSignatures)); return res; }
+ LDKAnnouncementSignatures* operator &() { return &self; }
+ LDKAnnouncementSignatures* operator ->() { return &self; }
+ const LDKAnnouncementSignatures* operator &() const { return &self; }
+ const LDKAnnouncementSignatures* operator ->() const { return &self; }
+};
+class NetAddress {
+private:
+ LDKNetAddress self;
+public:
+ NetAddress(const NetAddress&) = delete;
+ ~NetAddress() { NetAddress_free(self); }
+ NetAddress(NetAddress&& o) : self(o.self) { memset(&o, 0, sizeof(NetAddress)); }
+ NetAddress(LDKNetAddress&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetAddress)); }
+ operator LDKNetAddress() { LDKNetAddress res = self; memset(&self, 0, sizeof(LDKNetAddress)); return res; }
+ LDKNetAddress* operator &() { return &self; }
+ LDKNetAddress* operator ->() { return &self; }
+ const LDKNetAddress* operator &() const { return &self; }
+ const LDKNetAddress* operator ->() const { return &self; }
+};
+class UnsignedNodeAnnouncement {
+private:
+ LDKUnsignedNodeAnnouncement self;
+public:
+ UnsignedNodeAnnouncement(const UnsignedNodeAnnouncement&) = delete;
+ ~UnsignedNodeAnnouncement() { UnsignedNodeAnnouncement_free(self); }
+ UnsignedNodeAnnouncement(UnsignedNodeAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedNodeAnnouncement)); }
+ UnsignedNodeAnnouncement(LDKUnsignedNodeAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedNodeAnnouncement)); }
+ operator LDKUnsignedNodeAnnouncement() { LDKUnsignedNodeAnnouncement res = self; memset(&self, 0, sizeof(LDKUnsignedNodeAnnouncement)); return res; }
+ LDKUnsignedNodeAnnouncement* operator &() { return &self; }
+ LDKUnsignedNodeAnnouncement* operator ->() { return &self; }
+ const LDKUnsignedNodeAnnouncement* operator &() const { return &self; }
+ const LDKUnsignedNodeAnnouncement* operator ->() const { return &self; }
+};
+class NodeAnnouncement {
+private:
+ LDKNodeAnnouncement self;
+public:
+ NodeAnnouncement(const NodeAnnouncement&) = delete;
+ ~NodeAnnouncement() { NodeAnnouncement_free(self); }
+ NodeAnnouncement(NodeAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(NodeAnnouncement)); }
+ NodeAnnouncement(LDKNodeAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeAnnouncement)); }
+ operator LDKNodeAnnouncement() { LDKNodeAnnouncement res = self; memset(&self, 0, sizeof(LDKNodeAnnouncement)); return res; }
+ LDKNodeAnnouncement* operator &() { return &self; }
+ LDKNodeAnnouncement* operator ->() { return &self; }
+ const LDKNodeAnnouncement* operator &() const { return &self; }
+ const LDKNodeAnnouncement* operator ->() const { return &self; }
+};
+class UnsignedChannelAnnouncement {
+private:
+ LDKUnsignedChannelAnnouncement self;
+public:
+ UnsignedChannelAnnouncement(const UnsignedChannelAnnouncement&) = delete;
+ ~UnsignedChannelAnnouncement() { UnsignedChannelAnnouncement_free(self); }
+ UnsignedChannelAnnouncement(UnsignedChannelAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedChannelAnnouncement)); }
+ UnsignedChannelAnnouncement(LDKUnsignedChannelAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedChannelAnnouncement)); }
+ operator LDKUnsignedChannelAnnouncement() { LDKUnsignedChannelAnnouncement res = self; memset(&self, 0, sizeof(LDKUnsignedChannelAnnouncement)); return res; }
+ LDKUnsignedChannelAnnouncement* operator &() { return &self; }
+ LDKUnsignedChannelAnnouncement* operator ->() { return &self; }
+ const LDKUnsignedChannelAnnouncement* operator &() const { return &self; }
+ const LDKUnsignedChannelAnnouncement* operator ->() const { return &self; }
+};
+class ChannelAnnouncement {
+private:
+ LDKChannelAnnouncement self;
+public:
+ ChannelAnnouncement(const ChannelAnnouncement&) = delete;
+ ~ChannelAnnouncement() { ChannelAnnouncement_free(self); }
+ ChannelAnnouncement(ChannelAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelAnnouncement)); }
+ ChannelAnnouncement(LDKChannelAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelAnnouncement)); }
+ operator LDKChannelAnnouncement() { LDKChannelAnnouncement res = self; memset(&self, 0, sizeof(LDKChannelAnnouncement)); return res; }
+ LDKChannelAnnouncement* operator &() { return &self; }
+ LDKChannelAnnouncement* operator ->() { return &self; }
+ const LDKChannelAnnouncement* operator &() const { return &self; }
+ const LDKChannelAnnouncement* operator ->() const { return &self; }
+};
+class UnsignedChannelUpdate {
+private:
+ LDKUnsignedChannelUpdate self;
+public:
+ UnsignedChannelUpdate(const UnsignedChannelUpdate&) = delete;
+ ~UnsignedChannelUpdate() { UnsignedChannelUpdate_free(self); }
+ UnsignedChannelUpdate(UnsignedChannelUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedChannelUpdate)); }
+ UnsignedChannelUpdate(LDKUnsignedChannelUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedChannelUpdate)); }
+ operator LDKUnsignedChannelUpdate() { LDKUnsignedChannelUpdate res = self; memset(&self, 0, sizeof(LDKUnsignedChannelUpdate)); return res; }
+ LDKUnsignedChannelUpdate* operator &() { return &self; }
+ LDKUnsignedChannelUpdate* operator ->() { return &self; }
+ const LDKUnsignedChannelUpdate* operator &() const { return &self; }
+ const LDKUnsignedChannelUpdate* operator ->() const { return &self; }
+};
+class ChannelUpdate {
+private:
+ LDKChannelUpdate self;
+public:
+ ChannelUpdate(const ChannelUpdate&) = delete;
+ ~ChannelUpdate() { ChannelUpdate_free(self); }
+ ChannelUpdate(ChannelUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelUpdate)); }
+ ChannelUpdate(LDKChannelUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelUpdate)); }
+ operator LDKChannelUpdate() { LDKChannelUpdate res = self; memset(&self, 0, sizeof(LDKChannelUpdate)); return res; }
+ LDKChannelUpdate* operator &() { return &self; }
+ LDKChannelUpdate* operator ->() { return &self; }
+ const LDKChannelUpdate* operator &() const { return &self; }
+ const LDKChannelUpdate* operator ->() const { return &self; }
+};
+class ErrorAction {
+private:
+ LDKErrorAction self;
+public:
+ ErrorAction(const ErrorAction&) = delete;
+ ~ErrorAction() { ErrorAction_free(self); }
+ ErrorAction(ErrorAction&& o) : self(o.self) { memset(&o, 0, sizeof(ErrorAction)); }
+ ErrorAction(LDKErrorAction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErrorAction)); }
+ operator LDKErrorAction() { LDKErrorAction res = self; memset(&self, 0, sizeof(LDKErrorAction)); return res; }
+ LDKErrorAction* operator &() { return &self; }
+ LDKErrorAction* operator ->() { return &self; }
+ const LDKErrorAction* operator &() const { return &self; }
+ const LDKErrorAction* operator ->() const { return &self; }
+};
+class LightningError {
+private:
+ LDKLightningError self;
+public:
+ LightningError(const LightningError&) = delete;
+ ~LightningError() { LightningError_free(self); }
+ LightningError(LightningError&& o) : self(o.self) { memset(&o, 0, sizeof(LightningError)); }
+ LightningError(LDKLightningError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLightningError)); }
+ operator LDKLightningError() { LDKLightningError res = self; memset(&self, 0, sizeof(LDKLightningError)); return res; }
+ LDKLightningError* operator &() { return &self; }
+ LDKLightningError* operator ->() { return &self; }
+ const LDKLightningError* operator &() const { return &self; }
+ const LDKLightningError* operator ->() const { return &self; }
+};
+class CommitmentUpdate {
+private:
+ LDKCommitmentUpdate self;
+public:
+ CommitmentUpdate(const CommitmentUpdate&) = delete;
+ ~CommitmentUpdate() { CommitmentUpdate_free(self); }
+ CommitmentUpdate(CommitmentUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentUpdate)); }
+ CommitmentUpdate(LDKCommitmentUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentUpdate)); }
+ operator LDKCommitmentUpdate() { LDKCommitmentUpdate res = self; memset(&self, 0, sizeof(LDKCommitmentUpdate)); return res; }
+ LDKCommitmentUpdate* operator &() { return &self; }
+ LDKCommitmentUpdate* operator ->() { return &self; }
+ const LDKCommitmentUpdate* operator &() const { return &self; }
+ const LDKCommitmentUpdate* operator ->() const { return &self; }
+};
+class HTLCFailChannelUpdate {
+private:
+ LDKHTLCFailChannelUpdate self;
+public:
+ HTLCFailChannelUpdate(const HTLCFailChannelUpdate&) = delete;
+ ~HTLCFailChannelUpdate() { HTLCFailChannelUpdate_free(self); }
+ HTLCFailChannelUpdate(HTLCFailChannelUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCFailChannelUpdate)); }
+ HTLCFailChannelUpdate(LDKHTLCFailChannelUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCFailChannelUpdate)); }
+ operator LDKHTLCFailChannelUpdate() { LDKHTLCFailChannelUpdate res = self; memset(&self, 0, sizeof(LDKHTLCFailChannelUpdate)); return res; }
+ LDKHTLCFailChannelUpdate* operator &() { return &self; }
+ LDKHTLCFailChannelUpdate* operator ->() { return &self; }
+ const LDKHTLCFailChannelUpdate* operator &() const { return &self; }
+ const LDKHTLCFailChannelUpdate* operator ->() const { return &self; }
+};
+class ChannelMessageHandler {
+private:
+ LDKChannelMessageHandler self;
+public:
+ ChannelMessageHandler(const ChannelMessageHandler&) = delete;
+ ~ChannelMessageHandler() { ChannelMessageHandler_free(self); }
+ ChannelMessageHandler(ChannelMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMessageHandler)); }
+ ChannelMessageHandler(LDKChannelMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMessageHandler)); }
+ operator LDKChannelMessageHandler() { LDKChannelMessageHandler res = self; memset(&self, 0, sizeof(LDKChannelMessageHandler)); return res; }
+ LDKChannelMessageHandler* operator &() { return &self; }
+ LDKChannelMessageHandler* operator ->() { return &self; }
+ const LDKChannelMessageHandler* operator &() const { return &self; }
+ const LDKChannelMessageHandler* operator ->() const { return &self; }
+};
+class RoutingMessageHandler {
+private:
+ LDKRoutingMessageHandler self;
+public:
+ RoutingMessageHandler(const RoutingMessageHandler&) = delete;
+ ~RoutingMessageHandler() { RoutingMessageHandler_free(self); }
+ RoutingMessageHandler(RoutingMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(RoutingMessageHandler)); }
+ RoutingMessageHandler(LDKRoutingMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoutingMessageHandler)); }
+ operator LDKRoutingMessageHandler() { LDKRoutingMessageHandler res = self; memset(&self, 0, sizeof(LDKRoutingMessageHandler)); return res; }
+ LDKRoutingMessageHandler* operator &() { return &self; }
+ LDKRoutingMessageHandler* operator ->() { return &self; }
+ const LDKRoutingMessageHandler* operator &() const { return &self; }
+ const LDKRoutingMessageHandler* operator ->() const { return &self; }
+};
+class MessageHandler {
+private:
+ LDKMessageHandler self;
+public:
+ MessageHandler(const MessageHandler&) = delete;
+ ~MessageHandler() { MessageHandler_free(self); }
+ MessageHandler(MessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(MessageHandler)); }
+ MessageHandler(LDKMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageHandler)); }
+ operator LDKMessageHandler() { LDKMessageHandler res = self; memset(&self, 0, sizeof(LDKMessageHandler)); return res; }
+ LDKMessageHandler* operator &() { return &self; }
+ LDKMessageHandler* operator ->() { return &self; }
+ const LDKMessageHandler* operator &() const { return &self; }
+ const LDKMessageHandler* operator ->() const { return &self; }
+};
+class SocketDescriptor {
+private:
+ LDKSocketDescriptor self;
+public:
+ SocketDescriptor(const SocketDescriptor&) = delete;
+ ~SocketDescriptor() { SocketDescriptor_free(self); }
+ SocketDescriptor(SocketDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(SocketDescriptor)); }
+ SocketDescriptor(LDKSocketDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSocketDescriptor)); }
+ operator LDKSocketDescriptor() { LDKSocketDescriptor res = self; memset(&self, 0, sizeof(LDKSocketDescriptor)); return res; }
+ LDKSocketDescriptor* operator &() { return &self; }
+ LDKSocketDescriptor* operator ->() { return &self; }
+ const LDKSocketDescriptor* operator &() const { return &self; }
+ const LDKSocketDescriptor* operator ->() const { return &self; }
+};
+class PeerHandleError {
+private:
+ LDKPeerHandleError self;
+public:
+ PeerHandleError(const PeerHandleError&) = delete;
+ ~PeerHandleError() { PeerHandleError_free(self); }
+ PeerHandleError(PeerHandleError&& o) : self(o.self) { memset(&o, 0, sizeof(PeerHandleError)); }
+ PeerHandleError(LDKPeerHandleError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPeerHandleError)); }
+ operator LDKPeerHandleError() { LDKPeerHandleError res = self; memset(&self, 0, sizeof(LDKPeerHandleError)); return res; }
+ LDKPeerHandleError* operator &() { return &self; }
+ LDKPeerHandleError* operator ->() { return &self; }
+ const LDKPeerHandleError* operator &() const { return &self; }
+ const LDKPeerHandleError* operator ->() const { return &self; }
+};
+class PeerManager {
+private:
+ LDKPeerManager self;
+public:
+ PeerManager(const PeerManager&) = delete;
+ ~PeerManager() { PeerManager_free(self); }
+ PeerManager(PeerManager&& o) : self(o.self) { memset(&o, 0, sizeof(PeerManager)); }
+ PeerManager(LDKPeerManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPeerManager)); }
+ operator LDKPeerManager() { LDKPeerManager res = self; memset(&self, 0, sizeof(LDKPeerManager)); return res; }
+ LDKPeerManager* operator &() { return &self; }
+ LDKPeerManager* operator ->() { return &self; }
+ const LDKPeerManager* operator &() const { return &self; }
+ const LDKPeerManager* operator ->() const { return &self; }
+};
+class TxCreationKeys {
+private:
+ LDKTxCreationKeys self;
+public:
+ TxCreationKeys(const TxCreationKeys&) = delete;
+ ~TxCreationKeys() { TxCreationKeys_free(self); }
+ TxCreationKeys(TxCreationKeys&& o) : self(o.self) { memset(&o, 0, sizeof(TxCreationKeys)); }
+ TxCreationKeys(LDKTxCreationKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxCreationKeys)); }
+ operator LDKTxCreationKeys() { LDKTxCreationKeys res = self; memset(&self, 0, sizeof(LDKTxCreationKeys)); return res; }
+ LDKTxCreationKeys* operator &() { return &self; }
+ LDKTxCreationKeys* operator ->() { return &self; }
+ const LDKTxCreationKeys* operator &() const { return &self; }
+ const LDKTxCreationKeys* operator ->() const { return &self; }
+};
+class PreCalculatedTxCreationKeys {
+private:
+ LDKPreCalculatedTxCreationKeys self;
+public:
+ PreCalculatedTxCreationKeys(const PreCalculatedTxCreationKeys&) = delete;
+ ~PreCalculatedTxCreationKeys() { PreCalculatedTxCreationKeys_free(self); }
+ PreCalculatedTxCreationKeys(PreCalculatedTxCreationKeys&& o) : self(o.self) { memset(&o, 0, sizeof(PreCalculatedTxCreationKeys)); }
+ PreCalculatedTxCreationKeys(LDKPreCalculatedTxCreationKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPreCalculatedTxCreationKeys)); }
+ operator LDKPreCalculatedTxCreationKeys() { LDKPreCalculatedTxCreationKeys res = self; memset(&self, 0, sizeof(LDKPreCalculatedTxCreationKeys)); return res; }
+ LDKPreCalculatedTxCreationKeys* operator &() { return &self; }
+ LDKPreCalculatedTxCreationKeys* operator ->() { return &self; }
+ const LDKPreCalculatedTxCreationKeys* operator &() const { return &self; }
+ const LDKPreCalculatedTxCreationKeys* operator ->() const { return &self; }
+};
+class ChannelPublicKeys {
+private:
+ LDKChannelPublicKeys self;
+public:
+ ChannelPublicKeys(const ChannelPublicKeys&) = delete;
+ ~ChannelPublicKeys() { ChannelPublicKeys_free(self); }
+ ChannelPublicKeys(ChannelPublicKeys&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelPublicKeys)); }
+ ChannelPublicKeys(LDKChannelPublicKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelPublicKeys)); }
+ operator LDKChannelPublicKeys() { LDKChannelPublicKeys res = self; memset(&self, 0, sizeof(LDKChannelPublicKeys)); return res; }
+ LDKChannelPublicKeys* operator &() { return &self; }
+ LDKChannelPublicKeys* operator ->() { return &self; }
+ const LDKChannelPublicKeys* operator &() const { return &self; }
+ const LDKChannelPublicKeys* operator ->() const { return &self; }
+};
+class HTLCOutputInCommitment {
+private:
+ LDKHTLCOutputInCommitment self;
+public:
+ HTLCOutputInCommitment(const HTLCOutputInCommitment&) = delete;
+ ~HTLCOutputInCommitment() { HTLCOutputInCommitment_free(self); }
+ HTLCOutputInCommitment(HTLCOutputInCommitment&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCOutputInCommitment)); }
+ HTLCOutputInCommitment(LDKHTLCOutputInCommitment&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCOutputInCommitment)); }
+ operator LDKHTLCOutputInCommitment() { LDKHTLCOutputInCommitment res = self; memset(&self, 0, sizeof(LDKHTLCOutputInCommitment)); return res; }
+ LDKHTLCOutputInCommitment* operator &() { return &self; }
+ LDKHTLCOutputInCommitment* operator ->() { return &self; }
+ const LDKHTLCOutputInCommitment* operator &() const { return &self; }
+ const LDKHTLCOutputInCommitment* operator ->() const { return &self; }
+};
+class LocalCommitmentTransaction {
+private:
+ LDKLocalCommitmentTransaction self;
+public:
+ LocalCommitmentTransaction(const LocalCommitmentTransaction&) = delete;
+ ~LocalCommitmentTransaction() { LocalCommitmentTransaction_free(self); }
+ LocalCommitmentTransaction(LocalCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(LocalCommitmentTransaction)); }
+ LocalCommitmentTransaction(LDKLocalCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLocalCommitmentTransaction)); }
+ operator LDKLocalCommitmentTransaction() { LDKLocalCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKLocalCommitmentTransaction)); return res; }
+ LDKLocalCommitmentTransaction* operator &() { return &self; }
+ LDKLocalCommitmentTransaction* operator ->() { return &self; }
+ const LDKLocalCommitmentTransaction* operator &() const { return &self; }
+ const LDKLocalCommitmentTransaction* operator ->() const { return &self; }
+};
+class InitFeatures {
+private:
+ LDKInitFeatures self;
+public:
+ InitFeatures(const InitFeatures&) = delete;
+ ~InitFeatures() { InitFeatures_free(self); }
+ InitFeatures(InitFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InitFeatures)); }
+ InitFeatures(LDKInitFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInitFeatures)); }
+ operator LDKInitFeatures() { LDKInitFeatures res = self; memset(&self, 0, sizeof(LDKInitFeatures)); return res; }
+ LDKInitFeatures* operator &() { return &self; }
+ LDKInitFeatures* operator ->() { return &self; }
+ const LDKInitFeatures* operator &() const { return &self; }
+ const LDKInitFeatures* operator ->() const { return &self; }
+};
+class NodeFeatures {
+private:
+ LDKNodeFeatures self;
+public:
+ NodeFeatures(const NodeFeatures&) = delete;
+ ~NodeFeatures() { NodeFeatures_free(self); }
+ NodeFeatures(NodeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(NodeFeatures)); }
+ NodeFeatures(LDKNodeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeFeatures)); }
+ operator LDKNodeFeatures() { LDKNodeFeatures res = self; memset(&self, 0, sizeof(LDKNodeFeatures)); return res; }
+ LDKNodeFeatures* operator &() { return &self; }
+ LDKNodeFeatures* operator ->() { return &self; }
+ const LDKNodeFeatures* operator &() const { return &self; }
+ const LDKNodeFeatures* operator ->() const { return &self; }
+};
+class ChannelFeatures {
+private:
+ LDKChannelFeatures self;
+public:
+ ChannelFeatures(const ChannelFeatures&) = delete;
+ ~ChannelFeatures() { ChannelFeatures_free(self); }
+ ChannelFeatures(ChannelFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelFeatures)); }
+ ChannelFeatures(LDKChannelFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelFeatures)); }
+ operator LDKChannelFeatures() { LDKChannelFeatures res = self; memset(&self, 0, sizeof(LDKChannelFeatures)); return res; }
+ LDKChannelFeatures* operator &() { return &self; }
+ LDKChannelFeatures* operator ->() { return &self; }
+ const LDKChannelFeatures* operator &() const { return &self; }
+ const LDKChannelFeatures* operator ->() const { return &self; }
+};
+class RouteHop {
+private:
+ LDKRouteHop self;
+public:
+ RouteHop(const RouteHop&) = delete;
+ ~RouteHop() { RouteHop_free(self); }
+ RouteHop(RouteHop&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHop)); }
+ RouteHop(LDKRouteHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHop)); }
+ operator LDKRouteHop() { LDKRouteHop res = self; memset(&self, 0, sizeof(LDKRouteHop)); return res; }
+ LDKRouteHop* operator &() { return &self; }
+ LDKRouteHop* operator ->() { return &self; }
+ const LDKRouteHop* operator &() const { return &self; }
+ const LDKRouteHop* operator ->() const { return &self; }
+};
+class Route {
+private:
+ LDKRoute self;
+public:
+ Route(const Route&) = delete;
+ ~Route() { Route_free(self); }
+ Route(Route&& o) : self(o.self) { memset(&o, 0, sizeof(Route)); }
+ Route(LDKRoute&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoute)); }
+ operator LDKRoute() { LDKRoute res = self; memset(&self, 0, sizeof(LDKRoute)); return res; }
+ LDKRoute* operator &() { return &self; }
+ LDKRoute* operator ->() { return &self; }
+ const LDKRoute* operator &() const { return &self; }
+ const LDKRoute* operator ->() const { return &self; }
+};
+class RouteHint {
+private:
+ LDKRouteHint self;
+public:
+ RouteHint(const RouteHint&) = delete;
+ ~RouteHint() { RouteHint_free(self); }
+ RouteHint(RouteHint&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHint)); }
+ RouteHint(LDKRouteHint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHint)); }
+ operator LDKRouteHint() { LDKRouteHint res = self; memset(&self, 0, sizeof(LDKRouteHint)); return res; }
+ LDKRouteHint* operator &() { return &self; }
+ LDKRouteHint* operator ->() { return &self; }
+ const LDKRouteHint* operator &() const { return &self; }
+ const LDKRouteHint* operator ->() const { return &self; }
+};
+class NetworkGraph {
+private:
+ LDKNetworkGraph self;
+public:
+ NetworkGraph(const NetworkGraph&) = delete;
+ ~NetworkGraph() { NetworkGraph_free(self); }
+ NetworkGraph(NetworkGraph&& o) : self(o.self) { memset(&o, 0, sizeof(NetworkGraph)); }
+ NetworkGraph(LDKNetworkGraph&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetworkGraph)); }
+ operator LDKNetworkGraph() { LDKNetworkGraph res = self; memset(&self, 0, sizeof(LDKNetworkGraph)); return res; }
+ LDKNetworkGraph* operator &() { return &self; }
+ LDKNetworkGraph* operator ->() { return &self; }
+ const LDKNetworkGraph* operator &() const { return &self; }
+ const LDKNetworkGraph* operator ->() const { return &self; }
+};
+class LockedNetworkGraph {
+private:
+ LDKLockedNetworkGraph self;
+public:
+ LockedNetworkGraph(const LockedNetworkGraph&) = delete;
+ ~LockedNetworkGraph() { LockedNetworkGraph_free(self); }
+ LockedNetworkGraph(LockedNetworkGraph&& o) : self(o.self) { memset(&o, 0, sizeof(LockedNetworkGraph)); }
+ LockedNetworkGraph(LDKLockedNetworkGraph&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLockedNetworkGraph)); }
+ operator LDKLockedNetworkGraph() { LDKLockedNetworkGraph res = self; memset(&self, 0, sizeof(LDKLockedNetworkGraph)); return res; }
+ LDKLockedNetworkGraph* operator &() { return &self; }
+ LDKLockedNetworkGraph* operator ->() { return &self; }
+ const LDKLockedNetworkGraph* operator &() const { return &self; }
+ const LDKLockedNetworkGraph* operator ->() const { return &self; }
+};
+class NetGraphMsgHandler {
+private:
+ LDKNetGraphMsgHandler self;
+public:
+ NetGraphMsgHandler(const NetGraphMsgHandler&) = delete;
+ ~NetGraphMsgHandler() { NetGraphMsgHandler_free(self); }
+ NetGraphMsgHandler(NetGraphMsgHandler&& o) : self(o.self) { memset(&o, 0, sizeof(NetGraphMsgHandler)); }
+ NetGraphMsgHandler(LDKNetGraphMsgHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetGraphMsgHandler)); }
+ operator LDKNetGraphMsgHandler() { LDKNetGraphMsgHandler res = self; memset(&self, 0, sizeof(LDKNetGraphMsgHandler)); return res; }
+ LDKNetGraphMsgHandler* operator &() { return &self; }
+ LDKNetGraphMsgHandler* operator ->() { return &self; }
+ const LDKNetGraphMsgHandler* operator &() const { return &self; }
+ const LDKNetGraphMsgHandler* operator ->() const { return &self; }
+};
+class DirectionalChannelInfo {
+private:
+ LDKDirectionalChannelInfo self;
+public:
+ DirectionalChannelInfo(const DirectionalChannelInfo&) = delete;
+ ~DirectionalChannelInfo() { DirectionalChannelInfo_free(self); }
+ DirectionalChannelInfo(DirectionalChannelInfo&& o) : self(o.self) { memset(&o, 0, sizeof(DirectionalChannelInfo)); }
+ DirectionalChannelInfo(LDKDirectionalChannelInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDirectionalChannelInfo)); }
+ operator LDKDirectionalChannelInfo() { LDKDirectionalChannelInfo res = self; memset(&self, 0, sizeof(LDKDirectionalChannelInfo)); return res; }
+ LDKDirectionalChannelInfo* operator &() { return &self; }
+ LDKDirectionalChannelInfo* operator ->() { return &self; }
+ const LDKDirectionalChannelInfo* operator &() const { return &self; }
+ const LDKDirectionalChannelInfo* operator ->() const { return &self; }
+};
+class ChannelInfo {
+private:
+ LDKChannelInfo self;
+public:
+ ChannelInfo(const ChannelInfo&) = delete;
+ ~ChannelInfo() { ChannelInfo_free(self); }
+ ChannelInfo(ChannelInfo&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelInfo)); }
+ ChannelInfo(LDKChannelInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelInfo)); }
+ operator LDKChannelInfo() { LDKChannelInfo res = self; memset(&self, 0, sizeof(LDKChannelInfo)); return res; }
+ LDKChannelInfo* operator &() { return &self; }
+ LDKChannelInfo* operator ->() { return &self; }
+ const LDKChannelInfo* operator &() const { return &self; }
+ const LDKChannelInfo* operator ->() const { return &self; }
+};
+class RoutingFees {
+private:
+ LDKRoutingFees self;
+public:
+ RoutingFees(const RoutingFees&) = delete;
+ ~RoutingFees() { RoutingFees_free(self); }
+ RoutingFees(RoutingFees&& o) : self(o.self) { memset(&o, 0, sizeof(RoutingFees)); }
+ RoutingFees(LDKRoutingFees&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoutingFees)); }
+ operator LDKRoutingFees() { LDKRoutingFees res = self; memset(&self, 0, sizeof(LDKRoutingFees)); return res; }
+ LDKRoutingFees* operator &() { return &self; }
+ LDKRoutingFees* operator ->() { return &self; }
+ const LDKRoutingFees* operator &() const { return &self; }
+ const LDKRoutingFees* operator ->() const { return &self; }
+};
+class NodeAnnouncementInfo {
+private:
+ LDKNodeAnnouncementInfo self;
+public:
+ NodeAnnouncementInfo(const NodeAnnouncementInfo&) = delete;
+ ~NodeAnnouncementInfo() { NodeAnnouncementInfo_free(self); }
+ NodeAnnouncementInfo(NodeAnnouncementInfo&& o) : self(o.self) { memset(&o, 0, sizeof(NodeAnnouncementInfo)); }
+ NodeAnnouncementInfo(LDKNodeAnnouncementInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeAnnouncementInfo)); }
+ operator LDKNodeAnnouncementInfo() { LDKNodeAnnouncementInfo res = self; memset(&self, 0, sizeof(LDKNodeAnnouncementInfo)); return res; }
+ LDKNodeAnnouncementInfo* operator &() { return &self; }
+ LDKNodeAnnouncementInfo* operator ->() { return &self; }
+ const LDKNodeAnnouncementInfo* operator &() const { return &self; }
+ const LDKNodeAnnouncementInfo* operator ->() const { return &self; }
+};
+class NodeInfo {
+private:
+ LDKNodeInfo self;
+public:
+ NodeInfo(const NodeInfo&) = delete;
+ ~NodeInfo() { NodeInfo_free(self); }
+ NodeInfo(NodeInfo&& o) : self(o.self) { memset(&o, 0, sizeof(NodeInfo)); }
+ NodeInfo(LDKNodeInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeInfo)); }
+ operator LDKNodeInfo() { LDKNodeInfo res = self; memset(&self, 0, sizeof(LDKNodeInfo)); return res; }
+ LDKNodeInfo* operator &() { return &self; }
+ LDKNodeInfo* operator ->() { return &self; }
+ const LDKNodeInfo* operator &() const { return &self; }
+ const LDKNodeInfo* operator ->() const { return &self; }
+};
+class CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ {
+private:
+ LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ self;
+public:
+ CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(const CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&) = delete;
+ ~CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(self); }
+ CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); }
+ CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); }
+ operator LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); return res; }
+ LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() { return &self; }
+ LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() { return &self; }
+ const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() const { return &self; }
+ const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() const { return &self; }
+};
+class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+private:
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ self;
+public:
+ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(const CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&) = delete;
+ ~CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); }
+ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
+ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
+ operator LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return res; }
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() { return &self; }
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() { return &self; }
+ const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; }
+ const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; }
+};
+class CVec_CVec_RouteHopZZ {
+private:
+ LDKCVec_CVec_RouteHopZZ self;
+public:
+ CVec_CVec_RouteHopZZ(const CVec_CVec_RouteHopZZ&) = delete;
+ ~CVec_CVec_RouteHopZZ() { CVec_CVec_RouteHopZZ_free(self); }
+ CVec_CVec_RouteHopZZ(CVec_CVec_RouteHopZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_CVec_RouteHopZZ)); }
+ CVec_CVec_RouteHopZZ(LDKCVec_CVec_RouteHopZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); }
+ operator LDKCVec_CVec_RouteHopZZ() { LDKCVec_CVec_RouteHopZZ res = self; memset(&self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); return res; }
+ LDKCVec_CVec_RouteHopZZ* operator &() { return &self; }
+ LDKCVec_CVec_RouteHopZZ* operator ->() { return &self; }
+ const LDKCVec_CVec_RouteHopZZ* operator &() const { return &self; }
+ const LDKCVec_CVec_RouteHopZZ* operator ->() const { return &self; }
+};
+class CVec_HTLCOutputInCommitmentZ {
+private:
+ LDKCVec_HTLCOutputInCommitmentZ self;
+public:
+ CVec_HTLCOutputInCommitmentZ(const CVec_HTLCOutputInCommitmentZ&) = delete;
+ ~CVec_HTLCOutputInCommitmentZ() { CVec_HTLCOutputInCommitmentZ_free(self); }
+ CVec_HTLCOutputInCommitmentZ(CVec_HTLCOutputInCommitmentZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_HTLCOutputInCommitmentZ)); }
+ CVec_HTLCOutputInCommitmentZ(LDKCVec_HTLCOutputInCommitmentZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); }
+ operator LDKCVec_HTLCOutputInCommitmentZ() { LDKCVec_HTLCOutputInCommitmentZ res = self; memset(&self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); return res; }
+ LDKCVec_HTLCOutputInCommitmentZ* operator &() { return &self; }
+ LDKCVec_HTLCOutputInCommitmentZ* operator ->() { return &self; }
+ const LDKCVec_HTLCOutputInCommitmentZ* operator &() const { return &self; }
+ const LDKCVec_HTLCOutputInCommitmentZ* operator ->() const { return &self; }
+};
+class CResult_NoneMonitorUpdateErrorZ {
+private:
+ LDKCResult_NoneMonitorUpdateErrorZ self;
+public:
+ CResult_NoneMonitorUpdateErrorZ(const CResult_NoneMonitorUpdateErrorZ&) = delete;
+ ~CResult_NoneMonitorUpdateErrorZ() { CResult_NoneMonitorUpdateErrorZ_free(self); }
+ CResult_NoneMonitorUpdateErrorZ(CResult_NoneMonitorUpdateErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); }
+ CResult_NoneMonitorUpdateErrorZ(LDKCResult_NoneMonitorUpdateErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); }
+ operator LDKCResult_NoneMonitorUpdateErrorZ() { LDKCResult_NoneMonitorUpdateErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); return res; }
+ LDKCResult_NoneMonitorUpdateErrorZ* operator &() { return &self; }
+ LDKCResult_NoneMonitorUpdateErrorZ* operator ->() { return &self; }
+ const LDKCResult_NoneMonitorUpdateErrorZ* operator &() const { return &self; }
+ const LDKCResult_NoneMonitorUpdateErrorZ* operator ->() const { return &self; }
+};
+class C2Tuple_Txidu32Z {
+private:
+ LDKC2Tuple_Txidu32Z self;
+public:
+ C2Tuple_Txidu32Z(const C2Tuple_Txidu32Z&) = delete;
+ ~C2Tuple_Txidu32Z() { C2Tuple_Txidu32Z_free(self); }
+ C2Tuple_Txidu32Z(C2Tuple_Txidu32Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_Txidu32Z)); }
+ C2Tuple_Txidu32Z(LDKC2Tuple_Txidu32Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_Txidu32Z)); }
+ operator LDKC2Tuple_Txidu32Z() { LDKC2Tuple_Txidu32Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_Txidu32Z)); return res; }
+ LDKC2Tuple_Txidu32Z* operator &() { return &self; }
+ LDKC2Tuple_Txidu32Z* operator ->() { return &self; }
+ const LDKC2Tuple_Txidu32Z* operator &() const { return &self; }
+ const LDKC2Tuple_Txidu32Z* operator ->() const { return &self; }
+};
+class CResult_SignatureNoneZ {
+private:
+ LDKCResult_SignatureNoneZ self;
+public:
+ CResult_SignatureNoneZ(const CResult_SignatureNoneZ&) = delete;
+ ~CResult_SignatureNoneZ() { CResult_SignatureNoneZ_free(self); }
+ CResult_SignatureNoneZ(CResult_SignatureNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignatureNoneZ)); }
+ CResult_SignatureNoneZ(LDKCResult_SignatureNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignatureNoneZ)); }
+ operator LDKCResult_SignatureNoneZ() { LDKCResult_SignatureNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_SignatureNoneZ)); return res; }
+ LDKCResult_SignatureNoneZ* operator &() { return &self; }
+ LDKCResult_SignatureNoneZ* operator ->() { return &self; }
+ const LDKCResult_SignatureNoneZ* operator &() const { return &self; }
+ const LDKCResult_SignatureNoneZ* operator ->() const { return &self; }
+};
+class CVec_UpdateFailMalformedHTLCZ {
+private:
+ LDKCVec_UpdateFailMalformedHTLCZ self;
+public:
+ CVec_UpdateFailMalformedHTLCZ(const CVec_UpdateFailMalformedHTLCZ&) = delete;
+ ~CVec_UpdateFailMalformedHTLCZ() { CVec_UpdateFailMalformedHTLCZ_free(self); }
+ CVec_UpdateFailMalformedHTLCZ(CVec_UpdateFailMalformedHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); }
+ CVec_UpdateFailMalformedHTLCZ(LDKCVec_UpdateFailMalformedHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); }
+ operator LDKCVec_UpdateFailMalformedHTLCZ() { LDKCVec_UpdateFailMalformedHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); return res; }
+ LDKCVec_UpdateFailMalformedHTLCZ* operator &() { return &self; }
+ LDKCVec_UpdateFailMalformedHTLCZ* operator ->() { return &self; }
+ const LDKCVec_UpdateFailMalformedHTLCZ* operator &() const { return &self; }
+ const LDKCVec_UpdateFailMalformedHTLCZ* operator ->() const { return &self; }
+};
+class CResult_NoneAPIErrorZ {
+private:
+ LDKCResult_NoneAPIErrorZ self;
+public:
+ CResult_NoneAPIErrorZ(const CResult_NoneAPIErrorZ&) = delete;
+ ~CResult_NoneAPIErrorZ() { CResult_NoneAPIErrorZ_free(self); }
+ CResult_NoneAPIErrorZ(CResult_NoneAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneAPIErrorZ)); }
+ CResult_NoneAPIErrorZ(LDKCResult_NoneAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); }
+ operator LDKCResult_NoneAPIErrorZ() { LDKCResult_NoneAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); return res; }
+ LDKCResult_NoneAPIErrorZ* operator &() { return &self; }
+ LDKCResult_NoneAPIErrorZ* operator ->() { return &self; }
+ const LDKCResult_NoneAPIErrorZ* operator &() const { return &self; }
+ const LDKCResult_NoneAPIErrorZ* operator ->() const { return &self; }
+};
+class CVec_SpendableOutputDescriptorZ {
+private:
+ LDKCVec_SpendableOutputDescriptorZ self;
+public:
+ CVec_SpendableOutputDescriptorZ(const CVec_SpendableOutputDescriptorZ&) = delete;
+ ~CVec_SpendableOutputDescriptorZ() { CVec_SpendableOutputDescriptorZ_free(self); }
+ CVec_SpendableOutputDescriptorZ(CVec_SpendableOutputDescriptorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SpendableOutputDescriptorZ)); }
+ CVec_SpendableOutputDescriptorZ(LDKCVec_SpendableOutputDescriptorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); }
+ operator LDKCVec_SpendableOutputDescriptorZ() { LDKCVec_SpendableOutputDescriptorZ res = self; memset(&self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); return res; }
+ LDKCVec_SpendableOutputDescriptorZ* operator &() { return &self; }
+ LDKCVec_SpendableOutputDescriptorZ* operator ->() { return &self; }
+ const LDKCVec_SpendableOutputDescriptorZ* operator &() const { return &self; }
+ const LDKCVec_SpendableOutputDescriptorZ* operator ->() const { return &self; }
+};
+class C2Tuple_SignatureCVec_SignatureZZ {
+private:
+ LDKC2Tuple_SignatureCVec_SignatureZZ self;
+public:
+ C2Tuple_SignatureCVec_SignatureZZ(const C2Tuple_SignatureCVec_SignatureZZ&) = delete;
+ ~C2Tuple_SignatureCVec_SignatureZZ() { C2Tuple_SignatureCVec_SignatureZZ_free(self); }
+ C2Tuple_SignatureCVec_SignatureZZ(C2Tuple_SignatureCVec_SignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); }
+ C2Tuple_SignatureCVec_SignatureZZ(LDKC2Tuple_SignatureCVec_SignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); }
+ operator LDKC2Tuple_SignatureCVec_SignatureZZ() { LDKC2Tuple_SignatureCVec_SignatureZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); return res; }
+ LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() { return &self; }
+ LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() { return &self; }
+ const LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() const { return &self; }
+ const LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() const { return &self; }
+};
+class CResult_CVec_SignatureZNoneZ {
+private:
+ LDKCResult_CVec_SignatureZNoneZ self;
+public:
+ CResult_CVec_SignatureZNoneZ(const CResult_CVec_SignatureZNoneZ&) = delete;
+ ~CResult_CVec_SignatureZNoneZ() { CResult_CVec_SignatureZNoneZ_free(self); }
+ CResult_CVec_SignatureZNoneZ(CResult_CVec_SignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_SignatureZNoneZ)); }
+ CResult_CVec_SignatureZNoneZ(LDKCResult_CVec_SignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); }
+ operator LDKCResult_CVec_SignatureZNoneZ() { LDKCResult_CVec_SignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); return res; }
+ LDKCResult_CVec_SignatureZNoneZ* operator &() { return &self; }
+ LDKCResult_CVec_SignatureZNoneZ* operator ->() { return &self; }
+ const LDKCResult_CVec_SignatureZNoneZ* operator &() const { return &self; }
+ const LDKCResult_CVec_SignatureZNoneZ* operator ->() const { return &self; }
+};
+class CResult_CVec_u8ZPeerHandleErrorZ {
+private:
+ LDKCResult_CVec_u8ZPeerHandleErrorZ self;
+public:
+ CResult_CVec_u8ZPeerHandleErrorZ(const CResult_CVec_u8ZPeerHandleErrorZ&) = delete;
+ ~CResult_CVec_u8ZPeerHandleErrorZ() { CResult_CVec_u8ZPeerHandleErrorZ_free(self); }
+ CResult_CVec_u8ZPeerHandleErrorZ(CResult_CVec_u8ZPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_u8ZPeerHandleErrorZ)); }
+ CResult_CVec_u8ZPeerHandleErrorZ(LDKCResult_CVec_u8ZPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); }
+ operator LDKCResult_CVec_u8ZPeerHandleErrorZ() { LDKCResult_CVec_u8ZPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); return res; }
+ LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() { return &self; }
+ LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() { return &self; }
+ const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; }
+ const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; }
+};
+class CResult_TxCreationKeysSecpErrorZ {
+private:
+ LDKCResult_TxCreationKeysSecpErrorZ self;
+public:
+ CResult_TxCreationKeysSecpErrorZ(const CResult_TxCreationKeysSecpErrorZ&) = delete;
+ ~CResult_TxCreationKeysSecpErrorZ() { CResult_TxCreationKeysSecpErrorZ_free(self); }
+ CResult_TxCreationKeysSecpErrorZ(CResult_TxCreationKeysSecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysSecpErrorZ)); }
+ CResult_TxCreationKeysSecpErrorZ(LDKCResult_TxCreationKeysSecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysSecpErrorZ)); }
+ operator LDKCResult_TxCreationKeysSecpErrorZ() { LDKCResult_TxCreationKeysSecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysSecpErrorZ)); return res; }
+ LDKCResult_TxCreationKeysSecpErrorZ* operator &() { return &self; }
+ LDKCResult_TxCreationKeysSecpErrorZ* operator ->() { return &self; }
+ const LDKCResult_TxCreationKeysSecpErrorZ* operator &() const { return &self; }
+ const LDKCResult_TxCreationKeysSecpErrorZ* operator ->() const { return &self; }
+};
+class CVec_RouteHopZ {
+private:
+ LDKCVec_RouteHopZ self;
+public:
+ CVec_RouteHopZ(const CVec_RouteHopZ&) = delete;
+ ~CVec_RouteHopZ() { CVec_RouteHopZ_free(self); }
+ CVec_RouteHopZ(CVec_RouteHopZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHopZ)); }
+ CVec_RouteHopZ(LDKCVec_RouteHopZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHopZ)); }
+ operator LDKCVec_RouteHopZ() { LDKCVec_RouteHopZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHopZ)); return res; }
+ LDKCVec_RouteHopZ* operator &() { return &self; }
+ LDKCVec_RouteHopZ* operator ->() { return &self; }
+ const LDKCVec_RouteHopZ* operator &() const { return &self; }
+ const LDKCVec_RouteHopZ* operator ->() const { return &self; }
+};
+class CVec_RouteHintZ {
+private:
+ LDKCVec_RouteHintZ self;
+public:
+ CVec_RouteHintZ(const CVec_RouteHintZ&) = delete;
+ ~CVec_RouteHintZ() { CVec_RouteHintZ_free(self); }
+ CVec_RouteHintZ(CVec_RouteHintZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHintZ)); }
+ CVec_RouteHintZ(LDKCVec_RouteHintZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHintZ)); }
+ operator LDKCVec_RouteHintZ() { LDKCVec_RouteHintZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHintZ)); return res; }
+ LDKCVec_RouteHintZ* operator &() { return &self; }
+ LDKCVec_RouteHintZ* operator ->() { return &self; }
+ const LDKCVec_RouteHintZ* operator &() const { return &self; }
+ const LDKCVec_RouteHintZ* operator ->() const { return &self; }
+};
+class CResult_RouteLightningErrorZ {
+private:
+ LDKCResult_RouteLightningErrorZ self;
+public:
+ CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete;
+ ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); }
+ CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); }
+ CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); }
+ operator LDKCResult_RouteLightningErrorZ() { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; }
+ LDKCResult_RouteLightningErrorZ* operator &() { return &self; }
+ LDKCResult_RouteLightningErrorZ* operator ->() { return &self; }
+ const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; }
+ const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; }
+};
+class C2Tuple_u64u64Z {
+private:
+ LDKC2Tuple_u64u64Z self;
+public:
+ C2Tuple_u64u64Z(const C2Tuple_u64u64Z&) = delete;
+ ~C2Tuple_u64u64Z() { C2Tuple_u64u64Z_free(self); }
+ C2Tuple_u64u64Z(C2Tuple_u64u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_u64u64Z)); }
+ C2Tuple_u64u64Z(LDKC2Tuple_u64u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_u64u64Z)); }
+ operator LDKC2Tuple_u64u64Z() { LDKC2Tuple_u64u64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_u64u64Z)); return res; }
+ LDKC2Tuple_u64u64Z* operator &() { return &self; }
+ LDKC2Tuple_u64u64Z* operator ->() { return &self; }
+ const LDKC2Tuple_u64u64Z* operator &() const { return &self; }
+ const LDKC2Tuple_u64u64Z* operator ->() const { return &self; }
+};
+class CVec_MessageSendEventZ {
+private:
+ LDKCVec_MessageSendEventZ self;
+public:
+ CVec_MessageSendEventZ(const CVec_MessageSendEventZ&) = delete;
+ ~CVec_MessageSendEventZ() { CVec_MessageSendEventZ_free(self); }
+ CVec_MessageSendEventZ(CVec_MessageSendEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MessageSendEventZ)); }
+ CVec_MessageSendEventZ(LDKCVec_MessageSendEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MessageSendEventZ)); }
+ operator LDKCVec_MessageSendEventZ() { LDKCVec_MessageSendEventZ res = self; memset(&self, 0, sizeof(LDKCVec_MessageSendEventZ)); return res; }
+ LDKCVec_MessageSendEventZ* operator &() { return &self; }
+ LDKCVec_MessageSendEventZ* operator ->() { return &self; }
+ const LDKCVec_MessageSendEventZ* operator &() const { return &self; }
+ const LDKCVec_MessageSendEventZ* operator ->() const { return &self; }
+};
+class C2Tuple_HTLCOutputInCommitmentSignatureZ {
+private:
+ LDKC2Tuple_HTLCOutputInCommitmentSignatureZ self;
+public:
+ C2Tuple_HTLCOutputInCommitmentSignatureZ(const C2Tuple_HTLCOutputInCommitmentSignatureZ&) = delete;
+ ~C2Tuple_HTLCOutputInCommitmentSignatureZ() { C2Tuple_HTLCOutputInCommitmentSignatureZ_free(self); }
+ C2Tuple_HTLCOutputInCommitmentSignatureZ(C2Tuple_HTLCOutputInCommitmentSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_HTLCOutputInCommitmentSignatureZ)); }
+ C2Tuple_HTLCOutputInCommitmentSignatureZ(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); }
+ operator LDKC2Tuple_HTLCOutputInCommitmentSignatureZ() { LDKC2Tuple_HTLCOutputInCommitmentSignatureZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); return res; }
+ LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() { return &self; }
+ LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() { return &self; }
+ const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() const { return &self; }
+ const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() const { return &self; }
+};
+class CVec_SignatureZ {
+private:
+ LDKCVec_SignatureZ self;
+public:
+ CVec_SignatureZ(const CVec_SignatureZ&) = delete;
+ ~CVec_SignatureZ() { CVec_SignatureZ_free(self); }
+ CVec_SignatureZ(CVec_SignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SignatureZ)); }
+ CVec_SignatureZ(LDKCVec_SignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SignatureZ)); }
+ operator LDKCVec_SignatureZ() { LDKCVec_SignatureZ res = self; memset(&self, 0, sizeof(LDKCVec_SignatureZ)); return res; }
+ LDKCVec_SignatureZ* operator &() { return &self; }
+ LDKCVec_SignatureZ* operator ->() { return &self; }
+ const LDKCVec_SignatureZ* operator &() const { return &self; }
+ const LDKCVec_SignatureZ* operator ->() const { return &self; }
+};
+class CVec_usizeZ {
+private:
+ LDKCVec_usizeZ self;
+public:
+ CVec_usizeZ(const CVec_usizeZ&) = delete;
+ ~CVec_usizeZ() { CVec_usizeZ_free(self); }
+ CVec_usizeZ(CVec_usizeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_usizeZ)); }
+ CVec_usizeZ(LDKCVec_usizeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_usizeZ)); }
+ operator LDKCVec_usizeZ() { LDKCVec_usizeZ res = self; memset(&self, 0, sizeof(LDKCVec_usizeZ)); return res; }
+ LDKCVec_usizeZ* operator &() { return &self; }
+ LDKCVec_usizeZ* operator ->() { return &self; }
+ const LDKCVec_usizeZ* operator &() const { return &self; }
+ const LDKCVec_usizeZ* operator ->() const { return &self; }
+};
+class C2Tuple_Scriptu64Z {
+private:
+ LDKC2Tuple_Scriptu64Z self;
+public:
+ C2Tuple_Scriptu64Z(const C2Tuple_Scriptu64Z&) = delete;
+ ~C2Tuple_Scriptu64Z() { C2Tuple_Scriptu64Z_free(self); }
+ C2Tuple_Scriptu64Z(C2Tuple_Scriptu64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_Scriptu64Z)); }
+ C2Tuple_Scriptu64Z(LDKC2Tuple_Scriptu64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_Scriptu64Z)); }
+ operator LDKC2Tuple_Scriptu64Z() { LDKC2Tuple_Scriptu64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_Scriptu64Z)); return res; }
+ LDKC2Tuple_Scriptu64Z* operator &() { return &self; }
+ LDKC2Tuple_Scriptu64Z* operator ->() { return &self; }
+ const LDKC2Tuple_Scriptu64Z* operator &() const { return &self; }
+ const LDKC2Tuple_Scriptu64Z* operator ->() const { return &self; }
+};
+class CResult_NoneChannelMonitorUpdateErrZ {
+private:
+ LDKCResult_NoneChannelMonitorUpdateErrZ self;
+public:
+ CResult_NoneChannelMonitorUpdateErrZ(const CResult_NoneChannelMonitorUpdateErrZ&) = delete;
+ ~CResult_NoneChannelMonitorUpdateErrZ() { CResult_NoneChannelMonitorUpdateErrZ_free(self); }
+ CResult_NoneChannelMonitorUpdateErrZ(CResult_NoneChannelMonitorUpdateErrZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneChannelMonitorUpdateErrZ)); }
+ CResult_NoneChannelMonitorUpdateErrZ(LDKCResult_NoneChannelMonitorUpdateErrZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ)); }
+ operator LDKCResult_NoneChannelMonitorUpdateErrZ() { LDKCResult_NoneChannelMonitorUpdateErrZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ)); return res; }
+ LDKCResult_NoneChannelMonitorUpdateErrZ* operator &() { return &self; }
+ LDKCResult_NoneChannelMonitorUpdateErrZ* operator ->() { return &self; }
+ const LDKCResult_NoneChannelMonitorUpdateErrZ* operator &() const { return &self; }
+ const LDKCResult_NoneChannelMonitorUpdateErrZ* operator ->() const { return &self; }
+};
+class CVec_u64Z {
+private:
+ LDKCVec_u64Z self;
+public:
+ CVec_u64Z(const CVec_u64Z&) = delete;
+ ~CVec_u64Z() { CVec_u64Z_free(self); }
+ CVec_u64Z(CVec_u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u64Z)); }
+ CVec_u64Z(LDKCVec_u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u64Z)); }
+ operator LDKCVec_u64Z() { LDKCVec_u64Z res = self; memset(&self, 0, sizeof(LDKCVec_u64Z)); return res; }
+ LDKCVec_u64Z* operator &() { return &self; }
+ LDKCVec_u64Z* operator ->() { return &self; }
+ const LDKCVec_u64Z* operator &() const { return &self; }
+ const LDKCVec_u64Z* operator ->() const { return &self; }
+};
+class C2Tuple_OutPointScriptZ {
+private:
+ LDKC2Tuple_OutPointScriptZ self;
+public:
+ C2Tuple_OutPointScriptZ(const C2Tuple_OutPointScriptZ&) = delete;
+ ~C2Tuple_OutPointScriptZ() { C2Tuple_OutPointScriptZ_free(self); }
+ C2Tuple_OutPointScriptZ(C2Tuple_OutPointScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointScriptZ)); }
+ C2Tuple_OutPointScriptZ(LDKC2Tuple_OutPointScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); }
+ operator LDKC2Tuple_OutPointScriptZ() { LDKC2Tuple_OutPointScriptZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); return res; }
+ LDKC2Tuple_OutPointScriptZ* operator &() { return &self; }
+ LDKC2Tuple_OutPointScriptZ* operator ->() { return &self; }
+ const LDKC2Tuple_OutPointScriptZ* operator &() const { return &self; }
+ const LDKC2Tuple_OutPointScriptZ* operator ->() const { return &self; }
+};
+class CVec_ChannelMonitorZ {
+private:
+ LDKCVec_ChannelMonitorZ self;
+public:
+ CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete;
+ ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); }
+ CVec_ChannelMonitorZ(CVec_ChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); }
+ CVec_ChannelMonitorZ(LDKCVec_ChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelMonitorZ)); }
+ operator LDKCVec_ChannelMonitorZ() { LDKCVec_ChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelMonitorZ)); return res; }
+ LDKCVec_ChannelMonitorZ* operator &() { return &self; }
+ LDKCVec_ChannelMonitorZ* operator ->() { return &self; }
+ const LDKCVec_ChannelMonitorZ* operator &() const { return &self; }
+ const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; }
+};
+class CVec_UpdateFulfillHTLCZ {
+private:
+ LDKCVec_UpdateFulfillHTLCZ self;
+public:
+ CVec_UpdateFulfillHTLCZ(const CVec_UpdateFulfillHTLCZ&) = delete;
+ ~CVec_UpdateFulfillHTLCZ() { CVec_UpdateFulfillHTLCZ_free(self); }
+ CVec_UpdateFulfillHTLCZ(CVec_UpdateFulfillHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFulfillHTLCZ)); }
+ CVec_UpdateFulfillHTLCZ(LDKCVec_UpdateFulfillHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); }
+ operator LDKCVec_UpdateFulfillHTLCZ() { LDKCVec_UpdateFulfillHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); return res; }
+ LDKCVec_UpdateFulfillHTLCZ* operator &() { return &self; }
+ LDKCVec_UpdateFulfillHTLCZ* operator ->() { return &self; }
+ const LDKCVec_UpdateFulfillHTLCZ* operator &() const { return &self; }
+ const LDKCVec_UpdateFulfillHTLCZ* operator ->() const { return &self; }
+};
+class CResult_C2Tuple_Scriptu64ZChainErrorZ {
+private:
+ LDKCResult_C2Tuple_Scriptu64ZChainErrorZ self;
+public:
+ CResult_C2Tuple_Scriptu64ZChainErrorZ(const CResult_C2Tuple_Scriptu64ZChainErrorZ&) = delete;
+ ~CResult_C2Tuple_Scriptu64ZChainErrorZ() { CResult_C2Tuple_Scriptu64ZChainErrorZ_free(self); }
+ CResult_C2Tuple_Scriptu64ZChainErrorZ(CResult_C2Tuple_Scriptu64ZChainErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_Scriptu64ZChainErrorZ)); }
+ CResult_C2Tuple_Scriptu64ZChainErrorZ(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ)); }
+ operator LDKCResult_C2Tuple_Scriptu64ZChainErrorZ() { LDKCResult_C2Tuple_Scriptu64ZChainErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ)); return res; }
+ LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator &() { return &self; }
+ LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator ->() { return &self; }
+ const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator &() const { return &self; }
+ const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator ->() const { return &self; }
+};
+class CVec_ChannelDetailsZ {
+private:
+ LDKCVec_ChannelDetailsZ self;
+public:
+ CVec_ChannelDetailsZ(const CVec_ChannelDetailsZ&) = delete;
+ ~CVec_ChannelDetailsZ() { CVec_ChannelDetailsZ_free(self); }
+ CVec_ChannelDetailsZ(CVec_ChannelDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelDetailsZ)); }
+ CVec_ChannelDetailsZ(LDKCVec_ChannelDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelDetailsZ)); }
+ operator LDKCVec_ChannelDetailsZ() { LDKCVec_ChannelDetailsZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelDetailsZ)); return res; }
+ LDKCVec_ChannelDetailsZ* operator &() { return &self; }
+ LDKCVec_ChannelDetailsZ* operator ->() { return &self; }
+ const LDKCVec_ChannelDetailsZ* operator &() const { return &self; }
+ const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; }
+};
+class CResult_boolLightningErrorZ {
+private:
+ LDKCResult_boolLightningErrorZ self;
+public:
+ CResult_boolLightningErrorZ(const CResult_boolLightningErrorZ&) = delete;
+ ~CResult_boolLightningErrorZ() { CResult_boolLightningErrorZ_free(self); }
+ CResult_boolLightningErrorZ(CResult_boolLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); }
+ CResult_boolLightningErrorZ(LDKCResult_boolLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolLightningErrorZ)); }
+ operator LDKCResult_boolLightningErrorZ() { LDKCResult_boolLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolLightningErrorZ)); return res; }
+ LDKCResult_boolLightningErrorZ* operator &() { return &self; }
+ LDKCResult_boolLightningErrorZ* operator ->() { return &self; }
+ const LDKCResult_boolLightningErrorZ* operator &() const { return &self; }
+ const LDKCResult_boolLightningErrorZ* operator ->() const { return &self; }
+};
+class CVec_NetAddressZ {
+private:
+ LDKCVec_NetAddressZ self;
+public:
+ CVec_NetAddressZ(const CVec_NetAddressZ&) = delete;
+ ~CVec_NetAddressZ() { CVec_NetAddressZ_free(self); }
+ CVec_NetAddressZ(CVec_NetAddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NetAddressZ)); }
+ CVec_NetAddressZ(LDKCVec_NetAddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NetAddressZ)); }
+ operator LDKCVec_NetAddressZ() { LDKCVec_NetAddressZ res = self; memset(&self, 0, sizeof(LDKCVec_NetAddressZ)); return res; }
+ LDKCVec_NetAddressZ* operator &() { return &self; }
+ LDKCVec_NetAddressZ* operator ->() { return &self; }
+ const LDKCVec_NetAddressZ* operator &() const { return &self; }
+ const LDKCVec_NetAddressZ* operator ->() const { return &self; }
+};
+class CVec_UpdateFailHTLCZ {
+private:
+ LDKCVec_UpdateFailHTLCZ self;
+public:
+ CVec_UpdateFailHTLCZ(const CVec_UpdateFailHTLCZ&) = delete;
+ ~CVec_UpdateFailHTLCZ() { CVec_UpdateFailHTLCZ_free(self); }
+ CVec_UpdateFailHTLCZ(CVec_UpdateFailHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); }
+ CVec_UpdateFailHTLCZ(LDKCVec_UpdateFailHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); }
+ operator LDKCVec_UpdateFailHTLCZ() { LDKCVec_UpdateFailHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); return res; }
+ LDKCVec_UpdateFailHTLCZ* operator &() { return &self; }
+ LDKCVec_UpdateFailHTLCZ* operator ->() { return &self; }
+ const LDKCVec_UpdateFailHTLCZ* operator &() const { return &self; }
+ const LDKCVec_UpdateFailHTLCZ* operator ->() const { return &self; }
+};
+class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
+private:
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ self;
+public:
+ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(const C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&) = delete;
+ ~C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ() { C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(self); }
+ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); }
+ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); }
+ operator LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ() { LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); return res; }
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() { return &self; }
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() { return &self; }
+ const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() const { return &self; }
+ const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() const { return &self; }
+};
+class CVec_MonitorEventZ {
+private:
+ LDKCVec_MonitorEventZ self;
+public:
+ CVec_MonitorEventZ(const CVec_MonitorEventZ&) = delete;
+ ~CVec_MonitorEventZ() { CVec_MonitorEventZ_free(self); }
+ CVec_MonitorEventZ(CVec_MonitorEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MonitorEventZ)); }
+ CVec_MonitorEventZ(LDKCVec_MonitorEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MonitorEventZ)); }
+ operator LDKCVec_MonitorEventZ() { LDKCVec_MonitorEventZ res = self; memset(&self, 0, sizeof(LDKCVec_MonitorEventZ)); return res; }
+ LDKCVec_MonitorEventZ* operator &() { return &self; }
+ LDKCVec_MonitorEventZ* operator ->() { return &self; }
+ const LDKCVec_MonitorEventZ* operator &() const { return &self; }
+ const LDKCVec_MonitorEventZ* operator ->() const { return &self; }
+};
+class CVec_UpdateAddHTLCZ {
+private:
+ LDKCVec_UpdateAddHTLCZ self;
+public:
+ CVec_UpdateAddHTLCZ(const CVec_UpdateAddHTLCZ&) = delete;
+ ~CVec_UpdateAddHTLCZ() { CVec_UpdateAddHTLCZ_free(self); }
+ CVec_UpdateAddHTLCZ(CVec_UpdateAddHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateAddHTLCZ)); }
+ CVec_UpdateAddHTLCZ(LDKCVec_UpdateAddHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateAddHTLCZ)); }
+ operator LDKCVec_UpdateAddHTLCZ() { LDKCVec_UpdateAddHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateAddHTLCZ)); return res; }
+ LDKCVec_UpdateAddHTLCZ* operator &() { return &self; }
+ LDKCVec_UpdateAddHTLCZ* operator ->() { return &self; }
+ const LDKCVec_UpdateAddHTLCZ* operator &() const { return &self; }
+ const LDKCVec_UpdateAddHTLCZ* operator ->() const { return &self; }
+};
+class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+private:
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ self;
+public:
+ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(const CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&) = delete;
+ ~CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); }
+ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); }
+ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); }
+ operator LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return res; }
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() { return &self; }
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() { return &self; }
+ const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() const { return &self; }
+ const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() const { return &self; }
+};
+class CVec_PublicKeyZ {
+private:
+ LDKCVec_PublicKeyZ self;
+public:
+ CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete;
+ ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); }
+ CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); }
+ CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); }
+ operator LDKCVec_PublicKeyZ() { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; }
+ LDKCVec_PublicKeyZ* operator &() { return &self; }
+ LDKCVec_PublicKeyZ* operator ->() { return &self; }
+ const LDKCVec_PublicKeyZ* operator &() const { return &self; }
+ const LDKCVec_PublicKeyZ* operator ->() const { return &self; }
+};
+class CResult_NonePeerHandleErrorZ {
+private:
+ LDKCResult_NonePeerHandleErrorZ self;
+public:
+ CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete;
+ ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); }
+ CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); }
+ CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); }
+ operator LDKCResult_NonePeerHandleErrorZ() { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; }
+ LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; }
+ LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; }
+ const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; }
+ const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; }
+};
+class CVec_NodeAnnouncementZ {
+private:
+ LDKCVec_NodeAnnouncementZ self;
+public:
+ CVec_NodeAnnouncementZ(const CVec_NodeAnnouncementZ&) = delete;
+ ~CVec_NodeAnnouncementZ() { CVec_NodeAnnouncementZ_free(self); }
+ CVec_NodeAnnouncementZ(CVec_NodeAnnouncementZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NodeAnnouncementZ)); }
+ CVec_NodeAnnouncementZ(LDKCVec_NodeAnnouncementZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NodeAnnouncementZ)); }
+ operator LDKCVec_NodeAnnouncementZ() { LDKCVec_NodeAnnouncementZ res = self; memset(&self, 0, sizeof(LDKCVec_NodeAnnouncementZ)); return res; }
+ LDKCVec_NodeAnnouncementZ* operator &() { return &self; }
+ LDKCVec_NodeAnnouncementZ* operator ->() { return &self; }
+ const LDKCVec_NodeAnnouncementZ* operator &() const { return &self; }
+ const LDKCVec_NodeAnnouncementZ* operator ->() const { return &self; }
+};
+class CResult_boolPeerHandleErrorZ {
+private:
+ LDKCResult_boolPeerHandleErrorZ self;
+public:
+ CResult_boolPeerHandleErrorZ(const CResult_boolPeerHandleErrorZ&) = delete;
+ ~CResult_boolPeerHandleErrorZ() { CResult_boolPeerHandleErrorZ_free(self); }
+ CResult_boolPeerHandleErrorZ(CResult_boolPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); }
+ CResult_boolPeerHandleErrorZ(LDKCResult_boolPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); }
+ operator LDKCResult_boolPeerHandleErrorZ() { LDKCResult_boolPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); return res; }
+ LDKCResult_boolPeerHandleErrorZ* operator &() { return &self; }
+ LDKCResult_boolPeerHandleErrorZ* operator ->() { return &self; }
+ const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; }
+ const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; }
+};
+class CResult_SecretKeySecpErrorZ {
+private:
+ LDKCResult_SecretKeySecpErrorZ self;
+public:
+ CResult_SecretKeySecpErrorZ(const CResult_SecretKeySecpErrorZ&) = delete;
+ ~CResult_SecretKeySecpErrorZ() { CResult_SecretKeySecpErrorZ_free(self); }
+ CResult_SecretKeySecpErrorZ(CResult_SecretKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SecretKeySecpErrorZ)); }
+ CResult_SecretKeySecpErrorZ(LDKCResult_SecretKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); }
+ operator LDKCResult_SecretKeySecpErrorZ() { LDKCResult_SecretKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); return res; }
+ LDKCResult_SecretKeySecpErrorZ* operator &() { return &self; }
+ LDKCResult_SecretKeySecpErrorZ* operator ->() { return &self; }
+ const LDKCResult_SecretKeySecpErrorZ* operator &() const { return &self; }
+ const LDKCResult_SecretKeySecpErrorZ* operator ->() const { return &self; }
+};
+class CVec_TransactionZ {
+private:
+ LDKCVec_TransactionZ self;
+public:
+ CVec_TransactionZ(const CVec_TransactionZ&) = delete;
+ ~CVec_TransactionZ() { CVec_TransactionZ_free(self); }
+ CVec_TransactionZ(CVec_TransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TransactionZ)); }
+ CVec_TransactionZ(LDKCVec_TransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TransactionZ)); }
+ operator LDKCVec_TransactionZ() { LDKCVec_TransactionZ res = self; memset(&self, 0, sizeof(LDKCVec_TransactionZ)); return res; }
+ LDKCVec_TransactionZ* operator &() { return &self; }
+ LDKCVec_TransactionZ* operator ->() { return &self; }
+ const LDKCVec_TransactionZ* operator &() const { return &self; }
+ const LDKCVec_TransactionZ* operator ->() const { return &self; }
+};
+class CResult_NonePaymentSendFailureZ {
+private:
+ LDKCResult_NonePaymentSendFailureZ self;
+public:
+ CResult_NonePaymentSendFailureZ(const CResult_NonePaymentSendFailureZ&) = delete;
+ ~CResult_NonePaymentSendFailureZ() { CResult_NonePaymentSendFailureZ_free(self); }
+ CResult_NonePaymentSendFailureZ(CResult_NonePaymentSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); }
+ CResult_NonePaymentSendFailureZ(LDKCResult_NonePaymentSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); }
+ operator LDKCResult_NonePaymentSendFailureZ() { LDKCResult_NonePaymentSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); return res; }
+ LDKCResult_NonePaymentSendFailureZ* operator &() { return &self; }
+ LDKCResult_NonePaymentSendFailureZ* operator ->() { return &self; }
+ const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; }
+ const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; }
+};
+class CVec_EventZ {
+private:
+ LDKCVec_EventZ self;
+public:
+ CVec_EventZ(const CVec_EventZ&) = delete;
+ ~CVec_EventZ() { CVec_EventZ_free(self); }
+ CVec_EventZ(CVec_EventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_EventZ)); }
+ CVec_EventZ(LDKCVec_EventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_EventZ)); }
+ operator LDKCVec_EventZ() { LDKCVec_EventZ res = self; memset(&self, 0, sizeof(LDKCVec_EventZ)); return res; }
+ LDKCVec_EventZ* operator &() { return &self; }
+ LDKCVec_EventZ* operator ->() { return &self; }
+ const LDKCVec_EventZ* operator &() const { return &self; }
+ const LDKCVec_EventZ* operator ->() const { return &self; }
+};
+class CVec_u8Z {
+private:
+ LDKCVec_u8Z self;
+public:
+ CVec_u8Z(const CVec_u8Z&) = delete;
+ ~CVec_u8Z() { CVec_u8Z_free(self); }
+ CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); }
+ CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); }
+ operator LDKCVec_u8Z() { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; }
+ LDKCVec_u8Z* operator &() { return &self; }
+ LDKCVec_u8Z* operator ->() { return &self; }
+ const LDKCVec_u8Z* operator &() const { return &self; }
+ const LDKCVec_u8Z* operator ->() const { return &self; }
+};
+class CResult_PublicKeySecpErrorZ {
+private:
+ LDKCResult_PublicKeySecpErrorZ self;
+public:
+ CResult_PublicKeySecpErrorZ(const CResult_PublicKeySecpErrorZ&) = delete;
+ ~CResult_PublicKeySecpErrorZ() { CResult_PublicKeySecpErrorZ_free(self); }
+ CResult_PublicKeySecpErrorZ(CResult_PublicKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PublicKeySecpErrorZ)); }
+ CResult_PublicKeySecpErrorZ(LDKCResult_PublicKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); }
+ operator LDKCResult_PublicKeySecpErrorZ() { LDKCResult_PublicKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); return res; }
+ LDKCResult_PublicKeySecpErrorZ* operator &() { return &self; }
+ LDKCResult_PublicKeySecpErrorZ* operator ->() { return &self; }
+ const LDKCResult_PublicKeySecpErrorZ* operator &() const { return &self; }
+ const LDKCResult_PublicKeySecpErrorZ* operator ->() const { return &self; }
+};
+}
--- /dev/null
+#if defined(__GNUC__)
+#define MUST_USE_STRUCT __attribute__((warn_unused))
+#else
+#define MUST_USE_STRUCT
+#endif
+#if defined(__GNUC__)
+#define MUST_USE_RES __attribute__((warn_unused_result))
+#else
+#define MUST_USE_RES
+#endif
+struct nativeChannelHandshakeConfigOpaque;
+typedef struct nativeChannelHandshakeConfigOpaque LDKnativeChannelHandshakeConfig;
+struct nativeChannelHandshakeLimitsOpaque;
+typedef struct nativeChannelHandshakeLimitsOpaque LDKnativeChannelHandshakeLimits;
+struct nativeChannelConfigOpaque;
+typedef struct nativeChannelConfigOpaque LDKnativeChannelConfig;
+struct nativeUserConfigOpaque;
+typedef struct nativeUserConfigOpaque LDKnativeUserConfig;
+struct nativeChainWatchedUtilOpaque;
+typedef struct nativeChainWatchedUtilOpaque LDKnativeChainWatchedUtil;
+struct nativeBlockNotifierOpaque;
+typedef struct nativeBlockNotifierOpaque LDKnativeBlockNotifier;
+struct nativeChainWatchInterfaceUtilOpaque;
+typedef struct nativeChainWatchInterfaceUtilOpaque LDKnativeChainWatchInterfaceUtil;
+struct nativeOutPointOpaque;
+typedef struct nativeOutPointOpaque LDKnativeOutPoint;
+struct LDKChannelKeys;
+typedef struct LDKChannelKeys LDKChannelKeys;
+struct nativeInMemoryChannelKeysOpaque;
+typedef struct nativeInMemoryChannelKeysOpaque LDKnativeInMemoryChannelKeys;
+struct nativeKeysManagerOpaque;
+typedef struct nativeKeysManagerOpaque LDKnativeKeysManager;
+struct nativeChannelManagerOpaque;
+typedef struct nativeChannelManagerOpaque LDKnativeChannelManager;
+struct nativeChannelDetailsOpaque;
+typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails;
+struct nativePaymentSendFailureOpaque;
+typedef struct nativePaymentSendFailureOpaque LDKnativePaymentSendFailure;
+struct nativeChannelManagerReadArgsOpaque;
+typedef struct nativeChannelManagerReadArgsOpaque LDKnativeChannelManagerReadArgs;
+struct nativeChannelMonitorUpdateOpaque;
+typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate;
+struct nativeMonitorUpdateErrorOpaque;
+typedef struct nativeMonitorUpdateErrorOpaque LDKnativeMonitorUpdateError;
+struct nativeMonitorEventOpaque;
+typedef struct nativeMonitorEventOpaque LDKnativeMonitorEvent;
+struct nativeHTLCUpdateOpaque;
+typedef struct nativeHTLCUpdateOpaque LDKnativeHTLCUpdate;
+struct nativeChannelMonitorOpaque;
+typedef struct nativeChannelMonitorOpaque LDKnativeChannelMonitor;
+struct nativeDecodeErrorOpaque;
+typedef struct nativeDecodeErrorOpaque LDKnativeDecodeError;
+struct nativeInitOpaque;
+typedef struct nativeInitOpaque LDKnativeInit;
+struct nativeErrorMessageOpaque;
+typedef struct nativeErrorMessageOpaque LDKnativeErrorMessage;
+struct nativePingOpaque;
+typedef struct nativePingOpaque LDKnativePing;
+struct nativePongOpaque;
+typedef struct nativePongOpaque LDKnativePong;
+struct nativeOpenChannelOpaque;
+typedef struct nativeOpenChannelOpaque LDKnativeOpenChannel;
+struct nativeAcceptChannelOpaque;
+typedef struct nativeAcceptChannelOpaque LDKnativeAcceptChannel;
+struct nativeFundingCreatedOpaque;
+typedef struct nativeFundingCreatedOpaque LDKnativeFundingCreated;
+struct nativeFundingSignedOpaque;
+typedef struct nativeFundingSignedOpaque LDKnativeFundingSigned;
+struct nativeFundingLockedOpaque;
+typedef struct nativeFundingLockedOpaque LDKnativeFundingLocked;
+struct nativeShutdownOpaque;
+typedef struct nativeShutdownOpaque LDKnativeShutdown;
+struct nativeClosingSignedOpaque;
+typedef struct nativeClosingSignedOpaque LDKnativeClosingSigned;
+struct nativeUpdateAddHTLCOpaque;
+typedef struct nativeUpdateAddHTLCOpaque LDKnativeUpdateAddHTLC;
+struct nativeUpdateFulfillHTLCOpaque;
+typedef struct nativeUpdateFulfillHTLCOpaque LDKnativeUpdateFulfillHTLC;
+struct nativeUpdateFailHTLCOpaque;
+typedef struct nativeUpdateFailHTLCOpaque LDKnativeUpdateFailHTLC;
+struct nativeUpdateFailMalformedHTLCOpaque;
+typedef struct nativeUpdateFailMalformedHTLCOpaque LDKnativeUpdateFailMalformedHTLC;
+struct nativeCommitmentSignedOpaque;
+typedef struct nativeCommitmentSignedOpaque LDKnativeCommitmentSigned;
+struct nativeRevokeAndACKOpaque;
+typedef struct nativeRevokeAndACKOpaque LDKnativeRevokeAndACK;
+struct nativeUpdateFeeOpaque;
+typedef struct nativeUpdateFeeOpaque LDKnativeUpdateFee;
+struct nativeDataLossProtectOpaque;
+typedef struct nativeDataLossProtectOpaque LDKnativeDataLossProtect;
+struct nativeChannelReestablishOpaque;
+typedef struct nativeChannelReestablishOpaque LDKnativeChannelReestablish;
+struct nativeAnnouncementSignaturesOpaque;
+typedef struct nativeAnnouncementSignaturesOpaque LDKnativeAnnouncementSignatures;
+struct nativeUnsignedNodeAnnouncementOpaque;
+typedef struct nativeUnsignedNodeAnnouncementOpaque LDKnativeUnsignedNodeAnnouncement;
+struct nativeNodeAnnouncementOpaque;
+typedef struct nativeNodeAnnouncementOpaque LDKnativeNodeAnnouncement;
+struct nativeUnsignedChannelAnnouncementOpaque;
+typedef struct nativeUnsignedChannelAnnouncementOpaque LDKnativeUnsignedChannelAnnouncement;
+struct nativeChannelAnnouncementOpaque;
+typedef struct nativeChannelAnnouncementOpaque LDKnativeChannelAnnouncement;
+struct nativeUnsignedChannelUpdateOpaque;
+typedef struct nativeUnsignedChannelUpdateOpaque LDKnativeUnsignedChannelUpdate;
+struct nativeChannelUpdateOpaque;
+typedef struct nativeChannelUpdateOpaque LDKnativeChannelUpdate;
+struct nativeLightningErrorOpaque;
+typedef struct nativeLightningErrorOpaque LDKnativeLightningError;
+struct nativeCommitmentUpdateOpaque;
+typedef struct nativeCommitmentUpdateOpaque LDKnativeCommitmentUpdate;
+struct nativeMessageHandlerOpaque;
+typedef struct nativeMessageHandlerOpaque LDKnativeMessageHandler;
+struct nativePeerHandleErrorOpaque;
+typedef struct nativePeerHandleErrorOpaque LDKnativePeerHandleError;
+struct nativePeerManagerOpaque;
+typedef struct nativePeerManagerOpaque LDKnativePeerManager;
+struct nativeTxCreationKeysOpaque;
+typedef struct nativeTxCreationKeysOpaque LDKnativeTxCreationKeys;
+struct nativePreCalculatedTxCreationKeysOpaque;
+typedef struct nativePreCalculatedTxCreationKeysOpaque LDKnativePreCalculatedTxCreationKeys;
+struct nativeChannelPublicKeysOpaque;
+typedef struct nativeChannelPublicKeysOpaque LDKnativeChannelPublicKeys;
+struct nativeHTLCOutputInCommitmentOpaque;
+typedef struct nativeHTLCOutputInCommitmentOpaque LDKnativeHTLCOutputInCommitment;
+struct nativeLocalCommitmentTransactionOpaque;
+typedef struct nativeLocalCommitmentTransactionOpaque LDKnativeLocalCommitmentTransaction;
+struct nativeInitFeaturesOpaque;
+typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures;
+struct nativeNodeFeaturesOpaque;
+typedef struct nativeNodeFeaturesOpaque LDKnativeNodeFeatures;
+struct nativeChannelFeaturesOpaque;
+typedef struct nativeChannelFeaturesOpaque LDKnativeChannelFeatures;
+struct nativeRouteHopOpaque;
+typedef struct nativeRouteHopOpaque LDKnativeRouteHop;
+struct nativeRouteOpaque;
+typedef struct nativeRouteOpaque LDKnativeRoute;
+struct nativeRouteHintOpaque;
+typedef struct nativeRouteHintOpaque LDKnativeRouteHint;
+struct nativeNetworkGraphOpaque;
+typedef struct nativeNetworkGraphOpaque LDKnativeNetworkGraph;
+struct nativeLockedNetworkGraphOpaque;
+typedef struct nativeLockedNetworkGraphOpaque LDKnativeLockedNetworkGraph;
+struct nativeNetGraphMsgHandlerOpaque;
+typedef struct nativeNetGraphMsgHandlerOpaque LDKnativeNetGraphMsgHandler;
+struct nativeDirectionalChannelInfoOpaque;
+typedef struct nativeDirectionalChannelInfoOpaque LDKnativeDirectionalChannelInfo;
+struct nativeChannelInfoOpaque;
+typedef struct nativeChannelInfoOpaque LDKnativeChannelInfo;
+struct nativeRoutingFeesOpaque;
+typedef struct nativeRoutingFeesOpaque LDKnativeRoutingFees;
+struct nativeNodeAnnouncementInfoOpaque;
+typedef struct nativeNodeAnnouncementInfoOpaque LDKnativeNodeAnnouncementInfo;
+struct nativeNodeInfoOpaque;
+typedef struct nativeNodeInfoOpaque LDKnativeNodeInfo;
--- /dev/null
+#[no_mangle]
+pub type CVec_SpendableOutputDescriptorZ = crate::c_types::CVecTempl<crate::chain::keysinterface::SpendableOutputDescriptor>;
+#[no_mangle]
+pub static CVec_SpendableOutputDescriptorZ_free: extern "C" fn(CVec_SpendableOutputDescriptorZ) = crate::c_types::CVecTempl_free::<crate::chain::keysinterface::SpendableOutputDescriptor>;
+
+#[no_mangle]
+pub type CVec_MessageSendEventZ = crate::c_types::CVecTempl<crate::util::events::MessageSendEvent>;
+#[no_mangle]
+pub static CVec_MessageSendEventZ_free: extern "C" fn(CVec_MessageSendEventZ) = crate::c_types::CVecTempl_free::<crate::util::events::MessageSendEvent>;
+
+#[no_mangle]
+pub type CVec_EventZ = crate::c_types::CVecTempl<crate::util::events::Event>;
+#[no_mangle]
+pub static CVec_EventZ_free: extern "C" fn(CVec_EventZ) = crate::c_types::CVecTempl_free::<crate::util::events::Event>;
+
+#[no_mangle]
+pub type C2Tuple_Txidu32Z = crate::c_types::C2TupleTempl<crate::c_types::ThirtyTwoBytes, u32>;
+#[no_mangle]
+pub static C2Tuple_Txidu32Z_free: extern "C" fn(C2Tuple_Txidu32Z) = crate::c_types::C2TupleTempl_free::<crate::c_types::ThirtyTwoBytes, u32>;
+#[no_mangle]
+pub extern "C" fn C2Tuple_Txidu32Z_new(a: crate::c_types::ThirtyTwoBytes, b: u32) -> C2Tuple_Txidu32Z {
+ C2Tuple_Txidu32Z {
+ a: Box::into_raw(Box::new(a)),
+ b: Box::into_raw(Box::new(b)),
+ }
+}
+
+#[no_mangle]
+pub type C2Tuple_Scriptu64Z = crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>;
+#[no_mangle]
+pub static C2Tuple_Scriptu64Z_free: extern "C" fn(C2Tuple_Scriptu64Z) = crate::c_types::C2TupleTempl_free::<crate::c_types::derived::CVec_u8Z, u64>;
+#[no_mangle]
+pub extern "C" fn C2Tuple_Scriptu64Z_new(a: crate::c_types::derived::CVec_u8Z, b: u64) -> C2Tuple_Scriptu64Z {
+ C2Tuple_Scriptu64Z {
+ a: Box::into_raw(Box::new(a)),
+ b: Box::into_raw(Box::new(b)),
+ }
+}
+
+#[no_mangle]
+pub type CResult_C2Tuple_Scriptu64ZChainErrorZ = crate::c_types::CResultTempl<crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>, crate::chain::chaininterface::ChainError>;
+#[no_mangle]
+pub static CResult_C2Tuple_Scriptu64ZChainErrorZ_free: extern "C" fn(CResult_C2Tuple_Scriptu64ZChainErrorZ) = crate::c_types::CResultTempl_free::<crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>, crate::chain::chaininterface::ChainError>;
+#[no_mangle]
+pub static CResult_C2Tuple_Scriptu64ZChainErrorZ_ok: extern "C" fn (C2Tuple_Scriptu64Z) -> CResult_C2Tuple_Scriptu64ZChainErrorZ =
+ crate::c_types::CResultTempl::<crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>, crate::chain::chaininterface::ChainError>::ok;
+
+#[no_mangle]
+pub static CResult_C2Tuple_Scriptu64ZChainErrorZ_err: extern "C" fn (crate::chain::chaininterface::ChainError) -> CResult_C2Tuple_Scriptu64ZChainErrorZ =
+ crate::c_types::CResultTempl::<crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>, crate::chain::chaininterface::ChainError>::err;
+
+#[no_mangle]
+pub type CVec_usizeZ = crate::c_types::CVecTempl<usize>;
+#[no_mangle]
+pub static CVec_usizeZ_free: extern "C" fn(CVec_usizeZ) = crate::c_types::CVecTempl_free::<usize>;
+
+#[no_mangle]
+pub type CVec_TransactionZ = crate::c_types::CVecTempl<crate::c_types::derived::CVec_u8Z>;
+#[no_mangle]
+pub static CVec_TransactionZ_free: extern "C" fn(CVec_TransactionZ) = crate::c_types::CVecTempl_free::<crate::c_types::derived::CVec_u8Z>;
+
+#[no_mangle]
+pub type C2Tuple_u64u64Z = crate::c_types::C2TupleTempl<u64, u64>;
+#[no_mangle]
+pub static C2Tuple_u64u64Z_free: extern "C" fn(C2Tuple_u64u64Z) = crate::c_types::C2TupleTempl_free::<u64, u64>;
+#[no_mangle]
+pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z {
+ C2Tuple_u64u64Z {
+ a: Box::into_raw(Box::new(a)),
+ b: Box::into_raw(Box::new(b)),
+ }
+}
+
+#[no_mangle]
+pub type CVec_HTLCOutputInCommitmentZ = crate::c_types::CVecTempl<crate::ln::chan_utils::HTLCOutputInCommitment>;
+#[no_mangle]
+pub static CVec_HTLCOutputInCommitmentZ_free: extern "C" fn(CVec_HTLCOutputInCommitmentZ) = crate::c_types::CVecTempl_free::<crate::ln::chan_utils::HTLCOutputInCommitment>;
+
+#[no_mangle]
+pub type CVec_SignatureZ = crate::c_types::CVecTempl<crate::c_types::Signature>;
+#[no_mangle]
+pub static CVec_SignatureZ_free: extern "C" fn(CVec_SignatureZ) = crate::c_types::CVecTempl_free::<crate::c_types::Signature>;
+
+#[no_mangle]
+pub type C2Tuple_SignatureCVec_SignatureZZ = crate::c_types::C2TupleTempl<crate::c_types::Signature, crate::c_types::CVecTempl<crate::c_types::Signature>>;
+#[no_mangle]
+pub static C2Tuple_SignatureCVec_SignatureZZ_free: extern "C" fn(C2Tuple_SignatureCVec_SignatureZZ) = crate::c_types::C2TupleTempl_free::<crate::c_types::Signature, crate::c_types::CVecTempl<crate::c_types::Signature>>;
+#[no_mangle]
+pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_new(a: crate::c_types::Signature, b: crate::c_types::derived::CVec_SignatureZ) -> C2Tuple_SignatureCVec_SignatureZZ {
+ C2Tuple_SignatureCVec_SignatureZZ {
+ a: Box::into_raw(Box::new(a)),
+ b: Box::into_raw(Box::new(b)),
+ }
+}
+
+#[no_mangle]
+pub type CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ = crate::c_types::CResultTempl<crate::c_types::C2TupleTempl<crate::c_types::Signature, crate::c_types::CVecTempl<crate::c_types::Signature>>, u8>;
+#[no_mangle]
+pub static CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free: extern "C" fn(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) = crate::c_types::CResultTempl_free::<crate::c_types::C2TupleTempl<crate::c_types::Signature, crate::c_types::CVecTempl<crate::c_types::Signature>>, u8>;
+#[no_mangle]
+pub static CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok: extern "C" fn (C2Tuple_SignatureCVec_SignatureZZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ =
+ crate::c_types::CResultTempl::<crate::c_types::C2TupleTempl<crate::c_types::Signature, crate::c_types::CVecTempl<crate::c_types::Signature>>, u8>::ok;
+
+#[no_mangle]
+pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+ crate::c_types::CResultTempl::err(0)
+}
+
+#[no_mangle]
+pub type CResult_SignatureNoneZ = crate::c_types::CResultTempl<crate::c_types::Signature, u8>;
+#[no_mangle]
+pub static CResult_SignatureNoneZ_free: extern "C" fn(CResult_SignatureNoneZ) = crate::c_types::CResultTempl_free::<crate::c_types::Signature, u8>;
+#[no_mangle]
+pub static CResult_SignatureNoneZ_ok: extern "C" fn (crate::c_types::Signature) -> CResult_SignatureNoneZ =
+ crate::c_types::CResultTempl::<crate::c_types::Signature, u8>::ok;
+
+#[no_mangle]
+pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ {
+ crate::c_types::CResultTempl::err(0)
+}
+
+#[no_mangle]
+pub type CResult_CVec_SignatureZNoneZ = crate::c_types::CResultTempl<crate::c_types::CVecTempl<crate::c_types::Signature>, u8>;
+#[no_mangle]
+pub static CResult_CVec_SignatureZNoneZ_free: extern "C" fn(CResult_CVec_SignatureZNoneZ) = crate::c_types::CResultTempl_free::<crate::c_types::CVecTempl<crate::c_types::Signature>, u8>;
+#[no_mangle]
+pub static CResult_CVec_SignatureZNoneZ_ok: extern "C" fn (CVec_SignatureZ) -> CResult_CVec_SignatureZNoneZ =
+ crate::c_types::CResultTempl::<crate::c_types::CVecTempl<crate::c_types::Signature>, u8>::ok;
+
+#[no_mangle]
+pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ {
+ crate::c_types::CResultTempl::err(0)
+}
+
+#[no_mangle]
+pub type CResult_NoneAPIErrorZ = crate::c_types::CResultTempl<u8, crate::util::errors::APIError>;
+#[no_mangle]
+pub static CResult_NoneAPIErrorZ_free: extern "C" fn(CResult_NoneAPIErrorZ) = crate::c_types::CResultTempl_free::<u8, crate::util::errors::APIError>;
+#[no_mangle]
+pub extern "C" fn CResult_NoneAPIErrorZ_ok() -> CResult_NoneAPIErrorZ {
+ crate::c_types::CResultTempl::ok(0)
+}
+
+#[no_mangle]
+pub static CResult_NoneAPIErrorZ_err: extern "C" fn (crate::util::errors::APIError) -> CResult_NoneAPIErrorZ =
+ crate::c_types::CResultTempl::<u8, crate::util::errors::APIError>::err;
+
+#[no_mangle]
+pub type CVec_ChannelDetailsZ = crate::c_types::CVecTempl<crate::ln::channelmanager::ChannelDetails>;
+#[no_mangle]
+pub static CVec_ChannelDetailsZ_free: extern "C" fn(CVec_ChannelDetailsZ) = crate::c_types::CVecTempl_free::<crate::ln::channelmanager::ChannelDetails>;
+
+#[no_mangle]
+pub type CResult_NonePaymentSendFailureZ = crate::c_types::CResultTempl<u8, crate::ln::channelmanager::PaymentSendFailure>;
+#[no_mangle]
+pub static CResult_NonePaymentSendFailureZ_free: extern "C" fn(CResult_NonePaymentSendFailureZ) = crate::c_types::CResultTempl_free::<u8, crate::ln::channelmanager::PaymentSendFailure>;
+#[no_mangle]
+pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ {
+ crate::c_types::CResultTempl::ok(0)
+}
+
+#[no_mangle]
+pub static CResult_NonePaymentSendFailureZ_err: extern "C" fn (crate::ln::channelmanager::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ =
+ crate::c_types::CResultTempl::<u8, crate::ln::channelmanager::PaymentSendFailure>::err;
+
+#[no_mangle]
+pub type CVec_NetAddressZ = crate::c_types::CVecTempl<crate::ln::msgs::NetAddress>;
+#[no_mangle]
+pub static CVec_NetAddressZ_free: extern "C" fn(CVec_NetAddressZ) = crate::c_types::CVecTempl_free::<crate::ln::msgs::NetAddress>;
+
+#[no_mangle]
+pub type CVec_ChannelMonitorZ = crate::c_types::CVecTempl<crate::ln::channelmonitor::ChannelMonitor>;
+#[no_mangle]
+pub static CVec_ChannelMonitorZ_free: extern "C" fn(CVec_ChannelMonitorZ) = crate::c_types::CVecTempl_free::<crate::ln::channelmonitor::ChannelMonitor>;
+
+#[no_mangle]
+pub type CResult_NoneChannelMonitorUpdateErrZ = crate::c_types::CResultTempl<u8, crate::ln::channelmonitor::ChannelMonitorUpdateErr>;
+#[no_mangle]
+pub static CResult_NoneChannelMonitorUpdateErrZ_free: extern "C" fn(CResult_NoneChannelMonitorUpdateErrZ) = crate::c_types::CResultTempl_free::<u8, crate::ln::channelmonitor::ChannelMonitorUpdateErr>;
+#[no_mangle]
+pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_ok() -> CResult_NoneChannelMonitorUpdateErrZ {
+ crate::c_types::CResultTempl::ok(0)
+}
+
+#[no_mangle]
+pub static CResult_NoneChannelMonitorUpdateErrZ_err: extern "C" fn (crate::ln::channelmonitor::ChannelMonitorUpdateErr) -> CResult_NoneChannelMonitorUpdateErrZ =
+ crate::c_types::CResultTempl::<u8, crate::ln::channelmonitor::ChannelMonitorUpdateErr>::err;
+
+#[no_mangle]
+pub type CVec_MonitorEventZ = crate::c_types::CVecTempl<crate::ln::channelmonitor::MonitorEvent>;
+#[no_mangle]
+pub static CVec_MonitorEventZ_free: extern "C" fn(CVec_MonitorEventZ) = crate::c_types::CVecTempl_free::<crate::ln::channelmonitor::MonitorEvent>;
+
+#[no_mangle]
+pub type CResult_NoneMonitorUpdateErrorZ = crate::c_types::CResultTempl<u8, crate::ln::channelmonitor::MonitorUpdateError>;
+#[no_mangle]
+pub static CResult_NoneMonitorUpdateErrorZ_free: extern "C" fn(CResult_NoneMonitorUpdateErrorZ) = crate::c_types::CResultTempl_free::<u8, crate::ln::channelmonitor::MonitorUpdateError>;
+#[no_mangle]
+pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_ok() -> CResult_NoneMonitorUpdateErrorZ {
+ crate::c_types::CResultTempl::ok(0)
+}
+
+#[no_mangle]
+pub static CResult_NoneMonitorUpdateErrorZ_err: extern "C" fn (crate::ln::channelmonitor::MonitorUpdateError) -> CResult_NoneMonitorUpdateErrorZ =
+ crate::c_types::CResultTempl::<u8, crate::ln::channelmonitor::MonitorUpdateError>::err;
+
+#[no_mangle]
+pub type C2Tuple_OutPointScriptZ = crate::c_types::C2TupleTempl<crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z>;
+#[no_mangle]
+pub static C2Tuple_OutPointScriptZ_free: extern "C" fn(C2Tuple_OutPointScriptZ) = crate::c_types::C2TupleTempl_free::<crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z>;
+#[no_mangle]
+pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ {
+ C2Tuple_OutPointScriptZ {
+ a: Box::into_raw(Box::new(a)),
+ b: Box::into_raw(Box::new(b)),
+ }
+}
+
+#[no_mangle]
+pub type CVec_UpdateAddHTLCZ = crate::c_types::CVecTempl<crate::ln::msgs::UpdateAddHTLC>;
+#[no_mangle]
+pub static CVec_UpdateAddHTLCZ_free: extern "C" fn(CVec_UpdateAddHTLCZ) = crate::c_types::CVecTempl_free::<crate::ln::msgs::UpdateAddHTLC>;
+
+#[no_mangle]
+pub type CVec_UpdateFulfillHTLCZ = crate::c_types::CVecTempl<crate::ln::msgs::UpdateFulfillHTLC>;
+#[no_mangle]
+pub static CVec_UpdateFulfillHTLCZ_free: extern "C" fn(CVec_UpdateFulfillHTLCZ) = crate::c_types::CVecTempl_free::<crate::ln::msgs::UpdateFulfillHTLC>;
+
+#[no_mangle]
+pub type CVec_UpdateFailHTLCZ = crate::c_types::CVecTempl<crate::ln::msgs::UpdateFailHTLC>;
+#[no_mangle]
+pub static CVec_UpdateFailHTLCZ_free: extern "C" fn(CVec_UpdateFailHTLCZ) = crate::c_types::CVecTempl_free::<crate::ln::msgs::UpdateFailHTLC>;
+
+#[no_mangle]
+pub type CVec_UpdateFailMalformedHTLCZ = crate::c_types::CVecTempl<crate::ln::msgs::UpdateFailMalformedHTLC>;
+#[no_mangle]
+pub static CVec_UpdateFailMalformedHTLCZ_free: extern "C" fn(CVec_UpdateFailMalformedHTLCZ) = crate::c_types::CVecTempl_free::<crate::ln::msgs::UpdateFailMalformedHTLC>;
+
+#[no_mangle]
+pub type CResult_boolLightningErrorZ = crate::c_types::CResultTempl<bool, crate::ln::msgs::LightningError>;
+#[no_mangle]
+pub static CResult_boolLightningErrorZ_free: extern "C" fn(CResult_boolLightningErrorZ) = crate::c_types::CResultTempl_free::<bool, crate::ln::msgs::LightningError>;
+#[no_mangle]
+pub static CResult_boolLightningErrorZ_ok: extern "C" fn (bool) -> CResult_boolLightningErrorZ =
+ crate::c_types::CResultTempl::<bool, crate::ln::msgs::LightningError>::ok;
+
+#[no_mangle]
+pub static CResult_boolLightningErrorZ_err: extern "C" fn (crate::ln::msgs::LightningError) -> CResult_boolLightningErrorZ =
+ crate::c_types::CResultTempl::<bool, crate::ln::msgs::LightningError>::err;
+
+#[no_mangle]
+pub type C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ = crate::c_types::C3TupleTempl<crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate>;
+#[no_mangle]
+pub static C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free: extern "C" fn(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) = crate::c_types::C3TupleTempl_free::<crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate>;
+#[no_mangle]
+pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a: crate::ln::msgs::ChannelAnnouncement, b: crate::ln::msgs::ChannelUpdate, c: crate::ln::msgs::ChannelUpdate) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
+ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
+ a: Box::into_raw(Box::new(a)),
+ b: Box::into_raw(Box::new(b)),
+ c: Box::into_raw(Box::new(c)),
+ }
+}
+
+#[no_mangle]
+pub type CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ = crate::c_types::CVecTempl<crate::c_types::C3TupleTempl<crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate>>;
+#[no_mangle]
+pub static CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free: extern "C" fn(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) = crate::c_types::CVecTempl_free::<crate::c_types::C3TupleTempl<crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate>>;
+
+#[no_mangle]
+pub type CVec_NodeAnnouncementZ = crate::c_types::CVecTempl<crate::ln::msgs::NodeAnnouncement>;
+#[no_mangle]
+pub static CVec_NodeAnnouncementZ_free: extern "C" fn(CVec_NodeAnnouncementZ) = crate::c_types::CVecTempl_free::<crate::ln::msgs::NodeAnnouncement>;
+
+#[no_mangle]
+pub type CVec_PublicKeyZ = crate::c_types::CVecTempl<crate::c_types::PublicKey>;
+#[no_mangle]
+pub static CVec_PublicKeyZ_free: extern "C" fn(CVec_PublicKeyZ) = crate::c_types::CVecTempl_free::<crate::c_types::PublicKey>;
+
+#[no_mangle]
+pub type CVec_u8Z = crate::c_types::CVecTempl<u8>;
+#[no_mangle]
+pub static CVec_u8Z_free: extern "C" fn(CVec_u8Z) = crate::c_types::CVecTempl_free::<u8>;
+
+#[no_mangle]
+pub type CResult_CVec_u8ZPeerHandleErrorZ = crate::c_types::CResultTempl<crate::c_types::CVecTempl<u8>, crate::ln::peer_handler::PeerHandleError>;
+#[no_mangle]
+pub static CResult_CVec_u8ZPeerHandleErrorZ_free: extern "C" fn(CResult_CVec_u8ZPeerHandleErrorZ) = crate::c_types::CResultTempl_free::<crate::c_types::CVecTempl<u8>, crate::ln::peer_handler::PeerHandleError>;
+#[no_mangle]
+pub static CResult_CVec_u8ZPeerHandleErrorZ_ok: extern "C" fn (CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ =
+ crate::c_types::CResultTempl::<crate::c_types::CVecTempl<u8>, crate::ln::peer_handler::PeerHandleError>::ok;
+
+#[no_mangle]
+pub static CResult_CVec_u8ZPeerHandleErrorZ_err: extern "C" fn (crate::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ =
+ crate::c_types::CResultTempl::<crate::c_types::CVecTempl<u8>, crate::ln::peer_handler::PeerHandleError>::err;
+
+#[no_mangle]
+pub type CResult_NonePeerHandleErrorZ = crate::c_types::CResultTempl<u8, crate::ln::peer_handler::PeerHandleError>;
+#[no_mangle]
+pub static CResult_NonePeerHandleErrorZ_free: extern "C" fn(CResult_NonePeerHandleErrorZ) = crate::c_types::CResultTempl_free::<u8, crate::ln::peer_handler::PeerHandleError>;
+#[no_mangle]
+pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ {
+ crate::c_types::CResultTempl::ok(0)
+}
+
+#[no_mangle]
+pub static CResult_NonePeerHandleErrorZ_err: extern "C" fn (crate::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ =
+ crate::c_types::CResultTempl::<u8, crate::ln::peer_handler::PeerHandleError>::err;
+
+#[no_mangle]
+pub type CResult_boolPeerHandleErrorZ = crate::c_types::CResultTempl<bool, crate::ln::peer_handler::PeerHandleError>;
+#[no_mangle]
+pub static CResult_boolPeerHandleErrorZ_free: extern "C" fn(CResult_boolPeerHandleErrorZ) = crate::c_types::CResultTempl_free::<bool, crate::ln::peer_handler::PeerHandleError>;
+#[no_mangle]
+pub static CResult_boolPeerHandleErrorZ_ok: extern "C" fn (bool) -> CResult_boolPeerHandleErrorZ =
+ crate::c_types::CResultTempl::<bool, crate::ln::peer_handler::PeerHandleError>::ok;
+
+#[no_mangle]
+pub static CResult_boolPeerHandleErrorZ_err: extern "C" fn (crate::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ =
+ crate::c_types::CResultTempl::<bool, crate::ln::peer_handler::PeerHandleError>::err;
+
+#[no_mangle]
+pub type CResult_SecretKeySecpErrorZ = crate::c_types::CResultTempl<crate::c_types::SecretKey, crate::c_types::Secp256k1Error>;
+#[no_mangle]
+pub static CResult_SecretKeySecpErrorZ_free: extern "C" fn(CResult_SecretKeySecpErrorZ) = crate::c_types::CResultTempl_free::<crate::c_types::SecretKey, crate::c_types::Secp256k1Error>;
+#[no_mangle]
+pub static CResult_SecretKeySecpErrorZ_ok: extern "C" fn (crate::c_types::SecretKey) -> CResult_SecretKeySecpErrorZ =
+ crate::c_types::CResultTempl::<crate::c_types::SecretKey, crate::c_types::Secp256k1Error>::ok;
+
+#[no_mangle]
+pub static CResult_SecretKeySecpErrorZ_err: extern "C" fn (crate::c_types::Secp256k1Error) -> CResult_SecretKeySecpErrorZ =
+ crate::c_types::CResultTempl::<crate::c_types::SecretKey, crate::c_types::Secp256k1Error>::err;
+
+#[no_mangle]
+pub type CResult_PublicKeySecpErrorZ = crate::c_types::CResultTempl<crate::c_types::PublicKey, crate::c_types::Secp256k1Error>;
+#[no_mangle]
+pub static CResult_PublicKeySecpErrorZ_free: extern "C" fn(CResult_PublicKeySecpErrorZ) = crate::c_types::CResultTempl_free::<crate::c_types::PublicKey, crate::c_types::Secp256k1Error>;
+#[no_mangle]
+pub static CResult_PublicKeySecpErrorZ_ok: extern "C" fn (crate::c_types::PublicKey) -> CResult_PublicKeySecpErrorZ =
+ crate::c_types::CResultTempl::<crate::c_types::PublicKey, crate::c_types::Secp256k1Error>::ok;
+
+#[no_mangle]
+pub static CResult_PublicKeySecpErrorZ_err: extern "C" fn (crate::c_types::Secp256k1Error) -> CResult_PublicKeySecpErrorZ =
+ crate::c_types::CResultTempl::<crate::c_types::PublicKey, crate::c_types::Secp256k1Error>::err;
+
+#[no_mangle]
+pub type CResult_TxCreationKeysSecpErrorZ = crate::c_types::CResultTempl<crate::ln::chan_utils::TxCreationKeys, crate::c_types::Secp256k1Error>;
+#[no_mangle]
+pub static CResult_TxCreationKeysSecpErrorZ_free: extern "C" fn(CResult_TxCreationKeysSecpErrorZ) = crate::c_types::CResultTempl_free::<crate::ln::chan_utils::TxCreationKeys, crate::c_types::Secp256k1Error>;
+#[no_mangle]
+pub static CResult_TxCreationKeysSecpErrorZ_ok: extern "C" fn (crate::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysSecpErrorZ =
+ crate::c_types::CResultTempl::<crate::ln::chan_utils::TxCreationKeys, crate::c_types::Secp256k1Error>::ok;
+
+#[no_mangle]
+pub static CResult_TxCreationKeysSecpErrorZ_err: extern "C" fn (crate::c_types::Secp256k1Error) -> CResult_TxCreationKeysSecpErrorZ =
+ crate::c_types::CResultTempl::<crate::ln::chan_utils::TxCreationKeys, crate::c_types::Secp256k1Error>::err;
+
+#[no_mangle]
+pub type C2Tuple_HTLCOutputInCommitmentSignatureZ = crate::c_types::C2TupleTempl<crate::ln::chan_utils::HTLCOutputInCommitment, crate::c_types::Signature>;
+#[no_mangle]
+pub static C2Tuple_HTLCOutputInCommitmentSignatureZ_free: extern "C" fn(C2Tuple_HTLCOutputInCommitmentSignatureZ) = crate::c_types::C2TupleTempl_free::<crate::ln::chan_utils::HTLCOutputInCommitment, crate::c_types::Signature>;
+#[no_mangle]
+pub extern "C" fn C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a: crate::ln::chan_utils::HTLCOutputInCommitment, b: crate::c_types::Signature) -> C2Tuple_HTLCOutputInCommitmentSignatureZ {
+ C2Tuple_HTLCOutputInCommitmentSignatureZ {
+ a: Box::into_raw(Box::new(a)),
+ b: Box::into_raw(Box::new(b)),
+ }
+}
+
+#[no_mangle]
+pub type CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ = crate::c_types::CVecTempl<crate::c_types::C2TupleTempl<crate::ln::chan_utils::HTLCOutputInCommitment, crate::c_types::Signature>>;
+#[no_mangle]
+pub static CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free: extern "C" fn(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) = crate::c_types::CVecTempl_free::<crate::c_types::C2TupleTempl<crate::ln::chan_utils::HTLCOutputInCommitment, crate::c_types::Signature>>;
+
+#[no_mangle]
+pub type CVec_RouteHopZ = crate::c_types::CVecTempl<crate::routing::router::RouteHop>;
+#[no_mangle]
+pub static CVec_RouteHopZ_free: extern "C" fn(CVec_RouteHopZ) = crate::c_types::CVecTempl_free::<crate::routing::router::RouteHop>;
+
+#[no_mangle]
+pub type CVec_CVec_RouteHopZZ = crate::c_types::CVecTempl<crate::c_types::CVecTempl<crate::routing::router::RouteHop>>;
+#[no_mangle]
+pub static CVec_CVec_RouteHopZZ_free: extern "C" fn(CVec_CVec_RouteHopZZ) = crate::c_types::CVecTempl_free::<crate::c_types::CVecTempl<crate::routing::router::RouteHop>>;
+
+#[no_mangle]
+pub type CVec_RouteHintZ = crate::c_types::CVecTempl<crate::routing::router::RouteHint>;
+#[no_mangle]
+pub static CVec_RouteHintZ_free: extern "C" fn(CVec_RouteHintZ) = crate::c_types::CVecTempl_free::<crate::routing::router::RouteHint>;
+
+#[no_mangle]
+pub type CResult_RouteLightningErrorZ = crate::c_types::CResultTempl<crate::routing::router::Route, crate::ln::msgs::LightningError>;
+#[no_mangle]
+pub static CResult_RouteLightningErrorZ_free: extern "C" fn(CResult_RouteLightningErrorZ) = crate::c_types::CResultTempl_free::<crate::routing::router::Route, crate::ln::msgs::LightningError>;
+#[no_mangle]
+pub static CResult_RouteLightningErrorZ_ok: extern "C" fn (crate::routing::router::Route) -> CResult_RouteLightningErrorZ =
+ crate::c_types::CResultTempl::<crate::routing::router::Route, crate::ln::msgs::LightningError>::ok;
+
+#[no_mangle]
+pub static CResult_RouteLightningErrorZ_err: extern "C" fn (crate::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ =
+ crate::c_types::CResultTempl::<crate::routing::router::Route, crate::ln::msgs::LightningError>::err;
+
+#[no_mangle]
+pub type CVec_u64Z = crate::c_types::CVecTempl<u64>;
+#[no_mangle]
+pub static CVec_u64Z_free: extern "C" fn(CVec_u64Z) = crate::c_types::CVecTempl_free::<u64>;
+
--- /dev/null
+//! Traits and utility impls which allow other parts of rust-lightning to interact with the
+//! blockchain.
+//!
+//! Includes traits for monitoring and receiving notifications of new blocks and block
+//! disconnections, transaction broadcasting, and feerate information requests.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+/// Used to give chain error details upstream
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum ChainError {
+ /// Client doesn't support UTXO lookup (but the chain hash matches our genesis block hash)
+ NotSupported,
+ /// Chain isn't the one watched
+ NotWatched,
+ /// Tx doesn't exist or is unconfirmed
+ UnknownTx,
+}
+use lightning::chain::chaininterface::ChainError as nativeChainError;
+impl ChainError {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeChainError {
+ match self {
+ ChainError::NotSupported => nativeChainError::NotSupported,
+ ChainError::NotWatched => nativeChainError::NotWatched,
+ ChainError::UnknownTx => nativeChainError::UnknownTx,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeChainError {
+ match self {
+ ChainError::NotSupported => nativeChainError::NotSupported,
+ ChainError::NotWatched => nativeChainError::NotWatched,
+ ChainError::UnknownTx => nativeChainError::UnknownTx,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeChainError) -> Self {
+ match native {
+ nativeChainError::NotSupported => ChainError::NotSupported,
+ nativeChainError::NotWatched => ChainError::NotWatched,
+ nativeChainError::UnknownTx => ChainError::UnknownTx,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeChainError) -> Self {
+ match native {
+ nativeChainError::NotSupported => ChainError::NotSupported,
+ nativeChainError::NotWatched => ChainError::NotWatched,
+ nativeChainError::UnknownTx => ChainError::UnknownTx,
+ }
+ }
+}
+/// An interface to request notification of certain scripts as they appear the
+/// chain.
+///
+/// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
+/// called from inside the library in response to ChainListener events, P2P events, or timer
+/// events).
+#[repr(C)]
+pub struct ChainWatchInterface {
+ pub this_arg: *mut c_void,
+ /// Provides a txid/random-scriptPubKey-in-the-tx which much be watched for.
+ pub install_watch_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pub_key: crate::c_types::u8slice),
+ /// Provides an outpoint which must be watched for, providing any transactions which spend the
+ /// given outpoint.
+ pub install_watch_outpoint: extern "C" fn (this_arg: *const c_void, outpoint: crate::c_types::derived::C2Tuple_Txidu32Z, out_script: crate::c_types::u8slice),
+ /// Indicates that a listener needs to see all transactions.
+ pub watch_all_txn: extern "C" fn (this_arg: *const c_void),
+ /// Gets the script and value in satoshis for a given unspent transaction output given a
+ /// short_channel_id (aka unspent_tx_output_identier). For BTC/tBTC channels the top three
+ /// bytes are the block height, the next 3 the transaction index within the block, and the
+ /// final two the output within the transaction.
+ #[must_use]
+ pub get_chain_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: crate::c_types::ThirtyTwoBytes, unspent_tx_output_identifier: u64) -> crate::c_types::derived::CResult_C2Tuple_Scriptu64ZChainErrorZ,
+ /// Gets the list of transaction indices within a given block that the ChainWatchInterface is
+ /// watching for.
+ #[must_use]
+ pub filter_block: extern "C" fn (this_arg: *const c_void, block: crate::c_types::u8slice) -> crate::c_types::derived::CVec_usizeZ,
+ /// Returns a usize that changes when the ChainWatchInterface's watched data is modified.
+ /// Users of `filter_block` should pre-save a copy of `reentered`'s return value and use it to
+ /// determine whether they need to re-filter a given block.
+ #[must_use]
+ pub reentered: extern "C" fn (this_arg: *const c_void) -> usize,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Sync for ChainWatchInterface {}
+unsafe impl Send for ChainWatchInterface {}
+
+use lightning::chain::chaininterface::ChainWatchInterface as rustChainWatchInterface;
+impl rustChainWatchInterface for ChainWatchInterface {
+ fn install_watch_tx(&self, txid: &bitcoin::hash_types::Txid, script_pub_key: &bitcoin::blockdata::script::Script) {
+ (self.install_watch_tx)(self.this_arg, txid.as_inner(), crate::c_types::u8slice::from_slice(&script_pub_key[..]))
+ }
+ fn install_watch_outpoint(&self, outpoint: (bitcoin::hash_types::Txid, u32), out_script: &bitcoin::blockdata::script::Script) {
+ let (mut orig_outpoint_0, mut orig_outpoint_1) = outpoint; let mut local_outpoint = (crate::c_types::ThirtyTwoBytes { data: orig_outpoint_0.into_inner() }, orig_outpoint_1).into();
+ (self.install_watch_outpoint)(self.this_arg, local_outpoint, crate::c_types::u8slice::from_slice(&out_script[..]))
+ }
+ fn watch_all_txn(&self) {
+ (self.watch_all_txn)(self.this_arg)
+ }
+ fn get_chain_utxo(&self, genesis_hash: bitcoin::hash_types::BlockHash, unspent_tx_output_identifier: u64) -> Result<(bitcoin::blockdata::script::Script, u64), lightning::chain::chaininterface::ChainError> {
+ let mut ret = (self.get_chain_utxo)(self.this_arg, crate::c_types::ThirtyTwoBytes { data: genesis_hash.into_inner() }, unspent_tx_output_identifier);
+ let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).to_rust(); let mut local_ret_0 = (::bitcoin::blockdata::script::Script::from(orig_ret_0_0.into_rust()), orig_ret_0_1); local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
+ local_ret
+ }
+ fn filter_block(&self, block: &bitcoin::blockdata::block::Block) -> Vec<usize> {
+ let mut local_block = ::bitcoin::consensus::encode::serialize(block);
+ let mut ret = (self.filter_block)(self.this_arg, crate::c_types::u8slice::from_slice(&local_block));
+ let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item }); };
+ local_ret
+ }
+ fn reentered(&self) -> usize {
+ let mut ret = (self.reentered)(self.this_arg);
+ ret
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for ChainWatchInterface {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn ChainWatchInterface_free(this_ptr: ChainWatchInterface) { }
+impl Drop for ChainWatchInterface {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// An interface to send a transaction to the Bitcoin network.
+#[repr(C)]
+pub struct BroadcasterInterface {
+ pub this_arg: *mut c_void,
+ /// Sends a transaction out to (hopefully) be mined.
+ pub broadcast_transaction: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction),
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Sync for BroadcasterInterface {}
+unsafe impl Send for BroadcasterInterface {}
+
+use lightning::chain::chaininterface::BroadcasterInterface as rustBroadcasterInterface;
+impl rustBroadcasterInterface for BroadcasterInterface {
+ fn broadcast_transaction(&self, tx: &bitcoin::blockdata::transaction::Transaction) {
+ let mut local_tx = ::bitcoin::consensus::encode::serialize(tx);
+ (self.broadcast_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_tx))
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for BroadcasterInterface {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn BroadcasterInterface_free(this_ptr: BroadcasterInterface) { }
+impl Drop for BroadcasterInterface {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// A trait indicating a desire to listen for events from the chain
+#[repr(C)]
+pub struct ChainListener {
+ pub this_arg: *mut c_void,
+ /// Notifies a listener that a block was connected.
+ ///
+ /// The txn_matched array should be set to references to transactions which matched the
+ /// relevant installed watch outpoints/txn, or the full set of transactions in the block.
+ ///
+ /// Note that if txn_matched includes only matched transactions, and a new
+ /// transaction/outpoint is watched during a block_connected call, the block *must* be
+ /// re-scanned with the new transaction/outpoints and block_connected should be called
+ /// again with the same header and (at least) the new transactions.
+ ///
+ /// Note that if non-new transaction/outpoints are be registered during a call, a second call
+ /// *must not* happen.
+ ///
+ /// This also means those counting confirmations using block_connected callbacks should watch
+ /// for duplicate headers and not count them towards confirmations!
+ pub block_connected: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], height: u32, txn_matched: crate::c_types::derived::CVec_TransactionZ, indexes_of_txn_matched: crate::c_types::usizeslice),
+ /// Notifies a listener that a block was disconnected.
+ /// Unlike block_connected, this *must* never be called twice for the same disconnect event.
+ /// Height must be the one of the block which was disconnected (not new height of the best chain)
+ pub block_disconnected: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], disconnected_height: u32),
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Sync for ChainListener {}
+unsafe impl Send for ChainListener {}
+
+use lightning::chain::chaininterface::ChainListener as rustChainListener;
+impl rustChainListener for ChainListener {
+ fn block_connected(&self, header: &bitcoin::blockdata::block::BlockHeader, height: u32, txn_matched: &[&bitcoin::blockdata::transaction::Transaction], indexes_of_txn_matched: &[usize]) {
+ let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s };
+ let mut local_txn_matched = Vec::new(); for item in txn_matched.iter() { local_txn_matched.push( { let mut local_txn_matched_0 = ::bitcoin::consensus::encode::serialize(&**item); local_txn_matched_0.into() }); };
+ let mut local_indexes_of_txn_matched = crate::c_types::usizeslice::from_slice(indexes_of_txn_matched);
+ (self.block_connected)(self.this_arg, &local_header, height, local_txn_matched.into(), local_indexes_of_txn_matched)
+ }
+ fn block_disconnected(&self, header: &bitcoin::blockdata::block::BlockHeader, disconnected_height: u32) {
+ let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s };
+ (self.block_disconnected)(self.this_arg, &local_header, disconnected_height)
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for ChainListener {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn ChainListener_free(this_ptr: ChainListener) { }
+impl Drop for ChainListener {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// An enum that represents the speed at which we want a transaction to confirm used for feerate
+/// estimation.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum ConfirmationTarget {
+ /// We are happy with this transaction confirming slowly when feerate drops some.
+ Background,
+ /// We'd like this transaction to confirm without major delay, but 12-18 blocks is fine.
+ Normal,
+ /// We'd like this transaction to confirm in the next few blocks.
+ HighPriority,
+}
+use lightning::chain::chaininterface::ConfirmationTarget as nativeConfirmationTarget;
+impl ConfirmationTarget {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeConfirmationTarget {
+ match self {
+ ConfirmationTarget::Background => nativeConfirmationTarget::Background,
+ ConfirmationTarget::Normal => nativeConfirmationTarget::Normal,
+ ConfirmationTarget::HighPriority => nativeConfirmationTarget::HighPriority,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeConfirmationTarget {
+ match self {
+ ConfirmationTarget::Background => nativeConfirmationTarget::Background,
+ ConfirmationTarget::Normal => nativeConfirmationTarget::Normal,
+ ConfirmationTarget::HighPriority => nativeConfirmationTarget::HighPriority,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeConfirmationTarget) -> Self {
+ match native {
+ nativeConfirmationTarget::Background => ConfirmationTarget::Background,
+ nativeConfirmationTarget::Normal => ConfirmationTarget::Normal,
+ nativeConfirmationTarget::HighPriority => ConfirmationTarget::HighPriority,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeConfirmationTarget) -> Self {
+ match native {
+ nativeConfirmationTarget::Background => ConfirmationTarget::Background,
+ nativeConfirmationTarget::Normal => ConfirmationTarget::Normal,
+ nativeConfirmationTarget::HighPriority => ConfirmationTarget::HighPriority,
+ }
+ }
+}
+/// A trait which should be implemented to provide feerate information on a number of time
+/// horizons.
+///
+/// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
+/// called from inside the library in response to ChainListener events, P2P events, or timer
+/// events).
+#[repr(C)]
+pub struct FeeEstimator {
+ pub this_arg: *mut c_void,
+ /// Gets estimated satoshis of fee required per 1000 Weight-Units.
+ ///
+ /// Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
+ /// don't put us below 1 satoshi-per-byte).
+ ///
+ /// This translates to:
+ /// * satoshis-per-byte * 250
+ /// * ceil(satoshis-per-kbyte / 4)
+ #[must_use]
+ pub get_est_sat_per_1000_weight: extern "C" fn (this_arg: *const c_void, confirmation_target: crate::chain::chaininterface::ConfirmationTarget) -> u32,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Sync for FeeEstimator {}
+unsafe impl Send for FeeEstimator {}
+
+use lightning::chain::chaininterface::FeeEstimator as rustFeeEstimator;
+impl rustFeeEstimator for FeeEstimator {
+ fn get_est_sat_per_1000_weight(&self, confirmation_target: lightning::chain::chaininterface::ConfirmationTarget) -> u32 {
+ let mut ret = (self.get_est_sat_per_1000_weight)(self.this_arg, crate::chain::chaininterface::ConfirmationTarget::native_into(confirmation_target));
+ ret
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for FeeEstimator {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn FeeEstimator_free(this_ptr: FeeEstimator) { }
+impl Drop for FeeEstimator {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+
+#[no_mangle]
+pub static MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = lightning::chain::chaininterface::MIN_RELAY_FEE_SAT_PER_1000_WEIGHT;
+
+use lightning::chain::chaininterface::ChainWatchedUtil as nativeChainWatchedUtilImport;
+type nativeChainWatchedUtil = nativeChainWatchedUtilImport;
+
+/// Utility for tracking registered txn/outpoints and checking for matches
+#[must_use]
+#[repr(C)]
+pub struct ChainWatchedUtil {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChainWatchedUtil,
+ pub is_owned: bool,
+}
+
+impl Drop for ChainWatchedUtil {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChainWatchedUtil_free(this_ptr: ChainWatchedUtil) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChainWatchedUtil_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainWatchedUtil); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChainWatchedUtil {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChainWatchedUtil {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Constructs an empty (watches nothing) ChainWatchedUtil
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainWatchedUtil_new() -> ChainWatchedUtil {
+ let mut ret = lightning::chain::chaininterface::ChainWatchedUtil::new();
+ ChainWatchedUtil { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Registers a tx for monitoring, returning true if it was a new tx and false if we'd already
+/// been watching for it.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainWatchedUtil_register_tx(this_arg: &mut ChainWatchedUtil, txid: *const [u8; 32], script_pub_key: crate::c_types::u8slice) -> bool {
+ let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChainWatchedUtil)) }.register_tx(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(script_pub_key.to_slice())));
+ ret
+}
+
+/// Registers an outpoint for monitoring, returning true if it was a new outpoint and false if
+/// we'd already been watching for it
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainWatchedUtil_register_outpoint(this_arg: &mut ChainWatchedUtil, mut outpoint: crate::c_types::derived::C2Tuple_Txidu32Z, _script_pub_key: crate::c_types::u8slice) -> bool {
+ let (mut orig_outpoint_0, mut orig_outpoint_1) = outpoint.to_rust(); let mut local_outpoint = (::bitcoin::hash_types::Txid::from_slice(&orig_outpoint_0.data[..]).unwrap(), orig_outpoint_1);
+ let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChainWatchedUtil)) }.register_outpoint(local_outpoint, &::bitcoin::blockdata::script::Script::from(Vec::from(_script_pub_key.to_slice())));
+ ret
+}
+
+/// Sets us to match all transactions, returning true if this is a new setting and false if
+/// we'd already been set to match everything.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainWatchedUtil_watch_all(this_arg: &mut ChainWatchedUtil) -> bool {
+ let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChainWatchedUtil)) }.watch_all();
+ ret
+}
+
+/// Checks if a given transaction matches the current filter.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainWatchedUtil_does_match_tx(this_arg: &ChainWatchedUtil, tx: crate::c_types::Transaction) -> bool {
+ let mut ret = unsafe { &*this_arg.inner }.does_match_tx(&tx.into_bitcoin());
+ ret
+}
+
+
+use lightning::chain::chaininterface::BlockNotifier as nativeBlockNotifierImport;
+type nativeBlockNotifier = nativeBlockNotifierImport<'static, crate::chain::chaininterface::ChainListener, crate::chain::chaininterface::ChainWatchInterface>;
+
+/// Utility for notifying listeners about new blocks, and handling block rescans if new watch
+/// data is registered.
+///
+/// Rather than using a plain BlockNotifier, it is preferable to use either a BlockNotifierArc
+/// or a BlockNotifierRef for conciseness. See their documentation for more details, but essentially
+/// you should default to using a BlockNotifierRef, and use a BlockNotifierArc instead when you
+/// require ChainListeners with static lifetimes, such as when you're using lightning-net-tokio.
+#[must_use]
+#[repr(C)]
+pub struct BlockNotifier {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeBlockNotifier,
+ pub is_owned: bool,
+}
+
+impl Drop for BlockNotifier {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn BlockNotifier_free(this_ptr: BlockNotifier) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn BlockNotifier_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBlockNotifier); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl BlockNotifier {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeBlockNotifier {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Constructs a new BlockNotifier without any listeners.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn BlockNotifier_new(mut chain_monitor: crate::chain::chaininterface::ChainWatchInterface) -> crate::chain::chaininterface::BlockNotifier {
+ let mut ret = lightning::chain::chaininterface::BlockNotifier::new(chain_monitor);
+ crate::chain::chaininterface::BlockNotifier { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Register the given listener to receive events.
+#[no_mangle]
+pub extern "C" fn BlockNotifier_register_listener(this_arg: &BlockNotifier, mut listener: crate::chain::chaininterface::ChainListener) {
+ unsafe { &*this_arg.inner }.register_listener(listener)
+}
+
+/// Notify listeners that a block was connected given a full, unfiltered block.
+///
+/// Handles re-scanning the block and calling block_connected again if listeners register new
+/// watch data during the callbacks for you (see ChainListener::block_connected for more info).
+#[no_mangle]
+pub extern "C" fn BlockNotifier_block_connected(this_arg: &BlockNotifier, block: crate::c_types::u8slice, mut height: u32) {
+ unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height)
+}
+
+/// Notify listeners that a block was connected, given pre-filtered list of transactions in the
+/// block which matched the filter (probably using does_match_tx).
+///
+/// Returns true if notified listeners registered additional watch data (implying that the
+/// block must be re-scanned and this function called again prior to further block_connected
+/// calls, see ChainListener::block_connected for more info).
+#[must_use]
+#[no_mangle]
+pub extern "C" fn BlockNotifier_block_connected_checked(this_arg: &BlockNotifier, header: *const [u8; 80], mut height: u32, mut txn_matched: crate::c_types::derived::CVec_TransactionZ, mut indexes_of_txn_matched: crate::c_types::usizeslice) -> bool {
+ let mut local_txn_matched = Vec::new(); for mut item in txn_matched.into_rust().drain(..) { local_txn_matched.push( { ::bitcoin::consensus::encode::deserialize(&item.into_rust()[..]).unwrap() }); };
+ let mut ret = unsafe { &*this_arg.inner }.block_connected_checked(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, &local_txn_matched.iter().collect::<Vec<_>>()[..], indexes_of_txn_matched.to_slice());
+ ret
+}
+
+/// Notify listeners that a block was disconnected.
+#[no_mangle]
+pub extern "C" fn BlockNotifier_block_disconnected(this_arg: &BlockNotifier, header: *const [u8; 80], mut disconnected_height: u32) {
+ unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), disconnected_height)
+}
+
+
+use lightning::chain::chaininterface::ChainWatchInterfaceUtil as nativeChainWatchInterfaceUtilImport;
+type nativeChainWatchInterfaceUtil = nativeChainWatchInterfaceUtilImport;
+
+/// Utility to capture some common parts of ChainWatchInterface implementors.
+///
+/// Keeping a local copy of this in a ChainWatchInterface implementor is likely useful.
+#[must_use]
+#[repr(C)]
+pub struct ChainWatchInterfaceUtil {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChainWatchInterfaceUtil,
+ pub is_owned: bool,
+}
+
+impl Drop for ChainWatchInterfaceUtil {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChainWatchInterfaceUtil_free(this_ptr: ChainWatchInterfaceUtil) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChainWatchInterfaceUtil_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainWatchInterfaceUtil); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChainWatchInterfaceUtil {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChainWatchInterfaceUtil {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChainWatchInterfaceUtil_as_ChainWatchInterface(this_arg: *const ChainWatchInterfaceUtil) -> crate::chain::chaininterface::ChainWatchInterface {
+ crate::chain::chaininterface::ChainWatchInterface {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ install_watch_tx: ChainWatchInterfaceUtil_ChainWatchInterface_install_watch_tx,
+ install_watch_outpoint: ChainWatchInterfaceUtil_ChainWatchInterface_install_watch_outpoint,
+ watch_all_txn: ChainWatchInterfaceUtil_ChainWatchInterface_watch_all_txn,
+ get_chain_utxo: ChainWatchInterfaceUtil_ChainWatchInterface_get_chain_utxo,
+ filter_block: ChainWatchInterfaceUtil_ChainWatchInterface_filter_block,
+ reentered: ChainWatchInterfaceUtil_ChainWatchInterface_reentered,
+ }
+}
+use lightning::chain::chaininterface::ChainWatchInterface as ChainWatchInterfaceTraitImport;
+extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_install_watch_tx(this_arg: *const c_void, txid: *const [u8; 32], script_pub_key: crate::c_types::u8slice) {
+ unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.install_watch_tx(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(script_pub_key.to_slice())))
+}
+extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_install_watch_outpoint(this_arg: *const c_void, mut outpoint: crate::c_types::derived::C2Tuple_Txidu32Z, out_script: crate::c_types::u8slice) {
+ let (mut orig_outpoint_0, mut orig_outpoint_1) = outpoint.to_rust(); let mut local_outpoint = (::bitcoin::hash_types::Txid::from_slice(&orig_outpoint_0.data[..]).unwrap(), orig_outpoint_1);
+ unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.install_watch_outpoint(local_outpoint, &::bitcoin::blockdata::script::Script::from(Vec::from(out_script.to_slice())))
+}
+extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_watch_all_txn(this_arg: *const c_void) {
+ unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.watch_all_txn()
+}
+#[must_use]
+extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_get_chain_utxo(this_arg: *const c_void, mut genesis_hash: crate::c_types::ThirtyTwoBytes, mut _unspent_tx_output_identifier: u64) -> crate::c_types::derived::CResult_C2Tuple_Scriptu64ZChainErrorZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.get_chain_utxo(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), _unspent_tx_output_identifier);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (orig_ret_0_0.into_bytes().into(), orig_ret_0_1).into(); local_ret_0 }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::chaininterface::ChainError::native_into(e) }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_filter_block(this_arg: *const c_void, block: crate::c_types::u8slice) -> crate::c_types::derived::CVec_usizeZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.filter_block(&::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap());
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { item }); };
+ local_ret.into()
+}
+#[must_use]
+extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_reentered(this_arg: *const c_void) -> usize {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.reentered();
+ ret
+}
+
+/// Creates a new ChainWatchInterfaceUtil for the given network
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainWatchInterfaceUtil_new(mut network: crate::bitcoin::network::Network) -> crate::chain::chaininterface::ChainWatchInterfaceUtil {
+ let mut ret = lightning::chain::chaininterface::ChainWatchInterfaceUtil::new(network.into_bitcoin());
+ crate::chain::chaininterface::ChainWatchInterfaceUtil { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Checks if a given transaction matches the current filter.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainWatchInterfaceUtil_does_match_tx(this_arg: &ChainWatchInterfaceUtil, tx: crate::c_types::Transaction) -> bool {
+ let mut ret = unsafe { &*this_arg.inner }.does_match_tx(&tx.into_bitcoin());
+ ret
+}
+
--- /dev/null
+//! keysinterface provides keys into rust-lightning and defines some useful enums which describe
+//! spendable on-chain outputs which the user owns and is responsible for using just as any other
+//! on-chain output which is theirs.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+/// When on-chain outputs are created by rust-lightning (which our counterparty is not able to
+/// claim at any point in the future) an event is generated which you must track and be able to
+/// spend on-chain. The information needed to do this is provided in this enum, including the
+/// outpoint describing which txid and output index is available, the full output which exists at
+/// that txid/index, and any keys or other information required to sign.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum SpendableOutputDescriptor {
+ /// An output to a script which was provided via KeysInterface, thus you should already know
+ /// how to spend it. No keys are provided as rust-lightning was never given any keys - only the
+ /// script_pubkey as it appears in the output.
+ /// These may include outputs from a transaction punishing our counterparty or claiming an HTLC
+ /// on-chain using the payment preimage or after it has timed out.
+ StaticOutput {
+ outpoint: crate::chain::transaction::OutPoint,
+ output: crate::c_types::TxOut,
+ },
+ /// An output to a P2WSH script which can be spent with a single signature after a CSV delay.
+ ///
+ /// The witness in the spending input should be:
+ /// <BIP 143 signature> <empty vector> (MINIMALIF standard rule) <provided witnessScript>
+ ///
+ /// Note that the nSequence field in the spending input must be set to to_self_delay
+ /// (which means the transaction is not broadcastable until at least to_self_delay
+ /// blocks after the outpoint confirms).
+ ///
+ /// These are generally the result of a \"revocable\" output to us, spendable only by us unless
+ /// it is an output from an old state which we broadcast (which should never happen).
+ ///
+ /// To derive the delayed_payment key which is used to sign for this input, you must pass the
+ /// local delayed_payment_base_key (ie the private key which corresponds to the pubkey in
+ /// ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to
+ /// chan_utils::derive_private_key. The public key can be generated without the secret key
+ /// using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in
+ /// ChannelKeys::pubkeys().
+ ///
+ /// To derive the remote_revocation_pubkey provided here (which is used in the witness
+ /// script generation), you must pass the remote revocation_basepoint (which appears in the
+ /// call to ChannelKeys::on_accept) and the provided per_commitment point
+ /// to chan_utils::derive_public_revocation_key.
+ ///
+ /// The witness script which is hashed and included in the output script_pubkey may be
+ /// regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey
+ /// (derived as above), and the to_self_delay contained here to
+ /// chan_utils::get_revokeable_redeemscript.
+ DynamicOutputP2WSH {
+ outpoint: crate::chain::transaction::OutPoint,
+ per_commitment_point: crate::c_types::PublicKey,
+ to_self_delay: u16,
+ output: crate::c_types::TxOut,
+ key_derivation_params: crate::c_types::derived::C2Tuple_u64u64Z,
+ remote_revocation_pubkey: crate::c_types::PublicKey,
+ },
+ /// An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
+ /// corresponds to the public key in ChannelKeys::pubkeys().payment_point).
+ /// The witness in the spending input, is, thus, simply:
+ /// <BIP 143 signature> <payment key>
+ ///
+ /// These are generally the result of our counterparty having broadcast the current state,
+ /// allowing us to claim the non-HTLC-encumbered outputs immediately.
+ StaticOutputRemotePayment {
+ outpoint: crate::chain::transaction::OutPoint,
+ output: crate::c_types::TxOut,
+ key_derivation_params: crate::c_types::derived::C2Tuple_u64u64Z,
+ },
+}
+use lightning::chain::keysinterface::SpendableOutputDescriptor as nativeSpendableOutputDescriptor;
+impl SpendableOutputDescriptor {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeSpendableOutputDescriptor {
+ match self {
+ SpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => {
+ let mut outpoint_nonref = (*outpoint).clone();
+ let mut output_nonref = (*output).clone();
+ nativeSpendableOutputDescriptor::StaticOutput {
+ outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_ptr()) },
+ output: output_nonref.into_rust(),
+ }
+ },
+ SpendableOutputDescriptor::DynamicOutputP2WSH {ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref remote_revocation_pubkey, } => {
+ let mut outpoint_nonref = (*outpoint).clone();
+ let mut per_commitment_point_nonref = (*per_commitment_point).clone();
+ let mut to_self_delay_nonref = (*to_self_delay).clone();
+ let mut output_nonref = (*output).clone();
+ let mut key_derivation_params_nonref = (*key_derivation_params).clone();
+ let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref.to_rust(); let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1);
+ let mut remote_revocation_pubkey_nonref = (*remote_revocation_pubkey).clone();
+ nativeSpendableOutputDescriptor::DynamicOutputP2WSH {
+ outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_ptr()) },
+ per_commitment_point: per_commitment_point_nonref.into_rust(),
+ to_self_delay: to_self_delay_nonref,
+ output: output_nonref.into_rust(),
+ key_derivation_params: local_key_derivation_params_nonref,
+ remote_revocation_pubkey: remote_revocation_pubkey_nonref.into_rust(),
+ }
+ },
+ SpendableOutputDescriptor::StaticOutputRemotePayment {ref outpoint, ref output, ref key_derivation_params, } => {
+ let mut outpoint_nonref = (*outpoint).clone();
+ let mut output_nonref = (*output).clone();
+ let mut key_derivation_params_nonref = (*key_derivation_params).clone();
+ let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref.to_rust(); let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1);
+ nativeSpendableOutputDescriptor::StaticOutputRemotePayment {
+ outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_ptr()) },
+ output: output_nonref.into_rust(),
+ key_derivation_params: local_key_derivation_params_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeSpendableOutputDescriptor {
+ match self {
+ SpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => {
+ nativeSpendableOutputDescriptor::StaticOutput {
+ outpoint: *unsafe { Box::from_raw(outpoint.take_ptr()) },
+ output: output.into_rust(),
+ }
+ },
+ SpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut key_derivation_params, mut remote_revocation_pubkey, } => {
+ let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params.to_rust(); let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1);
+ nativeSpendableOutputDescriptor::DynamicOutputP2WSH {
+ outpoint: *unsafe { Box::from_raw(outpoint.take_ptr()) },
+ per_commitment_point: per_commitment_point.into_rust(),
+ to_self_delay: to_self_delay,
+ output: output.into_rust(),
+ key_derivation_params: local_key_derivation_params,
+ remote_revocation_pubkey: remote_revocation_pubkey.into_rust(),
+ }
+ },
+ SpendableOutputDescriptor::StaticOutputRemotePayment {mut outpoint, mut output, mut key_derivation_params, } => {
+ let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params.to_rust(); let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1);
+ nativeSpendableOutputDescriptor::StaticOutputRemotePayment {
+ outpoint: *unsafe { Box::from_raw(outpoint.take_ptr()) },
+ output: output.into_rust(),
+ key_derivation_params: local_key_derivation_params,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeSpendableOutputDescriptor) -> Self {
+ match native {
+ nativeSpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => {
+ let mut outpoint_nonref = (*outpoint).clone();
+ let mut output_nonref = (*output).clone();
+ SpendableOutputDescriptor::StaticOutput {
+ outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint_nonref)), is_owned: true },
+ output: crate::c_types::TxOut::from_rust(output_nonref),
+ }
+ },
+ nativeSpendableOutputDescriptor::DynamicOutputP2WSH {ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref remote_revocation_pubkey, } => {
+ let mut outpoint_nonref = (*outpoint).clone();
+ let mut per_commitment_point_nonref = (*per_commitment_point).clone();
+ let mut to_self_delay_nonref = (*to_self_delay).clone();
+ let mut output_nonref = (*output).clone();
+ let mut key_derivation_params_nonref = (*key_derivation_params).clone();
+ let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref; let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1).into();
+ let mut remote_revocation_pubkey_nonref = (*remote_revocation_pubkey).clone();
+ SpendableOutputDescriptor::DynamicOutputP2WSH {
+ outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint_nonref)), is_owned: true },
+ per_commitment_point: crate::c_types::PublicKey::from_rust(&per_commitment_point_nonref),
+ to_self_delay: to_self_delay_nonref,
+ output: crate::c_types::TxOut::from_rust(output_nonref),
+ key_derivation_params: local_key_derivation_params_nonref,
+ remote_revocation_pubkey: crate::c_types::PublicKey::from_rust(&remote_revocation_pubkey_nonref),
+ }
+ },
+ nativeSpendableOutputDescriptor::StaticOutputRemotePayment {ref outpoint, ref output, ref key_derivation_params, } => {
+ let mut outpoint_nonref = (*outpoint).clone();
+ let mut output_nonref = (*output).clone();
+ let mut key_derivation_params_nonref = (*key_derivation_params).clone();
+ let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref; let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1).into();
+ SpendableOutputDescriptor::StaticOutputRemotePayment {
+ outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint_nonref)), is_owned: true },
+ output: crate::c_types::TxOut::from_rust(output_nonref),
+ key_derivation_params: local_key_derivation_params_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeSpendableOutputDescriptor) -> Self {
+ match native {
+ nativeSpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => {
+ SpendableOutputDescriptor::StaticOutput {
+ outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint)), is_owned: true },
+ output: crate::c_types::TxOut::from_rust(output),
+ }
+ },
+ nativeSpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut key_derivation_params, mut remote_revocation_pubkey, } => {
+ let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params; let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1).into();
+ SpendableOutputDescriptor::DynamicOutputP2WSH {
+ outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint)), is_owned: true },
+ per_commitment_point: crate::c_types::PublicKey::from_rust(&per_commitment_point),
+ to_self_delay: to_self_delay,
+ output: crate::c_types::TxOut::from_rust(output),
+ key_derivation_params: local_key_derivation_params,
+ remote_revocation_pubkey: crate::c_types::PublicKey::from_rust(&remote_revocation_pubkey),
+ }
+ },
+ nativeSpendableOutputDescriptor::StaticOutputRemotePayment {mut outpoint, mut output, mut key_derivation_params, } => {
+ let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params; let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1).into();
+ SpendableOutputDescriptor::StaticOutputRemotePayment {
+ outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint)), is_owned: true },
+ output: crate::c_types::TxOut::from_rust(output),
+ key_derivation_params: local_key_derivation_params,
+ }
+ },
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn SpendableOutputDescriptor_free(this_ptr: SpendableOutputDescriptor) { }
+/// Set of lightning keys needed to operate a channel as described in BOLT 3.
+///
+/// Signing services could be implemented on a hardware wallet. In this case,
+/// the current ChannelKeys would be a front-end on top of a communication
+/// channel connected to your secure device and lightning key material wouldn't
+/// reside on a hot server. Nevertheless, a this deployment would still need
+/// to trust the ChannelManager to avoid loss of funds as this latest component
+/// could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
+///
+/// A more secure iteration would be to use hashlock (or payment points) to pair
+/// invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
+/// at the price of more state and computation on the hardware wallet side. In the future,
+/// we are looking forward to design such interface.
+///
+/// In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
+/// to act, as liveness and breach reply correctness are always going to be hard requirements
+/// of LN security model, orthogonal of key management issues.
+///
+/// If you're implementing a custom signer, you almost certainly want to implement
+/// Readable/Writable to serialize out a unique reference to this set of keys so
+/// that you can serialize the full ChannelManager object.
+///
+#[repr(C)]
+pub struct ChannelKeys {
+ pub this_arg: *mut c_void,
+ /// Gets the per-commitment point for a specific commitment number
+ ///
+ /// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
+ #[must_use]
+ pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::PublicKey,
+ /// Gets the commitment secret for a specific commitment number as part of the revocation process
+ ///
+ /// An external signer implementation should error here if the commitment was already signed
+ /// and should refuse to sign it in the future.
+ ///
+ /// May be called more than once for the same index.
+ ///
+ /// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
+ /// TODO: return a Result so we can signal a validation error
+ #[must_use]
+ pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes,
+ /// Gets the local channel public keys and basepoints
+ pub pubkeys: crate::ln::chan_utils::ChannelPublicKeys,
+ /// Fill in the pubkeys field as a reference to it will be given to Rust after this returns
+ /// Note that this takes a pointer to this object, not the this_ptr like other methods do
+ /// This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
+ pub set_pubkeys: Option<extern "C" fn(&ChannelKeys)>,
+ /// Gets arbitrary identifiers describing the set of keys which are provided back to you in
+ /// some SpendableOutputDescriptor types. These should be sufficient to identify this
+ /// ChannelKeys object uniquely and lookup or re-derive its keys.
+ #[must_use]
+ pub key_derivation_params: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::C2Tuple_u64u64Z,
+ /// Create a signature for a remote commitment transaction and associated HTLC transactions.
+ ///
+ /// Note that if signing fails or is rejected, the channel will be force-closed.
+ #[must_use]
+ pub sign_remote_commitment: extern "C" fn (this_arg: *const c_void, feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ,
+ /// Create a signature for a local commitment transaction. This will only ever be called with
+ /// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
+ /// that it will not be called multiple times.
+ /// An external signer implementation should check that the commitment has not been revoked.
+ #[must_use]
+ pub sign_local_commitment: extern "C" fn (this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ,
+ /// Create a signature for each HTLC transaction spending a local commitment transaction.
+ ///
+ /// Unlike sign_local_commitment, this may be called multiple times with *different*
+ /// local_commitment_tx values. While this will never be called with a revoked
+ /// local_commitment_tx, it is possible that it is called with the second-latest
+ /// local_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
+ /// ChannelMonitor decided to broadcast before it had been updated to the latest.
+ ///
+ /// Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
+ /// local_commitment_tx. For those HTLCs which have transaction_output_index set to None
+ /// (implying they were considered dust at the time the commitment transaction was negotiated),
+ /// a corresponding None should be included in the return value. All other positions in the
+ /// return value must contain a signature.
+ #[must_use]
+ pub sign_local_commitment_htlc_transactions: extern "C" fn (this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ,
+ /// Create a signature for the given input in a transaction spending an HTLC or commitment
+ /// transaction output when our counterparty broadcasts an old state.
+ ///
+ /// A justice transaction may claim multiples outputs at the same time if timelocks are
+ /// similar, but only a signature for the input at index `input` should be signed for here.
+ /// It may be called multiples time for same output(s) if a fee-bump is needed with regards
+ /// to an upcoming timelock expiration.
+ ///
+ /// Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ ///
+ /// per_commitment_key is revocation secret which was provided by our counterparty when they
+ /// revoked the state which they eventually broadcast. It's not a _local_ secret key and does
+ /// not allow the spending of any funds by itself (you need our local revocation_secret to do
+ /// so).
+ ///
+ /// htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
+ /// changing the format of the witness script (which is committed to in the BIP 143
+ /// signatures).
+ #[must_use]
+ pub sign_justice_transaction: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
+ /// Create a signature for a claiming transaction for a HTLC output on a remote commitment
+ /// transaction, either offered or received.
+ ///
+ /// Such a transaction may claim multiples offered outputs at same time if we know the
+ /// preimage for each when we create it, but only the input at index `input` should be
+ /// signed for here. It may be called multiple times for same output(s) if a fee-bump is
+ /// needed with regards to an upcoming timelock expiration.
+ ///
+ /// Witness_script is either a offered or received script as defined in BOLT3 for HTLC
+ /// outputs.
+ ///
+ /// Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ ///
+ /// Per_commitment_point is the dynamic point corresponding to the channel state
+ /// detected onchain. It has been generated by our counterparty and is used to derive
+ /// channel state keys, which are then included in the witness script and committed to in the
+ /// BIP 143 signature.
+ #[must_use]
+ pub sign_remote_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
+ /// Create a signature for a (proposed) closing transaction.
+ ///
+ /// Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
+ /// chosen to forgo their output as dust.
+ #[must_use]
+ pub sign_closing_transaction: extern "C" fn (this_arg: *const c_void, closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ,
+ /// Signs a channel announcement message with our funding key, proving it comes from one
+ /// of the channel participants.
+ ///
+ /// Note that if this fails or is rejected, the channel will not be publicly announced and
+ /// our counterparty may (though likely will not) close the channel on us for violating the
+ /// protocol.
+ #[must_use]
+ pub sign_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ,
+ /// Set the remote channel basepoints and remote/local to_self_delay.
+ /// This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels.
+ ///
+ /// We bind local_to_self_delay late here for API convenience.
+ ///
+ /// Will be called before any signatures are applied.
+ pub on_accept: extern "C" fn (this_arg: *mut c_void, channel_points: &crate::ln::chan_utils::ChannelPublicKeys, remote_to_self_delay: u16, local_to_self_delay: u16),
+ pub clone: Option<extern "C" fn (this_arg: *const c_void) -> *mut c_void>,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for ChannelKeys {}
+impl Clone for ChannelKeys {
+ fn clone(&self) -> Self {
+ Self {
+ this_arg: if let Some(f) = self.clone { (f)(self.this_arg) } else { self.this_arg },
+ get_per_commitment_point: self.get_per_commitment_point.clone(),
+ release_commitment_secret: self.release_commitment_secret.clone(),
+ pubkeys: self.pubkeys.clone(),
+ set_pubkeys: self.set_pubkeys.clone(),
+ key_derivation_params: self.key_derivation_params.clone(),
+ sign_remote_commitment: self.sign_remote_commitment.clone(),
+ sign_local_commitment: self.sign_local_commitment.clone(),
+ sign_local_commitment_htlc_transactions: self.sign_local_commitment_htlc_transactions.clone(),
+ sign_justice_transaction: self.sign_justice_transaction.clone(),
+ sign_remote_htlc_transaction: self.sign_remote_htlc_transaction.clone(),
+ sign_closing_transaction: self.sign_closing_transaction.clone(),
+ sign_channel_announcement: self.sign_channel_announcement.clone(),
+ on_accept: self.on_accept.clone(),
+ clone: self.clone.clone(),
+ free: self.free.clone(),
+ }
+ }
+}
+
+use lightning::chain::keysinterface::ChannelKeys as rustChannelKeys;
+impl rustChannelKeys for ChannelKeys {
+ fn get_per_commitment_point<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, idx: u64, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> bitcoin::secp256k1::key::PublicKey {
+ let mut ret = (self.get_per_commitment_point)(self.this_arg, idx);
+ ret.into_rust()
+ }
+ fn release_commitment_secret(&self, idx: u64) -> [u8; 32] {
+ let mut ret = (self.release_commitment_secret)(self.this_arg, idx);
+ ret.data
+ }
+ fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys {
+ if let Some(f) = self.set_pubkeys {
+ (f)(self);
+ }
+ unsafe { &*self.pubkeys.inner }
+ }
+ fn key_derivation_params(&self) -> (u64, u64) {
+ let mut ret = (self.key_derivation_params)(self.this_arg);
+ let (mut orig_ret_0, mut orig_ret_1) = ret.to_rust(); let mut local_ret = (orig_ret_0, orig_ret_1);
+ local_ret
+ }
+ fn sign_remote_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &bitcoin::blockdata::transaction::Transaction, keys: &lightning::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: &[&lightning::ln::chan_utils::HTLCOutputInCommitment], _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<(bitcoin::secp256k1::Signature, Vec<bitcoin::secp256k1::Signature>), ()> {
+ let mut local_commitment_tx = ::bitcoin::consensus::encode::serialize(commitment_tx);
+ let mut local_htlcs = Vec::new(); for item in htlcs.iter() { local_htlcs.push( { crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ( (&(**item) as *const _) as *mut _) }, is_owned: false } }); };
+ let mut ret = (self.sign_remote_commitment)(self.this_arg, feerate_per_kw, crate::c_types::Transaction::from_slice(&local_commitment_tx), &crate::ln::chan_utils::PreCalculatedTxCreationKeys { inner: unsafe { (keys as *const _) as *mut _ }, is_owned: false }, local_htlcs.into());
+ let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
+ local_ret
+ }
+ fn sign_local_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, local_commitment_tx: &lightning::ln::chan_utils::LocalCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut ret = (self.sign_local_commitment)(self.this_arg, &crate::ln::chan_utils::LocalCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false });
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
+ local_ret
+ }
+ fn sign_local_commitment_htlc_transactions<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, local_commitment_tx: &lightning::ln::chan_utils::LocalCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<Vec<Option<bitcoin::secp256k1::Signature>>, ()> {
+ let mut ret = (self.sign_local_commitment_htlc_transactions)(self.this_arg, &crate::ln::chan_utils::LocalCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false });
+ let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust().drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_null() { None } else { Some( { item.into_rust() }) }; local_ret_0_0 }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
+ local_ret
+ }
+ fn sign_justice_transaction<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, justice_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_key: &bitcoin::secp256k1::key::SecretKey, htlc: &Option<lightning::ln::chan_utils::HTLCOutputInCommitment>, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut local_justice_tx = ::bitcoin::consensus::encode::serialize(justice_tx);
+ let mut local_htlc = &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (if htlc.is_none() { std::ptr::null() } else { { (htlc.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ let mut ret = (self.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_justice_tx), input, amount, per_commitment_key.as_ref(), local_htlc);
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
+ local_ret
+ }
+ fn sign_remote_htlc_transaction<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, htlc_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_point: &bitcoin::secp256k1::key::PublicKey, htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx);
+ let mut ret = (self.sign_remote_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false });
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
+ local_ret
+ }
+ fn sign_closing_transaction<T:bitcoin::secp256k1::Signing>(&self, closing_tx: &bitcoin::blockdata::transaction::Transaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut local_closing_tx = ::bitcoin::consensus::encode::serialize(closing_tx);
+ let mut ret = (self.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_closing_tx));
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
+ local_ret
+ }
+ fn sign_channel_announcement<T:bitcoin::secp256k1::Signing>(&self, msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut ret = (self.sign_channel_announcement)(self.this_arg, &crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
+ local_ret
+ }
+ fn on_accept(&mut self, channel_points: &lightning::ln::chan_utils::ChannelPublicKeys, remote_to_self_delay: u16, local_to_self_delay: u16) {
+ (self.on_accept)(self.this_arg, &crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { (channel_points as *const _) as *mut _ }, is_owned: false }, remote_to_self_delay, local_to_self_delay)
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for ChannelKeys {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn ChannelKeys_free(this_ptr: ChannelKeys) { }
+impl Drop for ChannelKeys {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// A trait to describe an object which can get user secrets and key material.
+#[repr(C)]
+pub struct KeysInterface {
+ pub this_arg: *mut c_void,
+ /// Get node secret key (aka node_id or network_key)
+ #[must_use]
+ pub get_node_secret: extern "C" fn (this_arg: *const c_void) -> crate::c_types::SecretKey,
+ /// Get destination redeemScript to encumber static protocol exit points.
+ #[must_use]
+ pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z,
+ /// Get shutdown_pubkey to use as PublicKey at channel closure
+ #[must_use]
+ pub get_shutdown_pubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::PublicKey,
+ /// Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
+ /// restarted with some stale data!
+ #[must_use]
+ pub get_channel_keys: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys,
+ /// Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
+ /// onion packets and for temporary channel IDs. There is no requirement that these be
+ /// persisted anywhere, though they must be unique across restarts.
+ #[must_use]
+ pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for KeysInterface {}
+unsafe impl Sync for KeysInterface {}
+
+use lightning::chain::keysinterface::KeysInterface as rustKeysInterface;
+impl rustKeysInterface for KeysInterface {
+ type ChanKeySigner = crate::chain::keysinterface::ChannelKeys;
+ fn get_node_secret(&self) -> bitcoin::secp256k1::key::SecretKey {
+ let mut ret = (self.get_node_secret)(self.this_arg);
+ ret.into_rust()
+ }
+ fn get_destination_script(&self) -> bitcoin::blockdata::script::Script {
+ let mut ret = (self.get_destination_script)(self.this_arg);
+ ::bitcoin::blockdata::script::Script::from(ret.into_rust())
+ }
+ fn get_shutdown_pubkey(&self) -> bitcoin::secp256k1::key::PublicKey {
+ let mut ret = (self.get_shutdown_pubkey)(self.this_arg);
+ ret.into_rust()
+ }
+ fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> Self::ChanKeySigner {
+ let mut ret = (self.get_channel_keys)(self.this_arg, inbound, channel_value_satoshis);
+ ret
+ }
+ fn get_secure_random_bytes(&self) -> [u8; 32] {
+ let mut ret = (self.get_secure_random_bytes)(self.this_arg);
+ ret.data
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for KeysInterface {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn KeysInterface_free(this_ptr: KeysInterface) { }
+impl Drop for KeysInterface {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+
+use lightning::chain::keysinterface::InMemoryChannelKeys as nativeInMemoryChannelKeysImport;
+type nativeInMemoryChannelKeys = nativeInMemoryChannelKeysImport;
+
+/// A simple implementation of ChannelKeys that just keeps the private keys in memory.
+#[must_use]
+#[repr(C)]
+pub struct InMemoryChannelKeys {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeInMemoryChannelKeys,
+ pub is_owned: bool,
+}
+
+impl Drop for InMemoryChannelKeys {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_free(this_ptr: InMemoryChannelKeys) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn InMemoryChannelKeys_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInMemoryChannelKeys); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl InMemoryChannelKeys {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeInMemoryChannelKeys {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for InMemoryChannelKeys {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn InMemoryChannelKeys_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemoryChannelKeys)).clone() })) as *mut c_void
+}
+/// Private key of anchor tx
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_get_funding_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_key;
+ (*inner_val).as_ref()
+}
+/// Private key of anchor tx
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_set_funding_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
+ unsafe { &mut *this_ptr.inner }.funding_key = val.into_rust();
+}
+/// Local secret key for blinded revocation pubkey
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_get_revocation_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_base_key;
+ (*inner_val).as_ref()
+}
+/// Local secret key for blinded revocation pubkey
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_set_revocation_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
+ unsafe { &mut *this_ptr.inner }.revocation_base_key = val.into_rust();
+}
+/// Local secret key used for our balance in remote-broadcasted commitment transactions
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_get_payment_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key;
+ (*inner_val).as_ref()
+}
+/// Local secret key used for our balance in remote-broadcasted commitment transactions
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_set_payment_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
+ unsafe { &mut *this_ptr.inner }.payment_key = val.into_rust();
+}
+/// Local secret key used in HTLC tx
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_get_delayed_payment_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_base_key;
+ (*inner_val).as_ref()
+}
+/// Local secret key used in HTLC tx
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_set_delayed_payment_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
+ unsafe { &mut *this_ptr.inner }.delayed_payment_base_key = val.into_rust();
+}
+/// Local htlc secret key used in commitment tx htlc outputs
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_get_htlc_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_base_key;
+ (*inner_val).as_ref()
+}
+/// Local htlc secret key used in commitment tx htlc outputs
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_set_htlc_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
+ unsafe { &mut *this_ptr.inner }.htlc_base_key = val.into_rust();
+}
+/// Commitment seed
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_get_commitment_seed(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_seed;
+ &(*inner_val)
+}
+/// Commitment seed
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_set_commitment_seed(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.commitment_seed = val.data;
+}
+/// Create a new InMemoryChannelKeys
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut key_derivation_params: crate::c_types::derived::C2Tuple_u64u64Z) -> crate::chain::keysinterface::InMemoryChannelKeys {
+ let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params.to_rust(); let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1);
+ let mut ret = lightning::chain::keysinterface::InMemoryChannelKeys::new(&bitcoin::secp256k1::Secp256k1::new(), funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, local_key_derivation_params);
+ crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Remote pubkeys.
+/// Will panic if on_accept wasn't called.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_remote_pubkeys(this_arg: &InMemoryChannelKeys) -> crate::ln::chan_utils::ChannelPublicKeys {
+ let mut ret = unsafe { &*this_arg.inner }.remote_pubkeys();
+ crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
+}
+
+/// The to_self_delay value specified by our counterparty and applied on locally-broadcastable
+/// transactions, ie the amount of time that we have to wait to recover our funds if we
+/// broadcast a transaction. You'll likely want to pass this to the
+/// ln::chan_utils::build*_transaction functions when signing local transactions.
+/// Will panic if on_accept wasn't called.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_remote_to_self_delay(this_arg: &InMemoryChannelKeys) -> u16 {
+ let mut ret = unsafe { &*this_arg.inner }.remote_to_self_delay();
+ ret
+}
+
+/// The to_self_delay value specified by us and applied on transactions broadcastable
+/// by our counterparty, ie the amount of time that they have to wait to recover their funds
+/// if they broadcast a transaction.
+/// Will panic if on_accept wasn't called.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_local_to_self_delay(this_arg: &InMemoryChannelKeys) -> u16 {
+ let mut ret = unsafe { &*this_arg.inner }.local_to_self_delay();
+ ret
+}
+
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_as_ChannelKeys(this_arg: *const InMemoryChannelKeys) -> crate::chain::keysinterface::ChannelKeys {
+ crate::chain::keysinterface::ChannelKeys {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ get_per_commitment_point: InMemoryChannelKeys_ChannelKeys_get_per_commitment_point,
+ release_commitment_secret: InMemoryChannelKeys_ChannelKeys_release_commitment_secret,
+
+ pubkeys: crate::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true },
+ set_pubkeys: Some(InMemoryChannelKeys_ChannelKeys_set_pubkeys),
+ key_derivation_params: InMemoryChannelKeys_ChannelKeys_key_derivation_params,
+ sign_remote_commitment: InMemoryChannelKeys_ChannelKeys_sign_remote_commitment,
+ sign_local_commitment: InMemoryChannelKeys_ChannelKeys_sign_local_commitment,
+ sign_local_commitment_htlc_transactions: InMemoryChannelKeys_ChannelKeys_sign_local_commitment_htlc_transactions,
+ sign_justice_transaction: InMemoryChannelKeys_ChannelKeys_sign_justice_transaction,
+ sign_remote_htlc_transaction: InMemoryChannelKeys_ChannelKeys_sign_remote_htlc_transaction,
+ sign_closing_transaction: InMemoryChannelKeys_ChannelKeys_sign_closing_transaction,
+ sign_channel_announcement: InMemoryChannelKeys_ChannelKeys_sign_channel_announcement,
+ on_accept: InMemoryChannelKeys_ChannelKeys_on_accept,
+ clone: Some(InMemoryChannelKeys_clone_void),
+ }
+}
+use lightning::chain::keysinterface::ChannelKeys as ChannelKeysTraitImport;
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.get_per_commitment_point(idx, &bitcoin::secp256k1::Secp256k1::new());
+ crate::c_types::PublicKey::from_rust(&ret)
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.release_commitment_secret(idx);
+ crate::c_types::ThirtyTwoBytes { data: ret }
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_pubkeys(this_arg: *const c_void) -> crate::ln::chan_utils::ChannelPublicKeys {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.pubkeys();
+ crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
+}
+extern "C" fn InMemoryChannelKeys_ChannelKeys_set_pubkeys(trait_self_arg: &ChannelKeys) {
+ // This is a bit race-y in the general case, but for our specific use-cases today, we're safe
+ // Specifically, we must ensure that the first time we're called it can never be in parallel
+ if trait_self_arg.pubkeys.inner.is_null() {
+ unsafe { &mut *(trait_self_arg as *const ChannelKeys as *mut ChannelKeys) }.pubkeys = InMemoryChannelKeys_ChannelKeys_pubkeys(trait_self_arg.this_arg);
+ }
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_key_derivation_params(this_arg: *const c_void) -> crate::c_types::derived::C2Tuple_u64u64Z {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.key_derivation_params();
+ let (mut orig_ret_0, mut orig_ret_1) = ret; let mut local_ret = (orig_ret_0, orig_ret_1).into();
+ local_ret
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_remote_commitment(this_arg: *const c_void, mut feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, pre_keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, mut htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+ let mut local_htlcs = Vec::new(); for mut item in htlcs.as_slice().iter() { local_htlcs.push( { unsafe { &*item.inner } }); };
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_remote_commitment(feerate_per_kw, &commitment_tx.into_bitcoin(), unsafe { &*pre_keys.inner }, &local_htlcs[..], &bitcoin::secp256k1::Secp256k1::new());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_local_commitment(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_local_commitment(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_local_commitment_htlc_transactions(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_local_commitment_htlc_transactions(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_none() { crate::c_types::Signature::null() } else { { crate::c_types::Signature::from_rust(&(item.unwrap())) } }; local_ret_0_0 }); }; local_ret_0.into() }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_justice_transaction(this_arg: *const c_void, justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
+ let mut local_htlc = if htlc.inner.is_null() { None } else { Some((* { unsafe { &*htlc.inner } }).clone()) };
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_justice_transaction(&justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), &local_htlc, &bitcoin::secp256k1::Secp256k1::new());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_remote_htlc_transaction(this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_remote_htlc_transaction(&htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, &bitcoin::secp256k1::Secp256k1::new());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_closing_transaction(this_arg: *const c_void, closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_closing_transaction(&closing_tx.into_bitcoin(), &bitcoin::secp256k1::Secp256k1::new());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_channel_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_channel_announcement(unsafe { &*msg.inner }, &bitcoin::secp256k1::Secp256k1::new());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
+ local_ret
+}
+extern "C" fn InMemoryChannelKeys_ChannelKeys_on_accept(this_arg: *mut c_void, channel_pubkeys: &crate::ln::chan_utils::ChannelPublicKeys, mut remote_to_self_delay: u16, mut local_to_self_delay: u16) {
+ unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.on_accept(unsafe { &*channel_pubkeys.inner }, remote_to_self_delay, local_to_self_delay)
+}
+
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_write(obj: *const InMemoryChannelKeys) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn InMemoryChannelKeys_read(ser: crate::c_types::u8slice) -> InMemoryChannelKeys {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ InMemoryChannelKeys { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ InMemoryChannelKeys { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::chain::keysinterface::KeysManager as nativeKeysManagerImport;
+type nativeKeysManager = nativeKeysManagerImport;
+
+/// Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key
+/// and derives keys from that.
+///
+/// Your node_id is seed/0'
+/// ChannelMonitor closes may use seed/1'
+/// Cooperative closes may use seed/2'
+/// The two close keys may be needed to claim on-chain funds!
+#[must_use]
+#[repr(C)]
+pub struct KeysManager {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeKeysManager,
+ pub is_owned: bool,
+}
+
+impl Drop for KeysManager {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn KeysManager_free(this_ptr: KeysManager) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn KeysManager_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeKeysManager); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl KeysManager {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeKeysManager {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your
+/// CSRNG is busted) this may panic (but more importantly, you will possibly lose funds).
+/// starting_time isn't strictly required to actually be a time, but it must absolutely,
+/// without a doubt, be unique to this instance. ie if you start multiple times with the same
+/// seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to
+/// simply use the current time (with very high precision).
+///
+/// The seed MUST be backed up safely prior to use so that the keys can be re-created, however,
+/// obviously, starting_time should be unique every time you reload the library - it is only
+/// used to generate new ephemeral key data (which will be stored by the individual channel if
+/// necessary).
+///
+/// Note that the seed is required to recover certain on-chain funds independent of
+/// ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any
+/// channel, and some on-chain during-closing funds.
+///
+/// Note that until the 0.1 release there is no guarantee of backward compatibility between
+/// versions. Once the library is more fully supported, the docs will be updated to include a
+/// detailed description of the guarantee.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut network: crate::bitcoin::network::Network, mut starting_time_secs: u64, mut starting_time_nanos: u32) -> KeysManager {
+ let mut ret = lightning::chain::keysinterface::KeysManager::new(unsafe { &*seed}, network.into_bitcoin(), starting_time_secs, starting_time_nanos);
+ KeysManager { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Derive an old set of ChannelKeys for per-channel secrets based on a key derivation
+/// parameters.
+/// Key derivation parameters are accessible through a per-channel secrets
+/// ChannelKeys::key_derivation_params and is provided inside DynamicOuputP2WSH in case of
+/// onchain output detection for which a corresponding delayed_payment_key must be derived.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &KeysManager, mut channel_value_satoshis: u64, mut params_1: u64, mut params_2: u64) -> crate::chain::keysinterface::InMemoryChannelKeys {
+ let mut ret = unsafe { &*this_arg.inner }.derive_channel_keys(channel_value_satoshis, params_1, params_2);
+ crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+#[no_mangle]
+pub extern "C" fn KeysManager_as_KeysInterface(this_arg: *const KeysManager) -> crate::chain::keysinterface::KeysInterface {
+ crate::chain::keysinterface::KeysInterface {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ get_node_secret: KeysManager_KeysInterface_get_node_secret,
+ get_destination_script: KeysManager_KeysInterface_get_destination_script,
+ get_shutdown_pubkey: KeysManager_KeysInterface_get_shutdown_pubkey,
+ get_channel_keys: KeysManager_KeysInterface_get_channel_keys,
+ get_secure_random_bytes: KeysManager_KeysInterface_get_secure_random_bytes,
+ }
+}
+use lightning::chain::keysinterface::KeysInterface as KeysInterfaceTraitImport;
+#[must_use]
+extern "C" fn KeysManager_KeysInterface_get_node_secret(this_arg: *const c_void) -> crate::c_types::SecretKey {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_node_secret();
+ crate::c_types::SecretKey::from_rust(ret)
+}
+#[must_use]
+extern "C" fn KeysManager_KeysInterface_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_destination_script();
+ ret.into_bytes().into()
+}
+#[must_use]
+extern "C" fn KeysManager_KeysInterface_get_shutdown_pubkey(this_arg: *const c_void) -> crate::c_types::PublicKey {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_shutdown_pubkey();
+ crate::c_types::PublicKey::from_rust(&ret)
+}
+#[must_use]
+extern "C" fn KeysManager_KeysInterface_get_channel_keys(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_channel_keys(_inbound, channel_value_satoshis);
+ let mut rust_obj = InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true };
+ let mut ret = InMemoryChannelKeys_as_ChannelKeys(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = std::ptr::null_mut();
+ ret.free = Some(InMemoryChannelKeys_free_void);
+ ret
+
+}
+#[must_use]
+extern "C" fn KeysManager_KeysInterface_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_secure_random_bytes();
+ crate::c_types::ThirtyTwoBytes { data: ret }
+}
+
--- /dev/null
+//! Structs and traits which allow other parts of rust-lightning to interact with the blockchain.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+pub mod chaininterface;
+pub mod transaction;
+pub mod keysinterface;
--- /dev/null
+//! Contains simple structs describing parts of transactions on the chain.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::chain::transaction::OutPoint as nativeOutPointImport;
+type nativeOutPoint = nativeOutPointImport;
+
+/// A reference to a transaction output.
+///
+/// Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
+/// due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
+#[must_use]
+#[repr(C)]
+pub struct OutPoint {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeOutPoint,
+ pub is_owned: bool,
+}
+
+impl Drop for OutPoint {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn OutPoint_free(this_ptr: OutPoint) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn OutPoint_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOutPoint); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl OutPoint {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeOutPoint {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for OutPoint {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn OutPoint_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOutPoint)).clone() })) as *mut c_void
+}
+/// The referenced transaction's txid.
+#[no_mangle]
+pub extern "C" fn OutPoint_get_txid(this_ptr: &OutPoint) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.txid;
+ (*inner_val).as_inner()
+}
+/// The referenced transaction's txid.
+#[no_mangle]
+pub extern "C" fn OutPoint_set_txid(this_ptr: &mut OutPoint, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
+}
+/// The index of the referenced output in its transaction's vout.
+#[no_mangle]
+pub extern "C" fn OutPoint_get_index(this_ptr: &OutPoint) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.index;
+ (*inner_val)
+}
+/// The index of the referenced output in its transaction's vout.
+#[no_mangle]
+pub extern "C" fn OutPoint_set_index(this_ptr: &mut OutPoint, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.index = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn OutPoint_new(mut txid_arg: crate::c_types::ThirtyTwoBytes, mut index_arg: u16) -> OutPoint {
+ OutPoint { inner: Box::into_raw(Box::new(nativeOutPoint {
+ txid: ::bitcoin::hash_types::Txid::from_slice(&txid_arg.data[..]).unwrap(),
+ index: index_arg,
+ })), is_owned: true }
+}
+/// Convert an `OutPoint` to a lightning channel id.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn OutPoint_to_channel_id(this_arg: &OutPoint) -> crate::c_types::ThirtyTwoBytes {
+ let mut ret = unsafe { &*this_arg.inner }.to_channel_id();
+ crate::c_types::ThirtyTwoBytes { data: ret }
+}
+
+#[no_mangle]
+pub extern "C" fn OutPoint_write(obj: *const OutPoint) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn OutPoint_read(ser: crate::c_types::u8slice) -> OutPoint {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ OutPoint { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ OutPoint { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
--- /dev/null
+//!lightning
+//! Rust-Lightning, not Rusty's Lightning!
+//!
+//! A full-featured but also flexible lightning implementation, in library form. This allows the
+//! user (you) to decide how they wish to use it instead of being a fully self-contained daemon.
+//! This means there is no built-in threading/execution environment and it's up to the user to
+//! figure out how best to make networking happen/timers fire/things get written to disk/keys get
+//! generated/etc. This makes it a good candidate for tight integration into an existing wallet
+//! instead of having a rather-separate lightning appendage to a wallet.
+#![allow(unknown_lints)]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+#![allow(unused_imports)]
+#![allow(unused_variables)]
+#![allow(unused_mut)]
+#![allow(unused_parens)]
+#![allow(unused_unsafe)]
+#![allow(unused_braces)]
+mod c_types;
+mod bitcoin;
+pub mod util;
+pub mod chain;
+pub mod ln;
+pub mod routing;
--- /dev/null
+//! Various utilities for building scripts and deriving keys related to channels. These are
+//! largely of interest for those implementing chain::keysinterface::ChannelKeys message signing
+//! by hand.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+/// Build the commitment secret from the seed and the commitment number
+#[no_mangle]
+pub extern "C" fn build_commitment_secret(commitment_seed: *const [u8; 32], mut idx: u64) -> crate::c_types::ThirtyTwoBytes {
+ let mut ret = lightning::ln::chan_utils::build_commitment_secret(unsafe { &*commitment_seed}, idx);
+ crate::c_types::ThirtyTwoBytes { data: ret }
+}
+
+/// Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
+/// from the base secret and the per_commitment_point.
+///
+/// Note that this is infallible iff we trust that at least one of the two input keys are randomly
+/// generated (ie our own).
+#[no_mangle]
+pub extern "C" fn derive_private_key(per_commitment_point: crate::c_types::PublicKey, base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeySecpErrorZ {
+ let mut ret = lightning::ln::chan_utils::derive_private_key(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *base_secret}[..]).unwrap());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SecretKey::from_rust(o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
+ local_ret
+}
+
+/// Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
+/// from the base point and the per_commitment_key. This is the public equivalent of
+/// derive_private_key - using only public keys to derive a public key instead of private keys.
+///
+/// Note that this is infallible iff we trust that at least one of the two input keys are randomly
+/// generated (ie our own).
+#[no_mangle]
+pub extern "C" fn derive_public_key(per_commitment_point: crate::c_types::PublicKey, base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeySecpErrorZ {
+ let mut ret = lightning::ln::chan_utils::derive_public_key(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &base_point.into_rust());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
+ local_ret
+}
+
+/// Derives a per-commitment-transaction revocation key from its constituent parts.
+///
+/// Note that this is infallible iff we trust that at least one of the two input keys are randomly
+/// generated (ie our own).
+#[no_mangle]
+pub extern "C" fn derive_private_revocation_key(per_commitment_secret: *const [u8; 32], revocation_base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeySecpErrorZ {
+ let mut ret = lightning::ln::chan_utils::derive_private_revocation_key(&bitcoin::secp256k1::Secp256k1::new(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_secret}[..]).unwrap(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *revocation_base_secret}[..]).unwrap());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SecretKey::from_rust(o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
+ local_ret
+}
+
+/// Derives a per-commitment-transaction revocation public key from its constituent parts. This is
+/// the public equivalend of derive_private_revocation_key - using only public keys to derive a
+/// public key instead of private keys.
+///
+/// Note that this is infallible iff we trust that at least one of the two input keys are randomly
+/// generated (ie our own).
+#[no_mangle]
+pub extern "C" fn derive_public_revocation_key(per_commitment_point: crate::c_types::PublicKey, revocation_base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeySecpErrorZ {
+ let mut ret = lightning::ln::chan_utils::derive_public_revocation_key(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &revocation_base_point.into_rust());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
+ local_ret
+}
+
+
+use lightning::ln::chan_utils::TxCreationKeys as nativeTxCreationKeysImport;
+type nativeTxCreationKeys = nativeTxCreationKeysImport;
+
+/// The set of public keys which are used in the creation of one commitment transaction.
+/// These are derived from the channel base keys and per-commitment data.
+///
+/// These keys are assumed to be good, either because the code derived them from
+/// channel basepoints via the new function, or they were obtained via
+/// PreCalculatedTxCreationKeys.trust_key_derivation because we trusted the source of the
+/// pre-calculated keys.
+#[must_use]
+#[repr(C)]
+pub struct TxCreationKeys {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeTxCreationKeys,
+ pub is_owned: bool,
+}
+
+impl Drop for TxCreationKeys {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_free(this_ptr: TxCreationKeys) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn TxCreationKeys_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeTxCreationKeys); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl TxCreationKeys {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeTxCreationKeys {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for TxCreationKeys {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn TxCreationKeys_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxCreationKeys)).clone() })) as *mut c_void
+}
+/// The per-commitment public key which was used to derive the other keys.
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_get_per_commitment_point(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The per-commitment public key which was used to derive the other keys.
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_set_per_commitment_point(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.per_commitment_point = val.into_rust();
+}
+/// The revocation key which is used to allow the owner of the commitment transaction to
+/// provide their counterparty the ability to punish them if they broadcast an old state.
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_get_revocation_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_key;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The revocation key which is used to allow the owner of the commitment transaction to
+/// provide their counterparty the ability to punish them if they broadcast an old state.
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_set_revocation_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.revocation_key = val.into_rust();
+}
+/// A's HTLC Key
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_get_a_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.a_htlc_key;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// A's HTLC Key
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_set_a_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.a_htlc_key = val.into_rust();
+}
+/// B's HTLC Key
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_get_b_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.b_htlc_key;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// B's HTLC Key
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_set_b_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.b_htlc_key = val.into_rust();
+}
+/// A's Payment Key (which isn't allowed to be spent from for some delay)
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_get_a_delayed_payment_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.a_delayed_payment_key;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// A's Payment Key (which isn't allowed to be spent from for some delay)
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_set_a_delayed_payment_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.a_delayed_payment_key = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_new(mut per_commitment_point_arg: crate::c_types::PublicKey, mut revocation_key_arg: crate::c_types::PublicKey, mut a_htlc_key_arg: crate::c_types::PublicKey, mut b_htlc_key_arg: crate::c_types::PublicKey, mut a_delayed_payment_key_arg: crate::c_types::PublicKey) -> TxCreationKeys {
+ TxCreationKeys { inner: Box::into_raw(Box::new(nativeTxCreationKeys {
+ per_commitment_point: per_commitment_point_arg.into_rust(),
+ revocation_key: revocation_key_arg.into_rust(),
+ a_htlc_key: a_htlc_key_arg.into_rust(),
+ b_htlc_key: b_htlc_key_arg.into_rust(),
+ a_delayed_payment_key: a_delayed_payment_key_arg.into_rust(),
+ })), is_owned: true }
+}
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_write(obj: *const TxCreationKeys) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_read(ser: crate::c_types::u8slice) -> TxCreationKeys {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ TxCreationKeys { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ TxCreationKeys { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::ln::chan_utils::PreCalculatedTxCreationKeys as nativePreCalculatedTxCreationKeysImport;
+type nativePreCalculatedTxCreationKeys = nativePreCalculatedTxCreationKeysImport;
+
+/// The per-commitment point and a set of pre-calculated public keys used for transaction creation
+/// in the signer.
+/// The pre-calculated keys are an optimization, because ChannelKeys has enough
+/// information to re-derive them.
+#[must_use]
+#[repr(C)]
+pub struct PreCalculatedTxCreationKeys {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativePreCalculatedTxCreationKeys,
+ pub is_owned: bool,
+}
+
+impl Drop for PreCalculatedTxCreationKeys {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn PreCalculatedTxCreationKeys_free(this_ptr: PreCalculatedTxCreationKeys) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn PreCalculatedTxCreationKeys_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativePreCalculatedTxCreationKeys); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl PreCalculatedTxCreationKeys {
+ pub(crate) fn take_ptr(mut self) -> *mut nativePreCalculatedTxCreationKeys {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Create a new PreCalculatedTxCreationKeys from TxCreationKeys
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PreCalculatedTxCreationKeys_new(mut keys: crate::ln::chan_utils::TxCreationKeys) -> PreCalculatedTxCreationKeys {
+ let mut ret = lightning::ln::chan_utils::PreCalculatedTxCreationKeys::new(*unsafe { Box::from_raw(keys.take_ptr()) });
+ PreCalculatedTxCreationKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// The pre-calculated transaction creation public keys.
+/// An external validating signer should not trust these keys.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PreCalculatedTxCreationKeys_trust_key_derivation(this_arg: &PreCalculatedTxCreationKeys) -> crate::ln::chan_utils::TxCreationKeys {
+ let mut ret = unsafe { &*this_arg.inner }.trust_key_derivation();
+ crate::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
+}
+
+/// The transaction per-commitment point
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PreCalculatedTxCreationKeys_per_commitment_point(this_arg: &PreCalculatedTxCreationKeys) -> crate::c_types::PublicKey {
+ let mut ret = unsafe { &*this_arg.inner }.per_commitment_point();
+ crate::c_types::PublicKey::from_rust(&*ret)
+}
+
+
+use lightning::ln::chan_utils::ChannelPublicKeys as nativeChannelPublicKeysImport;
+type nativeChannelPublicKeys = nativeChannelPublicKeysImport;
+
+/// One counterparty's public keys which do not change over the life of a channel.
+#[must_use]
+#[repr(C)]
+pub struct ChannelPublicKeys {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelPublicKeys,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelPublicKeys {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_free(this_ptr: ChannelPublicKeys) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelPublicKeys_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelPublicKeys); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelPublicKeys {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelPublicKeys {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelPublicKeys {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelPublicKeys_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelPublicKeys)).clone() })) as *mut c_void
+}
+/// The public key which is used to sign all commitment transactions, as it appears in the
+/// on-chain channel lock-in 2-of-2 multisig output.
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_get_funding_pubkey(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The public key which is used to sign all commitment transactions, as it appears in the
+/// on-chain channel lock-in 2-of-2 multisig output.
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_set_funding_pubkey(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
+}
+/// The base point which is used (with derive_public_revocation_key) to derive per-commitment
+/// revocation keys. This is combined with the per-commitment-secret generated by the
+/// counterparty to create a secret which the counterparty can reveal to revoke previous
+/// states.
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_get_revocation_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The base point which is used (with derive_public_revocation_key) to derive per-commitment
+/// revocation keys. This is combined with the per-commitment-secret generated by the
+/// counterparty to create a secret which the counterparty can reveal to revoke previous
+/// states.
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_set_revocation_basepoint(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
+}
+/// The public key which receives our immediately spendable primary channel balance in
+/// remote-broadcasted commitment transactions. This key is static across every commitment
+/// transaction.
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_get_payment_point(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The public key which receives our immediately spendable primary channel balance in
+/// remote-broadcasted commitment transactions. This key is static across every commitment
+/// transaction.
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_set_payment_point(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
+}
+/// The base point which is used (with derive_public_key) to derive a per-commitment payment
+/// public key which receives non-HTLC-encumbered funds which are only available for spending
+/// after some delay (or can be claimed via the revocation path).
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_get_delayed_payment_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The base point which is used (with derive_public_key) to derive a per-commitment payment
+/// public key which receives non-HTLC-encumbered funds which are only available for spending
+/// after some delay (or can be claimed via the revocation path).
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_set_delayed_payment_basepoint(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
+}
+/// The base point which is used (with derive_public_key) to derive a per-commitment public key
+/// which is used to encumber HTLC-in-flight outputs.
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_get_htlc_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The base point which is used (with derive_public_key) to derive a per-commitment public key
+/// which is used to encumber HTLC-in-flight outputs.
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_set_htlc_basepoint(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_new(mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey) -> ChannelPublicKeys {
+ ChannelPublicKeys { inner: Box::into_raw(Box::new(nativeChannelPublicKeys {
+ funding_pubkey: funding_pubkey_arg.into_rust(),
+ revocation_basepoint: revocation_basepoint_arg.into_rust(),
+ payment_point: payment_point_arg.into_rust(),
+ delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
+ htlc_basepoint: htlc_basepoint_arg.into_rust(),
+ })), is_owned: true }
+}
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_write(obj: *const ChannelPublicKeys) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelPublicKeys_read(ser: crate::c_types::u8slice) -> ChannelPublicKeys {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ChannelPublicKeys { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+/// Create a new TxCreationKeys from channel base points and the per-commitment point
+#[must_use]
+#[no_mangle]
+pub extern "C" fn TxCreationKeys_derive_new(per_commitment_point: crate::c_types::PublicKey, a_delayed_payment_base: crate::c_types::PublicKey, a_htlc_base: crate::c_types::PublicKey, b_revocation_base: crate::c_types::PublicKey, b_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysSecpErrorZ {
+ let mut ret = lightning::ln::chan_utils::TxCreationKeys::derive_new(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &a_delayed_payment_base.into_rust(), &a_htlc_base.into_rust(), &b_revocation_base.into_rust(), &b_htlc_base.into_rust());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
+ local_ret
+}
+
+/// A script either spendable by the revocation
+/// key or the delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
+/// Encumbering a `to_local` output on a commitment transaction or 2nd-stage HTLC transactions.
+#[no_mangle]
+pub extern "C" fn get_revokeable_redeemscript(revocation_key: crate::c_types::PublicKey, mut to_self_delay: u16, delayed_payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
+ let mut ret = lightning::ln::chan_utils::get_revokeable_redeemscript(&revocation_key.into_rust(), to_self_delay, &delayed_payment_key.into_rust());
+ ret.into_bytes().into()
+}
+
+
+use lightning::ln::chan_utils::HTLCOutputInCommitment as nativeHTLCOutputInCommitmentImport;
+type nativeHTLCOutputInCommitment = nativeHTLCOutputInCommitmentImport;
+
+/// Information about an HTLC as it appears in a commitment transaction
+#[must_use]
+#[repr(C)]
+pub struct HTLCOutputInCommitment {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeHTLCOutputInCommitment,
+ pub is_owned: bool,
+}
+
+impl Drop for HTLCOutputInCommitment {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_free(this_ptr: HTLCOutputInCommitment) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn HTLCOutputInCommitment_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHTLCOutputInCommitment); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl HTLCOutputInCommitment {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeHTLCOutputInCommitment {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for HTLCOutputInCommitment {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn HTLCOutputInCommitment_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCOutputInCommitment)).clone() })) as *mut c_void
+}
+/// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
+/// Note that this is not the same as whether it is ountbound *from us*. To determine that you
+/// need to compare this value to whether the commitment transaction in question is that of
+/// the remote party or our own.
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_get_offered(this_ptr: &HTLCOutputInCommitment) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.offered;
+ (*inner_val)
+}
+/// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
+/// Note that this is not the same as whether it is ountbound *from us*. To determine that you
+/// need to compare this value to whether the commitment transaction in question is that of
+/// the remote party or our own.
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_set_offered(this_ptr: &mut HTLCOutputInCommitment, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.offered = val;
+}
+/// The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
+/// this divided by 1000.
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_get_amount_msat(this_ptr: &HTLCOutputInCommitment) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
+ (*inner_val)
+}
+/// The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
+/// this divided by 1000.
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_set_amount_msat(this_ptr: &mut HTLCOutputInCommitment, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.amount_msat = val;
+}
+/// The CLTV lock-time at which this HTLC expires.
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_get_cltv_expiry(this_ptr: &HTLCOutputInCommitment) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
+ (*inner_val)
+}
+/// The CLTV lock-time at which this HTLC expires.
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_set_cltv_expiry(this_ptr: &mut HTLCOutputInCommitment, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
+}
+/// The hash of the preimage which unlocks this HTLC.
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_get_payment_hash(this_ptr: &HTLCOutputInCommitment) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
+ &(*inner_val).0
+}
+/// The hash of the preimage which unlocks this HTLC.
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_set_payment_hash(this_ptr: &mut HTLCOutputInCommitment, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data);
+}
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_write(obj: *const HTLCOutputInCommitment) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> HTLCOutputInCommitment {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ HTLCOutputInCommitment { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ HTLCOutputInCommitment { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+/// note here that 'a_revocation_key' is generated using b_revocation_basepoint and a's
+/// commitment secret. 'htlc' does *not* need to have its previous_output_index filled.
+#[no_mangle]
+pub extern "C" fn get_htlc_redeemscript(htlc: &crate::ln::chan_utils::HTLCOutputInCommitment, keys: &crate::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z {
+ let mut ret = lightning::ln::chan_utils::get_htlc_redeemscript(unsafe { &*htlc.inner }, unsafe { &*keys.inner });
+ ret.into_bytes().into()
+}
+
+/// Gets the redeemscript for a funding output from the two funding public keys.
+/// Note that the order of funding public keys does not matter.
+#[no_mangle]
+pub extern "C" fn make_funding_redeemscript(a: crate::c_types::PublicKey, b: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
+ let mut ret = lightning::ln::chan_utils::make_funding_redeemscript(&a.into_rust(), &b.into_rust());
+ ret.into_bytes().into()
+}
+
+/// panics if htlc.transaction_output_index.is_none()!
+#[no_mangle]
+pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate_per_kw: u32, mut to_self_delay: u16, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment, a_delayed_payment_key: crate::c_types::PublicKey, revocation_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
+ let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, to_self_delay, unsafe { &*htlc.inner }, &a_delayed_payment_key.into_rust(), &revocation_key.into_rust());
+ let mut local_ret = ::bitcoin::consensus::encode::serialize(&ret);
+ local_ret.into()
+}
+
+
+use lightning::ln::chan_utils::LocalCommitmentTransaction as nativeLocalCommitmentTransactionImport;
+type nativeLocalCommitmentTransaction = nativeLocalCommitmentTransactionImport;
+
+/// We use this to track local commitment transactions and put off signing them until we are ready
+/// to broadcast. This class can be used inside a signer implementation to generate a signature
+/// given the relevant secret key.
+#[must_use]
+#[repr(C)]
+pub struct LocalCommitmentTransaction {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeLocalCommitmentTransaction,
+ pub is_owned: bool,
+}
+
+impl Drop for LocalCommitmentTransaction {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_free(this_ptr: LocalCommitmentTransaction) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn LocalCommitmentTransaction_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLocalCommitmentTransaction); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl LocalCommitmentTransaction {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeLocalCommitmentTransaction {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for LocalCommitmentTransaction {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn LocalCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLocalCommitmentTransaction)).clone() })) as *mut c_void
+}
+/// The commitment transaction itself, in unsigned form.
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_get_unsigned_tx(this_ptr: &LocalCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.unsigned_tx;
+ let mut local_inner_val = ::bitcoin::consensus::encode::serialize(inner_val);
+ local_inner_val.into()
+}
+/// The commitment transaction itself, in unsigned form.
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_set_unsigned_tx(this_ptr: &mut LocalCommitmentTransaction, mut val: crate::c_types::derived::CVec_u8Z) {
+ unsafe { &mut *this_ptr.inner }.unsigned_tx = ::bitcoin::consensus::encode::deserialize(&val.into_rust()[..]).unwrap();
+}
+/// Our counterparty's signature for the transaction, above.
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_get_their_sig(this_ptr: &LocalCommitmentTransaction) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.their_sig;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// Our counterparty's signature for the transaction, above.
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_set_their_sig(this_ptr: &mut LocalCommitmentTransaction, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.their_sig = val.into_rust();
+}
+/// The feerate paid per 1000-weight-unit in this commitment transaction. This value is
+/// controlled by the channel initiator.
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_get_feerate_per_kw(this_ptr: &LocalCommitmentTransaction) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
+ (*inner_val)
+}
+/// The feerate paid per 1000-weight-unit in this commitment transaction. This value is
+/// controlled by the channel initiator.
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_set_feerate_per_kw(this_ptr: &mut LocalCommitmentTransaction, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
+}
+/// The HTLCs and remote htlc signatures which were included in this commitment transaction.
+///
+/// Note that this includes all HTLCs, including ones which were considered dust and not
+/// actually included in the transaction as it appears on-chain, but who's value is burned as
+/// fees and not included in the to_local or to_remote outputs.
+///
+/// The remote HTLC signatures in the second element will always be set for non-dust HTLCs, ie
+/// those for which transaction_output_index.is_some().
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_set_per_htlc(this_ptr: &mut LocalCommitmentTransaction, mut val: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { let (mut orig_val_0_0, mut orig_val_0_1) = item.to_rust(); let mut local_orig_val_0_1 = if orig_val_0_1.is_null() { None } else { Some( { orig_val_0_1.into_rust() }) }; let mut local_val_0 = (*unsafe { Box::from_raw(orig_val_0_0.take_ptr()) }, local_orig_val_0_1); local_val_0 }); };
+ unsafe { &mut *this_ptr.inner }.per_htlc = local_val;
+}
+/// Generate a new LocalCommitmentTransaction based on a raw commitment transaction,
+/// remote signature and both parties keys.
+///
+/// The unsigned transaction outputs must be consistent with htlc_data. This function
+/// only checks that the shape and amounts are consistent, but does not check the scriptPubkey.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_new_missing_local_sig(mut unsigned_tx: crate::c_types::derived::CVec_u8Z, mut their_sig: crate::c_types::Signature, our_funding_key: crate::c_types::PublicKey, their_funding_key: crate::c_types::PublicKey, mut local_keys: crate::ln::chan_utils::TxCreationKeys, mut feerate_per_kw: u32, mut htlc_data: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) -> crate::ln::chan_utils::LocalCommitmentTransaction {
+ let mut local_htlc_data = Vec::new(); for mut item in htlc_data.into_rust().drain(..) { local_htlc_data.push( { let (mut orig_htlc_data_0_0, mut orig_htlc_data_0_1) = item.to_rust(); let mut local_orig_htlc_data_0_1 = if orig_htlc_data_0_1.is_null() { None } else { Some( { orig_htlc_data_0_1.into_rust() }) }; let mut local_htlc_data_0 = (*unsafe { Box::from_raw(orig_htlc_data_0_0.take_ptr()) }, local_orig_htlc_data_0_1); local_htlc_data_0 }); };
+ let mut ret = lightning::ln::chan_utils::LocalCommitmentTransaction::new_missing_local_sig(::bitcoin::consensus::encode::deserialize(&unsigned_tx.into_rust()[..]).unwrap(), their_sig.into_rust(), &our_funding_key.into_rust(), &their_funding_key.into_rust(), *unsafe { Box::from_raw(local_keys.take_ptr()) }, feerate_per_kw, local_htlc_data);
+ crate::ln::chan_utils::LocalCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// The pre-calculated transaction creation public keys.
+/// An external validating signer should not trust these keys.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_trust_key_derivation(this_arg: &LocalCommitmentTransaction) -> crate::ln::chan_utils::TxCreationKeys {
+ let mut ret = unsafe { &*this_arg.inner }.trust_key_derivation();
+ crate::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
+}
+
+/// Get the txid of the local commitment transaction contained in this
+/// LocalCommitmentTransaction
+#[must_use]
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_txid(this_arg: &LocalCommitmentTransaction) -> crate::c_types::ThirtyTwoBytes {
+ let mut ret = unsafe { &*this_arg.inner }.txid();
+ crate::c_types::ThirtyTwoBytes { data: ret.into_inner() }
+}
+
+/// Gets our signature for the contained commitment transaction given our funding private key.
+///
+/// Funding key is your key included in the 2-2 funding_outpoint lock. Should be provided
+/// by your ChannelKeys.
+/// Funding redeemscript is script locking funding_outpoint. This is the mutlsig script
+/// between your own funding key and your counterparty's. Currently, this is provided in
+/// ChannelKeys::sign_local_commitment() calls directly.
+/// Channel value is amount locked in funding_outpoint.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_get_local_sig(this_arg: &LocalCommitmentTransaction, funding_key: *const [u8; 32], funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature {
+ let mut ret = unsafe { &*this_arg.inner }.get_local_sig(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, &bitcoin::secp256k1::Secp256k1::new());
+ crate::c_types::Signature::from_rust(&ret)
+}
+
+/// Get a signature for each HTLC which was included in the commitment transaction (ie for
+/// which HTLCOutputInCommitment::transaction_output_index.is_some()).
+///
+/// The returned Vec has one entry for each HTLC, and in the same order. For HTLCs which were
+/// considered dust and not included, a None entry exists, for all others a signature is
+/// included.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_get_htlc_sigs(this_arg: &LocalCommitmentTransaction, htlc_base_key: *const [u8; 32], mut local_csv: u16) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
+ let mut ret = unsafe { &*this_arg.inner }.get_htlc_sigs(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), local_csv, &bitcoin::secp256k1::Secp256k1::new());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_none() { crate::c_types::Signature::null() } else { { crate::c_types::Signature::from_rust(&(item.unwrap())) } }; local_ret_0_0 }); }; local_ret_0.into() }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
+ local_ret
+}
+
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_write(obj: *const LocalCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn LocalCommitmentTransaction_read(ser: crate::c_types::u8slice) -> LocalCommitmentTransaction {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ LocalCommitmentTransaction { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ LocalCommitmentTransaction { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
--- /dev/null
+//! The top-level channel management and payment tracking stuff lives here.
+//!
+//! The ChannelManager is the main chunk of logic implementing the lightning protocol and is
+//! responsible for tracking which channels are open, HTLCs are in flight and reestablishing those
+//! upon reconnect to the relevant peer(s).
+//!
+//! It does not manage routing logic (see routing::router::get_route for that) nor does it manage constructing
+//! on-chain transactions (it only monitors the chain to watch for any force-closes that might
+//! imply it needs to fail HTLCs/payments/channels it manages).
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport;
+type nativeChannelManager = nativeChannelManagerImport<crate::chain::keysinterface::ChannelKeys, crate::ln::channelmonitor::ManyChannelMonitor, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>;
+
+/// Manager which keeps track of a number of channels and sends messages to the appropriate
+/// channel, also tracking HTLC preimages and forwarding onion packets appropriately.
+///
+/// Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
+/// to individual Channels.
+///
+/// Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
+/// all peers during write/read (though does not modify this instance, only the instance being
+/// serialized). This will result in any channels which have not yet exchanged funding_created (ie
+/// called funding_transaction_generated for outbound channels).
+///
+/// Note that you can be a bit lazier about writing out ChannelManager than you can be with
+/// ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
+/// returning from ManyChannelMonitor::add_/update_monitor, with ChannelManagers, writing updates
+/// happens out-of-band (and will prevent any other ChannelManager operations from occurring during
+/// the serialization process). If the deserialized version is out-of-date compared to the
+/// ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
+/// ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
+///
+/// Note that the deserializer is only implemented for (Sha256dHash, ChannelManager), which
+/// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
+/// the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
+/// block_connected() to step towards your best block) upon deserialization before using the
+/// object!
+///
+/// Note that ChannelManager is responsible for tracking liveness of its channels and generating
+/// ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
+/// spam due to quick disconnection/reconnection, updates are not sent until the channel has been
+/// offline for a full minute. In order to track this, you must call
+/// timer_chan_freshness_every_min roughly once per minute, though it doesn't have to be perfect.
+///
+/// Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
+/// a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
+/// essentially you should default to using a SimpleRefChannelManager, and use a
+/// SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
+/// you're using lightning-net-tokio.
+#[must_use]
+#[repr(C)]
+pub struct ChannelManager {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelManager,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelManager {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelManager_free(this_ptr: ChannelManager) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelManager_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelManager); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelManager {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelManager {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport;
+type nativeChannelDetails = nativeChannelDetailsImport;
+
+/// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
+#[must_use]
+#[repr(C)]
+pub struct ChannelDetails {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelDetails,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelDetails {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelDetails_free(this_ptr: ChannelDetails) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelDetails); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelDetails {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelDetails {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
+/// thereafter this is the txid of the funding transaction xor the funding transaction output).
+/// Note that this means this value is *not* persistent - it can change once during the
+/// lifetime of the channel.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
+/// thereafter this is the txid of the funding transaction xor the funding transaction output).
+/// Note that this means this value is *not* persistent - it can change once during the
+/// lifetime of the channel.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The node_id of our counterparty
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_remote_network_id(this_ptr: &ChannelDetails) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.remote_network_id;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The node_id of our counterparty
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_remote_network_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.remote_network_id = val.into_rust();
+}
+/// The Features the channel counterparty provided upon last connection.
+/// Useful for routing as it is the most up-to-date copy of the counterparty's features and
+/// many routing-relevant features are present in the init context.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_counterparty_features(this_ptr: &ChannelDetails) -> crate::ln::features::InitFeatures {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_features;
+ crate::ln::features::InitFeatures { inner: &mut (*inner_val), is_owned: false }
+}
+/// The Features the channel counterparty provided upon last connection.
+/// Useful for routing as it is the most up-to-date copy of the counterparty's features and
+/// many routing-relevant features are present in the init context.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_counterparty_features(this_ptr: &mut ChannelDetails, mut val: crate::ln::features::InitFeatures) {
+ unsafe { &mut *this_ptr.inner }.counterparty_features = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+/// The value, in satoshis, of this channel as appears in the funding output
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis;
+ (*inner_val)
+}
+/// The value, in satoshis, of this channel as appears in the funding output
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val;
+}
+/// The user_id passed in to create_channel, or 0 if the channel was inbound.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_user_id(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.user_id;
+ (*inner_val)
+}
+/// The user_id passed in to create_channel, or 0 if the channel was inbound.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_user_id(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.user_id = val;
+}
+/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
+/// any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+/// available for inclusion in new outbound HTLCs). This further does not include any pending
+/// outgoing HTLCs which are awaiting some other resolution to be sent.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outbound_capacity_msat;
+ (*inner_val)
+}
+/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
+/// any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+/// available for inclusion in new outbound HTLCs). This further does not include any pending
+/// outgoing HTLCs which are awaiting some other resolution to be sent.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.outbound_capacity_msat = val;
+}
+/// The available inbound capacity for the remote peer to send HTLCs to us. This does not
+/// include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+/// available for inclusion in new inbound HTLCs).
+/// Note that there are some corner cases not fully handled here, so the actual available
+/// inbound capacity may be slightly higher than this.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.inbound_capacity_msat;
+ (*inner_val)
+}
+/// The available inbound capacity for the remote peer to send HTLCs to us. This does not
+/// include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+/// available for inclusion in new inbound HTLCs).
+/// Note that there are some corner cases not fully handled here, so the actual available
+/// inbound capacity may be slightly higher than this.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.inbound_capacity_msat = val;
+}
+/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
+/// the peer is connected, and (c) no monitor update failure is pending resolution.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_is_live(this_ptr: &ChannelDetails) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_live;
+ (*inner_val)
+}
+/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
+/// the peer is connected, and (c) no monitor update failure is pending resolution.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_is_live(this_ptr: &mut ChannelDetails, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.is_live = val;
+}
+
+use lightning::ln::channelmanager::PaymentSendFailure as nativePaymentSendFailureImport;
+type nativePaymentSendFailure = nativePaymentSendFailureImport;
+
+/// If a payment fails to send, it can be in one of several states. This enum is returned as the
+/// Err() type describing which state the payment is in, see the description of individual enum
+/// states for more.
+#[must_use]
+#[repr(C)]
+pub struct PaymentSendFailure {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativePaymentSendFailure,
+ pub is_owned: bool,
+}
+
+impl Drop for PaymentSendFailure {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn PaymentSendFailure_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativePaymentSendFailure); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl PaymentSendFailure {
+ pub(crate) fn take_ptr(mut self) -> *mut nativePaymentSendFailure {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Constructs a new ChannelManager to hold several channels and route between them.
+///
+/// This is the main \"logic hub\" for all channel-related actions, and implements
+/// ChannelMessageHandler.
+///
+/// Non-proportional fees are fixed according to our risk using the provided fee estimator.
+///
+/// panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
+///
+/// Users must provide the current blockchain height from which to track onchain channel
+/// funding outpoints and send payments with reliable timelocks.
+///
+/// Users need to notify the new ChannelManager when a new block is connected or
+/// disconnected using its `block_connected` and `block_disconnected` methods.
+/// However, rather than calling these methods directly, the user should register
+/// the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's
+/// `block_(dis)connected` methods, which will notify all registered listeners in one
+/// go.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_new(mut network: crate::bitcoin::network::Network, mut fee_est: crate::chain::chaininterface::FeeEstimator, mut monitor: crate::ln::channelmonitor::ManyChannelMonitor, mut tx_broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut keys_manager: crate::chain::keysinterface::KeysInterface, mut config: crate::util::config::UserConfig, mut current_blockchain_height: usize) -> ChannelManager {
+ let mut ret = lightning::ln::channelmanager::ChannelManager::new(network.into_bitcoin(), fee_est, monitor, tx_broadcaster, logger, keys_manager, *unsafe { Box::from_raw(config.take_ptr()) }, current_blockchain_height);
+ ChannelManager { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Creates a new outbound channel to the given remote node and with the given value.
+///
+/// user_id will be provided back as user_channel_id in FundingGenerationReady and
+/// FundingBroadcastSafe events to allow tracking of which events correspond with which
+/// create_channel call. Note that user_channel_id defaults to 0 for inbound channels, so you
+/// may wish to avoid using 0 for user_id here.
+///
+/// If successful, will generate a SendOpenChannel message event, so you should probably poll
+/// PeerManager::process_events afterwards.
+///
+/// Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
+/// greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_create_channel(this_arg: &ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_id: u64, mut override_config: crate::util::config::UserConfig) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_ptr()) } }) };
+ let mut ret = unsafe { &*this_arg.inner }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_id, local_override_config);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }) };
+ local_ret
+}
+
+/// Gets the list of open channels, in random order. See ChannelDetail field documentation for
+/// more information.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_list_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
+ let mut ret = unsafe { &*this_arg.inner }.list_channels();
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::channelmanager::ChannelDetails { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
+ local_ret.into()
+}
+
+/// Gets the list of usable channels, in random order. Useful as an argument to
+/// get_route to ensure non-announced channels are used.
+///
+/// These are guaranteed to have their is_live value set to true, see the documentation for
+/// ChannelDetails::is_live for more info on exactly what the criteria are.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
+ let mut ret = unsafe { &*this_arg.inner }.list_usable_channels();
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::channelmanager::ChannelDetails { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
+ local_ret.into()
+}
+
+/// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
+/// will be accepted on the given channel, and after additional timeout/the closing of all
+/// pending HTLCs, the channel will be closed on chain.
+///
+/// May generate a SendShutdown message event on success, which should be relayed.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut ret = unsafe { &*this_arg.inner }.close_channel(unsafe { &*channel_id});
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }) };
+ local_ret
+}
+
+/// Force closes a channel, immediately broadcasting the latest local commitment transaction to
+/// the chain and rejecting new HTLCs on the given channel.
+#[no_mangle]
+pub extern "C" fn ChannelManager_force_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) {
+ unsafe { &*this_arg.inner }.force_close_channel(unsafe { &*channel_id})
+}
+
+/// Force close all channels, immediately broadcasting the latest local commitment transaction
+/// for each to the chain and rejecting new HTLCs on each.
+#[no_mangle]
+pub extern "C" fn ChannelManager_force_close_all_channels(this_arg: &ChannelManager) {
+ unsafe { &*this_arg.inner }.force_close_all_channels()
+}
+
+/// Sends a payment along a given route.
+///
+/// Value parameters are provided via the last hop in route, see documentation for RouteHop
+/// fields for more info.
+///
+/// Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
+/// payment), we don't do anything to stop you! We always try to ensure that if the provided
+/// next hop knows the preimage to payment_hash they can claim an additional amount as
+/// specified in the last hop in the route! Thus, you should probably do your own
+/// payment_preimage tracking (which you should already be doing as they represent \"proof of
+/// payment\") and prevent double-sends yourself.
+///
+/// May generate SendHTLCs message(s) event on success, which should be relayed.
+///
+/// Each path may have a different return value, and PaymentSendValue may return a Vec with
+/// each entry matching the corresponding-index entry in the route paths, see
+/// PaymentSendFailure for more info.
+///
+/// In general, a path may raise:
+/// * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
+/// node public key) is specified.
+/// * APIError::ChannelUnavailable if the next-hop channel is not available for updates
+/// (including due to previous monitor update failure or new permanent monitor update
+/// failure).
+/// * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
+/// relevant updates.
+///
+/// Note that depending on the type of the PaymentSendFailure the HTLC may have been
+/// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
+/// different route unless you intend to pay twice!
+///
+/// payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
+/// the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
+/// newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
+/// must not contain multiple paths as multi-path payments require a recipient-provided
+/// payment_secret.
+/// If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
+/// bit set (either as required or as available). If multiple paths are present in the Route,
+/// we assume the invoice had the basic_mpp feature set.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_send_payment(this_arg: &ChannelManager, route: &crate::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
+ let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
+ let mut ret = unsafe { &*this_arg.inner }.send_payment(unsafe { &*route.inner }, ::lightning::ln::channelmanager::PaymentHash(payment_hash.data), &local_payment_secret);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::channelmanager::PaymentSendFailure { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+
+/// Call this upon creation of a funding transaction for the given channel.
+///
+/// Note that ALL inputs in the transaction pointed to by funding_txo MUST spend SegWit outputs
+/// or your counterparty can steal your funds!
+///
+/// Panics if a funding transaction has already been provided for this channel.
+///
+/// May panic if the funding_txo is duplicative with some other channel (note that this should
+/// be trivially prevented by using unique funding transaction keys per-channel).
+#[no_mangle]
+pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32], mut funding_txo: crate::chain::transaction::OutPoint) {
+ unsafe { &*this_arg.inner }.funding_transaction_generated(unsafe { &*temporary_channel_id}, *unsafe { Box::from_raw(funding_txo.take_ptr()) })
+}
+
+/// Generates a signed node_announcement from the given arguments and creates a
+/// BroadcastNodeAnnouncement event. Note that such messages will be ignored unless peers have
+/// seen a channel_announcement from us (ie unless we have public channels open).
+///
+/// RGB is a node \"color\" and alias is a printable human-readable string to describe this node
+/// to humans. They carry no in-protocol meaning.
+///
+/// addresses represent the set (possibly empty) of socket addresses on which this node accepts
+/// incoming connections. These will be broadcast to the network, publicly tying these
+/// addresses together. If you wish to preserve user privacy, addresses should likely contain
+/// only Tor Onion addresses.
+///
+/// Panics if addresses is absurdly large (more than 500).
+#[no_mangle]
+pub extern "C" fn ChannelManager_broadcast_node_announcement(this_arg: &ChannelManager, mut rgb: crate::c_types::ThreeBytes, mut alias: crate::c_types::ThirtyTwoBytes, mut addresses: crate::c_types::derived::CVec_NetAddressZ) {
+ let mut local_addresses = Vec::new(); for mut item in addresses.into_rust().drain(..) { local_addresses.push( { item.into_native() }); };
+ unsafe { &*this_arg.inner }.broadcast_node_announcement(rgb.data, alias.data, local_addresses)
+}
+
+/// Processes HTLCs which are pending waiting on random forward delay.
+///
+/// Should only really ever be called in response to a PendingHTLCsForwardable event.
+/// Will likely generate further events.
+#[no_mangle]
+pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &ChannelManager) {
+ unsafe { &*this_arg.inner }.process_pending_htlc_forwards()
+}
+
+/// If a peer is disconnected we mark any channels with that peer as 'disabled'.
+/// After some time, if channels are still disabled we need to broadcast a ChannelUpdate
+/// to inform the network about the uselessness of these channels.
+///
+/// This method handles all the details, and must be called roughly once per minute.
+#[no_mangle]
+pub extern "C" fn ChannelManager_timer_chan_freshness_every_min(this_arg: &ChannelManager) {
+ unsafe { &*this_arg.inner }.timer_chan_freshness_every_min()
+}
+
+/// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
+/// after a PaymentReceived event, failing the HTLC back to its origin and freeing resources
+/// along the path (including in our own channel on which we received it).
+/// Returns false if no payment was found to fail backwards, true if the process of failing the
+/// HTLC backwards has been started.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager, payment_hash: *const [u8; 32], payment_secret: crate::c_types::ThirtyTwoBytes) -> bool {
+ let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
+ let mut ret = unsafe { &*this_arg.inner }.fail_htlc_backwards(&::lightning::ln::channelmanager::PaymentHash(unsafe { *payment_hash }), &local_payment_secret);
+ ret
+}
+
+/// Provides a payment preimage in response to a PaymentReceived event, returning true and
+/// generating message events for the net layer to claim the payment, if possible. Thus, you
+/// should probably kick the net layer to go send messages if this returns true!
+///
+/// You must specify the expected amounts for this HTLC, and we will only claim HTLCs
+/// available within a few percent of the expected amount. This is critical for several
+/// reasons : a) it avoids providing senders with `proof-of-payment` (in the form of the
+/// payment_preimage without having provided the full value and b) it avoids certain
+/// privacy-breaking recipient-probing attacks which may reveal payment activity to
+/// motivated attackers.
+///
+/// Note that the privacy concerns in (b) are not relevant in payments with a payment_secret
+/// set. Thus, for such payments we will claim any payments which do not under-pay.
+///
+/// May panic if called except in response to a PaymentReceived event.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_claim_funds(this_arg: &ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes, mut expected_amount: u64) -> bool {
+ let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
+ let mut ret = unsafe { &*this_arg.inner }.claim_funds(::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data), &local_payment_secret, expected_amount);
+ ret
+}
+
+/// Gets the node_id held by this ChannelManager
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &ChannelManager) -> crate::c_types::PublicKey {
+ let mut ret = unsafe { &*this_arg.inner }.get_our_node_id();
+ crate::c_types::PublicKey::from_rust(&ret)
+}
+
+/// Restores a single, given channel to normal operation after a
+/// ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update
+/// operation.
+///
+/// All ChannelMonitor updates up to and including highest_applied_update_id must have been
+/// fully committed in every copy of the given channels' ChannelMonitors.
+///
+/// Note that there is no effect to calling with a highest_applied_update_id other than the
+/// current latest ChannelMonitorUpdate and one call to this function after multiple
+/// ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field
+/// exists largely only to prevent races between this and concurrent update_monitor calls.
+///
+/// Thus, the anticipated use is, at a high level:
+/// 1) You register a ManyChannelMonitor with this ChannelManager,
+/// 2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
+/// said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
+/// any time it cannot do so instantly,
+/// 3) update(s) are applied to each remote copy of a ChannelMonitor,
+/// 4) once all remote copies are updated, you call this function with the update_id that
+/// completed, and once it is the latest the Channel will be re-enabled.
+#[no_mangle]
+pub extern "C" fn ChannelManager_channel_monitor_updated(this_arg: &ChannelManager, funding_txo: &crate::chain::transaction::OutPoint, mut highest_applied_update_id: u64) {
+ unsafe { &*this_arg.inner }.channel_monitor_updated(unsafe { &*funding_txo.inner }, highest_applied_update_id)
+}
+
+#[no_mangle]
+pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: *const ChannelManager) -> crate::util::events::MessageSendEventsProvider {
+ crate::util::events::MessageSendEventsProvider {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
+ }
+}
+use lightning::util::events::MessageSendEventsProvider as MessageSendEventsProviderTraitImport;
+#[must_use]
+extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeChannelManager) }.get_and_clear_pending_msg_events();
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
+ local_ret.into()
+}
+
+#[no_mangle]
+pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: *const ChannelManager) -> crate::util::events::EventsProvider {
+ crate::util::events::EventsProvider {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ get_and_clear_pending_events: ChannelManager_EventsProvider_get_and_clear_pending_events,
+ }
+}
+use lightning::util::events::EventsProvider as EventsProviderTraitImport;
+#[must_use]
+extern "C" fn ChannelManager_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeChannelManager) }.get_and_clear_pending_events();
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
+ local_ret.into()
+}
+
+#[no_mangle]
+pub extern "C" fn ChannelManager_as_ChainListener(this_arg: *const ChannelManager) -> crate::chain::chaininterface::ChainListener {
+ crate::chain::chaininterface::ChainListener {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ block_connected: ChannelManager_ChainListener_block_connected,
+ block_disconnected: ChannelManager_ChainListener_block_disconnected,
+ }
+}
+use lightning::chain::chaininterface::ChainListener as ChainListenerTraitImport;
+extern "C" fn ChannelManager_ChainListener_block_connected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32, mut txn_matched: crate::c_types::derived::CVec_TransactionZ, mut indexes_of_txn_matched: crate::c_types::usizeslice) {
+ let mut local_txn_matched = Vec::new(); for mut item in txn_matched.into_rust().drain(..) { local_txn_matched.push( { ::bitcoin::consensus::encode::deserialize(&item.into_rust()[..]).unwrap() }); };
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, &local_txn_matched.iter().collect::<Vec<_>>()[..], indexes_of_txn_matched.to_slice())
+}
+extern "C" fn ChannelManager_ChainListener_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], unused_0: u32) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), unused_0)
+}
+
+#[no_mangle]
+pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: *const ChannelManager) -> crate::ln::msgs::ChannelMessageHandler {
+ crate::ln::msgs::ChannelMessageHandler {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ handle_open_channel: ChannelManager_ChannelMessageHandler_handle_open_channel,
+ handle_accept_channel: ChannelManager_ChannelMessageHandler_handle_accept_channel,
+ handle_funding_created: ChannelManager_ChannelMessageHandler_handle_funding_created,
+ handle_funding_signed: ChannelManager_ChannelMessageHandler_handle_funding_signed,
+ handle_funding_locked: ChannelManager_ChannelMessageHandler_handle_funding_locked,
+ handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown,
+ handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed,
+ handle_update_add_htlc: ChannelManager_ChannelMessageHandler_handle_update_add_htlc,
+ handle_update_fulfill_htlc: ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc,
+ handle_update_fail_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_htlc,
+ handle_update_fail_malformed_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc,
+ handle_commitment_signed: ChannelManager_ChannelMessageHandler_handle_commitment_signed,
+ handle_revoke_and_ack: ChannelManager_ChannelMessageHandler_handle_revoke_and_ack,
+ handle_update_fee: ChannelManager_ChannelMessageHandler_handle_update_fee,
+ handle_announcement_signatures: ChannelManager_ChannelMessageHandler_handle_announcement_signatures,
+ peer_disconnected: ChannelManager_ChannelMessageHandler_peer_disconnected,
+ peer_connected: ChannelManager_ChannelMessageHandler_peer_connected,
+ handle_channel_reestablish: ChannelManager_ChannelMessageHandler_handle_channel_reestablish,
+ handle_error: ChannelManager_ChannelMessageHandler_handle_error,
+ MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ get_and_clear_pending_msg_events: ChannelManager_ChannelMessageHandler_get_and_clear_pending_msg_events,
+ },
+ }
+}
+use lightning::ln::msgs::ChannelMessageHandler as ChannelMessageHandlerTraitImport;
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_open_channel(&their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_ptr()) }, unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_accept_channel(&their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_ptr()) }, unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_created(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_signed(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_locked(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_shutdown(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_closing_signed(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_add_htlc(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fulfill_htlc(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fail_htlc(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fail_malformed_htlc(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_commitment_signed(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_revoke_and_ack(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fee(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_announcement_signatures(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_channel_reestablish(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.peer_disconnected(&their_node_id.into_rust(), no_connection_possible)
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.peer_connected(&their_node_id.into_rust(), unsafe { &*init_msg.inner })
+}
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage) {
+ unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_error(&their_node_id.into_rust(), unsafe { &*msg.inner })
+}
+use lightning::util::events::MessageSendEventsProvider as nativeMessageSendEventsProviderTrait;
+#[must_use]
+extern "C" fn ChannelManager_ChannelMessageHandler_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeChannelManager) }.get_and_clear_pending_msg_events();
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
+ local_ret.into()
+}
+
+
+use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport;
+type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::chain::keysinterface::ChannelKeys, crate::ln::channelmonitor::ManyChannelMonitor, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>;
+
+/// Arguments for the creation of a ChannelManager that are not deserialized.
+///
+/// At a high-level, the process for deserializing a ChannelManager and resuming normal operation
+/// is:
+/// 1) Deserialize all stored ChannelMonitors.
+/// 2) Deserialize the ChannelManager by filling in this struct and calling <(Sha256dHash,
+/// ChannelManager)>::read(reader, args).
+/// This may result in closing some Channels if the ChannelMonitor is newer than the stored
+/// ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted.
+/// 3) Register all relevant ChannelMonitor outpoints with your chain watch mechanism using
+/// ChannelMonitor::get_monitored_outpoints and ChannelMonitor::get_funding_txo().
+/// 4) Reconnect blocks on your ChannelMonitors.
+/// 5) Move the ChannelMonitors into your local ManyChannelMonitor.
+/// 6) Disconnect/connect blocks on the ChannelManager.
+/// 7) Register the new ChannelManager with your ChainWatchInterface.
+#[must_use]
+#[repr(C)]
+pub struct ChannelManagerReadArgs {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelManagerReadArgs,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelManagerReadArgs {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_free(this_ptr: ChannelManagerReadArgs) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelManagerReadArgs_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelManagerReadArgs); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelManagerReadArgs {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelManagerReadArgs {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// The keys provider which will give us relevant keys. Some keys will be loaded during
+/// deserialization.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_get_keys_manager(this_ptr: &ChannelManagerReadArgs) -> *const crate::chain::keysinterface::KeysInterface {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.keys_manager;
+ &(*inner_val)
+}
+/// The keys provider which will give us relevant keys. Some keys will be loaded during
+/// deserialization.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_set_keys_manager(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::chain::keysinterface::KeysInterface) {
+ unsafe { &mut *this_ptr.inner }.keys_manager = val;
+}
+/// The fee_estimator for use in the ChannelManager in the future.
+///
+/// No calls to the FeeEstimator will be made during deserialization.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_get_fee_estimator(this_ptr: &ChannelManagerReadArgs) -> *const crate::chain::chaininterface::FeeEstimator {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_estimator;
+ &(*inner_val)
+}
+/// The fee_estimator for use in the ChannelManager in the future.
+///
+/// No calls to the FeeEstimator will be made during deserialization.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_set_fee_estimator(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::chain::chaininterface::FeeEstimator) {
+ unsafe { &mut *this_ptr.inner }.fee_estimator = val;
+}
+/// The ManyChannelMonitor for use in the ChannelManager in the future.
+///
+/// No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
+/// you have deserialized ChannelMonitors separately and will add them to your
+/// ManyChannelMonitor after deserializing this ChannelManager.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_get_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::ln::channelmonitor::ManyChannelMonitor {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.monitor;
+ &(*inner_val)
+}
+/// The ManyChannelMonitor for use in the ChannelManager in the future.
+///
+/// No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
+/// you have deserialized ChannelMonitors separately and will add them to your
+/// ManyChannelMonitor after deserializing this ChannelManager.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_set_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::ln::channelmonitor::ManyChannelMonitor) {
+ unsafe { &mut *this_ptr.inner }.monitor = val;
+}
+/// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
+/// used to broadcast the latest local commitment transactions of channels which must be
+/// force-closed during deserialization.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_get_tx_broadcaster(this_ptr: &ChannelManagerReadArgs) -> *const crate::chain::chaininterface::BroadcasterInterface {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.tx_broadcaster;
+ &(*inner_val)
+}
+/// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
+/// used to broadcast the latest local commitment transactions of channels which must be
+/// force-closed during deserialization.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_set_tx_broadcaster(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::chain::chaininterface::BroadcasterInterface) {
+ unsafe { &mut *this_ptr.inner }.tx_broadcaster = val;
+}
+/// The Logger for use in the ChannelManager and which may be used to log information during
+/// deserialization.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_get_logger(this_ptr: &ChannelManagerReadArgs) -> *const crate::util::logger::Logger {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.logger;
+ &(*inner_val)
+}
+/// The Logger for use in the ChannelManager and which may be used to log information during
+/// deserialization.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_set_logger(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::util::logger::Logger) {
+ unsafe { &mut *this_ptr.inner }.logger = val;
+}
+/// Default settings used for new channels. Any existing channels will continue to use the
+/// runtime settings which were stored when the ChannelManager was serialized.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_get_default_config(this_ptr: &ChannelManagerReadArgs) -> crate::util::config::UserConfig {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.default_config;
+ crate::util::config::UserConfig { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Default settings used for new channels. Any existing channels will continue to use the
+/// runtime settings which were stored when the ChannelManager was serialized.
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::util::config::UserConfig) {
+ unsafe { &mut *this_ptr.inner }.default_config = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+/// Simple utility function to create a ChannelManagerReadArgs which creates the monitor
+/// HashMap for you. This is primarily useful for C bindings where it is not practical to
+/// populate a HashMap directly from C.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManagerReadArgs_new(mut keys_manager: crate::chain::keysinterface::KeysInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut monitor: crate::ln::channelmonitor::ManyChannelMonitor, mut tx_broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut default_config: crate::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> ChannelManagerReadArgs {
+ let mut local_channel_monitors = Vec::new(); for mut item in channel_monitors.into_rust().drain(..) { local_channel_monitors.push( { unsafe { &mut *item.inner } }); };
+ let mut ret = lightning::ln::channelmanager::ChannelManagerReadArgs::new(keys_manager, fee_estimator, monitor, tx_broadcaster, logger, *unsafe { Box::from_raw(default_config.take_ptr()) }, local_channel_monitors);
+ ChannelManagerReadArgs { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
--- /dev/null
+//! The logic to monitor for on-chain transactions and create the relevant claim responses lives
+//! here.
+//!
+//! ChannelMonitor objects are generated by ChannelManager in response to relevant
+//! messages/actions, and MUST be persisted to disk (and, preferably, remotely) before progress can
+//! be made in responding to certain messages, see ManyChannelMonitor for more.
+//!
+//! Note that ChannelMonitors are an important part of the lightning trust model and a copy of the
+//! latest ChannelMonitor must always be actively monitoring for chain updates (and no out-of-date
+//! ChannelMonitors should do so). Thus, if you're building rust-lightning into an HSM or other
+//! security-domain-separated system design, you should consider having multiple paths for
+//! ChannelMonitors to get out of the HSM and onto monitoring devices.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::ln::channelmonitor::ChannelMonitorUpdate as nativeChannelMonitorUpdateImport;
+type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport;
+
+/// An update generated by the underlying Channel itself which contains some new information the
+/// ChannelMonitor should be made aware of.
+#[must_use]
+#[repr(C)]
+pub struct ChannelMonitorUpdate {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelMonitorUpdate,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelMonitorUpdate {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_free(this_ptr: ChannelMonitorUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitorUpdate); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelMonitorUpdate {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitorUpdate {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelMonitorUpdate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelMonitorUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelMonitorUpdate)).clone() })) as *mut c_void
+}
+/// The sequence number of this update. Updates *must* be replayed in-order according to this
+/// sequence number (and updates may panic if they are not). The update_id values are strictly
+/// increasing and increase by one for each new update.
+///
+/// This sequence number is also used to track up to which points updates which returned
+/// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
+/// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUpdate) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_id;
+ (*inner_val)
+}
+/// The sequence number of this update. Updates *must* be replayed in-order according to this
+/// sequence number (and updates may panic if they are not). The update_id values are strictly
+/// increasing and increase by one for each new update.
+///
+/// This sequence number is also used to track up to which points updates which returned
+/// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
+/// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_set_update_id(this_ptr: &mut ChannelMonitorUpdate, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.update_id = val;
+}
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_write(obj: *const ChannelMonitorUpdate) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> ChannelMonitorUpdate {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ChannelMonitorUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ChannelMonitorUpdate { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+/// An error enum representing a failure to persist a channel monitor update.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum ChannelMonitorUpdateErr {
+ /// Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
+ /// our state failed, but is expected to succeed at some point in the future).
+ ///
+ /// Such a failure will \"freeze\" a channel, preventing us from revoking old states or
+ /// submitting new commitment transactions to the remote party. Once the update(s) which failed
+ /// have been successfully applied, ChannelManager::channel_monitor_updated can be used to
+ /// restore the channel to an operational state.
+ ///
+ /// Note that a given ChannelManager will *never* re-generate a given ChannelMonitorUpdate. If
+ /// you return a TemporaryFailure you must ensure that it is written to disk safely before
+ /// writing out the latest ChannelManager state.
+ ///
+ /// Even when a channel has been \"frozen\" updates to the ChannelMonitor can continue to occur
+ /// (eg if an inbound HTLC which we forwarded was claimed upstream resulting in us attempting
+ /// to claim it on this channel) and those updates must be applied wherever they can be. At
+ /// least one such updated ChannelMonitor must be persisted otherwise PermanentFailure should
+ /// be returned to get things on-chain ASAP using only the in-memory copy. Obviously updates to
+ /// the channel which would invalidate previous ChannelMonitors are not made when a channel has
+ /// been \"frozen\".
+ ///
+ /// Note that even if updates made after TemporaryFailure succeed you must still call
+ /// channel_monitor_updated to ensure you have the latest monitor and re-enable normal channel
+ /// operation.
+ ///
+ /// Note that the update being processed here will not be replayed for you when you call
+ /// ChannelManager::channel_monitor_updated, so you must store the update itself along
+ /// with the persisted ChannelMonitor on your own local disk prior to returning a
+ /// TemporaryFailure. You may, of course, employ a journaling approach, storing only the
+ /// ChannelMonitorUpdate on disk without updating the monitor itself, replaying the journal at
+ /// reload-time.
+ ///
+ /// For deployments where a copy of ChannelMonitors and other local state are backed up in a
+ /// remote location (with local copies persisted immediately), it is anticipated that all
+ /// updates will return TemporaryFailure until the remote copies could be updated.
+ TemporaryFailure,
+ /// Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a
+ /// different watchtower and cannot update with all watchtowers that were previously informed
+ /// of this channel). This will force-close the channel in question (which will generate one
+ /// final ChannelMonitorUpdate which must be delivered to at least one ChannelMonitor copy).
+ ///
+ /// Should also be used to indicate a failure to update the local persisted copy of the channel
+ /// monitor.
+ PermanentFailure,
+}
+use lightning::ln::channelmonitor::ChannelMonitorUpdateErr as nativeChannelMonitorUpdateErr;
+impl ChannelMonitorUpdateErr {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeChannelMonitorUpdateErr {
+ match self {
+ ChannelMonitorUpdateErr::TemporaryFailure => nativeChannelMonitorUpdateErr::TemporaryFailure,
+ ChannelMonitorUpdateErr::PermanentFailure => nativeChannelMonitorUpdateErr::PermanentFailure,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeChannelMonitorUpdateErr {
+ match self {
+ ChannelMonitorUpdateErr::TemporaryFailure => nativeChannelMonitorUpdateErr::TemporaryFailure,
+ ChannelMonitorUpdateErr::PermanentFailure => nativeChannelMonitorUpdateErr::PermanentFailure,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeChannelMonitorUpdateErr) -> Self {
+ match native {
+ nativeChannelMonitorUpdateErr::TemporaryFailure => ChannelMonitorUpdateErr::TemporaryFailure,
+ nativeChannelMonitorUpdateErr::PermanentFailure => ChannelMonitorUpdateErr::PermanentFailure,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeChannelMonitorUpdateErr) -> Self {
+ match native {
+ nativeChannelMonitorUpdateErr::TemporaryFailure => ChannelMonitorUpdateErr::TemporaryFailure,
+ nativeChannelMonitorUpdateErr::PermanentFailure => ChannelMonitorUpdateErr::PermanentFailure,
+ }
+ }
+}
+
+use lightning::ln::channelmonitor::MonitorUpdateError as nativeMonitorUpdateErrorImport;
+type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport;
+
+/// General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
+/// inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
+/// means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
+/// corrupted.
+/// Contains a human-readable error message.
+#[must_use]
+#[repr(C)]
+pub struct MonitorUpdateError {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeMonitorUpdateError,
+ pub is_owned: bool,
+}
+
+impl Drop for MonitorUpdateError {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn MonitorUpdateError_free(this_ptr: MonitorUpdateError) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorUpdateError); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl MonitorUpdateError {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorUpdateError {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::ln::channelmonitor::MonitorEvent as nativeMonitorEventImport;
+type nativeMonitorEvent = nativeMonitorEventImport;
+
+/// An event to be processed by the ChannelManager.
+#[must_use]
+#[repr(C)]
+pub struct MonitorEvent {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeMonitorEvent,
+ pub is_owned: bool,
+}
+
+impl Drop for MonitorEvent {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn MonitorEvent_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorEvent); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl MonitorEvent {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorEvent {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::ln::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport;
+type nativeHTLCUpdate = nativeHTLCUpdateImport;
+
+/// Simple structure send back by ManyChannelMonitor in case of HTLC detected onchain from a
+/// forward channel and from which info are needed to update HTLC in a backward channel.
+#[must_use]
+#[repr(C)]
+pub struct HTLCUpdate {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeHTLCUpdate,
+ pub is_owned: bool,
+}
+
+impl Drop for HTLCUpdate {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn HTLCUpdate_free(this_ptr: HTLCUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHTLCUpdate); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl HTLCUpdate {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeHTLCUpdate {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for HTLCUpdate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn HTLCUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCUpdate)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn HTLCUpdate_write(obj: *const HTLCUpdate) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> HTLCUpdate {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ HTLCUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ HTLCUpdate { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::ln::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
+type nativeChannelMonitor = nativeChannelMonitorImport<crate::chain::keysinterface::ChannelKeys>;
+
+/// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
+/// on-chain transactions to ensure no loss of funds occurs.
+///
+/// You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
+/// information and are actively monitoring the chain.
+///
+/// Pending Events or updated HTLCs which have not yet been read out by
+/// get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
+/// reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
+/// gotten are fully handled before re-serializing the new state.
+#[must_use]
+#[repr(C)]
+pub struct ChannelMonitor {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelMonitor,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelMonitor {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_free(this_ptr: ChannelMonitor) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelMonitor_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitor); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelMonitor {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitor {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Simple trait indicating ability to track a set of ChannelMonitors and multiplex events between
+/// them. Generally should be implemented by keeping a local SimpleManyChannelMonitor and passing
+/// events to it, while also taking any add/update_monitor events and passing them to some remote
+/// server(s).
+///
+/// In general, you must always have at least one local copy in memory, which must never fail to
+/// update (as it is responsible for broadcasting the latest state in case the channel is closed),
+/// and then persist it to various on-disk locations. If, for some reason, the in-memory copy fails
+/// to update (eg out-of-memory or some other condition), you must immediately shut down without
+/// taking any further action such as writing the current state to disk. This should likely be
+/// accomplished via panic!() or abort().
+///
+/// Note that any updates to a channel's monitor *must* be applied to each instance of the
+/// channel's monitor everywhere (including remote watchtowers) *before* this function returns. If
+/// an update occurs and a remote watchtower is left with old state, it may broadcast transactions
+/// which we have revoked, allowing our counterparty to claim all funds in the channel!
+///
+/// User needs to notify implementors of ManyChannelMonitor when a new block is connected or
+/// disconnected using their `block_connected` and `block_disconnected` methods. However, rather
+/// than calling these methods directly, the user should register implementors as listeners to the
+/// BlockNotifier and call the BlockNotifier's `block_(dis)connected` methods, which will notify
+/// all registered listeners in one go.
+#[repr(C)]
+pub struct ManyChannelMonitor {
+ pub this_arg: *mut c_void,
+ /// Adds a monitor for the given `funding_txo`.
+ ///
+ /// Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
+ /// any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
+ /// callbacks with the funding transaction, or any spends of it.
+ ///
+ /// Further, the implementer must also ensure that each output returned in
+ /// monitor.get_outputs_to_watch() is registered to ensure that the provided monitor learns about
+ /// any spends of any of the outputs.
+ ///
+ /// Any spends of outputs which should have been registered which aren't passed to
+ /// ChannelMonitors via block_connected may result in FUNDS LOSS.
+ #[must_use]
+ pub add_monitor: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::ln::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
+ /// Updates a monitor for the given `funding_txo`.
+ ///
+ /// Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
+ /// any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
+ /// callbacks with the funding transaction, or any spends of it.
+ ///
+ /// Further, the implementer must also ensure that each output returned in
+ /// monitor.get_watch_outputs() is registered to ensure that the provided monitor learns about
+ /// any spends of any of the outputs.
+ ///
+ /// Any spends of outputs which should have been registered which aren't passed to
+ /// ChannelMonitors via block_connected may result in FUNDS LOSS.
+ #[must_use]
+ pub update_monitor: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::ln::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
+ /// Used by ChannelManager to get list of HTLC resolved onchain and which needed to be updated
+ /// with success or failure.
+ ///
+ /// You should probably just call through to
+ /// ChannelMonitor::get_and_clear_pending_monitor_events() for each ChannelMonitor and return
+ /// the full list.
+ #[must_use]
+ pub get_and_clear_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for ManyChannelMonitor {}
+unsafe impl Sync for ManyChannelMonitor {}
+
+use lightning::ln::channelmonitor::ManyChannelMonitor as rustManyChannelMonitor;
+impl rustManyChannelMonitor for ManyChannelMonitor {
+ type Keys = crate::chain::keysinterface::ChannelKeys;
+ fn add_monitor(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::ln::channelmonitor::ChannelMonitor<Self::Keys>) -> Result<(), lightning::ln::channelmonitor::ChannelMonitorUpdateErr> {
+ let mut ret = (self.add_monitor)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::ln::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(monitor)), is_owned: true });
+ let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
+ local_ret
+ }
+ fn update_monitor(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::ln::channelmonitor::ChannelMonitorUpdate) -> Result<(), lightning::ln::channelmonitor::ChannelMonitorUpdateErr> {
+ let mut ret = (self.update_monitor)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::ln::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(monitor)), is_owned: true });
+ let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
+ local_ret
+ }
+ fn get_and_clear_pending_monitor_events(&self) -> Vec<lightning::ln::channelmonitor::MonitorEvent> {
+ let mut ret = (self.get_and_clear_pending_monitor_events)(self.this_arg);
+ let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ local_ret
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for ManyChannelMonitor {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn ManyChannelMonitor_free(this_ptr: ManyChannelMonitor) { }
+impl Drop for ManyChannelMonitor {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// Updates a ChannelMonitor on the basis of some new information provided by the Channel
+/// itself.
+///
+/// panics if the given update is not the next update by update_id.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &mut ChannelMonitor, mut updates: crate::ln::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ {
+ let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.update_monitor(*unsafe { Box::from_raw(updates.take_ptr()) }, broadcaster, logger);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::channelmonitor::MonitorUpdateError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+
+/// Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
+/// ChannelMonitor.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: &ChannelMonitor) -> u64 {
+ let mut ret = unsafe { &*this_arg.inner }.get_latest_update_id();
+ ret
+}
+
+/// Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> crate::c_types::derived::C2Tuple_OutPointScriptZ {
+ let mut ret = unsafe { &*this_arg.inner }.get_funding_txo();
+ let (ref orig_ret_0, ref orig_ret_1) = ret; let mut local_ret = (crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*orig_ret_0) as *const _) as *mut _) }, is_owned: false }, orig_ret_1.clone().into_bytes().into()).into();
+ local_ret
+}
+
+/// Get the list of HTLCs who's status has been updated on chain. This should be called by
+/// ChannelManager via ManyChannelMonitor::get_and_clear_pending_monitor_events().
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ {
+ let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_monitor_events();
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::channelmonitor::MonitorEvent { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
+ local_ret.into()
+}
+
+/// Gets the list of pending events which were generated by previous actions, clearing the list
+/// in the process.
+///
+/// This is called by ManyChannelMonitor::get_and_clear_pending_events() and is equivalent to
+/// EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
+/// no internal locking in ChannelMonitors.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_EventZ {
+ let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_events();
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
+ local_ret.into()
+}
+
+/// Used by ChannelManager deserialization to broadcast the latest local state if its copy of
+/// the Channel was out-of-date. You may use it to get a broadcastable local toxic tx in case of
+/// fallen-behind, i.e when receiving a channel_reestablish with a proof that our remote side knows
+/// a higher revocation secret than the local commitment number we are aware of. Broadcasting these
+/// transactions are UNSAFE, as they allow remote side to punish you. Nevertheless you may want to
+/// broadcast them if remote don't close channel with his higher commitment transaction after a
+/// substantial amount of time (a month or even a year) to get back funds. Best may be to contact
+/// out-of-band the other node operator to coordinate with him if option is available to you.
+/// In any-case, choice is up to the user.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_latest_local_commitment_txn(this_arg: &mut ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
+ let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_local_commitment_txn(logger);
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); local_ret_0.into() }); };
+ local_ret.into()
+}
+
--- /dev/null
+//! Feature flag definitions for the Lightning protocol according to [BOLT #9].
+//!
+//! Lightning nodes advertise a supported set of operation through feature flags. Features are
+//! applicable for a specific context as indicated in some [messages]. [`Features`] encapsulates
+//! behavior for specifying and checking feature flags for a particular context. Each feature is
+//! defined internally by a trait specifying the corresponding flags (i.e., even and odd bits). A
+//! [`Context`] is used to parameterize [`Features`] and defines which features it can support.
+//!
+//! Whether a feature is considered \"known\" or \"unknown\" is relative to the implementation, whereas
+//! the term \"supports\" is used in reference to a particular set of [`Features`]. That is, a node
+//! supports a feature if it advertises the feature (as either required or optional) to its peers.
+//! And the implementation can interpret a feature if the feature is known to it.
+//!
+//! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
+//! [messages]: ../msgs/index.html
+//! [`Features`]: struct.Features.html
+//! [`Context`]: sealed/trait.Context.html
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::ln::features::InitFeatures as nativeInitFeaturesImport;
+type nativeInitFeatures = nativeInitFeaturesImport;
+
+/// Features used within an `init` message.
+#[must_use]
+#[repr(C)]
+pub struct InitFeatures {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeInitFeatures,
+ pub is_owned: bool,
+}
+
+impl Drop for InitFeatures {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn InitFeatures_free(this_ptr: InitFeatures) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInitFeatures); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl InitFeatures {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeInitFeatures {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport;
+type nativeNodeFeatures = nativeNodeFeaturesImport;
+
+/// Features used within a `node_announcement` message.
+#[must_use]
+#[repr(C)]
+pub struct NodeFeatures {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeNodeFeatures,
+ pub is_owned: bool,
+}
+
+impl Drop for NodeFeatures {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NodeFeatures_free(this_ptr: NodeFeatures) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeFeatures); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl NodeFeatures {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeNodeFeatures {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport;
+type nativeChannelFeatures = nativeChannelFeaturesImport;
+
+/// Features used within a `channel_announcement` message.
+#[must_use]
+#[repr(C)]
+pub struct ChannelFeatures {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelFeatures,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelFeatures {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelFeatures_free(this_ptr: ChannelFeatures) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelFeatures); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelFeatures {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelFeatures {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
--- /dev/null
+//! High level lightning structs and impls live here.
+//!
+//! You probably want to create a channelmanager::ChannelManager, and a routing::NetGraphMsgHandler first.
+//! Then, you probably want to pass them both on to a peer_handler::PeerManager and use that to
+//! create/manage connections and call get_and_clear_pending_events after each action, handling
+//! them appropriately.
+//!
+//! When you want to open/close a channel or send a payment, call into your ChannelManager and when
+//! you want to learn things about the network topology (eg get a route for sending a payment),
+//! call into your NetGraphMsgHandler.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+pub mod channelmanager;
+pub mod channelmonitor;
+pub mod msgs;
+pub mod peer_handler;
+pub mod chan_utils;
+pub mod features;
--- /dev/null
+//! Wire messages, traits representing wire message handlers, and a few error types live here.
+//!
+//! For a normal node you probably don't need to use anything here, however, if you wish to split a
+//! node into an internet-facing route/message socket handling daemon and a separate daemon (or
+//! server entirely) which handles only channel-related messages you may wish to implement
+//! ChannelMessageHandler yourself and use it to re-serialize messages and pass them across
+//! daemons/servers.
+//!
+//! Note that if you go with such an architecture (instead of passing raw socket events to a
+//! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
+//! source node_id of the message, however this does allow you to significantly reduce bandwidth
+//! between the systems as routing messages can represent a significant chunk of bandwidth usage
+//! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
+//! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
+//! raw socket events into your non-internet-facing system and then send routing events back to
+//! track the network on the less-secure system.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
+type nativeDecodeError = nativeDecodeErrorImport;
+
+/// An error in decoding a message or struct.
+#[must_use]
+#[repr(C)]
+pub struct DecodeError {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeDecodeError,
+ pub is_owned: bool,
+}
+
+impl Drop for DecodeError {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDecodeError); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl DecodeError {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeDecodeError {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::ln::msgs::Init as nativeInitImport;
+type nativeInit = nativeInitImport;
+
+/// An init message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct Init {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeInit,
+ pub is_owned: bool,
+}
+
+impl Drop for Init {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Init_free(this_ptr: Init) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn Init_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl Init {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeInit {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
+type nativeErrorMessage = nativeErrorMessageImport;
+
+/// An error message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct ErrorMessage {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeErrorMessage,
+ pub is_owned: bool,
+}
+
+impl Drop for ErrorMessage {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ErrorMessage_free(this_ptr: ErrorMessage) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ErrorMessage {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeErrorMessage {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ErrorMessage {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
+}
+/// The channel ID involved in the error
+#[no_mangle]
+pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID involved in the error
+#[no_mangle]
+pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// A possibly human-readable error description.
+/// The string should be sanitized before it is used (e.g. emitted to logs
+/// or printed to stdout). Otherwise, a well crafted error message may trigger a security
+/// vulnerability in the terminal emulator or the logging subsystem.
+#[no_mangle]
+pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data;
+ (*inner_val).as_str().into()
+}
+/// A possibly human-readable error description.
+/// The string should be sanitized before it is used (e.g. emitted to logs
+/// or printed to stdout). Otherwise, a well crafted error message may trigger a security
+/// vulnerability in the terminal emulator or the logging subsystem.
+#[no_mangle]
+pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::derived::CVec_u8Z) {
+ unsafe { &mut *this_ptr.inner }.data = String::from_utf8(val.into_rust()).unwrap();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> ErrorMessage {
+ ErrorMessage { inner: Box::into_raw(Box::new(nativeErrorMessage {
+ channel_id: channel_id_arg.data,
+ data: String::from_utf8(data_arg.into_rust()).unwrap(),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::Ping as nativePingImport;
+type nativePing = nativePingImport;
+
+/// A ping message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct Ping {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativePing,
+ pub is_owned: bool,
+}
+
+impl Drop for Ping {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Ping_free(this_ptr: Ping) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl Ping {
+ pub(crate) fn take_ptr(mut self) -> *mut nativePing {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// The desired response length
+#[no_mangle]
+pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.ponglen;
+ (*inner_val)
+}
+/// The desired response length
+#[no_mangle]
+pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.ponglen = val;
+}
+/// The ping packet size.
+/// This field is not sent on the wire. byteslen zeros are sent.
+#[no_mangle]
+pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
+ (*inner_val)
+}
+/// The ping packet size.
+/// This field is not sent on the wire. byteslen zeros are sent.
+#[no_mangle]
+pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.byteslen = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
+ Ping { inner: Box::into_raw(Box::new(nativePing {
+ ponglen: ponglen_arg,
+ byteslen: byteslen_arg,
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::Pong as nativePongImport;
+type nativePong = nativePongImport;
+
+/// A pong message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct Pong {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativePong,
+ pub is_owned: bool,
+}
+
+impl Drop for Pong {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Pong_free(this_ptr: Pong) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl Pong {
+ pub(crate) fn take_ptr(mut self) -> *mut nativePong {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// The pong packet size.
+/// This field is not sent on the wire. byteslen zeros are sent.
+#[no_mangle]
+pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
+ (*inner_val)
+}
+/// The pong packet size.
+/// This field is not sent on the wire. byteslen zeros are sent.
+#[no_mangle]
+pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.byteslen = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
+ Pong { inner: Box::into_raw(Box::new(nativePong {
+ byteslen: byteslen_arg,
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
+type nativeOpenChannel = nativeOpenChannelImport;
+
+/// An open_channel message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct OpenChannel {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeOpenChannel,
+ pub is_owned: bool,
+}
+
+impl Drop for OpenChannel {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn OpenChannel_free(this_ptr: OpenChannel) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl OpenChannel {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeOpenChannel {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for OpenChannel {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
+ (*inner_val).as_inner()
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
+}
+/// A temporary channel ID, until the funding outpoint is announced
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
+ &(*inner_val)
+}
+/// A temporary channel ID, until the funding outpoint is announced
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
+}
+/// The channel value
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_satoshis;
+ (*inner_val)
+}
+/// The channel value
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.funding_satoshis = val;
+}
+/// The amount to push to the counterparty as part of the open, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.push_msat;
+ (*inner_val)
+}
+/// The amount to push to the counterparty as part of the open, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.push_msat = val;
+}
+/// The threshold below which outputs on transactions broadcast by sender will be omitted
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
+ (*inner_val)
+}
+/// The threshold below which outputs on transactions broadcast by sender will be omitted
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
+}
+/// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
+ (*inner_val)
+}
+/// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
+}
+/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
+ (*inner_val)
+}
+/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
+}
+/// The minimum HTLC size incoming to sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
+ (*inner_val)
+}
+/// The minimum HTLC size incoming to sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
+}
+/// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
+ (*inner_val)
+}
+/// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
+}
+/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
+ (*inner_val)
+}
+/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.to_self_delay = val;
+}
+/// The maximum number of inbound HTLCs towards sender
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
+ (*inner_val)
+}
+/// The maximum number of inbound HTLCs towards sender
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
+}
+/// The sender's key controlling the funding transaction
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The sender's key controlling the funding transaction
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
+}
+/// Used to derive a revocation key for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// Used to derive a revocation key for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
+}
+/// A payment key to sender for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// A payment key to sender for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
+}
+/// Used to derive a payment key to sender for transactions broadcast by sender
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// Used to derive a payment key to sender for transactions broadcast by sender
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
+}
+/// Used to derive an HTLC payment key to sender
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// Used to derive an HTLC payment key to sender
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
+}
+/// The first to-be-broadcast-by-sender transaction's per commitment point
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The first to-be-broadcast-by-sender transaction's per commitment point
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
+}
+/// Channel flags
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_flags;
+ (*inner_val)
+}
+/// Channel flags
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
+ unsafe { &mut *this_ptr.inner }.channel_flags = val;
+}
+
+use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
+type nativeAcceptChannel = nativeAcceptChannelImport;
+
+/// An accept_channel message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct AcceptChannel {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeAcceptChannel,
+ pub is_owned: bool,
+}
+
+impl Drop for AcceptChannel {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn AcceptChannel_free(this_ptr: AcceptChannel) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl AcceptChannel {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeAcceptChannel {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for AcceptChannel {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
+}
+/// A temporary channel ID, until the funding outpoint is announced
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
+ &(*inner_val)
+}
+/// A temporary channel ID, until the funding outpoint is announced
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
+}
+/// The threshold below which outputs on transactions broadcast by sender will be omitted
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
+ (*inner_val)
+}
+/// The threshold below which outputs on transactions broadcast by sender will be omitted
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
+}
+/// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
+ (*inner_val)
+}
+/// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
+}
+/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
+ (*inner_val)
+}
+/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
+}
+/// The minimum HTLC size incoming to sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
+ (*inner_val)
+}
+/// The minimum HTLC size incoming to sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
+}
+/// Minimum depth of the funding transaction before the channel is considered open
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth;
+ (*inner_val)
+}
+/// Minimum depth of the funding transaction before the channel is considered open
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.minimum_depth = val;
+}
+/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
+ (*inner_val)
+}
+/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.to_self_delay = val;
+}
+/// The maximum number of inbound HTLCs towards sender
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
+ (*inner_val)
+}
+/// The maximum number of inbound HTLCs towards sender
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
+}
+/// The sender's key controlling the funding transaction
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The sender's key controlling the funding transaction
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
+}
+/// Used to derive a revocation key for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// Used to derive a revocation key for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
+}
+/// A payment key to sender for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// A payment key to sender for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
+}
+/// Used to derive a payment key to sender for transactions broadcast by sender
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// Used to derive a payment key to sender for transactions broadcast by sender
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
+}
+/// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
+}
+/// The first to-be-broadcast-by-sender transaction's per commitment point
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The first to-be-broadcast-by-sender transaction's per commitment point
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
+}
+
+use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
+type nativeFundingCreated = nativeFundingCreatedImport;
+
+/// A funding_created message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct FundingCreated {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeFundingCreated,
+ pub is_owned: bool,
+}
+
+impl Drop for FundingCreated {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn FundingCreated_free(this_ptr: FundingCreated) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl FundingCreated {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeFundingCreated {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for FundingCreated {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
+}
+/// A temporary channel ID, until the funding is established
+#[no_mangle]
+pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
+ &(*inner_val)
+}
+/// A temporary channel ID, until the funding is established
+#[no_mangle]
+pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
+}
+/// The funding transaction ID
+#[no_mangle]
+pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txid;
+ (*inner_val).as_inner()
+}
+/// The funding transaction ID
+#[no_mangle]
+pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
+}
+/// The specific output index funding this channel
+#[no_mangle]
+pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_output_index;
+ (*inner_val)
+}
+/// The specific output index funding this channel
+#[no_mangle]
+pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.funding_output_index = val;
+}
+/// The signature of the channel initiator (funder) on the funding transaction
+#[no_mangle]
+pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// The signature of the channel initiator (funder) on the funding transaction
+#[no_mangle]
+pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::Signature) -> FundingCreated {
+ FundingCreated { inner: Box::into_raw(Box::new(nativeFundingCreated {
+ temporary_channel_id: temporary_channel_id_arg.data,
+ funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
+ funding_output_index: funding_output_index_arg,
+ signature: signature_arg.into_rust(),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
+type nativeFundingSigned = nativeFundingSignedImport;
+
+/// A funding_signed message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct FundingSigned {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeFundingSigned,
+ pub is_owned: bool,
+}
+
+impl Drop for FundingSigned {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn FundingSigned_free(this_ptr: FundingSigned) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl FundingSigned {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeFundingSigned {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for FundingSigned {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The signature of the channel acceptor (fundee) on the funding transaction
+#[no_mangle]
+pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// The signature of the channel acceptor (fundee) on the funding transaction
+#[no_mangle]
+pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
+ FundingSigned { inner: Box::into_raw(Box::new(nativeFundingSigned {
+ channel_id: channel_id_arg.data,
+ signature: signature_arg.into_rust(),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
+type nativeFundingLocked = nativeFundingLockedImport;
+
+/// A funding_locked message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct FundingLocked {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeFundingLocked,
+ pub is_owned: bool,
+}
+
+impl Drop for FundingLocked {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn FundingLocked_free(this_ptr: FundingLocked) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl FundingLocked {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeFundingLocked {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for FundingLocked {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The per-commitment point of the second commitment transaction
+#[no_mangle]
+pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The per-commitment point of the second commitment transaction
+#[no_mangle]
+pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn FundingLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> FundingLocked {
+ FundingLocked { inner: Box::into_raw(Box::new(nativeFundingLocked {
+ channel_id: channel_id_arg.data,
+ next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::Shutdown as nativeShutdownImport;
+type nativeShutdown = nativeShutdownImport;
+
+/// A shutdown message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct Shutdown {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeShutdown,
+ pub is_owned: bool,
+}
+
+impl Drop for Shutdown {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Shutdown_free(this_ptr: Shutdown) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl Shutdown {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeShutdown {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for Shutdown {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The destination of this peer's funds on closing.
+/// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
+#[no_mangle]
+pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.scriptpubkey;
+ crate::c_types::u8slice::from_slice(&(*inner_val)[..])
+}
+/// The destination of this peer's funds on closing.
+/// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
+#[no_mangle]
+pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
+ unsafe { &mut *this_ptr.inner }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
+ Shutdown { inner: Box::into_raw(Box::new(nativeShutdown {
+ channel_id: channel_id_arg.data,
+ scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
+type nativeClosingSigned = nativeClosingSignedImport;
+
+/// A closing_signed message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct ClosingSigned {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeClosingSigned,
+ pub is_owned: bool,
+}
+
+impl Drop for ClosingSigned {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ClosingSigned_free(this_ptr: ClosingSigned) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ClosingSigned {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeClosingSigned {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ClosingSigned {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The proposed total fee for the closing transaction
+#[no_mangle]
+pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis;
+ (*inner_val)
+}
+/// The proposed total fee for the closing transaction
+#[no_mangle]
+pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.fee_satoshis = val;
+}
+/// A signature on the closing transaction
+#[no_mangle]
+pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// A signature on the closing transaction
+#[no_mangle]
+pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::Signature) -> ClosingSigned {
+ ClosingSigned { inner: Box::into_raw(Box::new(nativeClosingSigned {
+ channel_id: channel_id_arg.data,
+ fee_satoshis: fee_satoshis_arg,
+ signature: signature_arg.into_rust(),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
+type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
+
+/// An update_add_htlc message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct UpdateAddHTLC {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUpdateAddHTLC,
+ pub is_owned: bool,
+}
+
+impl Drop for UpdateAddHTLC {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_free(this_ptr: UpdateAddHTLC) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UpdateAddHTLC {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateAddHTLC {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UpdateAddHTLC {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The HTLC ID
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
+ (*inner_val)
+}
+/// The HTLC ID
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_id = val;
+}
+/// The HTLC value in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
+ (*inner_val)
+}
+/// The HTLC value in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.amount_msat = val;
+}
+/// The payment hash, the pre-image of which controls HTLC redemption
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
+ &(*inner_val).0
+}
+/// The payment hash, the pre-image of which controls HTLC redemption
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data);
+}
+/// The expiry height of the HTLC
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
+ (*inner_val)
+}
+/// The expiry height of the HTLC
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
+}
+
+use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
+type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
+
+/// An update_fulfill_htlc message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct UpdateFulfillHTLC {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUpdateFulfillHTLC,
+ pub is_owned: bool,
+}
+
+impl Drop for UpdateFulfillHTLC {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_free(this_ptr: UpdateFulfillHTLC) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UpdateFulfillHTLC {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFulfillHTLC {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UpdateFulfillHTLC {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The HTLC ID
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
+ (*inner_val)
+}
+/// The HTLC ID
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_id = val;
+}
+/// The pre-image of the payment hash, allowing HTLC redemption
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage;
+ &(*inner_val).0
+}
+/// The pre-image of the payment hash, allowing HTLC redemption
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::channelmanager::PaymentPreimage(val.data);
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
+ UpdateFulfillHTLC { inner: Box::into_raw(Box::new(nativeUpdateFulfillHTLC {
+ channel_id: channel_id_arg.data,
+ htlc_id: htlc_id_arg,
+ payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_arg.data),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
+type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
+
+/// An update_fail_htlc message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct UpdateFailHTLC {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUpdateFailHTLC,
+ pub is_owned: bool,
+}
+
+impl Drop for UpdateFailHTLC {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateFailHTLC_free(this_ptr: UpdateFailHTLC) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UpdateFailHTLC {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFailHTLC {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UpdateFailHTLC {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The HTLC ID
+#[no_mangle]
+pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
+ (*inner_val)
+}
+/// The HTLC ID
+#[no_mangle]
+pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_id = val;
+}
+
+use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
+type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
+
+/// An update_fail_malformed_htlc message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct UpdateFailMalformedHTLC {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUpdateFailMalformedHTLC,
+ pub is_owned: bool,
+}
+
+impl Drop for UpdateFailMalformedHTLC {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_free(this_ptr: UpdateFailMalformedHTLC) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UpdateFailMalformedHTLC {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFailMalformedHTLC {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UpdateFailMalformedHTLC {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The HTLC ID
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
+ (*inner_val)
+}
+/// The HTLC ID
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_id = val;
+}
+/// The failure code
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code;
+ (*inner_val)
+}
+/// The failure code
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.failure_code = val;
+}
+
+use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
+type nativeCommitmentSigned = nativeCommitmentSignedImport;
+
+/// A commitment_signed message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct CommitmentSigned {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeCommitmentSigned,
+ pub is_owned: bool,
+}
+
+impl Drop for CommitmentSigned {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_free(this_ptr: CommitmentSigned) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl CommitmentSigned {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeCommitmentSigned {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for CommitmentSigned {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// A signature on the commitment transaction
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// A signature on the commitment transaction
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
+}
+/// Signatures on the HTLC transactions
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
+ unsafe { &mut *this_ptr.inner }.htlc_signatures = local_val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature, mut htlc_signatures_arg: crate::c_types::derived::CVec_SignatureZ) -> CommitmentSigned {
+ let mut local_htlc_signatures_arg = Vec::new(); for mut item in htlc_signatures_arg.into_rust().drain(..) { local_htlc_signatures_arg.push( { item.into_rust() }); };
+ CommitmentSigned { inner: Box::into_raw(Box::new(nativeCommitmentSigned {
+ channel_id: channel_id_arg.data,
+ signature: signature_arg.into_rust(),
+ htlc_signatures: local_htlc_signatures_arg,
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
+type nativeRevokeAndACK = nativeRevokeAndACKImport;
+
+/// A revoke_and_ack message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct RevokeAndACK {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeRevokeAndACK,
+ pub is_owned: bool,
+}
+
+impl Drop for RevokeAndACK {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_free(this_ptr: RevokeAndACK) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl RevokeAndACK {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeRevokeAndACK {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for RevokeAndACK {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The secret corresponding to the per-commitment point
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret;
+ &(*inner_val)
+}
+/// The secret corresponding to the per-commitment point
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.per_commitment_secret = val.data;
+}
+/// The next sender-broadcast commitment transaction's per-commitment point
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The next sender-broadcast commitment transaction's per-commitment point
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
+ RevokeAndACK { inner: Box::into_raw(Box::new(nativeRevokeAndACK {
+ channel_id: channel_id_arg.data,
+ per_commitment_secret: per_commitment_secret_arg.data,
+ next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
+type nativeUpdateFee = nativeUpdateFeeImport;
+
+/// An update_fee message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct UpdateFee {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUpdateFee,
+ pub is_owned: bool,
+}
+
+impl Drop for UpdateFee {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateFee_free(this_ptr: UpdateFee) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UpdateFee {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFee {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UpdateFee {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// Fee rate per 1000-weight of the transaction
+#[no_mangle]
+pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
+ (*inner_val)
+}
+/// Fee rate per 1000-weight of the transaction
+#[no_mangle]
+pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
+ UpdateFee { inner: Box::into_raw(Box::new(nativeUpdateFee {
+ channel_id: channel_id_arg.data,
+ feerate_per_kw: feerate_per_kw_arg,
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
+type nativeDataLossProtect = nativeDataLossProtectImport;
+
+/// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
+/// This is used to convince the recipient that the channel is at a certain commitment
+/// number even if they lost that data due to a local failure. Of course, the peer may lie
+/// and even later commitments may have been revoked.
+#[must_use]
+#[repr(C)]
+pub struct DataLossProtect {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeDataLossProtect,
+ pub is_owned: bool,
+}
+
+impl Drop for DataLossProtect {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn DataLossProtect_free(this_ptr: DataLossProtect) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl DataLossProtect {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeDataLossProtect {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for DataLossProtect {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
+}
+/// Proof that the sender knows the per-commitment secret of a specific commitment transaction
+/// belonging to the recipient
+#[no_mangle]
+pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret;
+ &(*inner_val)
+}
+/// Proof that the sender knows the per-commitment secret of a specific commitment transaction
+/// belonging to the recipient
+#[no_mangle]
+pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret = val.data;
+}
+/// The sender's per-commitment point for their current commitment transaction
+#[no_mangle]
+pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The sender's per-commitment point for their current commitment transaction
+#[no_mangle]
+pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey) -> DataLossProtect {
+ DataLossProtect { inner: Box::into_raw(Box::new(nativeDataLossProtect {
+ your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
+ my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
+type nativeChannelReestablish = nativeChannelReestablishImport;
+
+/// A channel_reestablish message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct ChannelReestablish {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelReestablish,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelReestablish {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_free(this_ptr: ChannelReestablish) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelReestablish {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelReestablish {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelReestablish {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The next commitment number for the sender
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number;
+ (*inner_val)
+}
+/// The next commitment number for the sender
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.next_local_commitment_number = val;
+}
+/// The next commitment number for the recipient
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number;
+ (*inner_val)
+}
+/// The next commitment number for the recipient
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.next_remote_commitment_number = val;
+}
+
+use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
+type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
+
+/// An announcement_signatures message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct AnnouncementSignatures {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeAnnouncementSignatures,
+ pub is_owned: bool,
+}
+
+impl Drop for AnnouncementSignatures {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_free(this_ptr: AnnouncementSignatures) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl AnnouncementSignatures {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeAnnouncementSignatures {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for AnnouncementSignatures {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
+ &(*inner_val)
+}
+/// The channel ID
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.channel_id = val.data;
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
+ (*inner_val)
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.short_channel_id = val;
+}
+/// A signature by the node key
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// A signature by the node key
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.node_signature = val.into_rust();
+}
+/// A signature by the funding key
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// A signature by the funding key
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.bitcoin_signature = val.into_rust();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::Signature, mut bitcoin_signature_arg: crate::c_types::Signature) -> AnnouncementSignatures {
+ AnnouncementSignatures { inner: Box::into_raw(Box::new(nativeAnnouncementSignatures {
+ channel_id: channel_id_arg.data,
+ short_channel_id: short_channel_id_arg,
+ node_signature: node_signature_arg.into_rust(),
+ bitcoin_signature: bitcoin_signature_arg.into_rust(),
+ })), is_owned: true }
+}
+/// An address which can be used to connect to a remote peer
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum NetAddress {
+ /// An IPv4 address/port on which the peer is listening.
+ IPv4 {
+ addr: crate::c_types::FourBytes,
+ port: u16,
+ },
+ /// An IPv6 address/port on which the peer is listening.
+ IPv6 {
+ addr: crate::c_types::SixteenBytes,
+ port: u16,
+ },
+ /// An old-style Tor onion address/port on which the peer is listening.
+ OnionV2 {
+ addr: crate::c_types::TenBytes,
+ port: u16,
+ },
+ /// A new-style Tor onion address/port on which the peer is listening.
+ /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
+ /// wrap as base32 and append \".onion\".
+ OnionV3 {
+ ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
+ checksum: u16,
+ version: u8,
+ port: u16,
+ },
+}
+use lightning::ln::msgs::NetAddress as nativeNetAddress;
+impl NetAddress {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeNetAddress {
+ match self {
+ NetAddress::IPv4 {ref addr, ref port, } => {
+ let mut addr_nonref = (*addr).clone();
+ let mut port_nonref = (*port).clone();
+ nativeNetAddress::IPv4 {
+ addr: addr_nonref.data,
+ port: port_nonref,
+ }
+ },
+ NetAddress::IPv6 {ref addr, ref port, } => {
+ let mut addr_nonref = (*addr).clone();
+ let mut port_nonref = (*port).clone();
+ nativeNetAddress::IPv6 {
+ addr: addr_nonref.data,
+ port: port_nonref,
+ }
+ },
+ NetAddress::OnionV2 {ref addr, ref port, } => {
+ let mut addr_nonref = (*addr).clone();
+ let mut port_nonref = (*port).clone();
+ nativeNetAddress::OnionV2 {
+ addr: addr_nonref.data,
+ port: port_nonref,
+ }
+ },
+ NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
+ let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
+ let mut checksum_nonref = (*checksum).clone();
+ let mut version_nonref = (*version).clone();
+ let mut port_nonref = (*port).clone();
+ nativeNetAddress::OnionV3 {
+ ed25519_pubkey: ed25519_pubkey_nonref.data,
+ checksum: checksum_nonref,
+ version: version_nonref,
+ port: port_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeNetAddress {
+ match self {
+ NetAddress::IPv4 {mut addr, mut port, } => {
+ nativeNetAddress::IPv4 {
+ addr: addr.data,
+ port: port,
+ }
+ },
+ NetAddress::IPv6 {mut addr, mut port, } => {
+ nativeNetAddress::IPv6 {
+ addr: addr.data,
+ port: port,
+ }
+ },
+ NetAddress::OnionV2 {mut addr, mut port, } => {
+ nativeNetAddress::OnionV2 {
+ addr: addr.data,
+ port: port,
+ }
+ },
+ NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
+ nativeNetAddress::OnionV3 {
+ ed25519_pubkey: ed25519_pubkey.data,
+ checksum: checksum,
+ version: version,
+ port: port,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
+ match native {
+ nativeNetAddress::IPv4 {ref addr, ref port, } => {
+ let mut addr_nonref = (*addr).clone();
+ let mut port_nonref = (*port).clone();
+ NetAddress::IPv4 {
+ addr: crate::c_types::FourBytes { data: addr_nonref },
+ port: port_nonref,
+ }
+ },
+ nativeNetAddress::IPv6 {ref addr, ref port, } => {
+ let mut addr_nonref = (*addr).clone();
+ let mut port_nonref = (*port).clone();
+ NetAddress::IPv6 {
+ addr: crate::c_types::SixteenBytes { data: addr_nonref },
+ port: port_nonref,
+ }
+ },
+ nativeNetAddress::OnionV2 {ref addr, ref port, } => {
+ let mut addr_nonref = (*addr).clone();
+ let mut port_nonref = (*port).clone();
+ NetAddress::OnionV2 {
+ addr: crate::c_types::TenBytes { data: addr_nonref },
+ port: port_nonref,
+ }
+ },
+ nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
+ let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
+ let mut checksum_nonref = (*checksum).clone();
+ let mut version_nonref = (*version).clone();
+ let mut port_nonref = (*port).clone();
+ NetAddress::OnionV3 {
+ ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
+ checksum: checksum_nonref,
+ version: version_nonref,
+ port: port_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeNetAddress) -> Self {
+ match native {
+ nativeNetAddress::IPv4 {mut addr, mut port, } => {
+ NetAddress::IPv4 {
+ addr: crate::c_types::FourBytes { data: addr },
+ port: port,
+ }
+ },
+ nativeNetAddress::IPv6 {mut addr, mut port, } => {
+ NetAddress::IPv6 {
+ addr: crate::c_types::SixteenBytes { data: addr },
+ port: port,
+ }
+ },
+ nativeNetAddress::OnionV2 {mut addr, mut port, } => {
+ NetAddress::OnionV2 {
+ addr: crate::c_types::TenBytes { data: addr },
+ port: port,
+ }
+ },
+ nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
+ NetAddress::OnionV3 {
+ ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
+ checksum: checksum,
+ version: version,
+ port: port,
+ }
+ },
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
+
+use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
+type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
+
+/// The unsigned part of a node_announcement
+#[must_use]
+#[repr(C)]
+pub struct UnsignedNodeAnnouncement {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUnsignedNodeAnnouncement,
+ pub is_owned: bool,
+}
+
+impl Drop for UnsignedNodeAnnouncement {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_free(this_ptr: UnsignedNodeAnnouncement) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UnsignedNodeAnnouncement {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedNodeAnnouncement {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UnsignedNodeAnnouncement {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
+}
+/// A strictly monotonic announcement counter, with gaps allowed
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
+ (*inner_val)
+}
+/// A strictly monotonic announcement counter, with gaps allowed
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.timestamp = val;
+}
+/// The node_id this announcement originated from (don't rebroadcast the node_announcement back
+/// to this node).
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The node_id this announcement originated from (don't rebroadcast the node_announcement back
+/// to this node).
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
+}
+/// An RGB color for UI purposes
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
+ &(*inner_val)
+}
+/// An RGB color for UI purposes
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
+ unsafe { &mut *this_ptr.inner }.rgb = val.data;
+}
+/// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
+/// of uniqueness.
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
+ &(*inner_val)
+}
+/// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
+/// of uniqueness.
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.alias = val.data;
+}
+/// List of addresses on which this node is reachable
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
+ unsafe { &mut *this_ptr.inner }.addresses = local_val;
+}
+
+use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
+type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
+
+/// A node_announcement message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct NodeAnnouncement {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeNodeAnnouncement,
+ pub is_owned: bool,
+}
+
+impl Drop for NodeAnnouncement {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_free(this_ptr: NodeAnnouncement) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl NodeAnnouncement {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeNodeAnnouncement {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for NodeAnnouncement {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
+}
+/// The signature by the node key
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// The signature by the node key
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
+}
+/// The actual content of the announcement
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::ln::msgs::UnsignedNodeAnnouncement {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
+ crate::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// The actual content of the announcement
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) {
+ unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
+ NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
+ signature: signature_arg.into_rust(),
+ contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
+type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
+
+/// The unsigned part of a channel_announcement
+#[must_use]
+#[repr(C)]
+pub struct UnsignedChannelAnnouncement {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUnsignedChannelAnnouncement,
+ pub is_owned: bool,
+}
+
+impl Drop for UnsignedChannelAnnouncement {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_free(this_ptr: UnsignedChannelAnnouncement) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UnsignedChannelAnnouncement {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedChannelAnnouncement {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UnsignedChannelAnnouncement {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
+ (*inner_val).as_inner()
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
+ (*inner_val)
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.short_channel_id = val;
+}
+/// One of the two node_ids which are endpoints of this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// One of the two node_ids which are endpoints of this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
+}
+/// The other of the two node_ids which are endpoints of this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The other of the two node_ids which are endpoints of this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
+}
+/// The funding key for the first node
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The funding key for the first node
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
+}
+/// The funding key for the second node
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The funding key for the second node
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
+}
+
+use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
+type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
+
+/// A channel_announcement message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct ChannelAnnouncement {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelAnnouncement,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelAnnouncement {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_free(this_ptr: ChannelAnnouncement) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelAnnouncement {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelAnnouncement {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelAnnouncement {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
+}
+/// Authentication of the announcement by the first public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// Authentication of the announcement by the first public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
+}
+/// Authentication of the announcement by the second public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// Authentication of the announcement by the second public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
+}
+/// Proof of funding UTXO ownership by the first public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// Proof of funding UTXO ownership by the first public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
+}
+/// Proof of funding UTXO ownership by the second public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// Proof of funding UTXO ownership by the second public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
+}
+/// The actual announcement
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::ln::msgs::UnsignedChannelAnnouncement {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
+ crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// The actual announcement
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) {
+ unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::Signature, mut node_signature_2_arg: crate::c_types::Signature, mut bitcoin_signature_1_arg: crate::c_types::Signature, mut bitcoin_signature_2_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
+ ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
+ node_signature_1: node_signature_1_arg.into_rust(),
+ node_signature_2: node_signature_2_arg.into_rust(),
+ bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
+ bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
+ contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
+type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
+
+/// The unsigned part of a channel_update
+#[must_use]
+#[repr(C)]
+pub struct UnsignedChannelUpdate {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUnsignedChannelUpdate,
+ pub is_owned: bool,
+}
+
+impl Drop for UnsignedChannelUpdate {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_free(this_ptr: UnsignedChannelUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UnsignedChannelUpdate {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedChannelUpdate {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UnsignedChannelUpdate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
+ (*inner_val).as_inner()
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
+ (*inner_val)
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.short_channel_id = val;
+}
+/// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
+ (*inner_val)
+}
+/// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.timestamp = val;
+}
+/// Channel flags
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
+ (*inner_val)
+}
+/// Channel flags
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
+ unsafe { &mut *this_ptr.inner }.flags = val;
+}
+/// The number of blocks to subtract from incoming HTLC cltv_expiry values
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
+ (*inner_val)
+}
+/// The number of blocks to subtract from incoming HTLC cltv_expiry values
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
+}
+/// The minimum HTLC size incoming to sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
+ (*inner_val)
+}
+/// The minimum HTLC size incoming to sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
+}
+/// The base HTLC fee charged by sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
+ (*inner_val)
+}
+/// The base HTLC fee charged by sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
+}
+/// The amount to fee multiplier, in micro-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
+ (*inner_val)
+}
+/// The amount to fee multiplier, in micro-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
+}
+
+use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
+type nativeChannelUpdate = nativeChannelUpdateImport;
+
+/// A channel_update message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct ChannelUpdate {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelUpdate,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelUpdate {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_free(this_ptr: ChannelUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelUpdate {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelUpdate {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelUpdate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
+}
+/// A signature of the channel update
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
+ crate::c_types::Signature::from_rust(&(*inner_val))
+}
+/// A signature of the channel update
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
+ unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
+}
+/// The actual channel update
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::ln::msgs::UnsignedChannelUpdate {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
+ crate::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// The actual channel update
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) {
+ unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
+ ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
+ signature: signature_arg.into_rust(),
+ contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
+ })), is_owned: true }
+}
+/// Used to put an error message in a LightningError
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum ErrorAction {
+ /// The peer took some action which made us think they were useless. Disconnect them.
+ DisconnectPeer {
+ msg: crate::ln::msgs::ErrorMessage,
+ },
+ /// The peer did something harmless that we weren't able to process, just log and ignore
+ IgnoreError,
+ /// The peer did something incorrect. Tell them.
+ SendErrorMessage {
+ msg: crate::ln::msgs::ErrorMessage,
+ },
+}
+use lightning::ln::msgs::ErrorAction as nativeErrorAction;
+impl ErrorAction {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeErrorAction {
+ match self {
+ ErrorAction::DisconnectPeer {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_ptr()) } }) };
+ nativeErrorAction::DisconnectPeer {
+ msg: local_msg_nonref,
+ }
+ },
+ ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
+ ErrorAction::SendErrorMessage {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ nativeErrorAction::SendErrorMessage {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeErrorAction {
+ match self {
+ ErrorAction::DisconnectPeer {mut msg, } => {
+ let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_ptr()) } }) };
+ nativeErrorAction::DisconnectPeer {
+ msg: local_msg,
+ }
+ },
+ ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
+ ErrorAction::SendErrorMessage {mut msg, } => {
+ nativeErrorAction::SendErrorMessage {
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
+ match native {
+ nativeErrorAction::DisconnectPeer {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ let mut local_msg_nonref = crate::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((msg_nonref.unwrap()))) } }, is_owned: true };
+ ErrorAction::DisconnectPeer {
+ msg: local_msg_nonref,
+ }
+ },
+ nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
+ nativeErrorAction::SendErrorMessage {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ ErrorAction::SendErrorMessage {
+ msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeErrorAction) -> Self {
+ match native {
+ nativeErrorAction::DisconnectPeer {mut msg, } => {
+ let mut local_msg = crate::ln::msgs::ErrorMessage { inner: if msg.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((msg.unwrap()))) } }, is_owned: true };
+ ErrorAction::DisconnectPeer {
+ msg: local_msg,
+ }
+ },
+ nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
+ nativeErrorAction::SendErrorMessage {mut msg, } => {
+ ErrorAction::SendErrorMessage {
+ msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
+
+use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
+type nativeLightningError = nativeLightningErrorImport;
+
+/// An Err type for failure to process messages.
+#[must_use]
+#[repr(C)]
+pub struct LightningError {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeLightningError,
+ pub is_owned: bool,
+}
+
+impl Drop for LightningError {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl LightningError {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeLightningError {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// A human-readable message describing the error
+#[no_mangle]
+pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
+ (*inner_val).as_str().into()
+}
+/// A human-readable message describing the error
+#[no_mangle]
+pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
+ unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
+}
+/// The action which should be taken against the offending peer.
+#[no_mangle]
+pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
+ crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
+}
+/// The action which should be taken against the offending peer.
+#[no_mangle]
+pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
+ unsafe { &mut *this_ptr.inner }.action = val.into_native();
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
+ LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
+ err: String::from_utf8(err_arg.into_rust()).unwrap(),
+ action: action_arg.into_native(),
+ })), is_owned: true }
+}
+
+use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
+type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
+
+/// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
+/// transaction updates if they were pending.
+#[must_use]
+#[repr(C)]
+pub struct CommitmentUpdate {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeCommitmentUpdate,
+ pub is_owned: bool,
+}
+
+impl Drop for CommitmentUpdate {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl CommitmentUpdate {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeCommitmentUpdate {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for CommitmentUpdate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
+}
+/// update_add_htlc messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
+}
+/// update_fulfill_htlc messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
+}
+/// update_fail_htlc messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
+}
+/// update_fail_malformed_htlc messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
+}
+/// An update_fee message which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
+ let mut local_inner_val = crate::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// An update_fee message which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
+ unsafe { &mut *this_ptr.inner }.update_fee = local_val;
+}
+/// Finally, the commitment_signed message which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
+ crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Finally, the commitment_signed message which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
+ unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_new(mut update_add_htlcs_arg: crate::c_types::derived::CVec_UpdateAddHTLCZ, mut update_fulfill_htlcs_arg: crate::c_types::derived::CVec_UpdateFulfillHTLCZ, mut update_fail_htlcs_arg: crate::c_types::derived::CVec_UpdateFailHTLCZ, mut update_fail_malformed_htlcs_arg: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ, mut update_fee_arg: crate::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::ln::msgs::CommitmentSigned) -> CommitmentUpdate {
+ let mut local_update_add_htlcs_arg = Vec::new(); for mut item in update_add_htlcs_arg.into_rust().drain(..) { local_update_add_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ let mut local_update_fulfill_htlcs_arg = Vec::new(); for mut item in update_fulfill_htlcs_arg.into_rust().drain(..) { local_update_fulfill_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ let mut local_update_fail_htlcs_arg = Vec::new(); for mut item in update_fail_htlcs_arg.into_rust().drain(..) { local_update_fail_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ let mut local_update_fail_malformed_htlcs_arg = Vec::new(); for mut item in update_fail_malformed_htlcs_arg.into_rust().drain(..) { local_update_fail_malformed_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_ptr()) } }) };
+ CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
+ update_add_htlcs: local_update_add_htlcs_arg,
+ update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
+ update_fail_htlcs: local_update_fail_htlcs_arg,
+ update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
+ update_fee: local_update_fee_arg,
+ commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_ptr()) },
+ })), is_owned: true }
+}
+/// The information we received from a peer along the route of a payment we originated. This is
+/// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
+/// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum HTLCFailChannelUpdate {
+ /// We received an error which included a full ChannelUpdate message.
+ ChannelUpdateMessage {
+ msg: crate::ln::msgs::ChannelUpdate,
+ },
+ /// We received an error which indicated only that a channel has been closed
+ ChannelClosed {
+ short_channel_id: u64,
+ is_permanent: bool,
+ },
+ /// We received an error which indicated only that a node has failed
+ NodeFailure {
+ node_id: crate::c_types::PublicKey,
+ is_permanent: bool,
+ },
+}
+use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
+impl HTLCFailChannelUpdate {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
+ match self {
+ HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
+ let mut short_channel_id_nonref = (*short_channel_id).clone();
+ let mut is_permanent_nonref = (*is_permanent).clone();
+ nativeHTLCFailChannelUpdate::ChannelClosed {
+ short_channel_id: short_channel_id_nonref,
+ is_permanent: is_permanent_nonref,
+ }
+ },
+ HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut is_permanent_nonref = (*is_permanent).clone();
+ nativeHTLCFailChannelUpdate::NodeFailure {
+ node_id: node_id_nonref.into_rust(),
+ is_permanent: is_permanent_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
+ match self {
+ HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
+ nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
+ nativeHTLCFailChannelUpdate::ChannelClosed {
+ short_channel_id: short_channel_id,
+ is_permanent: is_permanent,
+ }
+ },
+ HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
+ nativeHTLCFailChannelUpdate::NodeFailure {
+ node_id: node_id.into_rust(),
+ is_permanent: is_permanent,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
+ match native {
+ nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ HTLCFailChannelUpdate::ChannelUpdateMessage {
+ msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
+ let mut short_channel_id_nonref = (*short_channel_id).clone();
+ let mut is_permanent_nonref = (*is_permanent).clone();
+ HTLCFailChannelUpdate::ChannelClosed {
+ short_channel_id: short_channel_id_nonref,
+ is_permanent: is_permanent_nonref,
+ }
+ },
+ nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut is_permanent_nonref = (*is_permanent).clone();
+ HTLCFailChannelUpdate::NodeFailure {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ is_permanent: is_permanent_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
+ match native {
+ nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
+ HTLCFailChannelUpdate::ChannelUpdateMessage {
+ msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
+ HTLCFailChannelUpdate::ChannelClosed {
+ short_channel_id: short_channel_id,
+ is_permanent: is_permanent,
+ }
+ },
+ nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
+ HTLCFailChannelUpdate::NodeFailure {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ is_permanent: is_permanent,
+ }
+ },
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
+/// A trait to describe an object which can receive channel messages.
+///
+/// Messages MAY be called in parallel when they originate from different their_node_ids, however
+/// they MUST NOT be called in parallel when the two calls have the same their_node_id.
+#[repr(C)]
+pub struct ChannelMessageHandler {
+ pub this_arg: *mut c_void,
+ /// Handle an incoming open_channel message from the given peer.
+ pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel),
+ /// Handle an incoming accept_channel message from the given peer.
+ pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel),
+ /// Handle an incoming funding_created message from the given peer.
+ pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
+ /// Handle an incoming funding_signed message from the given peer.
+ pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
+ /// Handle an incoming funding_locked message from the given peer.
+ pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
+ /// Handle an incoming shutdown message from the given peer.
+ pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown),
+ /// Handle an incoming closing_signed message from the given peer.
+ pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
+ /// Handle an incoming update_add_htlc message from the given peer.
+ pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC),
+ /// Handle an incoming update_fulfill_htlc message from the given peer.
+ pub handle_update_fulfill_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC),
+ /// Handle an incoming update_fail_htlc message from the given peer.
+ pub handle_update_fail_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC),
+ /// Handle an incoming update_fail_malformed_htlc message from the given peer.
+ pub handle_update_fail_malformed_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC),
+ /// Handle an incoming commitment_signed message from the given peer.
+ pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
+ /// Handle an incoming revoke_and_ack message from the given peer.
+ pub handle_revoke_and_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK),
+ /// Handle an incoming update_fee message from the given peer.
+ pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
+ /// Handle an incoming announcement_signatures message from the given peer.
+ pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
+ /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
+ /// is believed to be possible in the future (eg they're sending us messages we don't
+ /// understand or indicate they require unknown feature bits), no_connection_possible is set
+ /// and any outstanding channels should be failed.
+ pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
+ /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
+ pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
+ /// Handle an incoming channel_reestablish message from the given peer.
+ pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
+ /// Handle an incoming error message from the given peer.
+ pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
+ pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
+ fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
+ <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
+ }
+}
+unsafe impl Send for ChannelMessageHandler {}
+unsafe impl Sync for ChannelMessageHandler {}
+
+use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
+impl rustChannelMessageHandler for ChannelMessageHandler {
+ fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
+ (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::features::InitFeatures { inner: Box::into_raw(Box::new(their_features)), is_owned: true }, &crate::ln::msgs::OpenChannel { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
+ (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::features::InitFeatures { inner: Box::into_raw(Box::new(their_features)), is_owned: true }, &crate::ln::msgs::AcceptChannel { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
+ (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::FundingCreated { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
+ (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::FundingSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
+ (self.handle_funding_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::FundingLocked { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Shutdown) {
+ (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Shutdown { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
+ (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ClosingSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
+ (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateAddHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
+ (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateFulfillHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
+ (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateFailHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
+ (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
+ (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::CommitmentSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
+ (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::RevokeAndACK { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
+ (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateFee { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
+ (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::AnnouncementSignatures { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
+ (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
+ }
+ fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
+ (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Init { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
+ (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ChannelReestablish { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+ fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
+ (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ErrorMessage { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for ChannelMessageHandler {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
+impl Drop for ChannelMessageHandler {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// A trait to describe an object which can receive routing messages.
+#[repr(C)]
+pub struct RoutingMessageHandler {
+ pub this_arg: *mut c_void,
+ /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
+ /// false or returning an Err otherwise.
+ #[must_use]
+ pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
+ /// Handle a channel_announcement message, returning true if it should be forwarded on, false
+ /// or returning an Err otherwise.
+ #[must_use]
+ pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
+ /// Handle an incoming channel_update message, returning true if it should be forwarded on,
+ /// false or returning an Err otherwise.
+ #[must_use]
+ pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
+ /// Handle some updates to the route graph that we learned due to an outbound failed payment.
+ pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
+ /// Gets a subset of the channel announcements and updates required to dump our routing table
+ /// to a remote node, starting at the short_channel_id indicated by starting_point and
+ /// including the batch_amount entries immediately higher in numerical value than starting_point.
+ #[must_use]
+ pub get_next_channel_announcements: extern "C" fn (this_arg: *const c_void, starting_point: u64, batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
+ /// Gets a subset of the node announcements required to dump our routing table to a remote node,
+ /// starting at the node *after* the provided publickey and including batch_amount entries
+ /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
+ /// If None is provided for starting_point, we start at the first node.
+ #[must_use]
+ pub get_next_node_announcements: extern "C" fn (this_arg: *const c_void, starting_point: crate::c_types::PublicKey, batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ,
+ /// Returns whether a full sync should be requested from a peer.
+ #[must_use]
+ pub should_request_full_sync: extern "C" fn (this_arg: *const c_void, node_id: crate::c_types::PublicKey) -> bool,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for RoutingMessageHandler {}
+unsafe impl Sync for RoutingMessageHandler {}
+
+use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
+impl rustRoutingMessageHandler for RoutingMessageHandler {
+ fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
+ let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })};
+ local_ret
+ }
+ fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
+ let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })};
+ local_ret
+ }
+ fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
+ let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })};
+ local_ret
+ }
+ fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
+ (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
+ }
+ fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
+ let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
+ let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_ptr()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_ptr()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_ptr()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); };
+ local_ret
+ }
+ fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
+ let mut local_starting_point = if starting_point.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(starting_point.unwrap())) } };
+ let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
+ let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+ local_ret
+ }
+ fn should_request_full_sync(&self, node_id: &bitcoin::secp256k1::key::PublicKey) -> bool {
+ let mut ret = (self.should_request_full_sync)(self.this_arg, crate::c_types::PublicKey::from_rust(&node_id));
+ ret
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for RoutingMessageHandler {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
+impl Drop for RoutingMessageHandler {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn AcceptChannel_write(obj: *const AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ AcceptChannel { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_write(obj: *const AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ AnnouncementSignatures { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_write(obj: *const ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> ChannelReestablish {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ChannelReestablish { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ChannelReestablish { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ClosingSigned_write(obj: *const ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ClosingSigned { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_write(obj: *const CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ CommitmentSigned { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn FundingCreated_write(obj: *const FundingCreated) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ FundingCreated { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn FundingSigned_write(obj: *const FundingSigned) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ FundingSigned { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn FundingLocked_write(obj: *const FundingLocked) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ FundingLocked { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Init_write(obj: *const Init) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> Init {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ Init { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ Init { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn OpenChannel_write(obj: *const OpenChannel) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ OpenChannel { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_write(obj: *const RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ RevokeAndACK { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Shutdown_write(obj: *const Shutdown) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> Shutdown {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ Shutdown { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateFailHTLC_write(obj: *const UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ UpdateFailHTLC { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_write(obj: *const UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ UpdateFailMalformedHTLC { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateFee_write(obj: *const UpdateFee) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ UpdateFee { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_write(obj: *const UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ UpdateFulfillHTLC { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_write(obj: *const UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ UpdateAddHTLC { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Ping_write(obj: *const Ping) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> Ping {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ Ping { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ Ping { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Pong_write(obj: *const Pong) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> Pong {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ Pong { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ Pong { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_write(obj: *const UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedChannelAnnouncement {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ UnsignedChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_write(obj: *const ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_write(obj: *const UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> UnsignedChannelUpdate {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ UnsignedChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ UnsignedChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_write(obj: *const ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ErrorMessage_write(obj: *const ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> ErrorMessage {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ErrorMessage { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ErrorMessage { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_write(obj: *const UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedNodeAnnouncement {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ UnsignedNodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_write(obj: *const NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
--- /dev/null
+//! Top level peer message handling and socket handling logic lives here.
+//!
+//! Instead of actually servicing sockets ourselves we require that you implement the
+//! SocketDescriptor interface and use that to receive actions which you should perform on the
+//! socket, and call into PeerManager with bytes read from the socket. The PeerManager will then
+//! call into the provided message handlers (probably a ChannelManager and NetGraphmsgHandler) with messages
+//! they should handle, and encoding/sending response messages.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::ln::peer_handler::MessageHandler as nativeMessageHandlerImport;
+type nativeMessageHandler = nativeMessageHandlerImport<crate::ln::msgs::ChannelMessageHandler, crate::ln::msgs::RoutingMessageHandler>;
+
+/// Provides references to trait impls which handle different types of messages.
+#[must_use]
+#[repr(C)]
+pub struct MessageHandler {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeMessageHandler,
+ pub is_owned: bool,
+}
+
+impl Drop for MessageHandler {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn MessageHandler_free(this_ptr: MessageHandler) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn MessageHandler_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMessageHandler); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl MessageHandler {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeMessageHandler {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// A message handler which handles messages specific to channels. Usually this is just a
+/// ChannelManager object.
+#[no_mangle]
+pub extern "C" fn MessageHandler_get_chan_handler(this_ptr: &MessageHandler) -> *const crate::ln::msgs::ChannelMessageHandler {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chan_handler;
+ &(*inner_val)
+}
+/// A message handler which handles messages specific to channels. Usually this is just a
+/// ChannelManager object.
+#[no_mangle]
+pub extern "C" fn MessageHandler_set_chan_handler(this_ptr: &mut MessageHandler, mut val: crate::ln::msgs::ChannelMessageHandler) {
+ unsafe { &mut *this_ptr.inner }.chan_handler = val;
+}
+/// A message handler which handles messages updating our knowledge of the network channel
+/// graph. Usually this is just a NetGraphMsgHandlerMonitor object.
+#[no_mangle]
+pub extern "C" fn MessageHandler_get_route_handler(this_ptr: &MessageHandler) -> *const crate::ln::msgs::RoutingMessageHandler {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.route_handler;
+ &(*inner_val)
+}
+/// A message handler which handles messages updating our knowledge of the network channel
+/// graph. Usually this is just a NetGraphMsgHandlerMonitor object.
+#[no_mangle]
+pub extern "C" fn MessageHandler_set_route_handler(this_ptr: &mut MessageHandler, mut val: crate::ln::msgs::RoutingMessageHandler) {
+ unsafe { &mut *this_ptr.inner }.route_handler = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::ln::msgs::ChannelMessageHandler, mut route_handler_arg: crate::ln::msgs::RoutingMessageHandler) -> MessageHandler {
+ MessageHandler { inner: Box::into_raw(Box::new(nativeMessageHandler {
+ chan_handler: chan_handler_arg,
+ route_handler: route_handler_arg,
+ })), is_owned: true }
+}
+/// Provides an object which can be used to send data to and which uniquely identifies a connection
+/// to a remote host. You will need to be able to generate multiple of these which meet Eq and
+/// implement Hash to meet the PeerManager API.
+///
+/// For efficiency, Clone should be relatively cheap for this type.
+///
+/// You probably want to just extend an int and put a file descriptor in a struct and implement
+/// send_data. Note that if you are using a higher-level net library that may call close() itself,
+/// be careful to ensure you don't have races whereby you might register a new connection with an
+/// fd which is the same as a previous one which has yet to be removed via
+/// PeerManager::socket_disconnected().
+#[repr(C)]
+pub struct SocketDescriptor {
+ pub this_arg: *mut c_void,
+ /// Attempts to send some data from the given slice to the peer.
+ ///
+ /// Returns the amount of data which was sent, possibly 0 if the socket has since disconnected.
+ /// Note that in the disconnected case, socket_disconnected must still fire and further write
+ /// attempts may occur until that time.
+ ///
+ /// If the returned size is smaller than data.len(), a write_available event must
+ /// trigger the next time more data can be written. Additionally, until the a send_data event
+ /// completes fully, no further read_events should trigger on the same peer!
+ ///
+ /// If a read_event on this descriptor had previously returned true (indicating that read
+ /// events should be paused to prevent DoS in the send buffer), resume_read may be set
+ /// indicating that read events on this descriptor should resume. A resume_read of false does
+ /// *not* imply that further read events should be paused.
+ #[must_use]
+ pub send_data: extern "C" fn (this_arg: *mut c_void, data: crate::c_types::u8slice, resume_read: bool) -> usize,
+ /// Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no
+ /// more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with
+ /// this descriptor. No socket_disconnected call should be generated as a result of this call,
+ /// though races may occur whereby disconnect_socket is called after a call to
+ /// socket_disconnected but prior to socket_disconnected returning.
+ pub disconnect_socket: extern "C" fn (this_arg: *mut c_void),
+ pub eq: extern "C" fn (this_arg: *const c_void, other_arg: *const c_void) -> bool,
+ pub hash: extern "C" fn (this_arg: *const c_void) -> u64,
+ pub clone: Option<extern "C" fn (this_arg: *const c_void) -> *mut c_void>,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+impl std::cmp::Eq for SocketDescriptor {}
+impl std::cmp::PartialEq for SocketDescriptor {
+ fn eq(&self, o: &Self) -> bool { (self.eq)(self.this_arg, o.this_arg) }
+}
+impl std::hash::Hash for SocketDescriptor {
+ fn hash<H: std::hash::Hasher>(&self, hasher: &mut H) { hasher.write_u64((self.hash)(self.this_arg)) }
+}
+impl Clone for SocketDescriptor {
+ fn clone(&self) -> Self {
+ Self {
+ this_arg: if let Some(f) = self.clone { (f)(self.this_arg) } else { self.this_arg },
+ send_data: self.send_data.clone(),
+ disconnect_socket: self.disconnect_socket.clone(),
+ eq: self.eq.clone(),
+ hash: self.hash.clone(),
+ clone: self.clone.clone(),
+ free: self.free.clone(),
+ }
+ }
+}
+
+use lightning::ln::peer_handler::SocketDescriptor as rustSocketDescriptor;
+impl rustSocketDescriptor for SocketDescriptor {
+ fn send_data(&mut self, data: &[u8], resume_read: bool) -> usize {
+ let mut local_data = crate::c_types::u8slice::from_slice(data);
+ let mut ret = (self.send_data)(self.this_arg, local_data, resume_read);
+ ret
+ }
+ fn disconnect_socket(&mut self) {
+ (self.disconnect_socket)(self.this_arg)
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for SocketDescriptor {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn SocketDescriptor_free(this_ptr: SocketDescriptor) { }
+impl Drop for SocketDescriptor {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+
+use lightning::ln::peer_handler::PeerHandleError as nativePeerHandleErrorImport;
+type nativePeerHandleError = nativePeerHandleErrorImport;
+
+/// Error for PeerManager errors. If you get one of these, you must disconnect the socket and
+/// generate no further read_event/write_buffer_space_avail calls for the descriptor, only
+/// triggering a single socket_disconnected call (unless it was provided in response to a
+/// new_*_connection event, in which case no such socket_disconnected() must be called and the
+/// socket silently disconencted).
+#[must_use]
+#[repr(C)]
+pub struct PeerHandleError {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativePeerHandleError,
+ pub is_owned: bool,
+}
+
+impl Drop for PeerHandleError {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn PeerHandleError_free(this_ptr: PeerHandleError) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn PeerHandleError_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativePeerHandleError); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl PeerHandleError {
+ pub(crate) fn take_ptr(mut self) -> *mut nativePeerHandleError {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Used to indicate that we probably can't make any future connections to this peer, implying
+/// we should go ahead and force-close any channels we have with it.
+#[no_mangle]
+pub extern "C" fn PeerHandleError_get_no_connection_possible(this_ptr: &PeerHandleError) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.no_connection_possible;
+ (*inner_val)
+}
+/// Used to indicate that we probably can't make any future connections to this peer, implying
+/// we should go ahead and force-close any channels we have with it.
+#[no_mangle]
+pub extern "C" fn PeerHandleError_set_no_connection_possible(this_ptr: &mut PeerHandleError, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.no_connection_possible = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PeerHandleError_new(mut no_connection_possible_arg: bool) -> PeerHandleError {
+ PeerHandleError { inner: Box::into_raw(Box::new(nativePeerHandleError {
+ no_connection_possible: no_connection_possible_arg,
+ })), is_owned: true }
+}
+
+use lightning::ln::peer_handler::PeerManager as nativePeerManagerImport;
+type nativePeerManager = nativePeerManagerImport<crate::ln::peer_handler::SocketDescriptor, crate::ln::msgs::ChannelMessageHandler, crate::ln::msgs::RoutingMessageHandler, crate::util::logger::Logger>;
+
+/// A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket
+/// events into messages which it passes on to its MessageHandlers.
+///
+/// Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager
+/// a SimpleRefPeerManager, for conciseness. See their documentation for more details, but
+/// essentially you should default to using a SimpleRefPeerManager, and use a
+/// SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when
+/// you're using lightning-net-tokio.
+#[must_use]
+#[repr(C)]
+pub struct PeerManager {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativePeerManager,
+ pub is_owned: bool,
+}
+
+impl Drop for PeerManager {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn PeerManager_free(this_ptr: PeerManager) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn PeerManager_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativePeerManager); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl PeerManager {
+ pub(crate) fn take_ptr(mut self) -> *mut nativePeerManager {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Constructs a new PeerManager with the given message handlers and node_id secret key
+/// ephemeral_random_data is used to derive per-connection ephemeral keys and must be
+/// cryptographically secure random bytes.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PeerManager_new(mut message_handler: crate::ln::peer_handler::MessageHandler, mut our_node_secret: crate::c_types::SecretKey, ephemeral_random_data: *const [u8; 32], mut logger: crate::util::logger::Logger) -> PeerManager {
+ let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_ptr()) }, our_node_secret.into_rust(), unsafe { &*ephemeral_random_data}, logger);
+ PeerManager { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Get the list of node ids for peers which have completed the initial handshake.
+///
+/// For outbound connections, this will be the same as the their_node_id parameter passed in to
+/// new_outbound_connection, however entries will only appear once the initial handshake has
+/// completed and we are sure the remote peer has the private key for the given node_id.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PeerManager_get_peer_node_ids(this_arg: &PeerManager) -> crate::c_types::derived::CVec_PublicKeyZ {
+ let mut ret = unsafe { &*this_arg.inner }.get_peer_node_ids();
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::c_types::PublicKey::from_rust(&item) }); };
+ local_ret.into()
+}
+
+/// Indicates a new outbound connection has been established to a node with the given node_id.
+/// Note that if an Err is returned here you MUST NOT call socket_disconnected for the new
+/// descriptor but must disconnect the connection immediately.
+///
+/// Returns a small number of bytes to send to the remote node (currently always 50).
+///
+/// Panics if descriptor is duplicative with some other descriptor which has not yet had a
+/// socket_disconnected().
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PeerManager_new_outbound_connection(this_arg: &PeerManager, mut their_node_id: crate::c_types::PublicKey, mut descriptor: crate::ln::peer_handler::SocketDescriptor) -> crate::c_types::derived::CResult_CVec_u8ZPeerHandleErrorZ {
+ let mut ret = unsafe { &*this_arg.inner }.new_outbound_connection(their_node_id.into_rust(), descriptor);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for item in o.drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+
+/// Indicates a new inbound connection has been established.
+///
+/// May refuse the connection by returning an Err, but will never write bytes to the remote end
+/// (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT
+/// call socket_disconnected for the new descriptor but must disconnect the connection
+/// immediately.
+///
+/// Panics if descriptor is duplicative with some other descriptor which has not yet had
+/// socket_disconnected called.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PeerManager_new_inbound_connection(this_arg: &PeerManager, mut descriptor: crate::ln::peer_handler::SocketDescriptor) -> crate::c_types::derived::CResult_NonePeerHandleErrorZ {
+ let mut ret = unsafe { &*this_arg.inner }.new_inbound_connection(descriptor);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+
+/// Indicates that there is room to write data to the given socket descriptor.
+///
+/// May return an Err to indicate that the connection should be closed.
+///
+/// Will most likely call send_data on the descriptor passed in (or the descriptor handed into
+/// new_*\\_connection) before returning. Thus, be very careful with reentrancy issues! The
+/// invariants around calling write_buffer_space_avail in case a write did not fully complete
+/// must still hold - be ready to call write_buffer_space_avail again if a write call generated
+/// here isn't sufficient! Panics if the descriptor was not previously registered in a
+/// new_\\*_connection event.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PeerManager_write_buffer_space_avail(this_arg: &PeerManager, descriptor: &mut crate::ln::peer_handler::SocketDescriptor) -> crate::c_types::derived::CResult_NonePeerHandleErrorZ {
+ let mut ret = unsafe { &*this_arg.inner }.write_buffer_space_avail(descriptor);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+
+/// Indicates that data was read from the given socket descriptor.
+///
+/// May return an Err to indicate that the connection should be closed.
+///
+/// Will *not* call back into send_data on any descriptors to avoid reentrancy complexity.
+/// Thus, however, you almost certainly want to call process_events() after any read_event to
+/// generate send_data calls to handle responses.
+///
+/// If Ok(true) is returned, further read_events should not be triggered until a send_data call
+/// on this file descriptor has resume_read set (preventing DoS issues in the send buffer).
+///
+/// Panics if the descriptor was not previously registered in a new_*_connection event.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PeerManager_read_event(this_arg: &PeerManager, peer_descriptor: &mut crate::ln::peer_handler::SocketDescriptor, mut data: crate::c_types::u8slice) -> crate::c_types::derived::CResult_boolPeerHandleErrorZ {
+ let mut ret = unsafe { &*this_arg.inner }.read_event(peer_descriptor, data.to_slice());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+
+/// Checks for any events generated by our handlers and processes them. Includes sending most
+/// response messages as well as messages generated by calls to handler functions directly (eg
+/// functions like ChannelManager::process_pending_htlc_forward or send_payment).
+#[no_mangle]
+pub extern "C" fn PeerManager_process_events(this_arg: &PeerManager) {
+ unsafe { &*this_arg.inner }.process_events()
+}
+
+/// Indicates that the given socket descriptor's connection is now closed.
+///
+/// This must only be called if the socket has been disconnected by the peer or your own
+/// decision to disconnect it and must NOT be called in any case where other parts of this
+/// library (eg PeerHandleError, explicit disconnect_socket calls) instruct you to disconnect
+/// the peer.
+///
+/// Panics if the descriptor was not previously registered in a successful new_*_connection event.
+#[no_mangle]
+pub extern "C" fn PeerManager_socket_disconnected(this_arg: &PeerManager, descriptor: &crate::ln::peer_handler::SocketDescriptor) {
+ unsafe { &*this_arg.inner }.socket_disconnected(descriptor)
+}
+
+/// This function should be called roughly once every 30 seconds.
+/// It will send pings to each peer and disconnect those which did not respond to the last round of pings.
+/// Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues!
+#[no_mangle]
+pub extern "C" fn PeerManager_timer_tick_occured(this_arg: &PeerManager) {
+ unsafe { &*this_arg.inner }.timer_tick_occured()
+}
+
--- /dev/null
+//! Structs and impls for receiving messages about the network and storing the topology live here.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+pub mod router;
+pub mod network_graph;
--- /dev/null
+//! The top-level network map tracking logic lives here.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::routing::network_graph::NetworkGraph as nativeNetworkGraphImport;
+type nativeNetworkGraph = nativeNetworkGraphImport;
+
+/// Represents the network as nodes and channels between them
+#[must_use]
+#[repr(C)]
+pub struct NetworkGraph {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeNetworkGraph,
+ pub is_owned: bool,
+}
+
+impl Drop for NetworkGraph {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NetworkGraph_free(this_ptr: NetworkGraph) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetworkGraph); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl NetworkGraph {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeNetworkGraph {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::routing::network_graph::LockedNetworkGraph as nativeLockedNetworkGraphImport;
+type nativeLockedNetworkGraph = nativeLockedNetworkGraphImport<'static>;
+
+/// A simple newtype for RwLockReadGuard<'a, NetworkGraph>.
+/// This exists only to make accessing a RwLock<NetworkGraph> possible from
+/// the C bindings, as it can be done directly in Rust code.
+#[must_use]
+#[repr(C)]
+pub struct LockedNetworkGraph {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeLockedNetworkGraph,
+ pub is_owned: bool,
+}
+
+impl Drop for LockedNetworkGraph {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn LockedNetworkGraph_free(this_ptr: LockedNetworkGraph) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn LockedNetworkGraph_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLockedNetworkGraph); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl LockedNetworkGraph {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeLockedNetworkGraph {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::routing::network_graph::NetGraphMsgHandler as nativeNetGraphMsgHandlerImport;
+type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::chain::chaininterface::ChainWatchInterface, crate::util::logger::Logger>;
+
+/// Receives and validates network updates from peers,
+/// stores authentic and relevant data as a network graph.
+/// This network graph is then used for routing payments.
+/// Provides interface to help with initial routing sync by
+/// serving historical announcements.
+#[must_use]
+#[repr(C)]
+pub struct NetGraphMsgHandler {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeNetGraphMsgHandler,
+ pub is_owned: bool,
+}
+
+impl Drop for NetGraphMsgHandler {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NetGraphMsgHandler_free(this_ptr: NetGraphMsgHandler) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn NetGraphMsgHandler_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetGraphMsgHandler); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl NetGraphMsgHandler {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeNetGraphMsgHandler {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Creates a new tracker of the actual state of the network of channels and nodes,
+/// assuming a fresh network graph.
+/// Chain monitor is used to make sure announced channels exist on-chain,
+/// channel data is correct, and that the announcement is signed with
+/// channel owners' keys.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetGraphMsgHandler_new(mut chain_monitor: crate::chain::chaininterface::ChainWatchInterface, mut logger: crate::util::logger::Logger) -> NetGraphMsgHandler {
+ let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(chain_monitor, logger);
+ NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Creates a new tracker of the actual state of the network of channels and nodes,
+/// assuming an existing Network Graph.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetGraphMsgHandler_from_net_graph(mut chain_monitor: crate::chain::chaininterface::ChainWatchInterface, mut logger: crate::util::logger::Logger, mut network_graph: crate::routing::network_graph::NetworkGraph) -> NetGraphMsgHandler {
+ let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(chain_monitor, logger, *unsafe { Box::from_raw(network_graph.take_ptr()) });
+ NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Take a read lock on the network_graph and return it in the C-bindings
+/// newtype helper. This is likely only useful when called via the C
+/// bindings as you can call `self.network_graph.read().unwrap()` in Rust
+/// yourself.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetGraphMsgHandler_read_locked_graph(this_arg: &NetGraphMsgHandler) -> crate::routing::network_graph::LockedNetworkGraph {
+ let mut ret = unsafe { &*this_arg.inner }.read_locked_graph();
+ crate::routing::network_graph::LockedNetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Get a reference to the NetworkGraph which this read-lock contains.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn LockedNetworkGraph_graph(this_arg: &LockedNetworkGraph) -> crate::routing::network_graph::NetworkGraph {
+ let mut ret = unsafe { &*this_arg.inner }.graph();
+ crate::routing::network_graph::NetworkGraph { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
+}
+
+#[no_mangle]
+pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: *const NetGraphMsgHandler) -> crate::ln::msgs::RoutingMessageHandler {
+ crate::ln::msgs::RoutingMessageHandler {
+ this_arg: unsafe { (*this_arg).inner as *mut c_void },
+ free: None,
+ handle_node_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement,
+ handle_channel_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement,
+ handle_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update,
+ handle_htlc_fail_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update,
+ get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements,
+ get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements,
+ should_request_full_sync: NetGraphMsgHandler_RoutingMessageHandler_should_request_full_sync,
+ }
+}
+use lightning::ln::msgs::RoutingMessageHandler as RoutingMessageHandlerTraitImport;
+#[must_use]
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.handle_node_announcement(unsafe { &*msg.inner });
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.handle_channel_announcement(unsafe { &*msg.inner });
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate) {
+ unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.handle_htlc_fail_channel_update(&update.to_native())
+}
+#[must_use]
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.handle_channel_update(unsafe { &*msg.inner });
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+#[must_use]
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements(this_arg: *const c_void, mut starting_point: u64, mut batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.get_next_channel_announcements(starting_point, batch_amount);
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((orig_ret_0_1.unwrap()))) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((orig_ret_0_2.unwrap()))) } }, is_owned: true }; let mut local_ret_0 = (crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(orig_ret_0_0)), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
+ local_ret.into()
+}
+#[must_use]
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements(this_arg: *const c_void, mut starting_point: crate::c_types::PublicKey, mut batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ {
+ let mut local_starting_point_base = if starting_point.is_null() { None } else { Some( { starting_point.into_rust() }) }; let mut local_starting_point = local_starting_point_base.as_ref();
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.get_next_node_announcements(local_starting_point, batch_amount);
+ let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
+ local_ret.into()
+}
+#[must_use]
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_should_request_full_sync(this_arg: *const c_void, _node_id: crate::c_types::PublicKey) -> bool {
+ let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.should_request_full_sync(&_node_id.into_rust());
+ ret
+}
+
+
+use lightning::routing::network_graph::DirectionalChannelInfo as nativeDirectionalChannelInfoImport;
+type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
+
+/// Details about one direction of a channel. Received
+/// within a channel update.
+#[must_use]
+#[repr(C)]
+pub struct DirectionalChannelInfo {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeDirectionalChannelInfo,
+ pub is_owned: bool,
+}
+
+impl Drop for DirectionalChannelInfo {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_free(this_ptr: DirectionalChannelInfo) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectionalChannelInfo); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl DirectionalChannelInfo {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeDirectionalChannelInfo {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// When the last update to the channel direction was issued.
+/// Value is opaque, as set in the announcement.
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_get_last_update(this_ptr: &DirectionalChannelInfo) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update;
+ (*inner_val)
+}
+/// When the last update to the channel direction was issued.
+/// Value is opaque, as set in the announcement.
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_set_last_update(this_ptr: &mut DirectionalChannelInfo, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.last_update = val;
+}
+/// Whether the channel can be currently used for payments (in this one direction).
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_get_enabled(this_ptr: &DirectionalChannelInfo) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.enabled;
+ (*inner_val)
+}
+/// Whether the channel can be currently used for payments (in this one direction).
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_set_enabled(this_ptr: &mut DirectionalChannelInfo, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.enabled = val;
+}
+/// The difference in CLTV values that you must have when routing through this channel.
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr: &DirectionalChannelInfo) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
+ (*inner_val)
+}
+/// The difference in CLTV values that you must have when routing through this channel.
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr: &mut DirectionalChannelInfo, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
+}
+/// The minimum value, which must be relayed to the next hop via the channel
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &DirectionalChannelInfo) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
+ (*inner_val)
+}
+/// The minimum value, which must be relayed to the next hop via the channel
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
+}
+/// Most recent update for the channel received from the network
+/// Mostly redundant with the data we store in fields explicitly.
+/// Everything else is useful only for sending out for initial routing sync.
+/// Not stored if contains excess data to prevent DoS.
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::ln::msgs::ChannelUpdate {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update_message;
+ let mut local_inner_val = crate::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// Most recent update for the channel received from the network
+/// Mostly redundant with the data we store in fields explicitly.
+/// Everything else is useful only for sending out for initial routing sync.
+/// Not stored if contains excess data to prevent DoS.
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_set_last_update_message(this_ptr: &mut DirectionalChannelInfo, mut val: crate::ln::msgs::ChannelUpdate) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
+ unsafe { &mut *this_ptr.inner }.last_update_message = local_val;
+}
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_write(obj: *const DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> DirectionalChannelInfo {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ DirectionalChannelInfo { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ DirectionalChannelInfo { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::routing::network_graph::ChannelInfo as nativeChannelInfoImport;
+type nativeChannelInfo = nativeChannelInfoImport;
+
+/// Details about a channel (both directions).
+/// Received within a channel announcement.
+#[must_use]
+#[repr(C)]
+pub struct ChannelInfo {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelInfo,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelInfo {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelInfo_free(this_ptr: ChannelInfo) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelInfo {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelInfo {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// Source node of the first direction of a channel
+#[no_mangle]
+pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_one;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// Source node of the first direction of a channel
+#[no_mangle]
+pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.node_one = val.into_rust();
+}
+/// Details about the first direction of a channel
+#[no_mangle]
+pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::routing::network_graph::DirectionalChannelInfo {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.one_to_two;
+ let mut local_inner_val = crate::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// Details about the first direction of a channel
+#[no_mangle]
+pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::routing::network_graph::DirectionalChannelInfo) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
+ unsafe { &mut *this_ptr.inner }.one_to_two = local_val;
+}
+/// Source node of the second direction of a channel
+#[no_mangle]
+pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_two;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// Source node of the second direction of a channel
+#[no_mangle]
+pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.node_two = val.into_rust();
+}
+/// Details about the second direction of a channel
+#[no_mangle]
+pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::routing::network_graph::DirectionalChannelInfo {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.two_to_one;
+ let mut local_inner_val = crate::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// Details about the second direction of a channel
+#[no_mangle]
+pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::routing::network_graph::DirectionalChannelInfo) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
+ unsafe { &mut *this_ptr.inner }.two_to_one = local_val;
+}
+/// An initial announcement of the channel
+/// Mostly redundant with the data we store in fields explicitly.
+/// Everything else is useful only for sending out for initial routing sync.
+/// Not stored if contains excess data to prevent DoS.
+#[no_mangle]
+pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::ln::msgs::ChannelAnnouncement {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message;
+ let mut local_inner_val = crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// An initial announcement of the channel
+/// Mostly redundant with the data we store in fields explicitly.
+/// Everything else is useful only for sending out for initial routing sync.
+/// Not stored if contains excess data to prevent DoS.
+#[no_mangle]
+pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInfo, mut val: crate::ln::msgs::ChannelAnnouncement) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
+ unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
+}
+#[no_mangle]
+pub extern "C" fn ChannelInfo_write(obj: *const ChannelInfo) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> ChannelInfo {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ChannelInfo { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ChannelInfo { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::routing::network_graph::RoutingFees as nativeRoutingFeesImport;
+type nativeRoutingFees = nativeRoutingFeesImport;
+
+/// Fees for routing via a given channel or a node
+#[must_use]
+#[repr(C)]
+pub struct RoutingFees {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeRoutingFees,
+ pub is_owned: bool,
+}
+
+impl Drop for RoutingFees {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn RoutingFees_free(this_ptr: RoutingFees) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl RoutingFees {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeRoutingFees {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for RoutingFees {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoutingFees)).clone() })) as *mut c_void
+}
+/// Flat routing fee in satoshis
+#[no_mangle]
+pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.base_msat;
+ (*inner_val)
+}
+/// Flat routing fee in satoshis
+#[no_mangle]
+pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.base_msat = val;
+}
+/// Liquidity-based routing fee in millionths of a routed amount.
+/// In other words, 10000 is 1%.
+#[no_mangle]
+pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.proportional_millionths;
+ (*inner_val)
+}
+/// Liquidity-based routing fee in millionths of a routed amount.
+/// In other words, 10000 is 1%.
+#[no_mangle]
+pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.proportional_millionths = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees {
+ RoutingFees { inner: Box::into_raw(Box::new(nativeRoutingFees {
+ base_msat: base_msat_arg,
+ proportional_millionths: proportional_millionths_arg,
+ })), is_owned: true }
+}
+#[no_mangle]
+pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> RoutingFees {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ RoutingFees { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ RoutingFees { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn RoutingFees_write(obj: *const RoutingFees) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+
+use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
+type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
+
+/// Information received in the latest node_announcement from this node.
+#[must_use]
+#[repr(C)]
+pub struct NodeAnnouncementInfo {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeNodeAnnouncementInfo,
+ pub is_owned: bool,
+}
+
+impl Drop for NodeAnnouncementInfo {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_free(this_ptr: NodeAnnouncementInfo) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl NodeAnnouncementInfo {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeNodeAnnouncementInfo {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// When the last known update to the node state was issued.
+/// Value is opaque, as set in the announcement.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update;
+ (*inner_val)
+}
+/// When the last known update to the node state was issued.
+/// Value is opaque, as set in the announcement.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.last_update = val;
+}
+/// Color assigned to the node
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
+ &(*inner_val)
+}
+/// Color assigned to the node
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) {
+ unsafe { &mut *this_ptr.inner }.rgb = val.data;
+}
+/// Moniker assigned to the node.
+/// May be invalid or malicious (eg control chars),
+/// should not be exposed to the user.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 32] {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
+ &(*inner_val)
+}
+/// Moniker assigned to the node.
+/// May be invalid or malicious (eg control chars),
+/// should not be exposed to the user.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *this_ptr.inner }.alias = val.data;
+}
+/// Internet-level addresses via which one can connect to the node
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::derived::CVec_NetAddressZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
+ unsafe { &mut *this_ptr.inner }.addresses = local_val;
+}
+/// An initial announcement of the node
+/// Mostly redundant with the data we store in fields explicitly.
+/// Everything else is useful only for sending out for initial routing sync.
+/// Not stored if contains excess data to prevent DoS.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::ln::msgs::NodeAnnouncement {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message;
+ let mut local_inner_val = crate::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// An initial announcement of the node
+/// Mostly redundant with the data we store in fields explicitly.
+/// Everything else is useful only for sending out for initial routing sync.
+/// Not stored if contains excess data to prevent DoS.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::ln::msgs::NodeAnnouncement) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
+ unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
+}
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_write(obj: *const NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> NodeAnnouncementInfo {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ NodeAnnouncementInfo { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ NodeAnnouncementInfo { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::routing::network_graph::NodeInfo as nativeNodeInfoImport;
+type nativeNodeInfo = nativeNodeInfoImport;
+
+/// Details about a node in the network, known from the network announcement.
+#[must_use]
+#[repr(C)]
+pub struct NodeInfo {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeNodeInfo,
+ pub is_owned: bool,
+}
+
+impl Drop for NodeInfo {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NodeInfo_free(this_ptr: NodeInfo) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl NodeInfo {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeNodeInfo {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// All valid channels a node has announced
+#[no_mangle]
+pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::CVec_u64Z) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
+ unsafe { &mut *this_ptr.inner }.channels = local_val;
+}
+/// Lowest fees enabling routing via any of the enabled, known channels to a node.
+/// The two fields (flat and proportional fee) are independent,
+/// meaning they don't have to refer to the same channel.
+#[no_mangle]
+pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::routing::network_graph::RoutingFees {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees;
+ let mut local_inner_val = crate::routing::network_graph::RoutingFees { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// Lowest fees enabling routing via any of the enabled, known channels to a node.
+/// The two fields (flat and proportional fee) are independent,
+/// meaning they don't have to refer to the same channel.
+#[no_mangle]
+pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeInfo, mut val: crate::routing::network_graph::RoutingFees) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
+ unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees = local_val;
+}
+/// More information about a node from node_announcement.
+/// Optional because we store a Node entry after learning about it from
+/// a channel announcement, but before receiving a node announcement.
+#[no_mangle]
+pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::routing::network_graph::NodeAnnouncementInfo {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_info;
+ let mut local_inner_val = crate::routing::network_graph::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// More information about a node from node_announcement.
+/// Optional because we store a Node entry after learning about it from
+/// a channel announcement, but before receiving a node announcement.
+#[no_mangle]
+pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::routing::network_graph::NodeAnnouncementInfo) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
+ unsafe { &mut *this_ptr.inner }.announcement_info = local_val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u64Z, mut lowest_inbound_channel_fees_arg: crate::routing::network_graph::RoutingFees, mut announcement_info_arg: crate::routing::network_graph::NodeAnnouncementInfo) -> NodeInfo {
+ let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); };
+ let mut local_lowest_inbound_channel_fees_arg = if lowest_inbound_channel_fees_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(lowest_inbound_channel_fees_arg.take_ptr()) } }) };
+ let mut local_announcement_info_arg = if announcement_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_info_arg.take_ptr()) } }) };
+ NodeInfo { inner: Box::into_raw(Box::new(nativeNodeInfo {
+ channels: local_channels_arg,
+ lowest_inbound_channel_fees: local_lowest_inbound_channel_fees_arg,
+ announcement_info: local_announcement_info_arg,
+ })), is_owned: true }
+}
+#[no_mangle]
+pub extern "C" fn NodeInfo_write(obj: *const NodeInfo) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> NodeInfo {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ NodeInfo { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ NodeInfo { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+#[no_mangle]
+pub extern "C" fn NetworkGraph_write(obj: *const NetworkGraph) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> NetworkGraph {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ NetworkGraph { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ NetworkGraph { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+/// Creates a new, empty, network graph.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetworkGraph_new() -> crate::routing::network_graph::NetworkGraph {
+ let mut ret = lightning::routing::network_graph::NetworkGraph::new();
+ crate::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+/// Close a channel if a corresponding HTLC fail was sent.
+/// If permanent, removes a channel from the local storage.
+/// May cause the removal of nodes too, if this was their last channel.
+/// If not permanent, makes channels unavailable for routing.
+#[no_mangle]
+pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &mut NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
+ unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.close_channel_from_update(short_channel_id, is_permanent)
+}
+
--- /dev/null
+//! The top-level routing/network map tracking logic lives here.
+//!
+//! You probably want to create a NetGraphMsgHandler and use that as your RoutingMessageHandler and then
+//! interrogate it to get routes for your own payments.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::routing::router::RouteHop as nativeRouteHopImport;
+type nativeRouteHop = nativeRouteHopImport;
+
+/// A hop in a route
+#[must_use]
+#[repr(C)]
+pub struct RouteHop {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeRouteHop,
+ pub is_owned: bool,
+}
+
+impl Drop for RouteHop {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn RouteHop_free(this_ptr: RouteHop) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn RouteHop_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHop); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl RouteHop {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeRouteHop {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for RouteHop {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RouteHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHop)).clone() })) as *mut c_void
+}
+/// The node_id of the node at this hop.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_pubkey(this_ptr: &RouteHop) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkey;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The node_id of the node at this hop.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.pubkey = val.into_rust();
+}
+/// The channel that should be used from the previous hop to reach this node.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_short_channel_id(this_ptr: &RouteHop) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
+ (*inner_val)
+}
+/// The channel that should be used from the previous hop to reach this node.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.short_channel_id = val;
+}
+/// The fee taken on this hop. For the last hop, this should be the full value of the payment.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_msat;
+ (*inner_val)
+}
+/// The fee taken on this hop. For the last hop, this should be the full value of the payment.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_fee_msat(this_ptr: &mut RouteHop, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.fee_msat = val;
+}
+/// The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
+/// expected at the destination, in excess of the current block height.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
+ (*inner_val)
+}
+/// The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
+/// expected at the destination, in excess of the current block height.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
+}
+
+use lightning::routing::router::Route as nativeRouteImport;
+type nativeRoute = nativeRouteImport;
+
+/// A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
+/// it can take multiple paths. Each path is composed of one or more hops through the network.
+#[must_use]
+#[repr(C)]
+pub struct Route {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeRoute,
+ pub is_owned: bool,
+}
+
+impl Drop for Route {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Route_free(this_ptr: Route) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn Route_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoute); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl Route {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeRoute {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for Route {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn Route_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoute)).clone() })) as *mut c_void
+}
+/// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
+/// last RouteHop in each path must be the same.
+/// Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the
+/// destination. Thus, this must always be at least length one. While the maximum length of any
+/// given path is variable, keeping the length of any path to less than 20 should currently
+/// ensure it is viable.
+#[no_mangle]
+pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_CVec_RouteHopZZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { let mut local_val_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_val_0.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; local_val_0 }); };
+ unsafe { &mut *this_ptr.inner }.paths = local_val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_CVec_RouteHopZZ) -> Route {
+ let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { let mut local_paths_arg_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_paths_arg_0.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; local_paths_arg_0 }); };
+ Route { inner: Box::into_raw(Box::new(nativeRoute {
+ paths: local_paths_arg,
+ })), is_owned: true }
+}
+#[no_mangle]
+pub extern "C" fn Route_write(obj: *const Route) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> Route {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ Route { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ Route { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::routing::router::RouteHint as nativeRouteHintImport;
+type nativeRouteHint = nativeRouteHintImport;
+
+/// A channel descriptor which provides a last-hop route to get_route
+#[must_use]
+#[repr(C)]
+pub struct RouteHint {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeRouteHint,
+ pub is_owned: bool,
+}
+
+impl Drop for RouteHint {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn RouteHint_free(this_ptr: RouteHint) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHint); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl RouteHint {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeRouteHint {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// The node_id of the non-target end of the route
+#[no_mangle]
+pub extern "C" fn RouteHint_get_src_node_id(this_ptr: &RouteHint) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.src_node_id;
+ crate::c_types::PublicKey::from_rust(&(*inner_val))
+}
+/// The node_id of the non-target end of the route
+#[no_mangle]
+pub extern "C" fn RouteHint_set_src_node_id(this_ptr: &mut RouteHint, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *this_ptr.inner }.src_node_id = val.into_rust();
+}
+/// The short_channel_id of this channel
+#[no_mangle]
+pub extern "C" fn RouteHint_get_short_channel_id(this_ptr: &RouteHint) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
+ (*inner_val)
+}
+/// The short_channel_id of this channel
+#[no_mangle]
+pub extern "C" fn RouteHint_set_short_channel_id(this_ptr: &mut RouteHint, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.short_channel_id = val;
+}
+/// The fees which must be paid to use this channel
+#[no_mangle]
+pub extern "C" fn RouteHint_get_fees(this_ptr: &RouteHint) -> crate::routing::network_graph::RoutingFees {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees;
+ crate::routing::network_graph::RoutingFees { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// The fees which must be paid to use this channel
+#[no_mangle]
+pub extern "C" fn RouteHint_set_fees(this_ptr: &mut RouteHint, mut val: crate::routing::network_graph::RoutingFees) {
+ unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+/// The difference in CLTV values between this node and the next node.
+#[no_mangle]
+pub extern "C" fn RouteHint_get_cltv_expiry_delta(this_ptr: &RouteHint) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
+ (*inner_val)
+}
+/// The difference in CLTV values between this node and the next node.
+#[no_mangle]
+pub extern "C" fn RouteHint_set_cltv_expiry_delta(this_ptr: &mut RouteHint, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
+}
+/// The minimum value, in msat, which must be relayed to the next hop.
+#[no_mangle]
+pub extern "C" fn RouteHint_get_htlc_minimum_msat(this_ptr: &RouteHint) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
+ (*inner_val)
+}
+/// The minimum value, in msat, which must be relayed to the next hop.
+#[no_mangle]
+pub extern "C" fn RouteHint_set_htlc_minimum_msat(this_ptr: &mut RouteHint, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RouteHint_new(mut src_node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: u64, mut fees_arg: crate::routing::network_graph::RoutingFees, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64) -> RouteHint {
+ RouteHint { inner: Box::into_raw(Box::new(nativeRouteHint {
+ src_node_id: src_node_id_arg.into_rust(),
+ short_channel_id: short_channel_id_arg,
+ fees: *unsafe { Box::from_raw(fees_arg.take_ptr()) },
+ cltv_expiry_delta: cltv_expiry_delta_arg,
+ htlc_minimum_msat: htlc_minimum_msat_arg,
+ })), is_owned: true }
+}
+/// Gets a route from us to the given target node.
+///
+/// Extra routing hops between known nodes and the target will be used if they are included in
+/// last_hops.
+///
+/// If some channels aren't announced, it may be useful to fill in a first_hops with the
+/// results from a local ChannelManager::list_usable_channels() call. If it is filled in, our
+/// view of our local channels (from net_graph_msg_handler) will be ignored, and only those in first_hops
+/// will be used.
+///
+/// Panics if first_hops contains channels without short_channel_ids
+/// (ChannelManager::list_usable_channels will never include such channels).
+///
+/// The fees on channels from us to next-hops are ignored (as they are assumed to all be
+/// equal), however the enabled/disabled bit on such channels as well as the htlc_minimum_msat
+/// *is* checked as they may change based on the receiving node.
+#[no_mangle]
+pub extern "C" fn get_route(our_node_id: crate::c_types::PublicKey, network: &crate::routing::network_graph::NetworkGraph, target: crate::c_types::PublicKey, mut first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut last_hops: crate::c_types::derived::CVec_RouteHintZ, mut final_value_msat: u64, mut final_cltv: u32, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
+ let mut local_first_hops_base = if first_hops.is_null() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { unsafe { &*item.inner } }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
+ let mut local_last_hops = Vec::new(); for mut item in last_hops.as_slice().iter() { local_last_hops.push( { unsafe { &*item.inner } }); };
+ let mut ret = lightning::routing::router::get_route(&our_node_id.into_rust(), unsafe { &*network.inner }, &target.into_rust(), local_first_hops, &local_last_hops[..], final_value_msat, final_cltv, logger);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::router::Route { inner: Box::into_raw(Box::new(o)), is_owned: true } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+ local_ret
+}
+
--- /dev/null
+//! Various user-configurable channel limits and settings which ChannelManager
+//! applies for you.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::util::config::ChannelHandshakeConfig as nativeChannelHandshakeConfigImport;
+type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
+
+/// Configuration we set when applicable.
+///
+/// Default::default() provides sane defaults.
+#[must_use]
+#[repr(C)]
+pub struct ChannelHandshakeConfig {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelHandshakeConfig,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelHandshakeConfig {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_free(this_ptr: ChannelHandshakeConfig) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeConfig); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelHandshakeConfig {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelHandshakeConfig {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelHandshakeConfig {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void
+}
+/// Confirmations we will wait for before considering the channel locked in.
+/// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
+/// equivalent limit applied to outbound channels).
+///
+/// Default value: 6.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHandshakeConfig) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth;
+ (*inner_val)
+}
+/// Confirmations we will wait for before considering the channel locked in.
+/// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
+/// equivalent limit applied to outbound channels).
+///
+/// Default value: 6.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.minimum_depth = val;
+}
+/// Set to the amount of time we require our counterparty to wait to claim their money.
+///
+/// It's one of the main parameter of our security model. We (or one of our watchtowers) MUST
+/// be online to check for peer having broadcast a revoked transaction to steal our funds
+/// at least once every our_to_self_delay blocks.
+///
+/// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
+/// case of an honest unilateral channel close, which implicitly decrease the economic value of
+/// our channel.
+///
+/// Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel
+/// opening so you can tweak config to ask for more security, not less.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.our_to_self_delay;
+ (*inner_val)
+}
+/// Set to the amount of time we require our counterparty to wait to claim their money.
+///
+/// It's one of the main parameter of our security model. We (or one of our watchtowers) MUST
+/// be online to check for peer having broadcast a revoked transaction to steal our funds
+/// at least once every our_to_self_delay blocks.
+///
+/// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
+/// case of an honest unilateral channel close, which implicitly decrease the economic value of
+/// our channel.
+///
+/// Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel
+/// opening so you can tweak config to ask for more security, not less.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.our_to_self_delay = val;
+}
+/// Set to the smallest value HTLC we will accept to process.
+///
+/// This value is sent to our counterparty on channel-open and we close the channel any time
+/// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
+///
+/// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
+/// by the protocol.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &ChannelHandshakeConfig) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.our_htlc_minimum_msat;
+ (*inner_val)
+}
+/// Set to the smallest value HTLC we will accept to process.
+///
+/// This value is sent to our counterparty on channel-open and we close the channel any time
+/// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
+///
+/// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
+/// by the protocol.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeConfig, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.our_htlc_minimum_msat = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64) -> ChannelHandshakeConfig {
+ ChannelHandshakeConfig { inner: Box::into_raw(Box::new(nativeChannelHandshakeConfig {
+ minimum_depth: minimum_depth_arg,
+ our_to_self_delay: our_to_self_delay_arg,
+ our_htlc_minimum_msat: our_htlc_minimum_msat_arg,
+ })), is_owned: true }
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
+ ChannelHandshakeConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
+}
+
+use lightning::util::config::ChannelHandshakeLimits as nativeChannelHandshakeLimitsImport;
+type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
+
+/// Optional channel limits which are applied during channel creation.
+///
+/// These limits are only applied to our counterparty's limits, not our own.
+///
+/// Use 0/<type>::max_value() as appropriate to skip checking.
+///
+/// Provides sane defaults for most configurations.
+///
+/// Most additional limits are disabled except those with which specify a default in individual
+/// field documentation. Note that this may result in barely-usable channels, but since they
+/// are applied mostly only to incoming channels that's not much of a problem.
+#[must_use]
+#[repr(C)]
+pub struct ChannelHandshakeLimits {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelHandshakeLimits,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelHandshakeLimits {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_free(this_ptr: ChannelHandshakeLimits) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelHandshakeLimits {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelHandshakeLimits {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelHandshakeLimits {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void
+}
+/// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
+/// only applies to inbound channels.
+///
+/// Default value: 0.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_funding_satoshis;
+ (*inner_val)
+}
+/// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
+/// only applies to inbound channels.
+///
+/// Default value: 0.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.min_funding_satoshis = val;
+}
+/// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
+/// you to limit the maximum minimum-size they can require.
+///
+/// Default value: u64::max_value.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_minimum_msat;
+ (*inner_val)
+}
+/// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
+/// you to limit the maximum minimum-size they can require.
+///
+/// Default value: u64::max_value.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.max_htlc_minimum_msat = val;
+}
+/// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
+/// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
+///
+/// Default value: 0.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_max_htlc_value_in_flight_msat;
+ (*inner_val)
+}
+/// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
+/// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
+///
+/// Default value: 0.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.min_max_htlc_value_in_flight_msat = val;
+}
+/// The remote node will require we keep a certain amount in direct payment to ourselves at all
+/// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
+/// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
+///
+/// Default value: u64::max_value.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_channel_reserve_satoshis;
+ (*inner_val)
+}
+/// The remote node will require we keep a certain amount in direct payment to ourselves at all
+/// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
+/// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
+///
+/// Default value: u64::max_value.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.max_channel_reserve_satoshis = val;
+}
+/// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
+/// time. This allows you to set a minimum such value.
+///
+/// Default value: 0.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_max_accepted_htlcs;
+ (*inner_val)
+}
+/// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
+/// time. This allows you to set a minimum such value.
+///
+/// Default value: 0.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.min_max_accepted_htlcs = val;
+}
+/// Outputs below a certain value will not be added to on-chain transactions. The dust value is
+/// required to always be higher than this value so this only applies to HTLC outputs (and
+/// potentially to-self outputs before any payments have been made).
+/// Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
+/// This setting allows you to set a minimum dust limit for their commitment transactions,
+/// reflecting the reality that tiny outputs are not considered standard transactions and will
+/// not propagate through the Bitcoin network.
+///
+/// Default value: 546, the current dust limit on the Bitcoin network.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_min_dust_limit_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_dust_limit_satoshis;
+ (*inner_val)
+}
+/// Outputs below a certain value will not be added to on-chain transactions. The dust value is
+/// required to always be higher than this value so this only applies to HTLC outputs (and
+/// potentially to-self outputs before any payments have been made).
+/// Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
+/// This setting allows you to set a minimum dust limit for their commitment transactions,
+/// reflecting the reality that tiny outputs are not considered standard transactions and will
+/// not propagate through the Bitcoin network.
+///
+/// Default value: 546, the current dust limit on the Bitcoin network.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_min_dust_limit_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.min_dust_limit_satoshis = val;
+}
+/// Maximum allowed threshold above which outputs will not be generated in their commitment
+/// transactions.
+/// HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
+///
+/// Default value: u64::max_value.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_max_dust_limit_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_dust_limit_satoshis;
+ (*inner_val)
+}
+/// Maximum allowed threshold above which outputs will not be generated in their commitment
+/// transactions.
+/// HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
+///
+/// Default value: u64::max_value.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_max_dust_limit_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
+ unsafe { &mut *this_ptr.inner }.max_dust_limit_satoshis = val;
+}
+/// Before a channel is usable the funding transaction will need to be confirmed by at least a
+/// certain number of blocks, specified by the node which is not the funder (as the funder can
+/// assume they aren't going to double-spend themselves).
+/// This config allows you to set a limit on the maximum amount of time to wait.
+///
+/// Default value: 144, or roughly one day and only applies to outbound channels.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_minimum_depth;
+ (*inner_val)
+}
+/// Before a channel is usable the funding transaction will need to be confirmed by at least a
+/// certain number of blocks, specified by the node which is not the funder (as the funder can
+/// assume they aren't going to double-spend themselves).
+/// This config allows you to set a limit on the maximum amount of time to wait.
+///
+/// Default value: 144, or roughly one day and only applies to outbound channels.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut ChannelHandshakeLimits, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.max_minimum_depth = val;
+}
+/// Set to force the incoming channel to match our announced channel preference in
+/// ChannelConfig.
+///
+/// Default value: true, to make the default that no announced channels are possible (which is
+/// appropriate for any nodes which are not online very reliably).
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.force_announced_channel_preference;
+ (*inner_val)
+}
+/// Set to force the incoming channel to match our announced channel preference in
+/// ChannelConfig.
+///
+/// Default value: true, to make the default that no announced channels are possible (which is
+/// appropriate for any nodes which are not online very reliably).
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.force_announced_channel_preference = val;
+}
+/// Set to the amount of time we're willing to wait to claim money back to us.
+///
+/// Not checking this value would be a security issue, as our peer would be able to set it to
+/// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
+///
+/// Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
+/// so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.their_to_self_delay;
+ (*inner_val)
+}
+/// Set to the amount of time we're willing to wait to claim money back to us.
+///
+/// Not checking this value would be a security issue, as our peer would be able to set it to
+/// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
+///
+/// Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
+/// so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_set_their_to_self_delay(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
+ unsafe { &mut *this_ptr.inner }.their_to_self_delay = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_new(mut min_funding_satoshis_arg: u64, mut max_htlc_minimum_msat_arg: u64, mut min_max_htlc_value_in_flight_msat_arg: u64, mut max_channel_reserve_satoshis_arg: u64, mut min_max_accepted_htlcs_arg: u16, mut min_dust_limit_satoshis_arg: u64, mut max_dust_limit_satoshis_arg: u64, mut max_minimum_depth_arg: u32, mut force_announced_channel_preference_arg: bool, mut their_to_self_delay_arg: u16) -> ChannelHandshakeLimits {
+ ChannelHandshakeLimits { inner: Box::into_raw(Box::new(nativeChannelHandshakeLimits {
+ min_funding_satoshis: min_funding_satoshis_arg,
+ max_htlc_minimum_msat: max_htlc_minimum_msat_arg,
+ min_max_htlc_value_in_flight_msat: min_max_htlc_value_in_flight_msat_arg,
+ max_channel_reserve_satoshis: max_channel_reserve_satoshis_arg,
+ min_max_accepted_htlcs: min_max_accepted_htlcs_arg,
+ min_dust_limit_satoshis: min_dust_limit_satoshis_arg,
+ max_dust_limit_satoshis: max_dust_limit_satoshis_arg,
+ max_minimum_depth: max_minimum_depth_arg,
+ force_announced_channel_preference: force_announced_channel_preference_arg,
+ their_to_self_delay: their_to_self_delay_arg,
+ })), is_owned: true }
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
+ ChannelHandshakeLimits { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
+}
+
+use lightning::util::config::ChannelConfig as nativeChannelConfigImport;
+type nativeChannelConfig = nativeChannelConfigImport;
+
+/// Options which apply on a per-channel basis and may change at runtime or based on negotiation
+/// with our counterparty.
+#[must_use]
+#[repr(C)]
+pub struct ChannelConfig {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelConfig,
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelConfig {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn ChannelConfig_free(this_ptr: ChannelConfig) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelConfig); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelConfig {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeChannelConfig {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for ChannelConfig {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void
+}
+/// Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
+/// This may be allowed to change at runtime in a later update, however doing so must result in
+/// update messages sent to notify all nodes of our updated relay fee.
+///
+/// Default value: 0.
+#[no_mangle]
+pub extern "C" fn ChannelConfig_get_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
+ (*inner_val)
+}
+/// Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
+/// This may be allowed to change at runtime in a later update, however doing so must result in
+/// update messages sent to notify all nodes of our updated relay fee.
+///
+/// Default value: 0.
+#[no_mangle]
+pub extern "C" fn ChannelConfig_set_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) {
+ unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
+}
+/// Set to announce the channel publicly and notify all nodes that they can route via this
+/// channel.
+///
+/// This should only be set to true for nodes which expect to be online reliably.
+///
+/// As the node which funds a channel picks this value this will only apply for new outbound
+/// channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
+///
+/// This cannot be changed after the initial channel handshake.
+///
+/// Default value: false.
+#[no_mangle]
+pub extern "C" fn ChannelConfig_get_announced_channel(this_ptr: &ChannelConfig) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announced_channel;
+ (*inner_val)
+}
+/// Set to announce the channel publicly and notify all nodes that they can route via this
+/// channel.
+///
+/// This should only be set to true for nodes which expect to be online reliably.
+///
+/// As the node which funds a channel picks this value this will only apply for new outbound
+/// channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
+///
+/// This cannot be changed after the initial channel handshake.
+///
+/// Default value: false.
+#[no_mangle]
+pub extern "C" fn ChannelConfig_set_announced_channel(this_ptr: &mut ChannelConfig, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.announced_channel = val;
+}
+/// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
+/// supports it, they will then enforce the mutual-close output to us matches what we provided
+/// at intialization, preventing us from closing to an alternate pubkey.
+///
+/// This is set to true by default to provide a slight increase in security, though ultimately
+/// any attacker who is able to take control of a channel can just as easily send the funds via
+/// lightning payments, so we never require that our counterparties support this option.
+///
+/// This cannot be changed after a channel has been initialized.
+///
+/// Default value: true.
+#[no_mangle]
+pub extern "C" fn ChannelConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelConfig) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commit_upfront_shutdown_pubkey;
+ (*inner_val)
+}
+/// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
+/// supports it, they will then enforce the mutual-close output to us matches what we provided
+/// at intialization, preventing us from closing to an alternate pubkey.
+///
+/// This is set to true by default to provide a slight increase in security, though ultimately
+/// any attacker who is able to take control of a channel can just as easily send the funds via
+/// lightning payments, so we never require that our counterparties support this option.
+///
+/// This cannot be changed after a channel has been initialized.
+///
+/// Default value: true.
+#[no_mangle]
+pub extern "C" fn ChannelConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelConfig, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.commit_upfront_shutdown_pubkey = val;
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelConfig_new(mut fee_proportional_millionths_arg: u32, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool) -> ChannelConfig {
+ ChannelConfig { inner: Box::into_raw(Box::new(nativeChannelConfig {
+ fee_proportional_millionths: fee_proportional_millionths_arg,
+ announced_channel: announced_channel_arg,
+ commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
+ })), is_owned: true }
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelConfig_default() -> ChannelConfig {
+ ChannelConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
+}
+#[no_mangle]
+pub extern "C" fn ChannelConfig_write(obj: *const ChannelConfig) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> ChannelConfig {
+ if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+ ChannelConfig { inner: Box::into_raw(Box::new(res)), is_owned: true }
+ } else {
+ ChannelConfig { inner: std::ptr::null_mut(), is_owned: true }
+ }
+}
+
+use lightning::util::config::UserConfig as nativeUserConfigImport;
+type nativeUserConfig = nativeUserConfigImport;
+
+/// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
+///
+/// Default::default() provides sane defaults for most configurations
+/// (but currently with 0 relay fees!)
+#[must_use]
+#[repr(C)]
+pub struct UserConfig {
+ /// Nearly everyhwere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeUserConfig,
+ pub is_owned: bool,
+}
+
+impl Drop for UserConfig {
+ fn drop(&mut self) {
+ if self.is_owned && !self.inner.is_null() {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn UserConfig_free(this_ptr: UserConfig) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUserConfig); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl UserConfig {
+ pub(crate) fn take_ptr(mut self) -> *mut nativeUserConfig {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for UserConfig {
+ fn clone(&self) -> Self {
+ Self {
+ inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
+}
+/// Channel config that we propose to our counterparty.
+#[no_mangle]
+pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::util::config::ChannelHandshakeConfig {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.own_channel_config;
+ crate::util::config::ChannelHandshakeConfig { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Channel config that we propose to our counterparty.
+#[no_mangle]
+pub extern "C" fn UserConfig_set_own_channel_config(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelHandshakeConfig) {
+ unsafe { &mut *this_ptr.inner }.own_channel_config = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+/// Limits applied to our counterparty's proposed channel config settings.
+#[no_mangle]
+pub extern "C" fn UserConfig_get_peer_channel_config_limits(this_ptr: &UserConfig) -> crate::util::config::ChannelHandshakeLimits {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.peer_channel_config_limits;
+ crate::util::config::ChannelHandshakeLimits { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Limits applied to our counterparty's proposed channel config settings.
+#[no_mangle]
+pub extern "C" fn UserConfig_set_peer_channel_config_limits(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelHandshakeLimits) {
+ unsafe { &mut *this_ptr.inner }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+/// Channel config which affects behavior during channel lifetime.
+#[no_mangle]
+pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate::util::config::ChannelConfig {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_options;
+ crate::util::config::ChannelConfig { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Channel config which affects behavior during channel lifetime.
+#[no_mangle]
+pub extern "C" fn UserConfig_set_channel_options(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelConfig) {
+ unsafe { &mut *this_ptr.inner }.channel_options = *unsafe { Box::from_raw(val.take_ptr()) };
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::util::config::ChannelHandshakeLimits, mut channel_options_arg: crate::util::config::ChannelConfig) -> UserConfig {
+ UserConfig { inner: Box::into_raw(Box::new(nativeUserConfig {
+ own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_ptr()) },
+ peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_ptr()) },
+ channel_options: *unsafe { Box::from_raw(channel_options_arg.take_ptr()) },
+ })), is_owned: true }
+}
+#[must_use]
+#[no_mangle]
+pub extern "C" fn UserConfig_default() -> UserConfig {
+ UserConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
+}
--- /dev/null
+//! Error types live here.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+/// Indicates an error on the client's part (usually some variant of attempting to use too-low or
+/// too-high values)
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum APIError {
+ /// Indicates the API was wholly misused (see err for more). Cases where these can be returned
+ /// are documented, but generally indicates some precondition of a function was violated.
+ APIMisuseError {
+ err: crate::c_types::derived::CVec_u8Z,
+ },
+ /// Due to a high feerate, we were unable to complete the request.
+ /// For example, this may be returned if the feerate implies we cannot open a channel at the
+ /// requested value, but opening a larger channel would succeed.
+ FeeRateTooHigh {
+ err: crate::c_types::derived::CVec_u8Z,
+ feerate: u32,
+ },
+ /// A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route,
+ /// too-many-hops, etc).
+ RouteError {
+ err: crate::c_types::Str,
+ },
+ /// We were unable to complete the request as the Channel required to do so is unable to
+ /// complete the request (or was not found). This can take many forms, including disconnected
+ /// peer, channel at capacity, channel shutting down, etc.
+ ChannelUnavailable {
+ err: crate::c_types::derived::CVec_u8Z,
+ },
+ /// An attempt to call add/update_monitor returned an Err (ie you did this!), causing the
+ /// attempted action to fail.
+ MonitorUpdateFailed,
+}
+use lightning::util::errors::APIError as nativeAPIError;
+impl APIError {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeAPIError {
+ match self {
+ APIError::APIMisuseError {ref err, } => {
+ let mut err_nonref = (*err).clone();
+ nativeAPIError::APIMisuseError {
+ err: String::from_utf8(err_nonref.into_rust()).unwrap(),
+ }
+ },
+ APIError::FeeRateTooHigh {ref err, ref feerate, } => {
+ let mut err_nonref = (*err).clone();
+ let mut feerate_nonref = (*feerate).clone();
+ nativeAPIError::FeeRateTooHigh {
+ err: String::from_utf8(err_nonref.into_rust()).unwrap(),
+ feerate: feerate_nonref,
+ }
+ },
+ APIError::RouteError {ref err, } => {
+ let mut err_nonref = (*err).clone();
+ nativeAPIError::RouteError {
+ err: err_nonref.into(),
+ }
+ },
+ APIError::ChannelUnavailable {ref err, } => {
+ let mut err_nonref = (*err).clone();
+ nativeAPIError::ChannelUnavailable {
+ err: String::from_utf8(err_nonref.into_rust()).unwrap(),
+ }
+ },
+ APIError::MonitorUpdateFailed => nativeAPIError::MonitorUpdateFailed,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeAPIError {
+ match self {
+ APIError::APIMisuseError {mut err, } => {
+ nativeAPIError::APIMisuseError {
+ err: String::from_utf8(err.into_rust()).unwrap(),
+ }
+ },
+ APIError::FeeRateTooHigh {mut err, mut feerate, } => {
+ nativeAPIError::FeeRateTooHigh {
+ err: String::from_utf8(err.into_rust()).unwrap(),
+ feerate: feerate,
+ }
+ },
+ APIError::RouteError {mut err, } => {
+ nativeAPIError::RouteError {
+ err: err.into(),
+ }
+ },
+ APIError::ChannelUnavailable {mut err, } => {
+ nativeAPIError::ChannelUnavailable {
+ err: String::from_utf8(err.into_rust()).unwrap(),
+ }
+ },
+ APIError::MonitorUpdateFailed => nativeAPIError::MonitorUpdateFailed,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeAPIError) -> Self {
+ match native {
+ nativeAPIError::APIMisuseError {ref err, } => {
+ let mut err_nonref = (*err).clone();
+ APIError::APIMisuseError {
+ err: err_nonref.into_bytes().into(),
+ }
+ },
+ nativeAPIError::FeeRateTooHigh {ref err, ref feerate, } => {
+ let mut err_nonref = (*err).clone();
+ let mut feerate_nonref = (*feerate).clone();
+ APIError::FeeRateTooHigh {
+ err: err_nonref.into_bytes().into(),
+ feerate: feerate_nonref,
+ }
+ },
+ nativeAPIError::RouteError {ref err, } => {
+ let mut err_nonref = (*err).clone();
+ APIError::RouteError {
+ err: err_nonref.into(),
+ }
+ },
+ nativeAPIError::ChannelUnavailable {ref err, } => {
+ let mut err_nonref = (*err).clone();
+ APIError::ChannelUnavailable {
+ err: err_nonref.into_bytes().into(),
+ }
+ },
+ nativeAPIError::MonitorUpdateFailed => APIError::MonitorUpdateFailed,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeAPIError) -> Self {
+ match native {
+ nativeAPIError::APIMisuseError {mut err, } => {
+ APIError::APIMisuseError {
+ err: err.into_bytes().into(),
+ }
+ },
+ nativeAPIError::FeeRateTooHigh {mut err, mut feerate, } => {
+ APIError::FeeRateTooHigh {
+ err: err.into_bytes().into(),
+ feerate: feerate,
+ }
+ },
+ nativeAPIError::RouteError {mut err, } => {
+ APIError::RouteError {
+ err: err.into(),
+ }
+ },
+ nativeAPIError::ChannelUnavailable {mut err, } => {
+ APIError::ChannelUnavailable {
+ err: err.into_bytes().into(),
+ }
+ },
+ nativeAPIError::MonitorUpdateFailed => APIError::MonitorUpdateFailed,
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn APIError_free(this_ptr: APIError) { }
--- /dev/null
+//! Events are returned from various bits in the library which indicate some action must be taken
+//! by the client.
+//!
+//! Because we don't have a built-in runtime, it's up to the client to call events at a time in the
+//! future, as well as generate and broadcast funding transactions handle payment preimages and a
+//! few other things.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+/// An Event which you should probably take some action in response to.
+///
+/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
+/// them directly as they don't round-trip exactly (for example FundingGenerationReady is never
+/// written as it makes no sense to respond to it after reconnecting to peers).
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum Event {
+ /// Used to indicate that the client should generate a funding transaction with the given
+ /// parameters and then call ChannelManager::funding_transaction_generated.
+ /// Generated in ChannelManager message handling.
+ /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
+ /// counterparty can steal your funds!
+ FundingGenerationReady {
+ temporary_channel_id: crate::c_types::ThirtyTwoBytes,
+ channel_value_satoshis: u64,
+ output_script: crate::c_types::derived::CVec_u8Z,
+ user_channel_id: u64,
+ },
+ /// Used to indicate that the client may now broadcast the funding transaction it created for a
+ /// channel. Broadcasting such a transaction prior to this event may lead to our counterparty
+ /// trivially stealing all funds in the funding transaction!
+ FundingBroadcastSafe {
+ funding_txo: crate::chain::transaction::OutPoint,
+ user_channel_id: u64,
+ },
+ /// Indicates we've received money! Just gotta dig out that payment preimage and feed it to
+ /// ChannelManager::claim_funds to get it....
+ /// Note that if the preimage is not known or the amount paid is incorrect, you should call
+ /// ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
+ /// network congestion.
+ /// The amount paid should be considered 'incorrect' when it is less than or more than twice
+ /// the amount expected.
+ /// If you fail to call either ChannelManager::claim_funds or
+ /// ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
+ /// automatically failed.
+ PaymentReceived {
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ payment_secret: crate::c_types::ThirtyTwoBytes,
+ amt: u64,
+ },
+ /// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
+ /// and we got back the payment preimage for it).
+ /// Note that duplicative PaymentSent Events may be generated - it is your responsibility to
+ /// deduplicate them by payment_preimage (which MUST be unique)!
+ PaymentSent {
+ payment_preimage: crate::c_types::ThirtyTwoBytes,
+ },
+ /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
+ /// something. You may wish to retry with a different route.
+ /// Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
+ /// deduplicate them by payment_hash (which MUST be unique)!
+ PaymentFailed {
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ rejected_by_dest: bool,
+ },
+ /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
+ /// time in the future.
+ PendingHTLCsForwardable {
+ time_forwardable: u64,
+ },
+ /// Used to indicate that an output was generated on-chain which you should know how to spend.
+ /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
+ /// counterparty spending them due to some kind of timeout. Thus, you need to store them
+ /// somewhere and spend them when you create on-chain transactions.
+ SpendableOutputs {
+ outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ,
+ },
+}
+use lightning::util::events::Event as nativeEvent;
+impl Event {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeEvent {
+ match self {
+ Event::FundingGenerationReady {ref temporary_channel_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
+ let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
+ let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
+ let mut output_script_nonref = (*output_script).clone();
+ let mut user_channel_id_nonref = (*user_channel_id).clone();
+ nativeEvent::FundingGenerationReady {
+ temporary_channel_id: temporary_channel_id_nonref.data,
+ channel_value_satoshis: channel_value_satoshis_nonref,
+ output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()),
+ user_channel_id: user_channel_id_nonref,
+ }
+ },
+ Event::FundingBroadcastSafe {ref funding_txo, ref user_channel_id, } => {
+ let mut funding_txo_nonref = (*funding_txo).clone();
+ let mut user_channel_id_nonref = (*user_channel_id).clone();
+ nativeEvent::FundingBroadcastSafe {
+ funding_txo: *unsafe { Box::from_raw(funding_txo_nonref.take_ptr()) },
+ user_channel_id: user_channel_id_nonref,
+ }
+ },
+ Event::PaymentReceived {ref payment_hash, ref payment_secret, ref amt, } => {
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut payment_secret_nonref = (*payment_secret).clone();
+ let mut local_payment_secret_nonref = if payment_secret_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret_nonref.data) }) };
+ let mut amt_nonref = (*amt).clone();
+ nativeEvent::PaymentReceived {
+ payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash_nonref.data),
+ payment_secret: local_payment_secret_nonref,
+ amt: amt_nonref,
+ }
+ },
+ Event::PaymentSent {ref payment_preimage, } => {
+ let mut payment_preimage_nonref = (*payment_preimage).clone();
+ nativeEvent::PaymentSent {
+ payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_nonref.data),
+ }
+ },
+ Event::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
+ nativeEvent::PaymentFailed {
+ payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash_nonref.data),
+ rejected_by_dest: rejected_by_dest_nonref,
+ }
+ },
+ Event::PendingHTLCsForwardable {ref time_forwardable, } => {
+ let mut time_forwardable_nonref = (*time_forwardable).clone();
+ nativeEvent::PendingHTLCsForwardable {
+ time_forwardable: std::time::Duration::from_secs(time_forwardable_nonref),
+ }
+ },
+ Event::SpendableOutputs {ref outputs, } => {
+ let mut outputs_nonref = (*outputs).clone();
+ let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); };
+ nativeEvent::SpendableOutputs {
+ outputs: local_outputs_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeEvent {
+ match self {
+ Event::FundingGenerationReady {mut temporary_channel_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
+ nativeEvent::FundingGenerationReady {
+ temporary_channel_id: temporary_channel_id.data,
+ channel_value_satoshis: channel_value_satoshis,
+ output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()),
+ user_channel_id: user_channel_id,
+ }
+ },
+ Event::FundingBroadcastSafe {mut funding_txo, mut user_channel_id, } => {
+ nativeEvent::FundingBroadcastSafe {
+ funding_txo: *unsafe { Box::from_raw(funding_txo.take_ptr()) },
+ user_channel_id: user_channel_id,
+ }
+ },
+ Event::PaymentReceived {mut payment_hash, mut payment_secret, mut amt, } => {
+ let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
+ nativeEvent::PaymentReceived {
+ payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash.data),
+ payment_secret: local_payment_secret,
+ amt: amt,
+ }
+ },
+ Event::PaymentSent {mut payment_preimage, } => {
+ nativeEvent::PaymentSent {
+ payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data),
+ }
+ },
+ Event::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
+ nativeEvent::PaymentFailed {
+ payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash.data),
+ rejected_by_dest: rejected_by_dest,
+ }
+ },
+ Event::PendingHTLCsForwardable {mut time_forwardable, } => {
+ nativeEvent::PendingHTLCsForwardable {
+ time_forwardable: std::time::Duration::from_secs(time_forwardable),
+ }
+ },
+ Event::SpendableOutputs {mut outputs, } => {
+ let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); };
+ nativeEvent::SpendableOutputs {
+ outputs: local_outputs,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeEvent) -> Self {
+ match native {
+ nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
+ let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
+ let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
+ let mut output_script_nonref = (*output_script).clone();
+ let mut user_channel_id_nonref = (*user_channel_id).clone();
+ Event::FundingGenerationReady {
+ temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
+ channel_value_satoshis: channel_value_satoshis_nonref,
+ output_script: output_script_nonref.into_bytes().into(),
+ user_channel_id: user_channel_id_nonref,
+ }
+ },
+ nativeEvent::FundingBroadcastSafe {ref funding_txo, ref user_channel_id, } => {
+ let mut funding_txo_nonref = (*funding_txo).clone();
+ let mut user_channel_id_nonref = (*user_channel_id).clone();
+ Event::FundingBroadcastSafe {
+ funding_txo: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo_nonref)), is_owned: true },
+ user_channel_id: user_channel_id_nonref,
+ }
+ },
+ nativeEvent::PaymentReceived {ref payment_hash, ref payment_secret, ref amt, } => {
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut payment_secret_nonref = (*payment_secret).clone();
+ let mut local_payment_secret_nonref = if payment_secret_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_secret_nonref.unwrap()).0 } } };
+ let mut amt_nonref = (*amt).clone();
+ Event::PaymentReceived {
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
+ payment_secret: local_payment_secret_nonref,
+ amt: amt_nonref,
+ }
+ },
+ nativeEvent::PaymentSent {ref payment_preimage, } => {
+ let mut payment_preimage_nonref = (*payment_preimage).clone();
+ Event::PaymentSent {
+ payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
+ }
+ },
+ nativeEvent::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
+ Event::PaymentFailed {
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
+ rejected_by_dest: rejected_by_dest_nonref,
+ }
+ },
+ nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
+ let mut time_forwardable_nonref = (*time_forwardable).clone();
+ Event::PendingHTLCsForwardable {
+ time_forwardable: time_forwardable_nonref.as_secs(),
+ }
+ },
+ nativeEvent::SpendableOutputs {ref outputs, } => {
+ let mut outputs_nonref = (*outputs).clone();
+ let mut local_outputs_nonref = Vec::new(); for item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
+ Event::SpendableOutputs {
+ outputs: local_outputs_nonref.into(),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeEvent) -> Self {
+ match native {
+ nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
+ Event::FundingGenerationReady {
+ temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
+ channel_value_satoshis: channel_value_satoshis,
+ output_script: output_script.into_bytes().into(),
+ user_channel_id: user_channel_id,
+ }
+ },
+ nativeEvent::FundingBroadcastSafe {mut funding_txo, mut user_channel_id, } => {
+ Event::FundingBroadcastSafe {
+ funding_txo: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true },
+ user_channel_id: user_channel_id,
+ }
+ },
+ nativeEvent::PaymentReceived {mut payment_hash, mut payment_secret, mut amt, } => {
+ let mut local_payment_secret = if payment_secret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_secret.unwrap()).0 } } };
+ Event::PaymentReceived {
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
+ payment_secret: local_payment_secret,
+ amt: amt,
+ }
+ },
+ nativeEvent::PaymentSent {mut payment_preimage, } => {
+ Event::PaymentSent {
+ payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
+ }
+ },
+ nativeEvent::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
+ Event::PaymentFailed {
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
+ rejected_by_dest: rejected_by_dest,
+ }
+ },
+ nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
+ Event::PendingHTLCsForwardable {
+ time_forwardable: time_forwardable.as_secs(),
+ }
+ },
+ nativeEvent::SpendableOutputs {mut outputs, } => {
+ let mut local_outputs = Vec::new(); for item in outputs.drain(..) { local_outputs.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
+ Event::SpendableOutputs {
+ outputs: local_outputs.into(),
+ }
+ },
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn Event_free(this_ptr: Event) { }
+/// An event generated by ChannelManager which indicates a message should be sent to a peer (or
+/// broadcast to most peers).
+/// These events are handled by PeerManager::process_events if you are using a PeerManager.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum MessageSendEvent {
+ /// Used to indicate that we've accepted a channel open and should send the accept_channel
+ /// message provided to the given peer.
+ SendAcceptChannel {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::AcceptChannel,
+ },
+ /// Used to indicate that we've initiated a channel open and should send the open_channel
+ /// message provided to the given peer.
+ SendOpenChannel {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::OpenChannel,
+ },
+ /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
+ SendFundingCreated {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::FundingCreated,
+ },
+ /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
+ SendFundingSigned {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::FundingSigned,
+ },
+ /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
+ SendFundingLocked {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::FundingLocked,
+ },
+ /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
+ SendAnnouncementSignatures {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::AnnouncementSignatures,
+ },
+ /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
+ /// message should be sent to the peer with the given node_id.
+ UpdateHTLCs {
+ node_id: crate::c_types::PublicKey,
+ updates: crate::ln::msgs::CommitmentUpdate,
+ },
+ /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
+ SendRevokeAndACK {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::RevokeAndACK,
+ },
+ /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
+ SendClosingSigned {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::ClosingSigned,
+ },
+ /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
+ SendShutdown {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::Shutdown,
+ },
+ /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
+ SendChannelReestablish {
+ node_id: crate::c_types::PublicKey,
+ msg: crate::ln::msgs::ChannelReestablish,
+ },
+ /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
+ /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
+ ///
+ /// Note that after doing so, you very likely (unless you did so very recently) want to call
+ /// ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
+ /// This ensures that any nodes which see our channel_announcement also have a relevant
+ /// node_announcement, including relevant feature flags which may be important for routing
+ /// through or to us.
+ BroadcastChannelAnnouncement {
+ msg: crate::ln::msgs::ChannelAnnouncement,
+ update_msg: crate::ln::msgs::ChannelUpdate,
+ },
+ /// Used to indicate that a node_announcement should be broadcast to all peers.
+ BroadcastNodeAnnouncement {
+ msg: crate::ln::msgs::NodeAnnouncement,
+ },
+ /// Used to indicate that a channel_update should be broadcast to all peers.
+ BroadcastChannelUpdate {
+ msg: crate::ln::msgs::ChannelUpdate,
+ },
+ /// Broadcast an error downstream to be handled
+ HandleError {
+ node_id: crate::c_types::PublicKey,
+ action: crate::ln::msgs::ErrorAction,
+ },
+ /// When a payment fails we may receive updates back from the hop where it failed. In such
+ /// cases this event is generated so that we can inform the network graph of this information.
+ PaymentFailureNetworkUpdate {
+ update: crate::ln::msgs::HTLCFailChannelUpdate,
+ },
+}
+use lightning::util::events::MessageSendEvent as nativeMessageSendEvent;
+impl MessageSendEvent {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeMessageSendEvent {
+ match self {
+ MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendAcceptChannel {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendOpenChannel {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendFundingCreated {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendFundingSigned {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendFundingLocked {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendFundingLocked {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendAnnouncementSignatures {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut updates_nonref = (*updates).clone();
+ nativeMessageSendEvent::UpdateHTLCs {
+ node_id: node_id_nonref.into_rust(),
+ updates: *unsafe { Box::from_raw(updates_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendRevokeAndACK {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendClosingSigned {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendShutdown {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendChannelReestablish {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ let mut update_msg_nonref = (*update_msg).clone();
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::BroadcastNodeAnnouncement {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::BroadcastChannelUpdate {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
+ }
+ },
+ MessageSendEvent::HandleError {ref node_id, ref action, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut action_nonref = (*action).clone();
+ nativeMessageSendEvent::HandleError {
+ node_id: node_id_nonref.into_rust(),
+ action: action_nonref.into_native(),
+ }
+ },
+ MessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
+ let mut update_nonref = (*update).clone();
+ nativeMessageSendEvent::PaymentFailureNetworkUpdate {
+ update: update_nonref.into_native(),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeMessageSendEvent {
+ match self {
+ MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendAcceptChannel {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendOpenChannel {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendFundingCreated {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendFundingSigned {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendFundingLocked {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendAnnouncementSignatures {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
+ nativeMessageSendEvent::UpdateHTLCs {
+ node_id: node_id.into_rust(),
+ updates: *unsafe { Box::from_raw(updates.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendRevokeAndACK {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendClosingSigned {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendShutdown {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendChannelReestablish {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ update_msg: *unsafe { Box::from_raw(update_msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
+ nativeMessageSendEvent::BroadcastNodeAnnouncement {
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
+ nativeMessageSendEvent::BroadcastChannelUpdate {
+ msg: *unsafe { Box::from_raw(msg.take_ptr()) },
+ }
+ },
+ MessageSendEvent::HandleError {mut node_id, mut action, } => {
+ nativeMessageSendEvent::HandleError {
+ node_id: node_id.into_rust(),
+ action: action.into_native(),
+ }
+ },
+ MessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
+ nativeMessageSendEvent::PaymentFailureNetworkUpdate {
+ update: update.into_native(),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self {
+ match native {
+ nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendAcceptChannel {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendOpenChannel {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendFundingCreated {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendFundingSigned {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendFundingLocked {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendFundingLocked {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendAnnouncementSignatures {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut updates_nonref = (*updates).clone();
+ MessageSendEvent::UpdateHTLCs {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ updates: crate::ln::msgs::CommitmentUpdate { inner: Box::into_raw(Box::new(updates_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendRevokeAndACK {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendClosingSigned {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendShutdown {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendChannelReestablish {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ let mut update_msg_nonref = (*update_msg).clone();
+ MessageSendEvent::BroadcastChannelAnnouncement {
+ msg: crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ update_msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::BroadcastNodeAnnouncement {
+ msg: crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::BroadcastChannelUpdate {
+ msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::HandleError {ref node_id, ref action, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut action_nonref = (*action).clone();
+ MessageSendEvent::HandleError {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ action: crate::ln::msgs::ErrorAction::native_into(action_nonref),
+ }
+ },
+ nativeMessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
+ let mut update_nonref = (*update).clone();
+ MessageSendEvent::PaymentFailureNetworkUpdate {
+ update: crate::ln::msgs::HTLCFailChannelUpdate::native_into(update_nonref),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self {
+ match native {
+ nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
+ MessageSendEvent::SendAcceptChannel {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
+ MessageSendEvent::SendOpenChannel {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
+ MessageSendEvent::SendFundingCreated {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
+ MessageSendEvent::SendFundingSigned {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => {
+ MessageSendEvent::SendFundingLocked {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
+ MessageSendEvent::SendAnnouncementSignatures {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
+ MessageSendEvent::UpdateHTLCs {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ updates: crate::ln::msgs::CommitmentUpdate { inner: Box::into_raw(Box::new(updates)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
+ MessageSendEvent::SendRevokeAndACK {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
+ MessageSendEvent::SendClosingSigned {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
+ MessageSendEvent::SendShutdown {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
+ MessageSendEvent::SendChannelReestablish {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
+ MessageSendEvent::BroadcastChannelAnnouncement {
+ msg: crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ update_msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
+ MessageSendEvent::BroadcastNodeAnnouncement {
+ msg: crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
+ MessageSendEvent::BroadcastChannelUpdate {
+ msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
+ }
+ },
+ nativeMessageSendEvent::HandleError {mut node_id, mut action, } => {
+ MessageSendEvent::HandleError {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ action: crate::ln::msgs::ErrorAction::native_into(action),
+ }
+ },
+ nativeMessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
+ MessageSendEvent::PaymentFailureNetworkUpdate {
+ update: crate::ln::msgs::HTLCFailChannelUpdate::native_into(update),
+ }
+ },
+ }
+ }
+}
+#[no_mangle]
+pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { }
+/// A trait indicating an object may generate message send events
+#[repr(C)]
+pub struct MessageSendEventsProvider {
+ pub this_arg: *mut c_void,
+ /// Gets the list of pending events which were generated by previous actions, clearing the list
+ /// in the process.
+ #[must_use]
+ pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+
+use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider;
+impl rustMessageSendEventsProvider for MessageSendEventsProvider {
+ fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
+ let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg);
+ let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
+ local_ret
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for MessageSendEventsProvider {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { }
+impl Drop for MessageSendEventsProvider {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// A trait indicating an object may generate events
+#[repr(C)]
+pub struct EventsProvider {
+ pub this_arg: *mut c_void,
+ /// Gets the list of pending events which were generated by previous actions, clearing the list
+ /// in the process.
+ #[must_use]
+ pub get_and_clear_pending_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ,
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+
+use lightning::util::events::EventsProvider as rustEventsProvider;
+impl rustEventsProvider for EventsProvider {
+ fn get_and_clear_pending_events(&self) -> Vec<lightning::util::events::Event> {
+ let mut ret = (self.get_and_clear_pending_events)(self.this_arg);
+ let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
+ local_ret
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for EventsProvider {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
+impl Drop for EventsProvider {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
--- /dev/null
+//! Log traits live here, which are called throughout the library to provide useful information for
+//! debugging purposes.
+//!
+//! There is currently 2 ways to filter log messages. First one, by using compilation features, e.g \"max_level_off\".
+//! The second one, client-side by implementing check against Record Level field.
+//! Each module may have its own Logger or share one.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+/// An enum representing the available verbosity levels of the logger.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum Level {
+ ///Designates logger being silent
+ Off,
+ /// Designates very serious errors
+ Error,
+ /// Designates hazardous situations
+ Warn,
+ /// Designates useful information
+ Info,
+ /// Designates lower priority information
+ Debug,
+ /// Designates very low priority, often extremely verbose, information
+ Trace,
+}
+use lightning::util::logger::Level as nativeLevel;
+impl Level {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeLevel {
+ match self {
+ Level::Off => nativeLevel::Off,
+ Level::Error => nativeLevel::Error,
+ Level::Warn => nativeLevel::Warn,
+ Level::Info => nativeLevel::Info,
+ Level::Debug => nativeLevel::Debug,
+ Level::Trace => nativeLevel::Trace,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeLevel {
+ match self {
+ Level::Off => nativeLevel::Off,
+ Level::Error => nativeLevel::Error,
+ Level::Warn => nativeLevel::Warn,
+ Level::Info => nativeLevel::Info,
+ Level::Debug => nativeLevel::Debug,
+ Level::Trace => nativeLevel::Trace,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeLevel) -> Self {
+ match native {
+ nativeLevel::Off => Level::Off,
+ nativeLevel::Error => Level::Error,
+ nativeLevel::Warn => Level::Warn,
+ nativeLevel::Info => Level::Info,
+ nativeLevel::Debug => Level::Debug,
+ nativeLevel::Trace => Level::Trace,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeLevel) -> Self {
+ match native {
+ nativeLevel::Off => Level::Off,
+ nativeLevel::Error => Level::Error,
+ nativeLevel::Warn => Level::Warn,
+ nativeLevel::Info => Level::Info,
+ nativeLevel::Debug => Level::Debug,
+ nativeLevel::Trace => Level::Trace,
+ }
+ }
+}
+/// Returns the most verbose logging level.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Level_max() -> crate::util::logger::Level {
+ let mut ret = lightning::util::logger::Level::max();
+ crate::util::logger::Level::native_into(ret)
+}
+
+/// A trait encapsulating the operations required of a logger
+#[repr(C)]
+pub struct Logger {
+ pub this_arg: *mut c_void,
+ /// Logs the `Record`
+ pub log: extern "C" fn (this_arg: *const c_void, record: *const std::os::raw::c_char),
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Sync for Logger {}
+unsafe impl Send for Logger {}
+
+use lightning::util::logger::Logger as rustLogger;
+impl rustLogger for Logger {
+ fn log(&self, record: &lightning::util::logger::Record) {
+ let mut local_record = std::ffi::CString::new(format!("{}", record.args)).unwrap();
+ (self.log)(self.this_arg, local_record.as_ptr())
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for Logger {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn Logger_free(this_ptr: Logger) { }
+impl Drop for Logger {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
--- /dev/null
+//! Some utility modules live here. See individual sub-modules for more info.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+pub mod events;
+pub mod errors;
+pub mod ser;
+pub mod logger;
+pub mod config;
--- /dev/null
+//! A very simple serialization framework which is used to serialize/deserialize messages as well
+//! as ChannelsManagers and ChannelMonitors.
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+