+typedef struct LDKC2Tuple_u64u64Z {
+ uint64_t a;
+ uint64_t b;
+} LDKC2Tuple_u64u64Z;
+
+/**
+ * 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
+ * holder 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 revocation_pubkey provided here (which is used in the witness
+ * script generation), you must pass the counterparty revocation_basepoint (which appears in the
+ * call to ChannelKeys::ready_channel) 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_StaticOutputCounterpartyPayment,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKSpendableOutputDescriptor_Sentinel,
+} LDKSpendableOutputDescriptor_Tag;
+
+typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body {
+ struct LDKOutPoint outpoint;
+ struct LDKTxOut output;
+} LDKSpendableOutputDescriptor_LDKStaticOutput_Body;
+
+typedef struct LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body {
+ struct LDKOutPoint outpoint;
+ struct LDKPublicKey per_commitment_point;
+ uint16_t to_self_delay;
+ struct LDKTxOut output;
+ struct LDKC2Tuple_u64u64Z key_derivation_params;
+ struct LDKPublicKey revocation_pubkey;
+} LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body;
+
+typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body {
+ struct LDKOutPoint outpoint;
+ struct LDKTxOut output;
+ struct LDKC2Tuple_u64u64Z key_derivation_params;
+} LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body;
+
+typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor {
+ LDKSpendableOutputDescriptor_Tag tag;
+ union {
+ LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output;
+ LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body dynamic_output_p2wsh;
+ LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body static_output_counterparty_payment;
+ };
+} LDKSpendableOutputDescriptor;
+
+typedef struct LDKCVec_SpendableOutputDescriptorZ {
+ struct LDKSpendableOutputDescriptor *data;
+ uintptr_t datalen;
+} 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 {
+ struct LDKThirtyTwoBytes temporary_channel_id;
+ uint64_t channel_value_satoshis;
+ struct LDKCVec_u8Z output_script;
+ uint64_t user_channel_id;
+} LDKEvent_LDKFundingGenerationReady_Body;
+
+typedef struct LDKEvent_LDKFundingBroadcastSafe_Body {
+ struct LDKOutPoint funding_txo;
+ uint64_t user_channel_id;
+} LDKEvent_LDKFundingBroadcastSafe_Body;
+
+typedef struct LDKEvent_LDKPaymentReceived_Body {
+ struct LDKThirtyTwoBytes payment_hash;
+ struct LDKThirtyTwoBytes payment_secret;
+ uint64_t amt;
+} LDKEvent_LDKPaymentReceived_Body;
+
+typedef struct LDKEvent_LDKPaymentSent_Body {
+ struct LDKThirtyTwoBytes payment_preimage;
+} LDKEvent_LDKPaymentSent_Body;
+
+typedef struct LDKEvent_LDKPaymentFailed_Body {
+ struct 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 {
+ struct LDKCVec_SpendableOutputDescriptorZ outputs;
+} LDKEvent_LDKSpendableOutputs_Body;
+
+typedef struct MUST_USE_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;
+
+typedef struct LDKCVec_EventZ {
+ struct LDKEvent *data;
+ uintptr_t datalen;
+} LDKCVec_EventZ;
+
+typedef union LDKCResult_OutPointDecodeErrorZPtr {
+ struct LDKOutPoint *result;
+ struct LDKDecodeError *err;
+} LDKCResult_OutPointDecodeErrorZPtr;
+
+typedef struct LDKCResult_OutPointDecodeErrorZ {
+ union LDKCResult_OutPointDecodeErrorZPtr contents;
+ bool result_ok;
+} LDKCResult_OutPointDecodeErrorZ;
+
+
+
+/**
+ * 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 everywhere, 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;
+
+typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr {
+ struct LDKChannelMonitorUpdate *result;
+ struct LDKDecodeError *err;
+} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr;
+
+typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ {
+ union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents;
+ bool result_ok;
+} LDKCResult_ChannelMonitorUpdateDecodeErrorZ;
+
+
+
+/**
+ * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
+ * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
+ * preimage claim backward will lead to loss of funds.
+ *
+ * [`chain::Watch`]: ../trait.Watch.html
+ */
+typedef struct MUST_USE_STRUCT LDKHTLCUpdate {
+ /**
+ * Nearly everywhere, 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;
+
+typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr {
+ struct LDKHTLCUpdate *result;
+ struct LDKDecodeError *err;
+} LDKCResult_HTLCUpdateDecodeErrorZPtr;
+
+typedef struct LDKCResult_HTLCUpdateDecodeErrorZ {
+ union LDKCResult_HTLCUpdateDecodeErrorZPtr contents;
+ bool result_ok;
+} LDKCResult_HTLCUpdateDecodeErrorZ;
+
+
+
+/**
+ * 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 developer-readable error message.
+ */
+typedef struct MUST_USE_STRUCT LDKMonitorUpdateError {
+ /**
+ * Nearly everywhere, 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 LDKCResult_NoneMonitorUpdateErrorZPtr {
+ /**
+ * Note that this value is always NULL, as there are no contents in the OK variant
+ */
+ void *result;
+ struct LDKMonitorUpdateError *err;
+} LDKCResult_NoneMonitorUpdateErrorZPtr;
+
+typedef struct LDKCResult_NoneMonitorUpdateErrorZ {
+ union LDKCResult_NoneMonitorUpdateErrorZPtr contents;
+ bool result_ok;
+} LDKCResult_NoneMonitorUpdateErrorZ;
+
+typedef struct LDKC2Tuple_OutPointScriptZ {
+ struct LDKOutPoint a;
+ struct LDKCVec_u8Z b;
+} LDKC2Tuple_OutPointScriptZ;
+
+typedef struct LDKCVec_TransactionZ {
+ struct LDKTransaction *data;
+ uintptr_t datalen;
+} LDKCVec_TransactionZ;
+
+typedef struct LDKC2Tuple_u32TxOutZ {
+ uint32_t a;
+ struct LDKTxOut b;
+} LDKC2Tuple_u32TxOutZ;
+
+typedef struct LDKCVec_C2Tuple_u32TxOutZZ {
+ struct LDKC2Tuple_u32TxOutZ *data;
+ uintptr_t datalen;
+} LDKCVec_C2Tuple_u32TxOutZZ;
+
+typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ {
+ struct LDKThirtyTwoBytes a;
+ struct LDKCVec_C2Tuple_u32TxOutZZ b;
+} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ;
+
+typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ {
+ struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data;
+ uintptr_t datalen;
+} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ;
+
+typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ {
+ struct LDKSignature a;
+ struct LDKCVec_SignatureZ b;
+} LDKC2Tuple_SignatureCVec_SignatureZZ;
+
+typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
+ struct LDKC2Tuple_SignatureCVec_SignatureZZ *result;
+ /**
+ * Note that this value is always NULL, as there are no contents in the Err variant
+ */
+ void *err;
+} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr;
+
+typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+ union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents;
+ bool result_ok;
+} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ;
+
+typedef union LDKCResult_SignatureNoneZPtr {
+ struct LDKSignature *result;
+ /**
+ * Note that this value is always NULL, as there are no contents in the Err variant
+ */
+ void *err;
+} LDKCResult_SignatureNoneZPtr;
+
+typedef struct LDKCResult_SignatureNoneZ {
+ union LDKCResult_SignatureNoneZPtr contents;
+ bool result_ok;
+} LDKCResult_SignatureNoneZ;
+
+
+
+/**
+ * The unsigned part of a channel_announcement
+ */
+typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
+ /**
+ * Nearly everywhere, 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.