From: Matt Corallo Date: Thu, 15 Apr 2021 17:20:09 +0000 (-0400) Subject: Update auto-generated bindings with new module structure X-Git-Tag: v0.0.98~14^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=d9866e870bbe080412dc70b1421e28a756e4407e;p=ldk-c-bindings Update auto-generated bindings with new module structure --- diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 608dfd5..c23de7e 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -289,6 +289,136 @@ typedef struct LDKTxOut { uint64_t value; } LDKTxOut; + + +/** + * 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 { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeChannelConfig *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelConfig; + + + +/** + * An error in decoding a message or struct. + */ +typedef struct MUST_USE_STRUCT LDKDecodeError { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeDecodeError *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKDecodeError; + +/** + * The contents of CResult_ChannelConfigDecodeErrorZ + */ +typedef union LDKCResult_ChannelConfigDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelConfig *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelConfigDecodeErrorZPtr; + +/** + * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelConfigDecodeErrorZ { + /** + * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ChannelConfigDecodeErrorZPtr contents; + /** + * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ChannelConfigDecodeErrorZ; + + + +/** + * 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 { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeOutPoint *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOutPoint; + +/** + * The contents of CResult_OutPointDecodeErrorZ + */ +typedef union LDKCResult_OutPointDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOutPoint *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_OutPointDecodeErrorZPtr; + +/** + * A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OutPointDecodeErrorZ { + /** + * The contents of this CResult_OutPointDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OutPointDecodeErrorZPtr contents; + /** + * Whether this CResult_OutPointDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OutPointDecodeErrorZ; + /** * Represents a valid secp256k1 secret key serialized as a 32 byte array. */ @@ -405,26 +535,6 @@ typedef struct MUST_USE_STRUCT LDKTxCreationKeys { bool is_owned; } LDKTxCreationKeys; - - -/** - * An error in decoding a message or struct. - */ -typedef struct MUST_USE_STRUCT LDKDecodeError { - /** - * A pointer to the opaque Rust object. - * 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. - */ - LDKnativeDecodeError *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKDecodeError; - /** * The contents of CResult_TxCreationKeysDecodeErrorZ */ @@ -443,7 +553,7 @@ typedef union LDKCResult_TxCreationKeysDecodeErrorZPtr { /** * A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::TxCreationKeys on success and a crate::ln::msgs::DecodeError on failure. + * containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_TxCreationKeysDecodeErrorZ { @@ -496,7 +606,7 @@ typedef union LDKCResult_ChannelPublicKeysDecodeErrorZPtr { /** * A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::ChannelPublicKeys on success and a crate::ln::msgs::DecodeError on failure. + * containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_ChannelPublicKeysDecodeErrorZ { @@ -529,7 +639,7 @@ typedef union LDKCResult_TxCreationKeysErrorZPtr { /** * A CResult_TxCreationKeysErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::TxCreationKeys on success and a crate::c_types::Secp256k1Error on failure. + * containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::c_types::Secp256k1Error on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_TxCreationKeysErrorZ { @@ -609,7 +719,7 @@ typedef union LDKCResult_HTLCOutputInCommitmentDecodeErrorZPtr { /** * A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::HTLCOutputInCommitment on success and a crate::ln::msgs::DecodeError on failure. + * containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ { @@ -662,7 +772,7 @@ typedef union LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr /** * A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::ln::msgs::DecodeError on failure. + * containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ { @@ -719,7 +829,7 @@ typedef union LDKCResult_ChannelTransactionParametersDecodeErrorZPtr { /** * A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::ChannelTransactionParameters on success and a crate::ln::msgs::DecodeError on failure. + * containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_ChannelTransactionParametersDecodeErrorZ { @@ -800,7 +910,7 @@ typedef union LDKCResult_HolderCommitmentTransactionDecodeErrorZPtr { /** * A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::HolderCommitmentTransaction on success and a crate::ln::msgs::DecodeError on failure. + * containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ { @@ -853,7 +963,7 @@ typedef union LDKCResult_BuiltCommitmentTransactionDecodeErrorZPtr { /** * A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::ln::msgs::DecodeError on failure. + * containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ { @@ -911,7 +1021,7 @@ typedef union LDKCResult_CommitmentTransactionDecodeErrorZPtr { /** * A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::CommitmentTransaction on success and a crate::ln::msgs::DecodeError on failure. + * containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_CommitmentTransactionDecodeErrorZ { @@ -968,7 +1078,7 @@ typedef union LDKCResult_TrustedCommitmentTransactionNoneZPtr { /** * A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, - * containing a crate::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. + * containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_TrustedCommitmentTransactionNoneZ { @@ -1018,5554 +1128,5444 @@ typedef struct LDKCResult_CVec_SignatureZNoneZ { /** - * An accept_channel message to be sent or received from a peer + * 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 LDKAcceptChannel { +typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeAcceptChannel *inner; + LDKnativeChannelMonitorUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKAcceptChannel; - +} LDKChannelMonitorUpdate; +/** + * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + */ +typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelMonitorUpdate *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; /** - * An open_channel message to be sent or received from a peer + * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKOpenChannel { +typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * 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. + * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeOpenChannel *inner; + union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKOpenChannel; + bool result_ok; +} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; /** - * A funding_created message to be sent or received from a peer + * 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. */ -typedef struct MUST_USE_STRUCT LDKFundingCreated { +typedef struct MUST_USE_STRUCT LDKHTLCUpdate { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeFundingCreated *inner; + LDKnativeHTLCUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKFundingCreated; - +} LDKHTLCUpdate; +/** + * The contents of CResult_HTLCUpdateDecodeErrorZ + */ +typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKHTLCUpdate *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_HTLCUpdateDecodeErrorZPtr; /** - * A funding_signed message to be sent or received from a peer + * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKFundingSigned { +typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * 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. + * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeFundingSigned *inner; + union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKFundingSigned; + bool result_ok; +} LDKCResult_HTLCUpdateDecodeErrorZ; /** - * A funding_locked message to be sent or received from a peer + * 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 LDKFundingLocked { +typedef struct MUST_USE_STRUCT LDKMonitorUpdateError { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeFundingLocked *inner; + LDKnativeMonitorUpdateError *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKFundingLocked; - - +} LDKMonitorUpdateError; /** - * An announcement_signatures message to be sent or received from a peer + * The contents of CResult_NoneMonitorUpdateErrorZ */ -typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { +typedef union LDKCResult_NoneMonitorUpdateErrorZPtr { /** - * A pointer to the opaque Rust object. - * 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. + * Note that this value is always NULL, as there are no contents in the OK variant */ - LDKnativeAnnouncementSignatures *inner; + void *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKAnnouncementSignatures; - - + struct LDKMonitorUpdateError *err; +} LDKCResult_NoneMonitorUpdateErrorZPtr; /** - * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment - * transaction updates if they were pending. + * A CResult_NoneMonitorUpdateErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::chain::channelmonitor::MonitorUpdateError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { +typedef struct LDKCResult_NoneMonitorUpdateErrorZ { /** - * A pointer to the opaque Rust object. - * 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. + * The contents of this CResult_NoneMonitorUpdateErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeCommitmentUpdate *inner; + union LDKCResult_NoneMonitorUpdateErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_NoneMonitorUpdateErrorZ represents a success state. */ - bool is_owned; -} LDKCommitmentUpdate; - - + bool result_ok; +} LDKCResult_NoneMonitorUpdateErrorZ; /** - * A revoke_and_ack message to be sent or received from a peer + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKRevokeAndACK { +typedef struct LDKC2Tuple_OutPointScriptZ { /** - * A pointer to the opaque Rust object. - * 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. + * The element at position 0 */ - LDKnativeRevokeAndACK *inner; + struct LDKOutPoint a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKRevokeAndACK; - - + struct LDKCVec_u8Z b; +} LDKC2Tuple_OutPointScriptZ; /** - * A closing_signed message to be sent or received from a peer + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKClosingSigned { +typedef struct LDKC2Tuple_u32ScriptZ { /** - * A pointer to the opaque Rust object. - * 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. + * The element at position 0 */ - LDKnativeClosingSigned *inner; + uint32_t a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKClosingSigned; - - + struct LDKCVec_u8Z b; +} LDKC2Tuple_u32ScriptZ; /** - * A shutdown message to be sent or received from a peer + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKShutdown { +typedef struct LDKCVec_C2Tuple_u32ScriptZZ { /** - * A pointer to the opaque Rust object. - * 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. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeShutdown *inner; + struct LDKC2Tuple_u32ScriptZ *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKShutdown; - + uintptr_t datalen; +} LDKCVec_C2Tuple_u32ScriptZZ; +/** + * 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 { + /** + * The thirty-two bytes + */ + uint8_t data[32]; +} LDKThirtyTwoBytes; /** - * A channel_reestablish message to be sent or received from a peer + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKChannelReestablish { +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { /** - * A pointer to the opaque Rust object. - * 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. + * The element at position 0 */ - LDKnativeChannelReestablish *inner; + struct LDKThirtyTwoBytes a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKChannelReestablish; - - + struct LDKCVec_C2Tuple_u32ScriptZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; /** - * A channel_announcement message to be sent or received from a peer + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { +typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { /** - * A pointer to the opaque Rust object. - * 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. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeChannelAnnouncement *inner; + struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKChannelAnnouncement; + uintptr_t datalen; +} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; +/** + * An event to be processed by the ChannelManager. + */ +typedef enum LDKMonitorEvent_Tag { + /** + * A monitor event containing an HTLCUpdate. + */ + LDKMonitorEvent_HTLCEvent, + /** + * A monitor event that the Channel's commitment transaction was broadcasted. + */ + LDKMonitorEvent_CommitmentTxBroadcasted, + /** + * Must be last for serialization purposes + */ + LDKMonitorEvent_Sentinel, +} LDKMonitorEvent_Tag; +typedef struct MUST_USE_STRUCT LDKMonitorEvent { + LDKMonitorEvent_Tag tag; + union { + struct { + struct LDKHTLCUpdate htlc_event; + }; + struct { + struct LDKOutPoint commitment_tx_broadcasted; + }; + }; +} LDKMonitorEvent; /** - * A channel_update message to be sent or received from a peer + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChannelUpdate { +typedef struct LDKCVec_MonitorEventZ { /** - * A pointer to the opaque Rust object. - * 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. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeChannelUpdate *inner; + struct LDKMonitorEvent *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKChannelUpdate; + uintptr_t datalen; +} LDKCVec_MonitorEventZ; /** - * A node_announcement message to be sent or received from a peer + * Information about a spendable output to a P2WSH script. See + * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { +typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeNodeAnnouncement *inner; + LDKnativeDelayedPaymentOutputDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNodeAnnouncement; +} LDKDelayedPaymentOutputDescriptor; /** - * An error message to be sent or received from a peer + * Information about a spendable output to our \"payment key\". See + * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKErrorMessage { +typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeErrorMessage *inner; + LDKnativeStaticPaymentOutputDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKErrorMessage; +} LDKStaticPaymentOutputDescriptor; /** - * Used to put an error message in a LightningError + * 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 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 { +typedef enum LDKSpendableOutputDescriptor_Tag { /** - * An error message which we should make an effort to send before we disconnect. + * An output to a script which was provided via KeysInterface directly, either from + * `get_destination_script()` or `get_shutdown_pubkey()`, thus you should already know how to + * spend it. No secret keys are provided as rust-lightning was never given any key. + * 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. */ - struct LDKErrorMessage msg; -} LDKErrorAction_LDKDisconnectPeer_Body; - -typedef struct LDKErrorAction_LDKSendErrorMessage_Body { + LDKSpendableOutputDescriptor_StaticOutput, /** - * The message to send. - */ - struct LDKErrorMessage msg; -} LDKErrorAction_LDKSendErrorMessage_Body; - -typedef struct MUST_USE_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 + * 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: + * (MINIMALIF standard rule) + * + * 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 + * Sign::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 + * Sign::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 Sign::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. */ - LDKHTLCFailChannelUpdate_ChannelClosed, + LDKSpendableOutputDescriptor_DelayedPaymentOutput, /** - * We received an error which indicated only that a node has failed + * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which + * corresponds to the public key in Sign::pubkeys().payment_point). + * The witness in the spending input, is, thus, simply: + * + * + * These are generally the result of our counterparty having broadcast the current state, + * allowing us to claim the non-HTLC-encumbered outputs immediately. */ - LDKHTLCFailChannelUpdate_NodeFailure, + LDKSpendableOutputDescriptor_StaticPaymentOutput, /** * Must be last for serialization purposes */ - LDKHTLCFailChannelUpdate_Sentinel, -} LDKHTLCFailChannelUpdate_Tag; - -typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body { - /** - * The unwrapped message we received - */ - struct LDKChannelUpdate msg; -} LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body; - -typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body { - /** - * The short_channel_id which has now closed. - */ - uint64_t short_channel_id; - /** - * when this true, this channel should be permanently removed from the - * consideration. Otherwise, this channel can be restored as new channel_update is received - */ - bool is_permanent; -} LDKHTLCFailChannelUpdate_LDKChannelClosed_Body; + LDKSpendableOutputDescriptor_Sentinel, +} LDKSpendableOutputDescriptor_Tag; -typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body { +typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { /** - * The node_id that has failed. + * The outpoint which is spendable */ - struct LDKPublicKey node_id; + struct LDKOutPoint outpoint; /** - * when this true, node should be permanently removed from the - * consideration. Otherwise, the channels connected to this node can be - * restored as new channel_update is received + * The output which is referenced by the given outpoint. */ - bool is_permanent; -} LDKHTLCFailChannelUpdate_LDKNodeFailure_Body; + struct LDKTxOut output; +} LDKSpendableOutputDescriptor_LDKStaticOutput_Body; -typedef struct MUST_USE_STRUCT LDKHTLCFailChannelUpdate { - LDKHTLCFailChannelUpdate_Tag tag; +typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { + LDKSpendableOutputDescriptor_Tag tag; union { - LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body channel_update_message; - LDKHTLCFailChannelUpdate_LDKChannelClosed_Body channel_closed; - LDKHTLCFailChannelUpdate_LDKNodeFailure_Body node_failure; + LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; + struct { + struct LDKDelayedPaymentOutputDescriptor delayed_payment_output; + }; + struct { + struct LDKStaticPaymentOutputDescriptor static_payment_output; + }; }; -} LDKHTLCFailChannelUpdate; - - +} LDKSpendableOutputDescriptor; /** - * A query_channel_range message is used to query a peer for channel - * UTXOs in a range of blocks. The recipient of a query makes a best - * effort to reply to the query using one or more reply_channel_range - * messages. + * A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKQueryChannelRange { +typedef struct LDKCVec_SpendableOutputDescriptorZ { /** - * A pointer to the opaque Rust object. - * 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. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeQueryChannelRange *inner; + struct LDKSpendableOutputDescriptor *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKQueryChannelRange; - - + uintptr_t datalen; +} LDKCVec_SpendableOutputDescriptorZ; /** - * A query_short_channel_ids message is used to query a peer for - * routing gossip messages related to one or more short_channel_ids. - * The query recipient will reply with the latest, if available, - * channel_announcement, channel_update and node_announcement messages - * it maintains for the requested short_channel_ids followed by a - * reply_short_channel_ids_end message. The short_channel_ids sent in - * this query are encoded. We only support encoding_type=0 uncompressed - * serialization and do not support encoding_type=1 zlib serialization. + * 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 struct MUST_USE_STRUCT LDKQueryShortChannelIds { +typedef enum LDKEvent_Tag { /** - * A pointer to the opaque Rust object. - * 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. + * 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! */ - LDKnativeQueryShortChannelIds *inner; + LDKEvent_FundingGenerationReady, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * 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. */ - bool is_owned; -} LDKQueryShortChannelIds; - - - -/** - * A reply_channel_range message is a reply to a query_channel_range - * message. Multiple reply_channel_range messages can be sent in reply - * to a single query_channel_range message. The query recipient makes a - * best effort to respond based on their local network view which may - * not be a perfect view of the network. The short_channel_ids in the - * reply are encoded. We only support encoding_type=0 uncompressed - * serialization and do not support encoding_type=1 zlib serialization. - */ -typedef struct MUST_USE_STRUCT LDKReplyChannelRange { + LDKEvent_PaymentReceived, /** - * A pointer to the opaque Rust object. - * 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. + * 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)! */ - LDKnativeReplyChannelRange *inner; + LDKEvent_PaymentSent, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * 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)! */ - bool is_owned; -} LDKReplyChannelRange; - -/** - * 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 { + LDKEvent_PaymentFailed, /** - * Used to indicate that we've accepted a channel open and should send the accept_channel - * message provided to the given peer. + * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a + * time in the future. */ - LDKMessageSendEvent_SendAcceptChannel, + LDKEvent_PendingHTLCsForwardable, /** - * Used to indicate that we've initiated a channel open and should send the open_channel - * message provided to the given peer. + * 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. */ - LDKMessageSendEvent_SendOpenChannel, + LDKEvent_SpendableOutputs, /** - * Used to indicate that a funding_created message should be sent to the peer with the given node_id. + * Must be last for serialization purposes */ - LDKMessageSendEvent_SendFundingCreated, + LDKEvent_Sentinel, +} LDKEvent_Tag; + +typedef struct LDKEvent_LDKFundingGenerationReady_Body { /** - * Used to indicate that a funding_signed message should be sent to the peer with the given node_id. + * The random channel_id we picked which you'll need to pass into + * ChannelManager::funding_transaction_generated. */ - LDKMessageSendEvent_SendFundingSigned, + struct LDKThirtyTwoBytes temporary_channel_id; /** - * Used to indicate that a funding_locked message should be sent to the peer with the given node_id. + * The value, in satoshis, that the output should have. */ - LDKMessageSendEvent_SendFundingLocked, + uint64_t channel_value_satoshis; /** - * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. + * The script which should be used in the transaction output. */ - 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, + struct LDKCVec_u8Z output_script; /** - * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. + * The value passed in to ChannelManager::create_channel */ - LDKMessageSendEvent_SendRevokeAndACK, + uint64_t user_channel_id; +} LDKEvent_LDKFundingGenerationReady_Body; + +typedef struct LDKEvent_LDKPaymentReceived_Body { /** - * Used to indicate that a closing_signed message should be sent to the peer with the given node_id. + * The hash for which the preimage should be handed to the ChannelManager. */ - LDKMessageSendEvent_SendClosingSigned, + struct LDKThirtyTwoBytes payment_hash; /** - * Used to indicate that a shutdown message should be sent to the peer with the given node_id. + * The \"payment secret\". This authenticates the sender to the recipient, preventing a + * number of deanonymization attacks during the routing process. + * As nodes upgrade, the invoices you provide should likely migrate to setting the + * payment_secret feature to required, at which point you should fail_backwards any HTLCs + * which have a None here. + * Until then, however, values of None should be ignored, and only incorrect Some values + * should result in an HTLC fail_backwards. + * Note that, in any case, this value must be passed as-is to any fail or claim calls as + * the HTLC index includes this value. */ - LDKMessageSendEvent_SendShutdown, + struct LDKThirtyTwoBytes payment_secret; /** - * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. + * The value, in thousandths of a satoshi, that this payment is for. Note that you must + * compare this to the expected value before accepting the payment (as otherwise you are + * providing proof-of-payment for less than the value you expected!). */ - LDKMessageSendEvent_SendChannelReestablish, + uint64_t amt; +} LDKEvent_LDKPaymentReceived_Body; + +typedef struct LDKEvent_LDKPaymentSent_Body { /** - * 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. + * The preimage to the hash given to ChannelManager::send_payment. + * Note that this serves as a payment receipt, if you wish to have such a thing, you must + * store it somehow! */ - LDKMessageSendEvent_BroadcastChannelAnnouncement, + struct LDKThirtyTwoBytes payment_preimage; +} LDKEvent_LDKPaymentSent_Body; + +typedef struct LDKEvent_LDKPaymentFailed_Body { /** - * Used to indicate that a node_announcement should be broadcast to all peers. + * The hash which was given to ChannelManager::send_payment. */ - LDKMessageSendEvent_BroadcastNodeAnnouncement, + struct LDKThirtyTwoBytes payment_hash; /** - * Used to indicate that a channel_update should be broadcast to all peers. + * Indicates the payment was rejected for some reason by the recipient. This implies that + * the payment has failed, not just the route in question. If this is not set, you may + * retry the payment via a different route. */ - LDKMessageSendEvent_BroadcastChannelUpdate, + bool rejected_by_dest; +} LDKEvent_LDKPaymentFailed_Body; + +typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { /** - * Broadcast an error downstream to be handled + * The minimum amount of time that should be waited prior to calling + * process_pending_htlc_forwards. To increase the effort required to correlate payments, + * you should wait a random amount of time in roughly the range (now + time_forwardable, + * now + 5*time_forwardable). */ - LDKMessageSendEvent_HandleError, + uint64_t time_forwardable; +} LDKEvent_LDKPendingHTLCsForwardable_Body; + +typedef struct LDKEvent_LDKSpendableOutputs_Body { /** - * 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. + * The outputs which you should store as spendable by you. */ - LDKMessageSendEvent_PaymentFailureNetworkUpdate, + struct LDKCVec_SpendableOutputDescriptorZ outputs; +} LDKEvent_LDKSpendableOutputs_Body; + +typedef struct MUST_USE_STRUCT LDKEvent { + LDKEvent_Tag tag; + union { + LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; + 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; + +/** + * A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_EventZ { /** - * Query a peer for channels with funding transaction UTXOs in a block range. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKMessageSendEvent_SendChannelRangeQuery, + struct LDKEvent *data; /** - * Request routing gossip messages from a peer for a list of channels identified by - * their short_channel_ids. + * The number of elements pointed to by `data`. */ - LDKMessageSendEvent_SendShortIdsQuery, + uintptr_t datalen; +} LDKCVec_EventZ; + +/** + * A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_TransactionZ { /** - * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events - * emitted during processing of the query. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKMessageSendEvent_SendReplyChannelRange, + struct LDKTransaction *data; /** - * Must be last for serialization purposes + * The number of elements pointed to by `data`. */ - LDKMessageSendEvent_Sentinel, -} LDKMessageSendEvent_Tag; + uintptr_t datalen; +} LDKCVec_TransactionZ; -typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_usizeTransactionZ { /** - * The node_id of the node which should receive this message + * The element at position 0 */ - struct LDKPublicKey node_id; + uintptr_t a; /** - * The message which should be sent. + * The element at position 1 */ - struct LDKAcceptChannel msg; -} LDKMessageSendEvent_LDKSendAcceptChannel_Body; + struct LDKTransaction b; +} LDKC2Tuple_usizeTransactionZ; -typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { /** - * The node_id of the node which should receive this message + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPublicKey node_id; + struct LDKC2Tuple_usizeTransactionZ *data; /** - * The message which should be sent. + * The number of elements pointed to by `data`. */ - struct LDKOpenChannel msg; -} LDKMessageSendEvent_LDKSendOpenChannel_Body; + uintptr_t datalen; +} LDKCVec_C2Tuple_usizeTransactionZZ; -typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_u32TxOutZ { /** - * The node_id of the node which should receive this message + * The element at position 0 */ - struct LDKPublicKey node_id; + uint32_t a; /** - * The message which should be sent. + * The element at position 1 */ - struct LDKFundingCreated msg; -} LDKMessageSendEvent_LDKSendFundingCreated_Body; + struct LDKTxOut b; +} LDKC2Tuple_u32TxOutZ; -typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_u32TxOutZZ { /** - * The node_id of the node which should receive this message + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPublicKey node_id; + struct LDKC2Tuple_u32TxOutZ *data; /** - * The message which should be sent. + * The number of elements pointed to by `data`. */ - struct LDKFundingSigned msg; -} LDKMessageSendEvent_LDKSendFundingSigned_Body; + uintptr_t datalen; +} LDKCVec_C2Tuple_u32TxOutZZ; -typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body { +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { /** - * The node_id of the node which should receive these message(s) + * The element at position 0 */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes a; /** - * The funding_locked message which should be sent. + * The element at position 1 */ - struct LDKFundingLocked msg; -} LDKMessageSendEvent_LDKSendFundingLocked_Body; + struct LDKCVec_C2Tuple_u32TxOutZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; -typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_TransactionOutputsZ { /** - * The node_id of the node which should receive these message(s) + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPublicKey node_id; + struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data; /** - * The announcement_signatures message which should be sent. + * The number of elements pointed to by `data`. */ - struct LDKAnnouncementSignatures msg; -} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; + uintptr_t datalen; +} LDKCVec_TransactionOutputsZ; -typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { +/** + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_TxidZ { /** - * The node_id of the node which should receive these message(s) + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes *data; /** - * The update messages which should be sent. ALL messages in the struct should be sent! + * The number of elements pointed to by `data`. */ - struct LDKCommitmentUpdate updates; -} LDKMessageSendEvent_LDKUpdateHTLCs_Body; + uintptr_t datalen; +} LDKCVec_TxidZ; -typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { +/** + * The contents of CResult_NoneChannelMonitorUpdateErrZ + */ +typedef union LDKCResult_NoneChannelMonitorUpdateErrZPtr { /** - * The node_id of the node which should receive this message + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKPublicKey node_id; + void *result; /** - * The message which should be sent. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKRevokeAndACK msg; -} LDKMessageSendEvent_LDKSendRevokeAndACK_Body; - -typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { - /** - * The node_id of the node which should receive this message - */ - struct LDKPublicKey node_id; - /** - * The message which should be sent. - */ - struct LDKClosingSigned msg; -} LDKMessageSendEvent_LDKSendClosingSigned_Body; - -typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { - /** - * The node_id of the node which should receive this message - */ - struct LDKPublicKey node_id; - /** - * The message which should be sent. - */ - struct LDKShutdown msg; -} LDKMessageSendEvent_LDKSendShutdown_Body; - -typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { - /** - * The node_id of the node which should receive this message - */ - struct LDKPublicKey node_id; - /** - * The message which should be sent. - */ - struct LDKChannelReestablish msg; -} LDKMessageSendEvent_LDKSendChannelReestablish_Body; - -typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { - /** - * The channel_announcement which should be sent. - */ - struct LDKChannelAnnouncement msg; - /** - * The followup channel_update which should be sent. - */ - struct LDKChannelUpdate update_msg; -} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; + enum LDKChannelMonitorUpdateErr *err; +} LDKCResult_NoneChannelMonitorUpdateErrZPtr; -typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { +/** + * A CResult_NoneChannelMonitorUpdateErrZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::chain::channelmonitor::ChannelMonitorUpdateErr on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ { /** - * The node_announcement which should be sent. + * The contents of this CResult_NoneChannelMonitorUpdateErrZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKNodeAnnouncement msg; -} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; - -typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { + union LDKCResult_NoneChannelMonitorUpdateErrZPtr contents; /** - * The channel_update which should be sent. + * Whether this CResult_NoneChannelMonitorUpdateErrZ represents a success state. */ - struct LDKChannelUpdate msg; -} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; + bool result_ok; +} LDKCResult_NoneChannelMonitorUpdateErrZ; -typedef struct LDKMessageSendEvent_LDKHandleError_Body { - /** - * The node_id of the node which should receive this message - */ - struct LDKPublicKey node_id; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ { /** - * The action which should be taken. + * The element at position 0 */ - struct LDKErrorAction action; -} LDKMessageSendEvent_LDKHandleError_Body; - -typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body { + struct LDKSignature a; /** - * The channel/node update which should be sent to NetGraphMsgHandler + * The element at position 1 */ - struct LDKHTLCFailChannelUpdate update; -} LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body; + struct LDKCVec_SignatureZ b; +} LDKC2Tuple_SignatureCVec_SignatureZZ; -typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { +/** + * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ + */ +typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { /** - * The node_id of this message recipient + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey node_id; + struct LDKC2Tuple_SignatureCVec_SignatureZZ *result; /** - * The query_channel_range which should be sent. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKQueryChannelRange msg; -} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; + void *err; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr; -typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { +/** + * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { /** - * The node_id of this message recipient + * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPublicKey node_id; + union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents; /** - * The query_short_channel_ids which should be sent. + * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. */ - struct LDKQueryShortChannelIds msg; -} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; + bool result_ok; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; -typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { +/** + * The contents of CResult_SignatureNoneZ + */ +typedef union LDKCResult_SignatureNoneZPtr { /** - * The node_id of this message recipient + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey node_id; + struct LDKSignature *result; /** - * The reply_channel_range which should be sent. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKReplyChannelRange msg; -} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; - -typedef struct MUST_USE_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_LDKSendChannelRangeQuery_Body send_channel_range_query; - LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; - LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; - }; -} LDKMessageSendEvent; + void *err; +} LDKCResult_SignatureNoneZPtr; /** - * A dynamically-allocated array of crate::util::events::MessageSendEvents of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_SignatureNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Signature on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_MessageSendEventZ { +typedef struct LDKCResult_SignatureNoneZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_SignatureNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKMessageSendEvent *data; + union LDKCResult_SignatureNoneZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_SignatureNoneZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_MessageSendEventZ; + bool result_ok; +} LDKCResult_SignatureNoneZ; /** - * An Err type for failure to process messages. + * The unsigned part of a channel_announcement */ -typedef struct MUST_USE_STRUCT LDKLightningError { +typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeLightningError *inner; + LDKnativeUnsignedChannelAnnouncement *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKLightningError; +} LDKUnsignedChannelAnnouncement; /** - * The contents of CResult_boolLightningErrorZ + * A trait to sign lightning channel transactions as described in BOLT 3. + * + * Signing services could be implemented on a hardware wallet. In this case, + * the current Sign 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. */ -typedef union LDKCResult_boolLightningErrorZPtr { +typedef struct LDKBaseSign { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - bool *result; + void *this_arg; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Gets the per-commitment point for a specific commitment number + * + * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. */ - struct LDKLightningError *err; -} LDKCResult_boolLightningErrorZPtr; - -/** - * A CResult_boolLightningErrorZ represents the result of a fallible operation, - * containing a bool on success and a crate::ln::msgs::LightningError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_boolLightningErrorZ { + struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); /** - * The contents of this CResult_boolLightningErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * 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. */ - union LDKCResult_boolLightningErrorZPtr contents; + struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); /** - * Whether this CResult_boolLightningErrorZ represents a success state. + * Gets the holder's channel public keys and basepoints */ - bool result_ok; -} LDKCResult_boolLightningErrorZ; - -/** - * A tuple of 3 elements. See the individual fields for the types contained. - */ -typedef struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + struct LDKChannelPublicKeys pubkeys; /** - * The element at position 0 + * 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. */ - struct LDKChannelAnnouncement a; + void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR ); /** - * The element at position 1 + * Gets an arbitrary identifier describing the set of keys which are provided back to you in + * some SpendableOutputDescriptor types. This should be sufficient to identify this + * Sign object uniquely and lookup or re-derive its keys. */ - struct LDKChannelUpdate b; + struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); /** - * The element at position 2 + * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. + * + * Note that if signing fails or is rejected, the channel will be force-closed. */ - struct LDKChannelUpdate c; -} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx); /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. + * This will only ever be called with a non-revoked commitment_tx. This will be called with the + * latest commitment_tx when we initiate a force-close. + * This will be called with the previous latest, just to get claiming HTLC signatures, if we are + * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to + * the latest. + * This may be called multiple times for the same transaction. + * + * An external signer implementation should check that the commitment has not been revoked. + * + * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. */ - struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *data; + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); /** - * The number of elements pointed to by `data`. + * 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 _holder_ secret key and does + * not allow the spending of any funds by itself (you need our holder 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). */ - uintptr_t datalen; -} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; - -/** - * A dynamically-allocated array of crate::ln::msgs::NodeAnnouncements of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_NodeAnnouncementZ { + struct LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Create a signature for a claiming transaction for a HTLC output on a counterparty's 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. */ - struct LDKNodeAnnouncement *data; + struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** - * The number of elements pointed to by `data`. + * 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. */ - uintptr_t datalen; -} LDKCVec_NodeAnnouncementZ; - -/** - * The contents of CResult_NoneLightningErrorZ - */ -typedef union LDKCResult_NoneLightningErrorZPtr { + struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, struct LDKTransaction closing_tx); /** - * Note that this value is always NULL, as there are no contents in the OK variant + * 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. */ - void *result; + struct LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Set the counterparty static channel data, including basepoints, + * counterparty_selected/holder_selected_contest_delay and funding outpoint. + * This is done as soon as the funding outpoint is known. Since these are static channel data, + * they MUST NOT be allowed to change to different values once set. + * + * channel_parameters.is_populated() MUST be true. + * + * We bind holder_selected_contest_delay late here for API convenience. + * + * Will be called before any signatures are applied. */ - struct LDKLightningError *err; -} LDKCResult_NoneLightningErrorZPtr; + void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKBaseSign; /** - * A CResult_NoneLightningErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::ln::msgs::LightningError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A cloneable signer. + * + * Although we require signers to be cloneable, it may be useful for developers to be able to use + * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait, + * which implies Sized, into this derived trait. */ -typedef struct LDKCResult_NoneLightningErrorZ { +typedef struct LDKSign { /** - * The contents of this CResult_NoneLightningErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - union LDKCResult_NoneLightningErrorZPtr contents; + void *this_arg; /** - * Whether this CResult_NoneLightningErrorZ represents a success state. + * Implementation of BaseSign for this object. */ - bool result_ok; -} LDKCResult_NoneLightningErrorZ; - -/** - * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_PublicKeyZ { + struct LDKBaseSign BaseSign; /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Creates a copy of the BaseSign, for a copy of this Sign. + * Because BaseSign doesn't natively support copying itself, you have to provide a full copy implementation here. */ - struct LDKPublicKey *data; + struct LDKBaseSign (*BaseSign_clone)(const struct LDKBaseSign *NONNULL_PTR orig_BaseSign); /** - * The number of elements pointed to by `data`. + * Serialize the object into a byte array */ - uintptr_t datalen; -} LDKCVec_PublicKeyZ; + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Creates a copy of the object pointed to by this_arg, for a copy of this Sign. + * Note that the ultimate copy of the Sign will have all function pointers the same as the original. + * May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new Sign. + */ + void *(*clone)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKSign; /** - * 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/socket_disconnected calls for the - * descriptor. + * 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. + * + * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which + * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along + * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the + * returned block hash and the the current chain and then reconnecting blocks to get to the + * best chain) upon deserializing the object! */ -typedef struct MUST_USE_STRUCT LDKPeerHandleError { +typedef struct MUST_USE_STRUCT LDKChannelMonitor { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativePeerHandleError *inner; + LDKnativeChannelMonitor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPeerHandleError; +} LDKChannelMonitor; /** - * The contents of CResult_CVec_u8ZPeerHandleErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_CVec_u8ZPeerHandleErrorZPtr { +typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKChannelMonitor b; +} LDKC2Tuple_BlockHashChannelMonitorZ; + +/** + * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ + */ +typedef union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_u8Z *result; + struct LDKC2Tuple_BlockHashChannelMonitorZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPeerHandleError *err; -} LDKCResult_CVec_u8ZPeerHandleErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr; /** - * A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_u8Z on success and a crate::ln::peer_handler::PeerHandleError on failure. + * A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_u8ZPeerHandleErrorZ { +typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { /** - * The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either + * The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_u8ZPeerHandleErrorZPtr contents; + union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr contents; /** - * Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. + * Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_u8ZPeerHandleErrorZ; +} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; + + /** - * The contents of CResult_NonePeerHandleErrorZ + * A hop in a route */ -typedef union LDKCResult_NonePeerHandleErrorZPtr { +typedef struct MUST_USE_STRUCT LDKRouteHop { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the opaque Rust object. + * 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. */ - void *result; + LDKnativeRouteHop *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKPeerHandleError *err; -} LDKCResult_NonePeerHandleErrorZPtr; - -/** - * A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::ln::peer_handler::PeerHandleError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NonePeerHandleErrorZ { - /** - * The contents of this CResult_NonePeerHandleErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NonePeerHandleErrorZPtr contents; - /** - * Whether this CResult_NonePeerHandleErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_NonePeerHandleErrorZ; + bool is_owned; +} LDKRouteHop; /** - * The contents of CResult_boolPeerHandleErrorZ + * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_boolPeerHandleErrorZPtr { +typedef struct LDKCVec_RouteHopZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - bool *result; + struct LDKRouteHop *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKPeerHandleError *err; -} LDKCResult_boolPeerHandleErrorZPtr; + uintptr_t datalen; +} LDKCVec_RouteHopZ; /** - * A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, - * containing a bool on success and a crate::ln::peer_handler::PeerHandleError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_boolPeerHandleErrorZ { +typedef struct LDKCVec_CVec_RouteHopZZ { /** - * The contents of this CResult_boolPeerHandleErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_boolPeerHandleErrorZPtr contents; + struct LDKCVec_RouteHopZ *data; /** - * Whether this CResult_boolPeerHandleErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_boolPeerHandleErrorZ; + uintptr_t datalen; +} LDKCVec_CVec_RouteHopZZ; /** - * Features used within an `init` message. + * 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 LDKInitFeatures { +typedef struct MUST_USE_STRUCT LDKRoute { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeInitFeatures *inner; + LDKnativeRoute *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInitFeatures; +} LDKRoute; /** - * The contents of CResult_InitFeaturesDecodeErrorZ + * The contents of CResult_RouteDecodeErrorZ */ -typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { +typedef union LDKCResult_RouteDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInitFeatures *result; + struct LDKRoute *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InitFeaturesDecodeErrorZPtr; +} LDKCResult_RouteDecodeErrorZPtr; /** - * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::features::InitFeatures on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_RouteDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InitFeaturesDecodeErrorZ { +typedef struct LDKCResult_RouteDecodeErrorZ { /** - * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_RouteDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InitFeaturesDecodeErrorZPtr contents; + union LDKCResult_RouteDecodeErrorZPtr contents; /** - * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_RouteDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InitFeaturesDecodeErrorZ; +} LDKCResult_RouteDecodeErrorZ; + +/** + * An enum which can either contain a u64 or not + */ +typedef enum LDKCOption_u64Z_Tag { + /** + * When we're in this state, this COption_u64Z contains a u64 + */ + LDKCOption_u64Z_Some, + /** + * When we're in this state, this COption_u64Z contains nothing + */ + LDKCOption_u64Z_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_u64Z_Sentinel, +} LDKCOption_u64Z_Tag; + +typedef struct LDKCOption_u64Z { + LDKCOption_u64Z_Tag tag; + union { + struct { + uint64_t some; + }; + }; +} LDKCOption_u64Z; /** - * Features used within a `node_announcement` message. + * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels */ -typedef struct MUST_USE_STRUCT LDKNodeFeatures { +typedef struct MUST_USE_STRUCT LDKChannelDetails { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeNodeFeatures *inner; + LDKnativeChannelDetails *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNodeFeatures; - -/** - * The contents of CResult_NodeFeaturesDecodeErrorZ - */ -typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKNodeFeatures *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_NodeFeaturesDecodeErrorZPtr; +} LDKChannelDetails; /** - * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::features::NodeFeatures on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { +typedef struct LDKCVec_ChannelDetailsZ { /** - * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_NodeFeaturesDecodeErrorZPtr contents; + struct LDKChannelDetails *data; /** - * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_NodeFeaturesDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_ChannelDetailsZ; /** - * Features used within a `channel_announcement` message. + * A channel descriptor which provides a last-hop route to get_route */ -typedef struct MUST_USE_STRUCT LDKChannelFeatures { +typedef struct MUST_USE_STRUCT LDKRouteHint { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeChannelFeatures *inner; + LDKnativeRouteHint *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelFeatures; - -/** - * The contents of CResult_ChannelFeaturesDecodeErrorZ - */ -typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKChannelFeatures *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_ChannelFeaturesDecodeErrorZPtr; +} LDKRouteHint; /** - * A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::features::ChannelFeatures on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { +typedef struct LDKCVec_RouteHintZ { /** - * The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_ChannelFeaturesDecodeErrorZPtr contents; + struct LDKRouteHint *data; /** - * Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_ChannelFeaturesDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_RouteHintZ; /** - * Features used within an invoice. + * An Err type for failure to process messages. */ -typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { +typedef struct MUST_USE_STRUCT LDKLightningError { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeInvoiceFeatures *inner; + LDKnativeLightningError *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceFeatures; +} LDKLightningError; /** - * The contents of CResult_InvoiceFeaturesDecodeErrorZ + * The contents of CResult_RouteLightningErrorZ */ -typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { +typedef union LDKCResult_RouteLightningErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoiceFeatures *result; + struct LDKRoute *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; + struct LDKLightningError *err; +} LDKCResult_RouteLightningErrorZPtr; /** - * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::features::InvoiceFeatures on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_RouteLightningErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { +typedef struct LDKCResult_RouteLightningErrorZ { /** - * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_RouteLightningErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; + union LDKCResult_RouteLightningErrorZPtr contents; /** - * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_RouteLightningErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceFeaturesDecodeErrorZ; +} LDKCResult_RouteLightningErrorZ; /** - * Options which apply on a per-channel basis and may change at runtime or based on negotiation - * with our counterparty. + * An accept_channel message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKChannelConfig { +typedef struct MUST_USE_STRUCT LDKAcceptChannel { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeChannelConfig *inner; + LDKnativeAcceptChannel *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelConfig; +} LDKAcceptChannel; + + /** - * The contents of CResult_ChannelConfigDecodeErrorZ + * An open_channel message to be sent or received from a peer */ -typedef union LDKCResult_ChannelConfigDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKOpenChannel { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * 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. */ - struct LDKChannelConfig *result; + LDKnativeOpenChannel *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelConfigDecodeErrorZPtr; + bool is_owned; +} LDKOpenChannel; + + /** - * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, - * containing a crate::util::config::ChannelConfig on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A funding_created message to be sent or received from a peer */ -typedef struct LDKCResult_ChannelConfigDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKFundingCreated { /** - * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * 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. */ - union LDKCResult_ChannelConfigDecodeErrorZPtr contents; + LDKnativeFundingCreated *inner; /** - * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_ChannelConfigDecodeErrorZ; + bool is_owned; +} LDKFundingCreated; + + /** - * An enum which can either contain a u64 or not + * A funding_signed message to be sent or received from a peer */ -typedef enum LDKCOption_u64Z_Tag { - /** - * When we're in this state, this COption_u64Z contains a u64 - */ - LDKCOption_u64Z_Some, +typedef struct MUST_USE_STRUCT LDKFundingSigned { /** - * When we're in this state, this COption_u64Z contains nothing + * A pointer to the opaque Rust object. + * 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. */ - LDKCOption_u64Z_None, + LDKnativeFundingSigned *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_u64Z_Sentinel, -} LDKCOption_u64Z_Tag; - -typedef struct LDKCOption_u64Z { - LDKCOption_u64Z_Tag tag; - union { - struct { - uint64_t some; - }; - }; -} LDKCOption_u64Z; + bool is_owned; +} LDKFundingSigned; /** - * Details about one direction of a channel. Received - * within a channel update. + * A funding_locked message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo { +typedef struct MUST_USE_STRUCT LDKFundingLocked { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeDirectionalChannelInfo *inner; + LDKnativeFundingLocked *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDirectionalChannelInfo; +} LDKFundingLocked; + + /** - * The contents of CResult_DirectionalChannelInfoDecodeErrorZ + * An announcement_signatures message to be sent or received from a peer */ -typedef union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * 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. */ - struct LDKDirectionalChannelInfo *result; + LDKnativeAnnouncementSignatures *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_DirectionalChannelInfoDecodeErrorZPtr; + bool is_owned; +} LDKAnnouncementSignatures; + + /** - * A CResult_DirectionalChannelInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::routing::network_graph::DirectionalChannelInfo on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment + * transaction updates if they were pending. */ -typedef struct LDKCResult_DirectionalChannelInfoDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { /** - * The contents of this CResult_DirectionalChannelInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * 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. */ - union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr contents; + LDKnativeCommitmentUpdate *inner; /** - * Whether this CResult_DirectionalChannelInfoDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_DirectionalChannelInfoDecodeErrorZ; + bool is_owned; +} LDKCommitmentUpdate; /** - * Details about a channel (both directions). - * Received within a channel announcement. + * A revoke_and_ack message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKChannelInfo { +typedef struct MUST_USE_STRUCT LDKRevokeAndACK { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeChannelInfo *inner; + LDKnativeRevokeAndACK *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelInfo; +} LDKRevokeAndACK; + + /** - * The contents of CResult_ChannelInfoDecodeErrorZ + * A closing_signed message to be sent or received from a peer */ -typedef union LDKCResult_ChannelInfoDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKClosingSigned { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * 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. */ - struct LDKChannelInfo *result; + LDKnativeClosingSigned *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelInfoDecodeErrorZPtr; + bool is_owned; +} LDKClosingSigned; + + /** - * A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::routing::network_graph::ChannelInfo on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A shutdown message to be sent or received from a peer */ -typedef struct LDKCResult_ChannelInfoDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKShutdown { /** - * The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * 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. */ - union LDKCResult_ChannelInfoDecodeErrorZPtr contents; + LDKnativeShutdown *inner; /** - * Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_ChannelInfoDecodeErrorZ; + bool is_owned; +} LDKShutdown; /** - * Fees for routing via a given channel or a node + * A channel_reestablish message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKRoutingFees { +typedef struct MUST_USE_STRUCT LDKChannelReestablish { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeRoutingFees *inner; + LDKnativeChannelReestablish *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKRoutingFees; +} LDKChannelReestablish; + + /** - * The contents of CResult_RoutingFeesDecodeErrorZ + * A channel_announcement message to be sent or received from a peer */ -typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * 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. */ - struct LDKRoutingFees *result; + LDKnativeChannelAnnouncement *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_RoutingFeesDecodeErrorZPtr; + bool is_owned; +} LDKChannelAnnouncement; + + /** - * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::routing::network_graph::RoutingFees on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A channel_update message to be sent or received from a peer */ -typedef struct LDKCResult_RoutingFeesDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKChannelUpdate { /** - * The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * 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. */ - union LDKCResult_RoutingFeesDecodeErrorZPtr contents; + LDKnativeChannelUpdate *inner; /** - * Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_RoutingFeesDecodeErrorZ; + bool is_owned; +} LDKChannelUpdate; + + /** - * A 4-byte byte array. + * A node_announcement message to be sent or received from a peer */ -typedef struct LDKFourBytes { +typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { /** - * The four bytes + * A pointer to the opaque Rust object. + * 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. */ - uint8_t data[4]; -} LDKFourBytes; + LDKnativeNodeAnnouncement *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKNodeAnnouncement; + + /** - * A 16-byte byte array. + * An error message to be sent or received from a peer */ -typedef struct LDKSixteenBytes { +typedef struct MUST_USE_STRUCT LDKErrorMessage { /** - * The sixteen bytes + * A pointer to the opaque Rust object. + * 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. */ - uint8_t data[16]; -} LDKSixteenBytes; + LDKnativeErrorMessage *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKErrorMessage; /** - * A 10-byte byte array. + * Used to put an error message in a LightningError */ -typedef struct LDKTenBytes { +typedef enum LDKErrorAction_Tag { /** - * The ten bytes + * The peer took some action which made us think they were useless. Disconnect them. */ - uint8_t data[10]; -} LDKTenBytes; - -/** - * 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 { - /** - * The thirty-two bytes - */ - uint8_t data[32]; -} LDKThirtyTwoBytes; - -/** - * An address which can be used to connect to a remote peer - */ -typedef enum LDKNetAddress_Tag { + LDKErrorAction_DisconnectPeer, /** - * An IPv4 address/port on which the peer is listening. + * The peer did something harmless that we weren't able to process, just log and ignore */ - LDKNetAddress_IPv4, + LDKErrorAction_IgnoreError, /** - * An IPv6 address/port on which the peer is listening. + * The peer did something incorrect. Tell them. */ - LDKNetAddress_IPv6, + LDKErrorAction_SendErrorMessage, /** - * An old-style Tor onion address/port on which the peer is listening. + * Must be last for serialization purposes */ - LDKNetAddress_OnionV2, + LDKErrorAction_Sentinel, +} LDKErrorAction_Tag; + +typedef struct LDKErrorAction_LDKDisconnectPeer_Body { /** - * 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\". + * An error message which we should make an effort to send before we disconnect. */ - LDKNetAddress_OnionV3, + struct LDKErrorMessage msg; +} LDKErrorAction_LDKDisconnectPeer_Body; + +typedef struct LDKErrorAction_LDKSendErrorMessage_Body { /** - * Must be last for serialization purposes + * The message to send. */ - LDKNetAddress_Sentinel, -} LDKNetAddress_Tag; + struct LDKErrorMessage msg; +} LDKErrorAction_LDKSendErrorMessage_Body; -typedef struct LDKNetAddress_LDKIPv4_Body { +typedef struct MUST_USE_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 { /** - * The 4-byte IPv4 address + * We received an error which included a full ChannelUpdate message. */ - struct LDKFourBytes addr; + LDKHTLCFailChannelUpdate_ChannelUpdateMessage, /** - * The port on which the node is listening + * We received an error which indicated only that a channel has been closed */ - uint16_t port; -} LDKNetAddress_LDKIPv4_Body; - -typedef struct LDKNetAddress_LDKIPv6_Body { + LDKHTLCFailChannelUpdate_ChannelClosed, /** - * The 16-byte IPv6 address + * We received an error which indicated only that a node has failed */ - struct LDKSixteenBytes addr; + LDKHTLCFailChannelUpdate_NodeFailure, /** - * The port on which the node is listening + * Must be last for serialization purposes */ - uint16_t port; -} LDKNetAddress_LDKIPv6_Body; + LDKHTLCFailChannelUpdate_Sentinel, +} LDKHTLCFailChannelUpdate_Tag; -typedef struct LDKNetAddress_LDKOnionV2_Body { - /** - * The bytes (usually encoded in base32 with \".onion\" appended) - */ - struct LDKTenBytes addr; +typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body { /** - * The port on which the node is listening + * The unwrapped message we received */ - uint16_t port; -} LDKNetAddress_LDKOnionV2_Body; + struct LDKChannelUpdate msg; +} LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body; -typedef struct LDKNetAddress_LDKOnionV3_Body { +typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body { /** - * The ed25519 long-term public key of the peer + * The short_channel_id which has now closed. */ - struct LDKThirtyTwoBytes ed25519_pubkey; + uint64_t short_channel_id; /** - * The checksum of the pubkey and version, as included in the onion address + * when this true, this channel should be permanently removed from the + * consideration. Otherwise, this channel can be restored as new channel_update is received */ - uint16_t checksum; + bool is_permanent; +} LDKHTLCFailChannelUpdate_LDKChannelClosed_Body; + +typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body { /** - * The version byte, as defined by the Tor Onion v3 spec. + * The node_id that has failed. */ - uint8_t version; + struct LDKPublicKey node_id; /** - * The port on which the node is listening + * when this true, node should be permanently removed from the + * consideration. Otherwise, the channels connected to this node can be + * restored as new channel_update is received */ - uint16_t port; -} LDKNetAddress_LDKOnionV3_Body; + bool is_permanent; +} LDKHTLCFailChannelUpdate_LDKNodeFailure_Body; -typedef struct MUST_USE_STRUCT LDKNetAddress { - LDKNetAddress_Tag tag; +typedef struct MUST_USE_STRUCT LDKHTLCFailChannelUpdate { + LDKHTLCFailChannelUpdate_Tag tag; union { - LDKNetAddress_LDKIPv4_Body i_pv4; - LDKNetAddress_LDKIPv6_Body i_pv6; - LDKNetAddress_LDKOnionV2_Body onion_v2; - LDKNetAddress_LDKOnionV3_Body onion_v3; + LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body channel_update_message; + LDKHTLCFailChannelUpdate_LDKChannelClosed_Body channel_closed; + LDKHTLCFailChannelUpdate_LDKNodeFailure_Body node_failure; }; -} LDKNetAddress; - -/** - * A dynamically-allocated array of crate::ln::msgs::NetAddresss of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_NetAddressZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKNetAddress *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_NetAddressZ; +} LDKHTLCFailChannelUpdate; /** - * Information received in the latest node_announcement from this node. + * A query_channel_range message is used to query a peer for channel + * UTXOs in a range of blocks. The recipient of a query makes a best + * effort to reply to the query using one or more reply_channel_range + * messages. */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { +typedef struct MUST_USE_STRUCT LDKQueryChannelRange { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeNodeAnnouncementInfo *inner; + LDKnativeQueryChannelRange *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNodeAnnouncementInfo; +} LDKQueryChannelRange; -/** - * The contents of CResult_NodeAnnouncementInfoDecodeErrorZ - */ -typedef union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKNodeAnnouncementInfo *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr; -/** - * A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::routing::network_graph::NodeAnnouncementInfo on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ { - /** - * The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr contents; - /** - * Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_NodeAnnouncementInfoDecodeErrorZ; /** - * A dynamically-allocated array of u64s of arbitrary size. - * This corresponds to std::vector in C++ + * A query_short_channel_ids message is used to query a peer for + * routing gossip messages related to one or more short_channel_ids. + * The query recipient will reply with the latest, if available, + * channel_announcement, channel_update and node_announcement messages + * it maintains for the requested short_channel_ids followed by a + * reply_short_channel_ids_end message. The short_channel_ids sent in + * this query are encoded. We only support encoding_type=0 uncompressed + * serialization and do not support encoding_type=1 zlib serialization. */ -typedef struct LDKCVec_u64Z { +typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * 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. */ - uint64_t *data; + LDKnativeQueryShortChannelIds *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_u64Z; + bool is_owned; +} LDKQueryShortChannelIds; /** - * Details about a node in the network, known from the network announcement. + * A reply_channel_range message is a reply to a query_channel_range + * message. Multiple reply_channel_range messages can be sent in reply + * to a single query_channel_range message. The query recipient makes a + * best effort to respond based on their local network view which may + * not be a perfect view of the network. The short_channel_ids in the + * reply are encoded. We only support encoding_type=0 uncompressed + * serialization and do not support encoding_type=1 zlib serialization. */ -typedef struct MUST_USE_STRUCT LDKNodeInfo { +typedef struct MUST_USE_STRUCT LDKReplyChannelRange { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeNodeInfo *inner; + LDKnativeReplyChannelRange *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNodeInfo; +} LDKReplyChannelRange; /** - * The contents of CResult_NodeInfoDecodeErrorZ + * 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 union LDKCResult_NodeInfoDecodeErrorZPtr { +typedef enum LDKMessageSendEvent_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Used to indicate that we've accepted a channel open and should send the accept_channel + * message provided to the given peer. */ - struct LDKNodeInfo *result; + LDKMessageSendEvent_SendAcceptChannel, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Used to indicate that we've initiated a channel open and should send the open_channel + * message provided to the given peer. */ - struct LDKDecodeError *err; -} LDKCResult_NodeInfoDecodeErrorZPtr; - -/** - * A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::routing::network_graph::NodeInfo on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NodeInfoDecodeErrorZ { + LDKMessageSendEvent_SendOpenChannel, /** - * The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Used to indicate that a funding_created message should be sent to the peer with the given node_id. */ - union LDKCResult_NodeInfoDecodeErrorZPtr contents; + LDKMessageSendEvent_SendFundingCreated, /** - * Whether this CResult_NodeInfoDecodeErrorZ represents a success state. + * Used to indicate that a funding_signed message should be sent to the peer with the given node_id. */ - bool result_ok; -} LDKCResult_NodeInfoDecodeErrorZ; - - - -/** - * Represents the network as nodes and channels between them - */ -typedef struct MUST_USE_STRUCT LDKNetworkGraph { + LDKMessageSendEvent_SendFundingSigned, /** - * A pointer to the opaque Rust object. - * 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. + * Used to indicate that a funding_locked message should be sent to the peer with the given node_id. */ - LDKnativeNetworkGraph *inner; + LDKMessageSendEvent_SendFundingLocked, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. */ - bool is_owned; -} LDKNetworkGraph; - -/** - * The contents of CResult_NetworkGraphDecodeErrorZ - */ -typedef union LDKCResult_NetworkGraphDecodeErrorZPtr { + LDKMessageSendEvent_SendAnnouncementSignatures, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * 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. */ - struct LDKNetworkGraph *result; + LDKMessageSendEvent_UpdateHTLCs, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. */ - struct LDKDecodeError *err; -} LDKCResult_NetworkGraphDecodeErrorZPtr; - -/** - * A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, - * containing a crate::routing::network_graph::NetworkGraph on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NetworkGraphDecodeErrorZ { + LDKMessageSendEvent_SendRevokeAndACK, /** - * The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Used to indicate that a closing_signed message should be sent to the peer with the given node_id. */ - union LDKCResult_NetworkGraphDecodeErrorZPtr contents; + LDKMessageSendEvent_SendClosingSigned, /** - * Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. + * Used to indicate that a shutdown message should be sent to the peer with the given node_id. */ - bool result_ok; -} LDKCResult_NetworkGraphDecodeErrorZ; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_usizeTransactionZ { + LDKMessageSendEvent_SendShutdown, /** - * The element at position 0 + * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. */ - uintptr_t a; + LDKMessageSendEvent_SendChannelReestablish, /** - * The element at position 1 + * 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. */ - struct LDKTransaction b; -} LDKC2Tuple_usizeTransactionZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { + LDKMessageSendEvent_BroadcastChannelAnnouncement, /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Used to indicate that a node_announcement should be broadcast to all peers. */ - struct LDKC2Tuple_usizeTransactionZ *data; + LDKMessageSendEvent_BroadcastNodeAnnouncement, /** - * The number of elements pointed to by `data`. + * Used to indicate that a channel_update should be broadcast to all peers. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_usizeTransactionZZ; - -/** - * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_TxidZ { + LDKMessageSendEvent_BroadcastChannelUpdate, /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Broadcast an error downstream to be handled */ - struct LDKThirtyTwoBytes *data; + LDKMessageSendEvent_HandleError, /** - * The number of elements pointed to by `data`. + * 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. */ - uintptr_t datalen; -} LDKCVec_TxidZ; - -/** - * The contents of CResult_NoneChannelMonitorUpdateErrZ - */ -typedef union LDKCResult_NoneChannelMonitorUpdateErrZPtr { + LDKMessageSendEvent_PaymentFailureNetworkUpdate, /** - * Note that this value is always NULL, as there are no contents in the OK variant + * Query a peer for channels with funding transaction UTXOs in a block range. */ - void *result; + LDKMessageSendEvent_SendChannelRangeQuery, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Request routing gossip messages from a peer for a list of channels identified by + * their short_channel_ids. */ - enum LDKChannelMonitorUpdateErr *err; -} LDKCResult_NoneChannelMonitorUpdateErrZPtr; - -/** - * A CResult_NoneChannelMonitorUpdateErrZ represents the result of a fallible operation, - * containing a () on success and a crate::chain::channelmonitor::ChannelMonitorUpdateErr on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ { + LDKMessageSendEvent_SendShortIdsQuery, /** - * The contents of this CResult_NoneChannelMonitorUpdateErrZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + * emitted during processing of the query. */ - union LDKCResult_NoneChannelMonitorUpdateErrZPtr contents; + LDKMessageSendEvent_SendReplyChannelRange, /** - * Whether this CResult_NoneChannelMonitorUpdateErrZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_NoneChannelMonitorUpdateErrZ; - - + LDKMessageSendEvent_Sentinel, +} LDKMessageSendEvent_Tag; -/** - * 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. - */ -typedef struct MUST_USE_STRUCT LDKHTLCUpdate { +typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { /** - * A pointer to the opaque Rust object. - * 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. + * The node_id of the node which should receive this message */ - LDKnativeHTLCUpdate *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The message which should be sent. */ - bool is_owned; -} LDKHTLCUpdate; - - + struct LDKAcceptChannel msg; +} LDKMessageSendEvent_LDKSendAcceptChannel_Body; -/** - * 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 { +typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { /** - * A pointer to the opaque Rust object. - * 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. + * The node_id of the node which should receive this message */ - LDKnativeOutPoint *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The message which should be sent. */ - bool is_owned; -} LDKOutPoint; + struct LDKOpenChannel msg; +} LDKMessageSendEvent_LDKSendOpenChannel_Body; -/** - * An event to be processed by the ChannelManager. - */ -typedef enum LDKMonitorEvent_Tag { +typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { /** - * A monitor event containing an HTLCUpdate. + * The node_id of the node which should receive this message */ - LDKMonitorEvent_HTLCEvent, + struct LDKPublicKey node_id; /** - * A monitor event that the Channel's commitment transaction was broadcasted. + * The message which should be sent. */ - LDKMonitorEvent_CommitmentTxBroadcasted, + struct LDKFundingCreated msg; +} LDKMessageSendEvent_LDKSendFundingCreated_Body; + +typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { /** - * Must be last for serialization purposes + * The node_id of the node which should receive this message */ - LDKMonitorEvent_Sentinel, -} LDKMonitorEvent_Tag; - -typedef struct MUST_USE_STRUCT LDKMonitorEvent { - LDKMonitorEvent_Tag tag; - union { - struct { - struct LDKHTLCUpdate htlc_event; - }; - struct { - struct LDKOutPoint commitment_tx_broadcasted; - }; - }; -} LDKMonitorEvent; + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKFundingSigned msg; +} LDKMessageSendEvent_LDKSendFundingSigned_Body; -/** - * A dynamically-allocated array of crate::chain::channelmonitor::MonitorEvents of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_MonitorEventZ { +typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The node_id of the node which should receive these message(s) */ - struct LDKMonitorEvent *data; + struct LDKPublicKey node_id; /** - * The number of elements pointed to by `data`. + * The funding_locked message which should be sent. */ - uintptr_t datalen; -} LDKCVec_MonitorEventZ; - - + struct LDKFundingLocked msg; +} LDKMessageSendEvent_LDKSendFundingLocked_Body; -/** - * Information about a spendable output to a P2WSH script. See - * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. - */ -typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { +typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { /** - * A pointer to the opaque Rust object. - * 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. + * The node_id of the node which should receive these message(s) */ - LDKnativeDelayedPaymentOutputDescriptor *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The announcement_signatures message which should be sent. */ - bool is_owned; -} LDKDelayedPaymentOutputDescriptor; - - + struct LDKAnnouncementSignatures msg; +} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; -/** - * Information about a spendable output to our \"payment key\". See - * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this. - */ -typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { +typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { /** - * A pointer to the opaque Rust object. - * 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. + * The node_id of the node which should receive these message(s) */ - LDKnativeStaticPaymentOutputDescriptor *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The update messages which should be sent. ALL messages in the struct should be sent! */ - bool is_owned; -} LDKStaticPaymentOutputDescriptor; + struct LDKCommitmentUpdate updates; +} LDKMessageSendEvent_LDKUpdateHTLCs_Body; -/** - * 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 { +typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { /** - * An output to a script which was provided via KeysInterface directly, either from - * `get_destination_script()` or `get_shutdown_pubkey()`, thus you should already know how to - * spend it. No secret keys are provided as rust-lightning was never given any key. - * 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. + * The node_id of the node which should receive this message */ - LDKSpendableOutputDescriptor_StaticOutput, + struct LDKPublicKey node_id; /** - * 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: - * (MINIMALIF standard rule) - * - * 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 - * Sign::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 - * Sign::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 Sign::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. + * The message which should be sent. */ - LDKSpendableOutputDescriptor_DelayedPaymentOutput, + struct LDKRevokeAndACK msg; +} LDKMessageSendEvent_LDKSendRevokeAndACK_Body; + +typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { /** - * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which - * corresponds to the public key in Sign::pubkeys().payment_point). - * The witness in the spending input, is, thus, simply: - * - * - * These are generally the result of our counterparty having broadcast the current state, - * allowing us to claim the non-HTLC-encumbered outputs immediately. + * The node_id of the node which should receive this message */ - LDKSpendableOutputDescriptor_StaticPaymentOutput, + struct LDKPublicKey node_id; /** - * Must be last for serialization purposes + * The message which should be sent. */ - LDKSpendableOutputDescriptor_Sentinel, -} LDKSpendableOutputDescriptor_Tag; + struct LDKClosingSigned msg; +} LDKMessageSendEvent_LDKSendClosingSigned_Body; -typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { +typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { /** - * The outpoint which is spendable + * The node_id of the node which should receive this message */ - struct LDKOutPoint outpoint; + struct LDKPublicKey node_id; /** - * The output which is referenced by the given outpoint. + * The message which should be sent. */ - struct LDKTxOut output; -} LDKSpendableOutputDescriptor_LDKStaticOutput_Body; - -typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { - LDKSpendableOutputDescriptor_Tag tag; - union { - LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; - struct { - struct LDKDelayedPaymentOutputDescriptor delayed_payment_output; - }; - struct { - struct LDKStaticPaymentOutputDescriptor static_payment_output; - }; - }; -} LDKSpendableOutputDescriptor; + struct LDKShutdown msg; +} LDKMessageSendEvent_LDKSendShutdown_Body; -/** - * A dynamically-allocated array of crate::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_SpendableOutputDescriptorZ { +typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The node_id of the node which should receive this message */ - struct LDKSpendableOutputDescriptor *data; + struct LDKPublicKey node_id; /** - * The number of elements pointed to by `data`. + * The message which should be sent. */ - uintptr_t datalen; -} LDKCVec_SpendableOutputDescriptorZ; + struct LDKChannelReestablish msg; +} LDKMessageSendEvent_LDKSendChannelReestablish_Body; -/** - * 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 { +typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { /** - * 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! + * The channel_announcement which should be sent. */ - LDKEvent_FundingGenerationReady, + struct LDKChannelAnnouncement msg; /** - * 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. + * The followup channel_update which should be sent. */ - LDKEvent_PaymentReceived, + struct LDKChannelUpdate update_msg; +} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; + +typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { /** - * 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)! + * The node_announcement which should be sent. */ - LDKEvent_PaymentSent, + struct LDKNodeAnnouncement msg; +} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; + +typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { /** - * 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)! + * The channel_update which should be sent. */ - LDKEvent_PaymentFailed, + struct LDKChannelUpdate msg; +} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; + +typedef struct LDKMessageSendEvent_LDKHandleError_Body { /** - * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a - * time in the future. + * The node_id of the node which should receive this message */ - LDKEvent_PendingHTLCsForwardable, + struct LDKPublicKey node_id; /** - * 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. + * The action which should be taken. */ - LDKEvent_SpendableOutputs, + struct LDKErrorAction action; +} LDKMessageSendEvent_LDKHandleError_Body; + +typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body { /** - * Must be last for serialization purposes + * The channel/node update which should be sent to NetGraphMsgHandler */ - LDKEvent_Sentinel, -} LDKEvent_Tag; + struct LDKHTLCFailChannelUpdate update; +} LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body; -typedef struct LDKEvent_LDKFundingGenerationReady_Body { +typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { /** - * The random channel_id we picked which you'll need to pass into - * ChannelManager::funding_transaction_generated. + * The node_id of this message recipient */ - struct LDKThirtyTwoBytes temporary_channel_id; + struct LDKPublicKey node_id; /** - * The value, in satoshis, that the output should have. + * The query_channel_range which should be sent. */ - uint64_t channel_value_satoshis; + struct LDKQueryChannelRange msg; +} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; + +typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { /** - * The script which should be used in the transaction output. + * The node_id of this message recipient */ - struct LDKCVec_u8Z output_script; + struct LDKPublicKey node_id; /** - * The value passed in to ChannelManager::create_channel + * The query_short_channel_ids which should be sent. */ - uint64_t user_channel_id; -} LDKEvent_LDKFundingGenerationReady_Body; + struct LDKQueryShortChannelIds msg; +} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; -typedef struct LDKEvent_LDKPaymentReceived_Body { +typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { /** - * The hash for which the preimage should be handed to the ChannelManager. + * The node_id of this message recipient */ - struct LDKThirtyTwoBytes payment_hash; + struct LDKPublicKey node_id; /** - * The \"payment secret\". This authenticates the sender to the recipient, preventing a - * number of deanonymization attacks during the routing process. - * As nodes upgrade, the invoices you provide should likely migrate to setting the - * payment_secret feature to required, at which point you should fail_backwards any HTLCs - * which have a None here. - * Until then, however, values of None should be ignored, and only incorrect Some values - * should result in an HTLC fail_backwards. - * Note that, in any case, this value must be passed as-is to any fail or claim calls as - * the HTLC index includes this value. - */ - struct LDKThirtyTwoBytes payment_secret; - /** - * The value, in thousandths of a satoshi, that this payment is for. Note that you must - * compare this to the expected value before accepting the payment (as otherwise you are - * providing proof-of-payment for less than the value you expected!). - */ - uint64_t amt; -} LDKEvent_LDKPaymentReceived_Body; - -typedef struct LDKEvent_LDKPaymentSent_Body { - /** - * The preimage to the hash given to ChannelManager::send_payment. - * Note that this serves as a payment receipt, if you wish to have such a thing, you must - * store it somehow! - */ - struct LDKThirtyTwoBytes payment_preimage; -} LDKEvent_LDKPaymentSent_Body; - -typedef struct LDKEvent_LDKPaymentFailed_Body { - /** - * The hash which was given to ChannelManager::send_payment. - */ - struct LDKThirtyTwoBytes payment_hash; - /** - * Indicates the payment was rejected for some reason by the recipient. This implies that - * the payment has failed, not just the route in question. If this is not set, you may - * retry the payment via a different route. - */ - bool rejected_by_dest; -} LDKEvent_LDKPaymentFailed_Body; - -typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { - /** - * The minimum amount of time that should be waited prior to calling - * process_pending_htlc_forwards. To increase the effort required to correlate payments, - * you should wait a random amount of time in roughly the range (now + time_forwardable, - * now + 5*time_forwardable). - */ - uint64_t time_forwardable; -} LDKEvent_LDKPendingHTLCsForwardable_Body; - -typedef struct LDKEvent_LDKSpendableOutputs_Body { - /** - * The outputs which you should store as spendable by you. + * The reply_channel_range which should be sent. */ - struct LDKCVec_SpendableOutputDescriptorZ outputs; -} LDKEvent_LDKSpendableOutputs_Body; + struct LDKReplyChannelRange msg; +} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; -typedef struct MUST_USE_STRUCT LDKEvent { - LDKEvent_Tag tag; +typedef struct MUST_USE_STRUCT LDKMessageSendEvent { + LDKMessageSendEvent_Tag tag; union { - LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; - 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; + 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_LDKSendChannelRangeQuery_Body send_channel_range_query; + LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; + LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; }; -} LDKEvent; +} LDKMessageSendEvent; /** - * A dynamically-allocated array of crate::util::events::Events of arbitrary size. + * A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_EventZ { +typedef struct LDKCVec_MessageSendEventZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKEvent *data; + struct LDKMessageSendEvent *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_EventZ; +} LDKCVec_MessageSendEventZ; /** - * The contents of CResult_OutPointDecodeErrorZ + * The contents of CResult_boolLightningErrorZ */ -typedef union LDKCResult_OutPointDecodeErrorZPtr { +typedef union LDKCResult_boolLightningErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOutPoint *result; + bool *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_OutPointDecodeErrorZPtr; + struct LDKLightningError *err; +} LDKCResult_boolLightningErrorZPtr; /** - * A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, - * containing a crate::chain::transaction::OutPoint on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_boolLightningErrorZ represents the result of a fallible operation, + * containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_OutPointDecodeErrorZ { +typedef struct LDKCResult_boolLightningErrorZ { /** - * The contents of this CResult_OutPointDecodeErrorZ, accessible via either + * The contents of this CResult_boolLightningErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_OutPointDecodeErrorZPtr contents; + union LDKCResult_boolLightningErrorZPtr contents; /** - * Whether this CResult_OutPointDecodeErrorZ represents a success state. + * Whether this CResult_boolLightningErrorZ represents a success state. */ bool result_ok; -} LDKCResult_OutPointDecodeErrorZ; - - +} LDKCResult_boolLightningErrorZ; /** - * An update generated by the underlying Channel itself which contains some new information the - * ChannelMonitor should be made aware of. + * A tuple of 3 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { +typedef struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { /** - * A pointer to the opaque Rust object. - * 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. + * The element at position 0 */ - LDKnativeChannelMonitorUpdate *inner; + struct LDKChannelAnnouncement a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKChannelMonitorUpdate; + struct LDKChannelUpdate b; + /** + * The element at position 2 + */ + struct LDKChannelUpdate c; +} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; /** - * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + * A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { +typedef struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKChannelMonitorUpdate *result; + struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; /** - * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::lightning::ln::msgs::NodeAnnouncements of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { +typedef struct LDKCVec_NodeAnnouncementZ { /** - * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; + struct LDKNodeAnnouncement *data; /** - * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_NodeAnnouncementZ; /** - * The contents of CResult_HTLCUpdateDecodeErrorZ + * The contents of CResult_NoneLightningErrorZ */ -typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { +typedef union LDKCResult_NoneLightningErrorZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKHTLCUpdate *result; + void *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_HTLCUpdateDecodeErrorZPtr; + struct LDKLightningError *err; +} LDKCResult_NoneLightningErrorZPtr; /** - * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::chain::channelmonitor::HTLCUpdate on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_NoneLightningErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { +typedef struct LDKCResult_NoneLightningErrorZ { /** - * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_NoneLightningErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; + union LDKCResult_NoneLightningErrorZPtr contents; /** - * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. + * Whether this CResult_NoneLightningErrorZ represents a success state. */ bool result_ok; -} LDKCResult_HTLCUpdateDecodeErrorZ; +} LDKCResult_NoneLightningErrorZ; + +/** + * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PublicKeyZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKPublicKey *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_PublicKeyZ; /** - * 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. + * 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/socket_disconnected calls for the + * descriptor. */ -typedef struct MUST_USE_STRUCT LDKMonitorUpdateError { +typedef struct MUST_USE_STRUCT LDKPeerHandleError { /** * A pointer to the opaque Rust object. * 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; + LDKnativePeerHandleError *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKMonitorUpdateError; +} LDKPeerHandleError; /** - * The contents of CResult_NoneMonitorUpdateErrorZ + * The contents of CResult_CVec_u8ZPeerHandleErrorZ */ -typedef union LDKCResult_NoneMonitorUpdateErrorZPtr { +typedef union LDKCResult_CVec_u8ZPeerHandleErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKCVec_u8Z *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKMonitorUpdateError *err; -} LDKCResult_NoneMonitorUpdateErrorZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_CVec_u8ZPeerHandleErrorZPtr; /** - * A CResult_NoneMonitorUpdateErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::chain::channelmonitor::MonitorUpdateError on failure. + * A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneMonitorUpdateErrorZ { +typedef struct LDKCResult_CVec_u8ZPeerHandleErrorZ { /** - * The contents of this CResult_NoneMonitorUpdateErrorZ, accessible via either + * The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneMonitorUpdateErrorZPtr contents; + union LDKCResult_CVec_u8ZPeerHandleErrorZPtr contents; /** - * Whether this CResult_NoneMonitorUpdateErrorZ represents a success state. + * Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneMonitorUpdateErrorZ; +} LDKCResult_CVec_u8ZPeerHandleErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_NonePeerHandleErrorZ */ -typedef struct LDKC2Tuple_OutPointScriptZ { +typedef union LDKCResult_NonePeerHandleErrorZPtr { /** - * The element at position 0 + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKOutPoint a; + void *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_OutPointScriptZ; + struct LDKPeerHandleError *err; +} LDKCResult_NonePeerHandleErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_u32ScriptZ { +typedef struct LDKCResult_NonePeerHandleErrorZ { /** - * The element at position 0 + * The contents of this CResult_NonePeerHandleErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint32_t a; + union LDKCResult_NonePeerHandleErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_NonePeerHandleErrorZ represents a success state. */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_u32ScriptZ; + bool result_ok; +} LDKCResult_NonePeerHandleErrorZ; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_boolPeerHandleErrorZ */ -typedef struct LDKCVec_C2Tuple_u32ScriptZZ { +typedef union LDKCResult_boolPeerHandleErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_u32ScriptZ *data; + bool *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_u32ScriptZZ; + struct LDKPeerHandleError *err; +} LDKCResult_boolPeerHandleErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, + * containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { +typedef struct LDKCResult_boolPeerHandleErrorZ { /** - * The element at position 0 + * The contents of this CResult_boolPeerHandleErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes a; + union LDKCResult_boolPeerHandleErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_boolPeerHandleErrorZ represents a success state. */ - struct LDKCVec_C2Tuple_u32ScriptZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; + bool result_ok; +} LDKCResult_boolPeerHandleErrorZ; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_TxOutAccessErrorZ */ -typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { +typedef union LDKCResult_TxOutAccessErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; + struct LDKTxOut *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; + enum LDKAccessError *err; +} LDKCResult_TxOutAccessErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_TxOutAccessErrorZ represents the result of a fallible operation, + * containing a crate::c_types::TxOut on success and a crate::lightning::chain::AccessError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_TransactionZ { +typedef struct LDKCResult_TxOutAccessErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_TxOutAccessErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKTransaction *data; + union LDKCResult_TxOutAccessErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_TxOutAccessErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_TransactionZ; + bool result_ok; +} LDKCResult_TxOutAccessErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not */ -typedef struct LDKC2Tuple_u32TxOutZ { +typedef enum LDKCOption_C2Tuple_usizeTransactionZZ_Tag { /** - * The element at position 0 + * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ */ - uint32_t a; + LDKCOption_C2Tuple_usizeTransactionZZ_Some, /** - * The element at position 1 + * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing */ - struct LDKTxOut b; -} LDKC2Tuple_u32TxOutZ; + LDKCOption_C2Tuple_usizeTransactionZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_C2Tuple_usizeTransactionZZ_Sentinel, +} LDKCOption_C2Tuple_usizeTransactionZZ_Tag; + +typedef struct LDKCOption_C2Tuple_usizeTransactionZZ { + LDKCOption_C2Tuple_usizeTransactionZZ_Tag tag; + union { + struct { + struct LDKC2Tuple_usizeTransactionZ some; + }; + }; +} LDKCOption_C2Tuple_usizeTransactionZZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. - * This corresponds to std::vector in C++ + * Details about one direction of a channel. Received + * within a channel update. */ -typedef struct LDKCVec_C2Tuple_u32TxOutZZ { +typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * 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. */ - struct LDKC2Tuple_u32TxOutZ *data; + LDKnativeDirectionalChannelInfo *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_u32TxOutZZ; + bool is_owned; +} LDKDirectionalChannelInfo; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_DirectionalChannelInfoDecodeErrorZ */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { +typedef union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes a; + struct LDKDirectionalChannelInfo *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_C2Tuple_u32TxOutZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; + struct LDKDecodeError *err; +} LDKCResult_DirectionalChannelInfoDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_DirectionalChannelInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::DirectionalChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_TransactionOutputsZ { +typedef struct LDKCResult_DirectionalChannelInfoDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_DirectionalChannelInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data; + union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_DirectionalChannelInfoDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_TransactionOutputsZ; + bool result_ok; +} LDKCResult_DirectionalChannelInfoDecodeErrorZ; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * Details about a channel (both directions). + * Received within a channel announcement. */ -typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ { +typedef struct MUST_USE_STRUCT LDKChannelInfo { /** - * The element at position 0 + * A pointer to the opaque Rust object. + * 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. */ - struct LDKSignature a; + LDKnativeChannelInfo *inner; /** - * The element at position 1 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCVec_SignatureZ b; -} LDKC2Tuple_SignatureCVec_SignatureZZ; + bool is_owned; +} LDKChannelInfo; /** - * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ + * The contents of CResult_ChannelInfoDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { +typedef union LDKCResult_ChannelInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_SignatureCVec_SignatureZZ *result; + struct LDKChannelInfo *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelInfoDecodeErrorZPtr; /** - * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. + * A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { +typedef struct LDKCResult_ChannelInfoDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either + * The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents; + union LDKCResult_ChannelInfoDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. + * Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; +} LDKCResult_ChannelInfoDecodeErrorZ; + + /** - * The contents of CResult_SignatureNoneZ + * Fees for routing via a given channel or a node */ -typedef union LDKCResult_SignatureNoneZPtr { +typedef struct MUST_USE_STRUCT LDKRoutingFees { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * 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. */ - struct LDKSignature *result; + LDKnativeRoutingFees *inner; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void *err; -} LDKCResult_SignatureNoneZPtr; + bool is_owned; +} LDKRoutingFees; /** - * A CResult_SignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Signature on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * The contents of CResult_RoutingFeesDecodeErrorZ */ -typedef struct LDKCResult_SignatureNoneZ { +typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { /** - * The contents of this CResult_SignatureNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - union LDKCResult_SignatureNoneZPtr contents; + struct LDKRoutingFees *result; /** - * Whether this CResult_SignatureNoneZ represents a success state. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool result_ok; -} LDKCResult_SignatureNoneZ; - - + struct LDKDecodeError *err; +} LDKCResult_RoutingFeesDecodeErrorZPtr; /** - * The unsigned part of a channel_announcement + * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { +typedef struct LDKCResult_RoutingFeesDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * 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. + * The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeUnsignedChannelAnnouncement *inner; + union LDKCResult_RoutingFeesDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKUnsignedChannelAnnouncement; + bool result_ok; +} LDKCResult_RoutingFeesDecodeErrorZ; /** - * A trait to sign lightning channel transactions as described in BOLT 3. - * - * Signing services could be implemented on a hardware wallet. In this case, - * the current Sign 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. + * A 4-byte byte array. */ -typedef struct LDKBaseSign { +typedef struct LDKFourBytes { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The four bytes */ - void *this_arg; + uint8_t data[4]; +} LDKFourBytes; + +/** + * A 16-byte byte array. + */ +typedef struct LDKSixteenBytes { /** - * Gets the per-commitment point for a specific commitment number - * - * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. + * The sixteen bytes */ - struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); + uint8_t data[16]; +} LDKSixteenBytes; + +/** + * A 10-byte byte array. + */ +typedef struct LDKTenBytes { /** - * 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. + * The ten bytes */ - struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); + uint8_t data[10]; +} LDKTenBytes; + +/** + * An address which can be used to connect to a remote peer + */ +typedef enum LDKNetAddress_Tag { /** - * Gets the holder's channel public keys and basepoints + * An IPv4 address/port on which the peer is listening. */ - struct LDKChannelPublicKeys pubkeys; + LDKNetAddress_IPv4, /** - * 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. + * An IPv6 address/port on which the peer is listening. */ - void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR ); + LDKNetAddress_IPv6, /** - * Gets an arbitrary identifier describing the set of keys which are provided back to you in - * some SpendableOutputDescriptor types. This should be sufficient to identify this - * Sign object uniquely and lookup or re-derive its keys. + * An old-style Tor onion address/port on which the peer is listening. */ - struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); + LDKNetAddress_OnionV2, /** - * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. - * - * Note that if signing fails or is rejected, the channel will be force-closed. + * 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\". */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx); + LDKNetAddress_OnionV3, /** - * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. - * This will only ever be called with a non-revoked commitment_tx. This will be called with the - * latest commitment_tx when we initiate a force-close. - * This will be called with the previous latest, just to get claiming HTLC signatures, if we are - * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to - * the latest. - * This may be called multiple times for the same transaction. - * - * An external signer implementation should check that the commitment has not been revoked. - * - * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. + * Must be last for serialization purposes */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); + LDKNetAddress_Sentinel, +} LDKNetAddress_Tag; + +typedef struct LDKNetAddress_LDKIPv4_Body { /** - * 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 _holder_ secret key and does - * not allow the spending of any funds by itself (you need our holder 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). + * The 4-byte IPv4 address */ - struct LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + struct LDKFourBytes addr; /** - * Create a signature for a claiming transaction for a HTLC output on a counterparty's 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. + * The port on which the node is listening */ - struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + uint16_t port; +} LDKNetAddress_LDKIPv4_Body; + +typedef struct LDKNetAddress_LDKIPv6_Body { /** - * 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. + * The 16-byte IPv6 address */ - struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, struct LDKTransaction closing_tx); + struct LDKSixteenBytes addr; /** - * 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. + * The port on which the node is listening */ - struct LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); + uint16_t port; +} LDKNetAddress_LDKIPv6_Body; + +typedef struct LDKNetAddress_LDKOnionV2_Body { /** - * Set the counterparty static channel data, including basepoints, - * counterparty_selected/holder_selected_contest_delay and funding outpoint. - * This is done as soon as the funding outpoint is known. Since these are static channel data, - * they MUST NOT be allowed to change to different values once set. - * - * channel_parameters.is_populated() MUST be true. - * - * We bind holder_selected_contest_delay late here for API convenience. - * - * Will be called before any signatures are applied. + * The bytes (usually encoded in base32 with \".onion\" appended) */ - void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + struct LDKTenBytes addr; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The port on which the node is listening */ - void (*free)(void *this_arg); -} LDKBaseSign; + uint16_t port; +} LDKNetAddress_LDKOnionV2_Body; -/** - * A cloneable signer. - * - * Although we require signers to be cloneable, it may be useful for developers to be able to use - * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait, - * which implies Sized, into this derived trait. - */ -typedef struct LDKSign { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKNetAddress_LDKOnionV3_Body { /** - * Implementation of BaseSign for this object. + * The ed25519 long-term public key of the peer */ - struct LDKBaseSign BaseSign; + struct LDKThirtyTwoBytes ed25519_pubkey; /** - * Creates a copy of the BaseSign, for a copy of this Sign. - * Because BaseSign doesn't natively support copying itself, you have to provide a full copy implementation here. + * The checksum of the pubkey and version, as included in the onion address */ - struct LDKBaseSign (*BaseSign_clone)(const struct LDKBaseSign *NONNULL_PTR orig_BaseSign); + uint16_t checksum; /** - * Serialize the object into a byte array + * The version byte, as defined by the Tor Onion v3 spec. */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + uint8_t version; /** - * Creates a copy of the object pointed to by this_arg, for a copy of this Sign. - * Note that the ultimate copy of the Sign will have all function pointers the same as the original. - * May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new Sign. + * The port on which the node is listening */ - void *(*clone)(const void *this_arg); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + uint16_t port; +} LDKNetAddress_LDKOnionV3_Body; + +typedef struct MUST_USE_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; + +/** + * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_NetAddressZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void (*free)(void *this_arg); -} LDKSign; + struct LDKNetAddress *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_NetAddressZ; /** - * 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. - * - * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which - * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along - * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the - * returned block hash and the the current chain and then reconnecting blocks to get to the - * best chain) upon deserializing the object! + * Information received in the latest node_announcement from this node. */ -typedef struct MUST_USE_STRUCT LDKChannelMonitor { +typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeChannelMonitor *inner; + LDKnativeNodeAnnouncementInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelMonitor; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { - /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 - */ - struct LDKChannelMonitor b; -} LDKC2Tuple_BlockHashChannelMonitorZ; +} LDKNodeAnnouncementInfo; /** - * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ + * The contents of CResult_NodeAnnouncementInfoDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +typedef union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_BlockHashChannelMonitorZ *result; + struct LDKNodeAnnouncementInfo *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr; +} LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr; /** - * A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::NodeAnnouncementInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +typedef struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either + * The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr contents; + union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. + * Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; +} LDKCResult_NodeAnnouncementInfoDecodeErrorZ; /** - * The contents of CResult_TxOutAccessErrorZ + * A dynamically-allocated array of u64s of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_TxOutAccessErrorZPtr { +typedef struct LDKCVec_u64Z { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + uint64_t *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_u64Z; + + + +/** + * Details about a node in the network, known from the network announcement. + */ +typedef struct MUST_USE_STRUCT LDKNodeInfo { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeNodeInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKNodeInfo; + +/** + * The contents of CResult_NodeInfoDecodeErrorZ + */ +typedef union LDKCResult_NodeInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTxOut *result; + struct LDKNodeInfo *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKAccessError *err; -} LDKCResult_TxOutAccessErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_NodeInfoDecodeErrorZPtr; /** - * A CResult_TxOutAccessErrorZ represents the result of a fallible operation, - * containing a crate::c_types::TxOut on success and a crate::chain::AccessError on failure. + * A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::NodeInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_TxOutAccessErrorZ { +typedef struct LDKCResult_NodeInfoDecodeErrorZ { /** - * The contents of this CResult_TxOutAccessErrorZ, accessible via either + * The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_TxOutAccessErrorZPtr contents; + union LDKCResult_NodeInfoDecodeErrorZPtr contents; /** - * Whether this CResult_TxOutAccessErrorZ represents a success state. + * Whether this CResult_NodeInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_TxOutAccessErrorZ; +} LDKCResult_NodeInfoDecodeErrorZ; + + /** - * An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not + * Represents the network as nodes and channels between them */ -typedef enum LDKCOption_C2Tuple_usizeTransactionZZ_Tag { - /** - * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ - */ - LDKCOption_C2Tuple_usizeTransactionZZ_Some, +typedef struct MUST_USE_STRUCT LDKNetworkGraph { /** - * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing + * A pointer to the opaque Rust object. + * 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. */ - LDKCOption_C2Tuple_usizeTransactionZZ_None, + LDKnativeNetworkGraph *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_C2Tuple_usizeTransactionZZ_Sentinel, -} LDKCOption_C2Tuple_usizeTransactionZZ_Tag; - -typedef struct LDKCOption_C2Tuple_usizeTransactionZZ { - LDKCOption_C2Tuple_usizeTransactionZZ_Tag tag; - union { - struct { - struct LDKC2Tuple_usizeTransactionZ some; - }; - }; -} LDKCOption_C2Tuple_usizeTransactionZZ; + bool is_owned; +} LDKNetworkGraph; /** - * 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! + * The contents of CResult_NetworkGraphDecodeErrorZ */ -typedef struct LDKStr { +typedef union LDKCResult_NetworkGraphDecodeErrorZPtr { /** - * A pointer to the string's bytes, in UTF8 encoding + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - const uint8_t *chars; + struct LDKNetworkGraph *result; /** - * The number of bytes (not characters!) pointed to by `chars` + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t len; -} LDKStr; + struct LDKDecodeError *err; +} LDKCResult_NetworkGraphDecodeErrorZPtr; /** - * Indicates an error on the client's part (usually some variant of attempting to use too-low or - * too-high values) + * A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::NetworkGraph on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKAPIError_Tag { +typedef struct LDKCResult_NetworkGraphDecodeErrorZ { /** - * 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. + * The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKAPIError_APIMisuseError, + union LDKCResult_NetworkGraphDecodeErrorZPtr contents; /** - * 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. + * Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. */ - LDKAPIError_FeeRateTooHigh, + bool result_ok; +} LDKCResult_NetworkGraphDecodeErrorZ; + + + +/** + * Features used within an `init` message. + */ +typedef struct MUST_USE_STRUCT LDKInitFeatures { /** - * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, - * too-many-hops, etc). + * A pointer to the opaque Rust object. + * 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. */ - LDKAPIError_RouteError, + LDKnativeInitFeatures *inner; /** - * 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. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKAPIError_ChannelUnavailable, + bool is_owned; +} LDKInitFeatures; + +/** + * The contents of CResult_InitFeaturesDecodeErrorZ + */ +typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { /** - * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the - * attempted action to fail. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKAPIError_MonitorUpdateFailed, + struct LDKInitFeatures *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKAPIError_Sentinel, -} LDKAPIError_Tag; + struct LDKDecodeError *err; +} LDKCResult_InitFeaturesDecodeErrorZPtr; -typedef struct LDKAPIError_LDKAPIMisuseError_Body { - /** - * A human-readable error message - */ - struct LDKCVec_u8Z err; -} LDKAPIError_LDKAPIMisuseError_Body; - -typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { +/** + * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InitFeaturesDecodeErrorZ { /** - * A human-readable error message + * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCVec_u8Z err; + union LDKCResult_InitFeaturesDecodeErrorZPtr contents; /** - * The feerate which was too high. + * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. */ - uint32_t feerate; -} LDKAPIError_LDKFeeRateTooHigh_Body; + bool result_ok; +} LDKCResult_InitFeaturesDecodeErrorZ; -typedef struct LDKAPIError_LDKRouteError_Body { + + +/** + * Features used within a `node_announcement` message. + */ +typedef struct MUST_USE_STRUCT LDKNodeFeatures { /** - * A human-readable error message + * A pointer to the opaque Rust object. + * 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. */ - struct LDKStr err; -} LDKAPIError_LDKRouteError_Body; - -typedef struct LDKAPIError_LDKChannelUnavailable_Body { + LDKnativeNodeFeatures *inner; /** - * A human-readable error message + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCVec_u8Z err; -} LDKAPIError_LDKChannelUnavailable_Body; - -typedef struct MUST_USE_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; + bool is_owned; +} LDKNodeFeatures; /** - * The contents of CResult_NoneAPIErrorZ + * The contents of CResult_NodeFeaturesDecodeErrorZ */ -typedef union LDKCResult_NoneAPIErrorZPtr { +typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKNodeFeatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKAPIError *err; -} LDKCResult_NoneAPIErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_NodeFeaturesDecodeErrorZPtr; /** - * A CResult_NoneAPIErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::util::errors::APIError on failure. + * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneAPIErrorZ { +typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { /** - * The contents of this CResult_NoneAPIErrorZ, accessible via either + * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneAPIErrorZPtr contents; + union LDKCResult_NodeFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_NoneAPIErrorZ represents a success state. + * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneAPIErrorZ; +} LDKCResult_NodeFeaturesDecodeErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. - * This corresponds to std::vector in C++ + * Features used within a `channel_announcement` message. */ -typedef struct LDKCVec_CResult_NoneAPIErrorZZ { +typedef struct MUST_USE_STRUCT LDKChannelFeatures { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * 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. */ - struct LDKCResult_NoneAPIErrorZ *data; + LDKnativeChannelFeatures *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_CResult_NoneAPIErrorZZ; + bool is_owned; +} LDKChannelFeatures; /** - * A dynamically-allocated array of crate::util::errors::APIErrors of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_ChannelFeaturesDecodeErrorZ */ -typedef struct LDKCVec_APIErrorZ { +typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKAPIError *data; + struct LDKChannelFeatures *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_APIErrorZ; + struct LDKDecodeError *err; +} LDKCResult_ChannelFeaturesDecodeErrorZPtr; + +/** + * A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { + /** + * The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ChannelFeaturesDecodeErrorZPtr contents; + /** + * Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ChannelFeaturesDecodeErrorZ; /** - * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels + * Features used within an invoice. */ -typedef struct MUST_USE_STRUCT LDKChannelDetails { +typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeChannelDetails *inner; + LDKnativeInvoiceFeatures *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelDetails; +} LDKInvoiceFeatures; /** - * A dynamically-allocated array of crate::ln::channelmanager::ChannelDetailss of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_InvoiceFeaturesDecodeErrorZ */ -typedef struct LDKCVec_ChannelDetailsZ { +typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelDetails *data; + struct LDKInvoiceFeatures *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_ChannelDetailsZ; + struct LDKDecodeError *err; +} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; /** - * 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. + * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKPaymentSendFailure_Tag { - /** - * A parameter which was passed to send_payment was invalid, preventing us from attempting to - * send the payment at all. No channel state has been changed or messages sent to peers, and - * once you've changed the parameter at error, you can freely retry the payment in full. - */ - LDKPaymentSendFailure_ParameterError, - /** - * A parameter in a single path which was passed to send_payment was invalid, preventing us - * from attempting to send the payment at all. No channel state has been changed or messages - * sent to peers, and once you've changed the parameter at error, you can freely retry the - * payment in full. - * - * The results here are ordered the same as the paths in the route object which was passed to - * send_payment. - */ - LDKPaymentSendFailure_PathParameterError, - /** - * All paths which were attempted failed to send, with no channel state change taking place. - * You can freely retry the payment in full (though you probably want to do so over different - * paths than the ones selected). - */ - LDKPaymentSendFailure_AllFailedRetrySafe, +typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { /** - * Some paths which were attempted failed to send, though possibly not all. At least some - * paths have irrevocably committed to the HTLC and retrying the payment in full would result - * in over-/re-payment. - * - * The results here are ordered the same as the paths in the route object which was passed to - * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely - * retried (though there is currently no API with which to do so). - * - * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried - * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the - * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel - * with the latest update_id. + * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKPaymentSendFailure_PartialFailure, + union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. */ - LDKPaymentSendFailure_Sentinel, -} LDKPaymentSendFailure_Tag; - -typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { - LDKPaymentSendFailure_Tag tag; - union { - struct { - struct LDKAPIError parameter_error; - }; - struct { - struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; - }; - struct { - struct LDKCVec_APIErrorZ all_failed_retry_safe; - }; - struct { - struct LDKCVec_CResult_NoneAPIErrorZZ partial_failure; - }; - }; -} LDKPaymentSendFailure; + bool result_ok; +} LDKCResult_InvoiceFeaturesDecodeErrorZ; /** - * The contents of CResult_NonePaymentSendFailureZ + * The contents of CResult_NetAddressu8Z */ -typedef union LDKCResult_NonePaymentSendFailureZPtr { +typedef union LDKCResult_NetAddressu8ZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKNetAddress *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentSendFailure *err; -} LDKCResult_NonePaymentSendFailureZPtr; + uint8_t *err; +} LDKCResult_NetAddressu8ZPtr; /** - * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, - * containing a () on success and a crate::ln::channelmanager::PaymentSendFailure on failure. + * A CResult_NetAddressu8Z represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NetAddress on success and a u8 on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NonePaymentSendFailureZ { +typedef struct LDKCResult_NetAddressu8Z { /** - * The contents of this CResult_NonePaymentSendFailureZ, accessible via either + * The contents of this CResult_NetAddressu8Z, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NonePaymentSendFailureZPtr contents; + union LDKCResult_NetAddressu8ZPtr contents; /** - * Whether this CResult_NonePaymentSendFailureZ represents a success state. + * Whether this CResult_NetAddressu8Z represents a success state. */ bool result_ok; -} LDKCResult_NonePaymentSendFailureZ; +} LDKCResult_NetAddressu8Z; /** - * A dynamically-allocated array of crate::chain::channelmonitor::ChannelMonitors of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_CResult_NetAddressu8ZDecodeErrorZ */ -typedef struct LDKCVec_ChannelMonitorZ { +typedef union LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCResult_NetAddressu8Z *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr; + +/** + * A CResult_CResult_NetAddressu8ZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CResult_NetAddressu8Z on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ { + /** + * The contents of this CResult_CResult_NetAddressu8ZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr contents; + /** + * Whether this CResult_CResult_NetAddressu8ZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_CResult_NetAddressu8ZDecodeErrorZ; + + + +/** + * An update_add_htlc message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeUpdateAddHTLC *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUpdateAddHTLC; + +/** + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_UpdateAddHTLCZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKChannelMonitor *data; + struct LDKUpdateAddHTLC *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_ChannelMonitorZ; +} LDKCVec_UpdateAddHTLCZ; + + /** - * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as - * blocks are connected and disconnected. - * - * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are - * responsible for maintaining a set of monitors such that they can be updated accordingly as - * channel state changes and HTLCs are resolved. See method documentation for specific - * requirements. - * - * Implementations **must** ensure that updates are successfully applied and persisted upon method - * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down - * without taking any further action such as persisting the current state. - * - * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing - * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it - * could result in a revoked transaction being broadcast, allowing the counterparty to claim all - * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle - * multiple instances. - * - * [`ChannelMonitor`]: channelmonitor::ChannelMonitor - * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr - * [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure + * An update_fulfill_htlc message to be sent or received from a peer */ -typedef struct LDKWatch { +typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the opaque Rust object. + * 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. */ - void *this_arg; + LDKnativeUpdateFulfillHTLC *inner; /** - * Watches a channel identified by `funding_txo` using `monitor`. - * - * Implementations are responsible for watching the chain for the funding transaction along - * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means - * calling [`block_connected`] and [`block_disconnected`] on the monitor. - * - * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch - * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected - * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + bool is_owned; +} LDKUpdateFulfillHTLC; + +/** + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_UpdateFulfillHTLCZ { /** - * Updates a channel identified by `funding_txo` by applying `update` to its monitor. - * - * Implementations must call [`update_monitor`] with the given update. See - * [`ChannelMonitorUpdateErr`] for invariants around returning an error. - * - * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor - * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); + struct LDKUpdateFulfillHTLC *data; /** - * Returns any monitor events since the last call. Subsequent calls must only return new - * events. + * The number of elements pointed to by `data`. */ - struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg); + uintptr_t datalen; +} LDKCVec_UpdateFulfillHTLCZ; + + + +/** + * An update_fail_htlc message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the opaque Rust object. + * 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. */ - void (*free)(void *this_arg); -} LDKWatch; + LDKnativeUpdateFailHTLC *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUpdateFailHTLC; /** - * An interface to send a transaction to the Bitcoin network. + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKBroadcasterInterface { +typedef struct LDKCVec_UpdateFailHTLCZ { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void *this_arg; + struct LDKUpdateFailHTLC *data; /** - * Sends a transaction out to (hopefully) be mined. + * The number of elements pointed to by `data`. */ - void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); + uintptr_t datalen; +} LDKCVec_UpdateFailHTLCZ; + + + +/** + * An update_fail_malformed_htlc message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the opaque Rust object. + * 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. */ - void (*free)(void *this_arg); -} LDKBroadcasterInterface; + LDKnativeUpdateFailMalformedHTLC *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUpdateFailMalformedHTLC; /** - * The contents of CResult_SignDecodeErrorZ + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_SignDecodeErrorZPtr { +typedef struct LDKCVec_UpdateFailMalformedHTLCZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKUpdateFailMalformedHTLC *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_UpdateFailMalformedHTLCZ; + +/** + * The contents of CResult_AcceptChannelDecodeErrorZ + */ +typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSign *result; + struct LDKAcceptChannel *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_SignDecodeErrorZPtr; +} LDKCResult_AcceptChannelDecodeErrorZPtr; /** - * A CResult_SignDecodeErrorZ represents the result of a fallible operation, - * containing a crate::chain::keysinterface::Sign on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SignDecodeErrorZ { +typedef struct LDKCResult_AcceptChannelDecodeErrorZ { /** - * The contents of this CResult_SignDecodeErrorZ, accessible via either + * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignDecodeErrorZPtr contents; + union LDKCResult_AcceptChannelDecodeErrorZPtr contents; /** - * Whether this CResult_SignDecodeErrorZ represents a success state. + * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SignDecodeErrorZ; +} LDKCResult_AcceptChannelDecodeErrorZ; /** - * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not - * own the memory pointed to by data. + * The contents of CResult_AnnouncementSignaturesDecodeErrorZ */ -typedef struct LDKu8slice { +typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { /** - * A pointer to the byte buffer + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - const uint8_t *data; + struct LDKAnnouncementSignatures *result; /** - * The number of bytes pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKu8slice; + struct LDKDecodeError *err; +} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; /** - * A trait to describe an object which can get user secrets and key material. + * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKKeysInterface { +typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void *this_arg; + union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; /** - * Get node secret key (aka node_id or network_key). - * - * This method must return the same value each time it is called. + * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. */ - struct LDKSecretKey (*get_node_secret)(const void *this_arg); - /** - * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. - */ - struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); - /** - * Get a public key which we will send funds to (in the form of a P2WPKH output) when closing - * a channel. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. - */ - struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg); + bool result_ok; +} LDKCResult_AnnouncementSignaturesDecodeErrorZ; + +/** + * The contents of CResult_ChannelReestablishDecodeErrorZ + */ +typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { /** - * Get a new set of Sign for per-channel secrets. These MUST be unique even if you - * restarted with some stale data! - * - * This method must return a different value each time it is called. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); + struct LDKChannelReestablish *result; /** - * 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. - * - * This method must return a different value each time it is called. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); + struct LDKDecodeError *err; +} LDKCResult_ChannelReestablishDecodeErrorZPtr; + +/** + * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { /** - * Reads a `Signer` for this `KeysInterface` from the given input stream. - * This is only called during deserialization of other objects which contain - * `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). - * The bytes are exactly those which `::write()` writes, and - * contain no versioning scheme. You may wish to include your own version prefix and ensure - * you've read all of the provided bytes to ensure no corruption occurred. + * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKKeysInterface; + bool result_ok; +} LDKCResult_ChannelReestablishDecodeErrorZ; /** - * 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 chain events, P2P events, or timer events). + * The contents of CResult_ClosingSignedDecodeErrorZ */ -typedef struct LDKFeeEstimator { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { /** - * 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) + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); + struct LDKClosingSigned *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKFeeEstimator; + struct LDKDecodeError *err; +} LDKCResult_ClosingSignedDecodeErrorZPtr; /** - * A trait encapsulating the operations required of a logger + * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKLogger { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_ClosingSignedDecodeErrorZ { /** - * Logs the `Record` + * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*log)(const void *this_arg, const char *record); + union LDKCResult_ClosingSignedDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKLogger; + bool result_ok; +} LDKCResult_ClosingSignedDecodeErrorZ; /** - * 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 chain::Watch::watch_/update_channel, 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 (BlockHash, 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_tick_occurred 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. + * A commitment_signed message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKChannelManager { +typedef struct MUST_USE_STRUCT LDKCommitmentSigned { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeChannelManager *inner; + LDKnativeCommitmentSigned *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelManager; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_BlockHashChannelManagerZ { - /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 - */ - struct LDKChannelManager b; -} LDKC2Tuple_BlockHashChannelManagerZ; +} LDKCommitmentSigned; /** - * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ + * The contents of CResult_CommitmentSignedDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { +typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_BlockHashChannelManagerZ *result; + struct LDKCommitmentSigned *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; +} LDKCResult_CommitmentSignedDecodeErrorZPtr; /** - * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +typedef struct LDKCResult_CommitmentSignedDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either + * The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; + union LDKCResult_CommitmentSignedDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. + * Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; +} LDKCResult_CommitmentSignedDecodeErrorZ; /** - * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ + * The contents of CResult_FundingCreatedDecodeErrorZ */ -typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr { +typedef union LDKCResult_FundingCreatedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSpendableOutputDescriptor *result; + struct LDKFundingCreated *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr; +} LDKCResult_FundingCreatedDecodeErrorZPtr; /** - * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::chain::keysinterface::SpendableOutputDescriptor on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { +typedef struct LDKCResult_FundingCreatedDecodeErrorZ { /** - * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either + * The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents; + union LDKCResult_FundingCreatedDecodeErrorZPtr contents; /** - * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. + * Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SpendableOutputDescriptorDecodeErrorZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_CVec_u8ZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKCVec_u8Z *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_CVec_u8ZZ; +} LDKCResult_FundingCreatedDecodeErrorZ; /** - * The contents of CResult_CVec_CVec_u8ZZNoneZ + * The contents of CResult_FundingSignedDecodeErrorZ */ -typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr { +typedef union LDKCResult_FundingSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_CVec_u8ZZ *result; + struct LDKFundingSigned *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_CVec_CVec_u8ZZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_FundingSignedDecodeErrorZPtr; /** - * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. + * A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { +typedef struct LDKCResult_FundingSignedDecodeErrorZ { /** - * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either + * The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents; + union LDKCResult_FundingSignedDecodeErrorZPtr contents; /** - * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + * Whether this CResult_FundingSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_CVec_u8ZZNoneZ; +} LDKCResult_FundingSignedDecodeErrorZ; + +/** + * The contents of CResult_FundingLockedDecodeErrorZ + */ +typedef union LDKCResult_FundingLockedDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKFundingLocked *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_FundingLockedDecodeErrorZPtr; + +/** + * A CResult_FundingLockedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingLocked on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_FundingLockedDecodeErrorZ { + /** + * The contents of this CResult_FundingLockedDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_FundingLockedDecodeErrorZPtr contents; + /** + * Whether this CResult_FundingLockedDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_FundingLockedDecodeErrorZ; /** - * A simple implementation of Sign that just keeps the private keys in memory. - * - * This implementation performs no policy checks and is insufficient by itself as - * a secure external signer. + * An init message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKInMemorySigner { +typedef struct MUST_USE_STRUCT LDKInit { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeInMemorySigner *inner; + LDKnativeInit *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInMemorySigner; +} LDKInit; /** - * The contents of CResult_InMemorySignerDecodeErrorZ + * The contents of CResult_InitDecodeErrorZ */ -typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { +typedef union LDKCResult_InitDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInMemorySigner *result; + struct LDKInit *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InMemorySignerDecodeErrorZPtr; +} LDKCResult_InitDecodeErrorZPtr; /** - * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::chain::keysinterface::InMemorySigner on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_InitDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InMemorySignerDecodeErrorZ { +typedef struct LDKCResult_InitDecodeErrorZ { /** - * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either + * The contents of this CResult_InitDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InMemorySignerDecodeErrorZPtr contents; + union LDKCResult_InitDecodeErrorZPtr contents; /** - * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. + * Whether this CResult_InitDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InMemorySignerDecodeErrorZ; +} LDKCResult_InitDecodeErrorZ; /** - * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_OpenChannelDecodeErrorZ */ -typedef struct LDKCVec_TxOutZ { +typedef union LDKCResult_OpenChannelDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTxOut *data; + struct LDKOpenChannel *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_TxOutZ; + struct LDKDecodeError *err; +} LDKCResult_OpenChannelDecodeErrorZPtr; /** - * The contents of CResult_TransactionNoneZ + * A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef union LDKCResult_TransactionNoneZPtr { +typedef struct LDKCResult_OpenChannelDecodeErrorZ { + /** + * The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OpenChannelDecodeErrorZPtr contents; + /** + * Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OpenChannelDecodeErrorZ; + +/** + * The contents of CResult_RevokeAndACKDecodeErrorZ + */ +typedef union LDKCResult_RevokeAndACKDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTransaction *result; + struct LDKRevokeAndACK *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_TransactionNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_RevokeAndACKDecodeErrorZPtr; /** - * A CResult_TransactionNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Transaction on success and a () on failure. + * A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_TransactionNoneZ { +typedef struct LDKCResult_RevokeAndACKDecodeErrorZ { /** - * The contents of this CResult_TransactionNoneZ, accessible via either + * The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_TransactionNoneZPtr contents; + union LDKCResult_RevokeAndACKDecodeErrorZPtr contents; /** - * Whether this CResult_TransactionNoneZ represents a success state. + * Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_TransactionNoneZ; - - +} LDKCResult_RevokeAndACKDecodeErrorZ; /** - * A hop in a route + * The contents of CResult_ShutdownDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKRouteHop { +typedef union LDKCResult_ShutdownDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * 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. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeRouteHop *inner; + struct LDKShutdown *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKRouteHop; + struct LDKDecodeError *err; +} LDKCResult_ShutdownDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::routing::router::RouteHops of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_RouteHopZ { +typedef struct LDKCResult_ShutdownDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_ShutdownDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKRouteHop *data; + union LDKCResult_ShutdownDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_ShutdownDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_RouteHopZ; + bool result_ok; +} LDKCResult_ShutdownDecodeErrorZ; /** - * A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_UpdateFailHTLCDecodeErrorZ */ -typedef struct LDKCVec_CVec_RouteHopZZ { +typedef union LDKCResult_UpdateFailHTLCDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_RouteHopZ *data; + struct LDKUpdateFailHTLC *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_CVec_RouteHopZZ; - - + struct LDKDecodeError *err; +} LDKCResult_UpdateFailHTLCDecodeErrorZPtr; /** - * 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. + * A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKRoute { +typedef struct LDKCResult_UpdateFailHTLCDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * 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. + * The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeRoute *inner; + union LDKCResult_UpdateFailHTLCDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKRoute; + bool result_ok; +} LDKCResult_UpdateFailHTLCDecodeErrorZ; /** - * The contents of CResult_RouteDecodeErrorZ + * The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ */ -typedef union LDKCResult_RouteDecodeErrorZPtr { +typedef union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRoute *result; + struct LDKUpdateFailMalformedHTLC *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_RouteDecodeErrorZPtr; +} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr; /** - * A CResult_RouteDecodeErrorZ represents the result of a fallible operation, - * containing a crate::routing::router::Route on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_RouteDecodeErrorZ { +typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { /** - * The contents of this CResult_RouteDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RouteDecodeErrorZPtr contents; + union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_RouteDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_RouteDecodeErrorZ; +} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ; /** - * A channel descriptor which provides a last-hop route to get_route + * An update_fee message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKRouteHint { +typedef struct MUST_USE_STRUCT LDKUpdateFee { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeRouteHint *inner; + LDKnativeUpdateFee *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKRouteHint; - -/** - * A dynamically-allocated array of crate::routing::router::RouteHints of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_RouteHintZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKRouteHint *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_RouteHintZ; +} LDKUpdateFee; /** - * The contents of CResult_RouteLightningErrorZ + * The contents of CResult_UpdateFeeDecodeErrorZ */ -typedef union LDKCResult_RouteLightningErrorZPtr { +typedef union LDKCResult_UpdateFeeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRoute *result; + struct LDKUpdateFee *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKLightningError *err; -} LDKCResult_RouteLightningErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_UpdateFeeDecodeErrorZPtr; /** - * A CResult_RouteLightningErrorZ represents the result of a fallible operation, - * containing a crate::routing::router::Route on success and a crate::ln::msgs::LightningError on failure. + * A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_RouteLightningErrorZ { +typedef struct LDKCResult_UpdateFeeDecodeErrorZ { /** - * The contents of this CResult_RouteLightningErrorZ, accessible via either + * The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RouteLightningErrorZPtr contents; + union LDKCResult_UpdateFeeDecodeErrorZPtr contents; /** - * Whether this CResult_RouteLightningErrorZ represents a success state. + * Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_RouteLightningErrorZ; +} LDKCResult_UpdateFeeDecodeErrorZ; /** - * The contents of CResult_NetAddressu8Z + * The contents of CResult_UpdateFulfillHTLCDecodeErrorZ */ -typedef union LDKCResult_NetAddressu8ZPtr { +typedef union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNetAddress *result; + struct LDKUpdateFulfillHTLC *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - uint8_t *err; -} LDKCResult_NetAddressu8ZPtr; + struct LDKDecodeError *err; +} LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr; /** - * A CResult_NetAddressu8Z represents the result of a fallible operation, - * containing a crate::ln::msgs::NetAddress on success and a u8 on failure. + * A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NetAddressu8Z { +typedef struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ { /** - * The contents of this CResult_NetAddressu8Z, accessible via either + * The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NetAddressu8ZPtr contents; + union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_NetAddressu8Z represents a success state. + * Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NetAddressu8Z; +} LDKCResult_UpdateFulfillHTLCDecodeErrorZ; /** - * The contents of CResult_CResult_NetAddressu8ZDecodeErrorZ + * The contents of CResult_UpdateAddHTLCDecodeErrorZ */ -typedef union LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr { +typedef union LDKCResult_UpdateAddHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_NetAddressu8Z *result; + struct LDKUpdateAddHTLC *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr; +} LDKCResult_UpdateAddHTLCDecodeErrorZPtr; /** - * A CResult_CResult_NetAddressu8ZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CResult_NetAddressu8Z on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ { +typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { /** - * The contents of this CResult_CResult_NetAddressu8ZDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr contents; + union LDKCResult_UpdateAddHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_CResult_NetAddressu8ZDecodeErrorZ represents a success state. + * Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CResult_NetAddressu8ZDecodeErrorZ; +} LDKCResult_UpdateAddHTLCDecodeErrorZ; /** - * An update_add_htlc message to be sent or received from a peer + * A ping message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { +typedef struct MUST_USE_STRUCT LDKPing { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeUpdateAddHTLC *inner; + LDKnativePing *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUpdateAddHTLC; - -/** - * A dynamically-allocated array of crate::ln::msgs::UpdateAddHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateAddHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKUpdateAddHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_UpdateAddHTLCZ; - - +} LDKPing; /** - * An update_fulfill_htlc message to be sent or received from a peer + * The contents of CResult_PingDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { +typedef union LDKCResult_PingDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * 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. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeUpdateFulfillHTLC *inner; + struct LDKPing *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKUpdateFulfillHTLC; + struct LDKDecodeError *err; +} LDKCResult_PingDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::ln::msgs::UpdateFulfillHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_PingDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_UpdateFulfillHTLCZ { +typedef struct LDKCResult_PingDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_PingDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKUpdateFulfillHTLC *data; + union LDKCResult_PingDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_PingDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_UpdateFulfillHTLCZ; + bool result_ok; +} LDKCResult_PingDecodeErrorZ; /** - * An update_fail_htlc message to be sent or received from a peer + * A pong message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { +typedef struct MUST_USE_STRUCT LDKPong { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeUpdateFailHTLC *inner; + LDKnativePong *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUpdateFailHTLC; - -/** - * A dynamically-allocated array of crate::ln::msgs::UpdateFailHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateFailHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKUpdateFailHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_UpdateFailHTLCZ; - - +} LDKPong; /** - * An update_fail_malformed_htlc message to be sent or received from a peer + * The contents of CResult_PongDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { +typedef union LDKCResult_PongDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * 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. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeUpdateFailMalformedHTLC *inner; + struct LDKPong *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKUpdateFailMalformedHTLC; + struct LDKDecodeError *err; +} LDKCResult_PongDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_PongDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_UpdateFailMalformedHTLCZ { +typedef struct LDKCResult_PongDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_PongDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKUpdateFailMalformedHTLC *data; + union LDKCResult_PongDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_PongDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_UpdateFailMalformedHTLCZ; + bool result_ok; +} LDKCResult_PongDecodeErrorZ; /** - * The contents of CResult_AcceptChannelDecodeErrorZ + * The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ */ -typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { +typedef union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKAcceptChannel *result; + struct LDKUnsignedChannelAnnouncement *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_AcceptChannelDecodeErrorZPtr; +} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr; /** - * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::AcceptChannel on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_AcceptChannelDecodeErrorZ { +typedef struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ { /** - * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either + * The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_AcceptChannelDecodeErrorZPtr contents; + union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + * Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_AcceptChannelDecodeErrorZ; +} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ; /** - * The contents of CResult_AnnouncementSignaturesDecodeErrorZ + * The contents of CResult_ChannelAnnouncementDecodeErrorZ */ -typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { +typedef union LDKCResult_ChannelAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKAnnouncementSignatures *result; + struct LDKChannelAnnouncement *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; +} LDKCResult_ChannelAnnouncementDecodeErrorZPtr; /** - * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::AnnouncementSignatures on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { +typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { /** - * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; + union LDKCResult_ChannelAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + * Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_AnnouncementSignaturesDecodeErrorZ; +} LDKCResult_ChannelAnnouncementDecodeErrorZ; + + /** - * The contents of CResult_ChannelReestablishDecodeErrorZ + * The unsigned part of a channel_update */ -typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeUnsignedChannelUpdate *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUnsignedChannelUpdate; + +/** + * The contents of CResult_UnsignedChannelUpdateDecodeErrorZ + */ +typedef union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelReestablish *result; + struct LDKUnsignedChannelUpdate *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelReestablishDecodeErrorZPtr; +} LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr; /** - * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::ChannelReestablish on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { +typedef struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ { /** - * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + * The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; + union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + * Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelReestablishDecodeErrorZ; +} LDKCResult_UnsignedChannelUpdateDecodeErrorZ; /** - * The contents of CResult_ClosingSignedDecodeErrorZ + * The contents of CResult_ChannelUpdateDecodeErrorZ */ -typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { +typedef union LDKCResult_ChannelUpdateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKClosingSigned *result; + struct LDKChannelUpdate *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ClosingSignedDecodeErrorZPtr; +} LDKCResult_ChannelUpdateDecodeErrorZPtr; /** - * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::ClosingSigned on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ClosingSignedDecodeErrorZ { +typedef struct LDKCResult_ChannelUpdateDecodeErrorZ { /** - * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ClosingSignedDecodeErrorZPtr contents; + union LDKCResult_ChannelUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + * Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ClosingSignedDecodeErrorZ; - - - -/** - * A commitment_signed message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKCommitmentSigned { - /** - * A pointer to the opaque Rust object. - * 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. - */ - LDKnativeCommitmentSigned *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKCommitmentSigned; +} LDKCResult_ChannelUpdateDecodeErrorZ; /** - * The contents of CResult_CommitmentSignedDecodeErrorZ + * The contents of CResult_ErrorMessageDecodeErrorZ */ -typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr { +typedef union LDKCResult_ErrorMessageDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCommitmentSigned *result; + struct LDKErrorMessage *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_CommitmentSignedDecodeErrorZPtr; +} LDKCResult_ErrorMessageDecodeErrorZPtr; /** - * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::CommitmentSigned on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CommitmentSignedDecodeErrorZ { +typedef struct LDKCResult_ErrorMessageDecodeErrorZ { /** - * The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either + * The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CommitmentSignedDecodeErrorZPtr contents; + union LDKCResult_ErrorMessageDecodeErrorZPtr contents; /** - * Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + * Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CommitmentSignedDecodeErrorZ; +} LDKCResult_ErrorMessageDecodeErrorZ; + + /** - * The contents of CResult_FundingCreatedDecodeErrorZ + * The unsigned part of a node_announcement */ -typedef union LDKCResult_FundingCreatedDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeUnsignedNodeAnnouncement *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUnsignedNodeAnnouncement; + +/** + * The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ + */ +typedef union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKFundingCreated *result; + struct LDKUnsignedNodeAnnouncement *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_FundingCreatedDecodeErrorZPtr; +} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr; /** - * A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::FundingCreated on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_FundingCreatedDecodeErrorZ { +typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { /** - * The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either + * The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_FundingCreatedDecodeErrorZPtr contents; + union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + * Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_FundingCreatedDecodeErrorZ; +} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; /** - * The contents of CResult_FundingSignedDecodeErrorZ + * The contents of CResult_NodeAnnouncementDecodeErrorZ */ -typedef union LDKCResult_FundingSignedDecodeErrorZPtr { +typedef union LDKCResult_NodeAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKFundingSigned *result; + struct LDKNodeAnnouncement *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_FundingSignedDecodeErrorZPtr; +} LDKCResult_NodeAnnouncementDecodeErrorZPtr; /** - * A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::FundingSigned on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_FundingSignedDecodeErrorZ { +typedef struct LDKCResult_NodeAnnouncementDecodeErrorZ { /** - * The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either + * The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_FundingSignedDecodeErrorZPtr contents; + union LDKCResult_NodeAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + * Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_FundingSignedDecodeErrorZ; +} LDKCResult_NodeAnnouncementDecodeErrorZ; /** - * The contents of CResult_FundingLockedDecodeErrorZ + * The contents of CResult_QueryShortChannelIdsDecodeErrorZ */ -typedef union LDKCResult_FundingLockedDecodeErrorZPtr { +typedef union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKFundingLocked *result; + struct LDKQueryShortChannelIds *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_FundingLockedDecodeErrorZPtr; +} LDKCResult_QueryShortChannelIdsDecodeErrorZPtr; /** - * A CResult_FundingLockedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::FundingLocked on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_FundingLockedDecodeErrorZ { +typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { /** - * The contents of this CResult_FundingLockedDecodeErrorZ, accessible via either + * The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_FundingLockedDecodeErrorZPtr contents; + union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr contents; /** - * Whether this CResult_FundingLockedDecodeErrorZ represents a success state. + * Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_FundingLockedDecodeErrorZ; +} LDKCResult_QueryShortChannelIdsDecodeErrorZ; /** - * An init message to be sent or received from a peer + * A reply_short_channel_ids_end message is sent as a reply to a + * query_short_channel_ids message. The query recipient makes a best + * effort to respond based on their local network view which may not be + * a perfect view of the network. */ -typedef struct MUST_USE_STRUCT LDKInit { +typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeInit *inner; + LDKnativeReplyShortChannelIdsEnd *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInit; +} LDKReplyShortChannelIdsEnd; /** - * The contents of CResult_InitDecodeErrorZ + * The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ */ -typedef union LDKCResult_InitDecodeErrorZPtr { +typedef union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInit *result; + struct LDKReplyShortChannelIdsEnd *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InitDecodeErrorZPtr; +} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr; /** - * A CResult_InitDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::Init on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InitDecodeErrorZ { +typedef struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ { /** - * The contents of this CResult_InitDecodeErrorZ, accessible via either + * The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InitDecodeErrorZPtr contents; + union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr contents; /** - * Whether this CResult_InitDecodeErrorZ represents a success state. + * Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InitDecodeErrorZ; +} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ; /** - * The contents of CResult_OpenChannelDecodeErrorZ + * The contents of CResult_QueryChannelRangeDecodeErrorZ */ -typedef union LDKCResult_OpenChannelDecodeErrorZPtr { +typedef union LDKCResult_QueryChannelRangeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOpenChannel *result; + struct LDKQueryChannelRange *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_OpenChannelDecodeErrorZPtr; +} LDKCResult_QueryChannelRangeDecodeErrorZPtr; /** - * A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::OpenChannel on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_OpenChannelDecodeErrorZ { +typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { /** - * The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either + * The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_OpenChannelDecodeErrorZPtr contents; + union LDKCResult_QueryChannelRangeDecodeErrorZPtr contents; /** - * Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + * Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_OpenChannelDecodeErrorZ; +} LDKCResult_QueryChannelRangeDecodeErrorZ; /** - * The contents of CResult_RevokeAndACKDecodeErrorZ + * The contents of CResult_ReplyChannelRangeDecodeErrorZ */ -typedef union LDKCResult_RevokeAndACKDecodeErrorZPtr { +typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRevokeAndACK *result; + struct LDKReplyChannelRange *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_RevokeAndACKDecodeErrorZPtr; +} LDKCResult_ReplyChannelRangeDecodeErrorZPtr; /** - * A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::RevokeAndACK on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_RevokeAndACKDecodeErrorZ { +typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { /** - * The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either + * The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RevokeAndACKDecodeErrorZPtr contents; + union LDKCResult_ReplyChannelRangeDecodeErrorZPtr contents; /** - * Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + * Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_RevokeAndACKDecodeErrorZ; +} LDKCResult_ReplyChannelRangeDecodeErrorZ; + + /** - * The contents of CResult_ShutdownDecodeErrorZ + * A gossip_timestamp_filter message is used by a node to request + * gossip relay for messages in the requested time range when the + * gossip_queries feature has been negotiated. */ -typedef union LDKCResult_ShutdownDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeGossipTimestampFilter *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKGossipTimestampFilter; + +/** + * The contents of CResult_GossipTimestampFilterDecodeErrorZ + */ +typedef union LDKCResult_GossipTimestampFilterDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKShutdown *result; + struct LDKGossipTimestampFilter *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ShutdownDecodeErrorZPtr; +} LDKCResult_GossipTimestampFilterDecodeErrorZPtr; /** - * A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::Shutdown on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ShutdownDecodeErrorZ { +typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { /** - * The contents of this CResult_ShutdownDecodeErrorZ, accessible via either + * The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ShutdownDecodeErrorZPtr contents; + union LDKCResult_GossipTimestampFilterDecodeErrorZPtr contents; /** - * Whether this CResult_ShutdownDecodeErrorZ represents a success state. + * Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ShutdownDecodeErrorZ; +} LDKCResult_GossipTimestampFilterDecodeErrorZ; /** - * The contents of CResult_UpdateFailHTLCDecodeErrorZ - */ -typedef union LDKCResult_UpdateFailHTLCDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKUpdateFailHTLC *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFailHTLCDecodeErrorZPtr; - -/** - * A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::UpdateFailHTLC on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UpdateFailHTLCDecodeErrorZ { - /** - * The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_UpdateFailHTLCDecodeErrorZPtr contents; - /** - * Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_UpdateFailHTLCDecodeErrorZ; - -/** - * The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ + * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ */ -typedef union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFailMalformedHTLC *result; + struct LDKSpendableOutputDescriptor *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr; +} LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr; /** - * A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::UpdateFailMalformedHTLC on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { +typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { /** - * The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either + * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr contents; + union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ; - - - -/** - * An update_fee message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKUpdateFee { - /** - * A pointer to the opaque Rust object. - * 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. - */ - LDKnativeUpdateFee *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKUpdateFee; +} LDKCResult_SpendableOutputDescriptorDecodeErrorZ; /** - * The contents of CResult_UpdateFeeDecodeErrorZ + * The contents of CResult_SignDecodeErrorZ */ -typedef union LDKCResult_UpdateFeeDecodeErrorZPtr { +typedef union LDKCResult_SignDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFee *result; + struct LDKSign *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UpdateFeeDecodeErrorZPtr; +} LDKCResult_SignDecodeErrorZPtr; /** - * A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::UpdateFee on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_SignDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateFeeDecodeErrorZ { +typedef struct LDKCResult_SignDecodeErrorZ { /** - * The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either + * The contents of this CResult_SignDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateFeeDecodeErrorZPtr contents; + union LDKCResult_SignDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + * Whether this CResult_SignDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateFeeDecodeErrorZ; - -/** - * The contents of CResult_UpdateFulfillHTLCDecodeErrorZ - */ -typedef union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKUpdateFulfillHTLC *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr; +} LDKCResult_SignDecodeErrorZ; /** - * A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::UpdateFulfillHTLC on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ { +typedef struct LDKCVec_CVec_u8ZZ { /** - * The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr contents; + struct LDKCVec_u8Z *data; /** - * Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_UpdateFulfillHTLCDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_CVec_u8ZZ; /** - * The contents of CResult_UpdateAddHTLCDecodeErrorZ + * The contents of CResult_CVec_CVec_u8ZZNoneZ */ -typedef union LDKCResult_UpdateAddHTLCDecodeErrorZPtr { +typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateAddHTLC *result; + struct LDKCVec_CVec_u8ZZ *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_UpdateAddHTLCDecodeErrorZPtr; + void *err; +} LDKCResult_CVec_CVec_u8ZZNoneZPtr; /** - * A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::UpdateAddHTLC on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { +typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { /** - * The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either + * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateAddHTLCDecodeErrorZPtr contents; + union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents; /** - * Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateAddHTLCDecodeErrorZ; +} LDKCResult_CVec_CVec_u8ZZNoneZ; /** - * A ping message to be sent or received from a peer + * A simple implementation of Sign that just keeps the private keys in memory. + * + * This implementation performs no policy checks and is insufficient by itself as + * a secure external signer. */ -typedef struct MUST_USE_STRUCT LDKPing { +typedef struct MUST_USE_STRUCT LDKInMemorySigner { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativePing *inner; + LDKnativeInMemorySigner *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPing; +} LDKInMemorySigner; /** - * The contents of CResult_PingDecodeErrorZ + * The contents of CResult_InMemorySignerDecodeErrorZ */ -typedef union LDKCResult_PingDecodeErrorZPtr { +typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPing *result; + struct LDKInMemorySigner *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_PingDecodeErrorZPtr; +} LDKCResult_InMemorySignerDecodeErrorZPtr; /** - * A CResult_PingDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::Ping on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PingDecodeErrorZ { +typedef struct LDKCResult_InMemorySignerDecodeErrorZ { /** - * The contents of this CResult_PingDecodeErrorZ, accessible via either + * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PingDecodeErrorZPtr contents; + union LDKCResult_InMemorySignerDecodeErrorZPtr contents; /** - * Whether this CResult_PingDecodeErrorZ represents a success state. + * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PingDecodeErrorZ; - - +} LDKCResult_InMemorySignerDecodeErrorZ; /** - * A pong message to be sent or received from a peer + * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKPong { +typedef struct LDKCVec_TxOutZ { /** - * A pointer to the opaque Rust object. - * 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. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativePong *inner; + struct LDKTxOut *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKPong; + uintptr_t datalen; +} LDKCVec_TxOutZ; /** - * The contents of CResult_PongDecodeErrorZ + * The contents of CResult_TransactionNoneZ */ -typedef union LDKCResult_PongDecodeErrorZPtr { +typedef union LDKCResult_TransactionNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPong *result; + struct LDKTransaction *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_PongDecodeErrorZPtr; + void *err; +} LDKCResult_TransactionNoneZPtr; /** - * A CResult_PongDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::Pong on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_TransactionNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Transaction on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PongDecodeErrorZ { +typedef struct LDKCResult_TransactionNoneZ { /** - * The contents of this CResult_PongDecodeErrorZ, accessible via either + * The contents of this CResult_TransactionNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PongDecodeErrorZPtr contents; + union LDKCResult_TransactionNoneZPtr contents; /** - * Whether this CResult_PongDecodeErrorZ represents a success state. + * Whether this CResult_TransactionNoneZ represents a success state. */ bool result_ok; -} LDKCResult_PongDecodeErrorZ; +} LDKCResult_TransactionNoneZ; /** - * The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ + * 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 union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +typedef struct LDKStr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the string's bytes, in UTF8 encoding */ - struct LDKUnsignedChannelAnnouncement *result; + const uint8_t *chars; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of bytes (not characters!) pointed to by `chars` */ - struct LDKDecodeError *err; -} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr; + uintptr_t len; +} LDKStr; /** - * A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::UnsignedChannelAnnouncement on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Indicates an error on the client's part (usually some variant of attempting to use too-low or + * too-high values) */ -typedef struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ { +typedef enum LDKAPIError_Tag { /** - * The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr contents; + * 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, /** - * Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + * 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. */ - bool result_ok; -} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ; - -/** - * The contents of CResult_ChannelAnnouncementDecodeErrorZ - */ -typedef union LDKCResult_ChannelAnnouncementDecodeErrorZPtr { + LDKAPIError_FeeRateTooHigh, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, + * too-many-hops, etc). */ - struct LDKChannelAnnouncement *result; + LDKAPIError_RouteError, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * 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. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelAnnouncementDecodeErrorZPtr; - -/** - * A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::ChannelAnnouncement on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { + LDKAPIError_ChannelUnavailable, /** - * The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the + * attempted action to fail. */ - union LDKCResult_ChannelAnnouncementDecodeErrorZPtr contents; + LDKAPIError_MonitorUpdateFailed, /** - * Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_ChannelAnnouncementDecodeErrorZ; + LDKAPIError_Sentinel, +} LDKAPIError_Tag; +typedef struct LDKAPIError_LDKAPIMisuseError_Body { + /** + * A human-readable error message + */ + struct LDKCVec_u8Z err; +} LDKAPIError_LDKAPIMisuseError_Body; +typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { + /** + * A human-readable error message + */ + struct LDKCVec_u8Z err; + /** + * The feerate which was too high. + */ + uint32_t feerate; +} LDKAPIError_LDKFeeRateTooHigh_Body; -/** - * The unsigned part of a channel_update - */ -typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { +typedef struct LDKAPIError_LDKRouteError_Body { /** - * A pointer to the opaque Rust object. - * 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. + * A human-readable error message */ - LDKnativeUnsignedChannelUpdate *inner; + struct LDKStr err; +} LDKAPIError_LDKRouteError_Body; + +typedef struct LDKAPIError_LDKChannelUnavailable_Body { /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A human-readable error message */ - bool is_owned; -} LDKUnsignedChannelUpdate; + struct LDKCVec_u8Z err; +} LDKAPIError_LDKChannelUnavailable_Body; + +typedef struct MUST_USE_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; /** - * The contents of CResult_UnsignedChannelUpdateDecodeErrorZ + * The contents of CResult_NoneAPIErrorZ */ -typedef union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr { +typedef union LDKCResult_NoneAPIErrorZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKUnsignedChannelUpdate *result; + void *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr; + struct LDKAPIError *err; +} LDKCResult_NoneAPIErrorZPtr; /** - * A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::UnsignedChannelUpdate on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_NoneAPIErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::util::errors::APIError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ { +typedef struct LDKCResult_NoneAPIErrorZ { /** - * The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_NoneAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr contents; + union LDKCResult_NoneAPIErrorZPtr contents; /** - * Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + * Whether this CResult_NoneAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UnsignedChannelUpdateDecodeErrorZ; +} LDKCResult_NoneAPIErrorZ; /** - * The contents of CResult_ChannelUpdateDecodeErrorZ + * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_ChannelUpdateDecodeErrorZPtr { +typedef struct LDKCVec_CResult_NoneAPIErrorZZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKChannelUpdate *result; + struct LDKCResult_NoneAPIErrorZ *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelUpdateDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_CResult_NoneAPIErrorZZ; /** - * A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::ChannelUpdate on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_ChannelUpdateDecodeErrorZ { +typedef struct LDKCVec_APIErrorZ { /** - * The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_ChannelUpdateDecodeErrorZPtr contents; + struct LDKAPIError *data; /** - * Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_ChannelUpdateDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_APIErrorZ; /** - * The contents of CResult_ErrorMessageDecodeErrorZ + * 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 union LDKCResult_ErrorMessageDecodeErrorZPtr { +typedef enum LDKPaymentSendFailure_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A parameter which was passed to send_payment was invalid, preventing us from attempting to + * send the payment at all. No channel state has been changed or messages sent to peers, and + * once you've changed the parameter at error, you can freely retry the payment in full. */ - struct LDKErrorMessage *result; + LDKPaymentSendFailure_ParameterError, + /** + * A parameter in a single path which was passed to send_payment was invalid, preventing us + * from attempting to send the payment at all. No channel state has been changed or messages + * sent to peers, and once you've changed the parameter at error, you can freely retry the + * payment in full. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment. + */ + LDKPaymentSendFailure_PathParameterError, + /** + * All paths which were attempted failed to send, with no channel state change taking place. + * You can freely retry the payment in full (though you probably want to do so over different + * paths than the ones selected). + */ + LDKPaymentSendFailure_AllFailedRetrySafe, + /** + * Some paths which were attempted failed to send, though possibly not all. At least some + * paths have irrevocably committed to the HTLC and retrying the payment in full would result + * in over-/re-payment. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely + * retried (though there is currently no API with which to do so). + * + * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried + * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the + * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel + * with the latest update_id. + */ + LDKPaymentSendFailure_PartialFailure, + /** + * Must be last for serialization purposes + */ + LDKPaymentSendFailure_Sentinel, +} LDKPaymentSendFailure_Tag; + +typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { + LDKPaymentSendFailure_Tag tag; + union { + struct { + struct LDKAPIError parameter_error; + }; + struct { + struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; + }; + struct { + struct LDKCVec_APIErrorZ all_failed_retry_safe; + }; + struct { + struct LDKCVec_CResult_NoneAPIErrorZZ partial_failure; + }; + }; +} LDKPaymentSendFailure; + +/** + * The contents of CResult_NonePaymentSendFailureZ + */ +typedef union LDKCResult_NonePaymentSendFailureZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_ErrorMessageDecodeErrorZPtr; + struct LDKPaymentSendFailure *err; +} LDKCResult_NonePaymentSendFailureZPtr; /** - * A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::ErrorMessage on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ErrorMessageDecodeErrorZ { +typedef struct LDKCResult_NonePaymentSendFailureZ { /** - * The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either + * The contents of this CResult_NonePaymentSendFailureZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ErrorMessageDecodeErrorZPtr contents; + union LDKCResult_NonePaymentSendFailureZPtr contents; /** - * Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + * Whether this CResult_NonePaymentSendFailureZ represents a success state. */ bool result_ok; -} LDKCResult_ErrorMessageDecodeErrorZ; - - +} LDKCResult_NonePaymentSendFailureZ; /** - * The unsigned part of a node_announcement + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement { +typedef struct LDKCVec_ChannelMonitorZ { /** - * A pointer to the opaque Rust object. - * 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. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeUnsignedNodeAnnouncement *inner; + struct LDKChannelMonitor *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKUnsignedNodeAnnouncement; + uintptr_t datalen; +} LDKCVec_ChannelMonitorZ; /** - * The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ + * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as + * blocks are connected and disconnected. + * + * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are + * responsible for maintaining a set of monitors such that they can be updated accordingly as + * channel state changes and HTLCs are resolved. See method documentation for specific + * requirements. + * + * Implementations **must** ensure that updates are successfully applied and persisted upon method + * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down + * without taking any further action such as persisting the current state. + * + * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing + * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it + * could result in a revoked transaction being broadcast, allowing the counterparty to claim all + * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle + * multiple instances. + * + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr + * [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure */ -typedef union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +typedef struct LDKWatch { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKUnsignedNodeAnnouncement *result; + void *this_arg; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Watches a channel identified by `funding_txo` using `monitor`. + * + * Implementations are responsible for watching the chain for the funding transaction along + * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means + * calling [`block_connected`] and [`block_disconnected`] on the monitor. + * + * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch + * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected + * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected */ - struct LDKDecodeError *err; -} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr; - -/** - * A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::UnsignedNodeAnnouncement on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { + struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); /** - * The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Updates a channel identified by `funding_txo` by applying `update` to its monitor. + * + * Implementations must call [`update_monitor`] with the given update. See + * [`ChannelMonitorUpdateErr`] for invariants around returning an error. + * + * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr */ - union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr contents; + struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); /** - * Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + * Returns any monitor events since the last call. Subsequent calls must only return new + * events. */ - bool result_ok; -} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; + struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKWatch; /** - * The contents of CResult_NodeAnnouncementDecodeErrorZ + * An interface to send a transaction to the Bitcoin network. */ -typedef union LDKCResult_NodeAnnouncementDecodeErrorZPtr { +typedef struct LDKBroadcasterInterface { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKNodeAnnouncement *result; + void *this_arg; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Sends a transaction out to (hopefully) be mined. */ - struct LDKDecodeError *err; -} LDKCResult_NodeAnnouncementDecodeErrorZPtr; + void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKBroadcasterInterface; /** - * A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::NodeAnnouncement on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not + * own the memory pointed to by data. */ -typedef struct LDKCResult_NodeAnnouncementDecodeErrorZ { +typedef struct LDKu8slice { /** - * The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the byte buffer */ - union LDKCResult_NodeAnnouncementDecodeErrorZPtr contents; + const uint8_t *data; /** - * Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + * The number of bytes pointed to by `data`. */ - bool result_ok; -} LDKCResult_NodeAnnouncementDecodeErrorZ; + uintptr_t datalen; +} LDKu8slice; /** - * The contents of CResult_QueryShortChannelIdsDecodeErrorZ + * A trait to describe an object which can get user secrets and key material. */ -typedef union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr { +typedef struct LDKKeysInterface { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKQueryShortChannelIds *result; + void *this_arg; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Get node secret key (aka node_id or network_key). + * + * This method must return the same value each time it is called. */ - struct LDKDecodeError *err; -} LDKCResult_QueryShortChannelIdsDecodeErrorZPtr; - -/** - * A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::QueryShortChannelIds on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { + struct LDKSecretKey (*get_node_secret)(const void *this_arg); /** - * The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr contents; + struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); /** - * Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. + * Get a public key which we will send funds to (in the form of a P2WPKH output) when closing + * a channel. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - bool result_ok; -} LDKCResult_QueryShortChannelIdsDecodeErrorZ; - - - -/** - * A reply_short_channel_ids_end message is sent as a reply to a - * query_short_channel_ids message. The query recipient makes a best - * effort to respond based on their local network view which may not be - * a perfect view of the network. - */ -typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { + struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg); /** - * A pointer to the opaque Rust object. - * 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. + * Get a new set of Sign for per-channel secrets. These MUST be unique even if you + * restarted with some stale data! + * + * This method must return a different value each time it is called. */ - LDKnativeReplyShortChannelIdsEnd *inner; + struct LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * 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. + * + * This method must return a different value each time it is called. */ - bool is_owned; -} LDKReplyShortChannelIdsEnd; - -/** - * The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ - */ -typedef union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr { + struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Reads a `Signer` for this `KeysInterface` from the given input stream. + * This is only called during deserialization of other objects which contain + * `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). + * The bytes are exactly those which `::write()` writes, and + * contain no versioning scheme. You may wish to include your own version prefix and ensure + * you've read all of the provided bytes to ensure no corruption occurred. */ - struct LDKReplyShortChannelIdsEnd *result; + struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - struct LDKDecodeError *err; -} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr; + void (*free)(void *this_arg); +} LDKKeysInterface; /** - * A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * 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 chain events, P2P events, or timer events). */ -typedef struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ { +typedef struct LDKFeeEstimator { /** - * The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr contents; + void *this_arg; /** - * Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. + * 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) */ - bool result_ok; -} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ; + uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKFeeEstimator; /** - * The contents of CResult_QueryChannelRangeDecodeErrorZ + * A trait encapsulating the operations required of a logger */ -typedef union LDKCResult_QueryChannelRangeDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKQueryChannelRange *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_QueryChannelRangeDecodeErrorZPtr; - -/** - * A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::QueryChannelRange on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { - /** - * The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_QueryChannelRangeDecodeErrorZPtr contents; - /** - * Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_QueryChannelRangeDecodeErrorZ; - -/** - * The contents of CResult_ReplyChannelRangeDecodeErrorZ - */ -typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKReplyChannelRange *result; +typedef struct LDKLogger { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKDecodeError *err; -} LDKCResult_ReplyChannelRangeDecodeErrorZPtr; - -/** - * A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::ReplyChannelRange on success and a crate::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { + void *this_arg; /** - * The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Logs the `Record` */ - union LDKCResult_ReplyChannelRangeDecodeErrorZPtr contents; + void (*log)(const void *this_arg, const char *record); /** - * Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - bool result_ok; -} LDKCResult_ReplyChannelRangeDecodeErrorZ; + void (*free)(void *this_arg); +} LDKLogger; /** - * A gossip_timestamp_filter message is used by a node to request - * gossip relay for messages in the requested time range when the - * gossip_queries feature has been negotiated. + * 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 chain::Watch::watch_/update_channel, 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 (BlockHash, 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_tick_occurred 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 LDKGossipTimestampFilter { +typedef struct MUST_USE_STRUCT LDKChannelManager { /** * A pointer to the opaque Rust object. * 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. */ - LDKnativeGossipTimestampFilter *inner; + LDKnativeChannelManager *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKGossipTimestampFilter; +} LDKChannelManager; /** - * The contents of CResult_GossipTimestampFilterDecodeErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_GossipTimestampFilterDecodeErrorZPtr { +typedef struct LDKC2Tuple_BlockHashChannelManagerZ { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKChannelManager b; +} LDKC2Tuple_BlockHashChannelManagerZ; + +/** + * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ + */ +typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKGossipTimestampFilter *result; + struct LDKC2Tuple_BlockHashChannelManagerZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_GossipTimestampFilterDecodeErrorZPtr; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; /** - * A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, - * containing a crate::ln::msgs::GossipTimestampFilter on success and a crate::ln::msgs::DecodeError on failure. + * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { +typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { /** - * The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either + * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_GossipTimestampFilterDecodeErrorZPtr contents; + union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; /** - * Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. + * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_GossipTimestampFilterDecodeErrorZ; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; /** * A trait indicating an object may generate message send events @@ -7452,784 +7452,370 @@ typedef struct MUST_USE_STRUCT 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 { - /** - * A pointer to the opaque Rust object. - * 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. - */ - LDKnativeNetGraphMsgHandler *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKNetGraphMsgHandler; - -extern const uintptr_t MAX_BUF_SIZE; - -extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; - -extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; - -extern const uint16_t BREAKDOWN_TIMEOUT; - -extern const uint16_t MIN_CLTV_EXPIRY_DELTA; - -extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; - -/** - * Frees the data buffer, if data_is_owned is set and datalen > 0. - */ -void Transaction_free(struct LDKTransaction _res); - -/** - * Frees the data pointed to by script_pubkey. - */ -void TxOut_free(struct LDKTxOut _res); - -/** - * Creates a new TxOut which has the same data as `orig` but with a new script buffer. - */ -struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); - -/** - * Creates a new CResult_SecretKeyErrorZ in the success state. - */ -struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_ok(struct LDKSecretKey o); - -/** - * Creates a new CResult_SecretKeyErrorZ in the error state. - */ -struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_err(enum LDKSecp256k1Error e); - -/** - * Frees any resources used by the CResult_SecretKeyErrorZ. - */ -void CResult_SecretKeyErrorZ_free(struct LDKCResult_SecretKeyErrorZ _res); - -/** - * Creates a new CResult_PublicKeyErrorZ in the success state. - */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); - -/** - * Creates a new CResult_PublicKeyErrorZ in the error state. - */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); - -/** - * Frees any resources used by the CResult_PublicKeyErrorZ. - */ -void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); - -/** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. - */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); - -/** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. - */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. - */ -void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); - -/** - * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. - */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); - -/** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. - */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. - */ -void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); - -/** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_TxCreationKeysErrorZ in the success state. - */ -struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_ok(struct LDKTxCreationKeys o); - -/** - * Creates a new CResult_TxCreationKeysErrorZ in the error state. - */ -struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_err(enum LDKSecp256k1Error e); - -/** - * Frees any resources used by the CResult_TxCreationKeysErrorZ. - */ -void CResult_TxCreationKeysErrorZ_free(struct LDKCResult_TxCreationKeysErrorZ _res); - -/** - * Constructs a new COption_u32Z containing a u32 - */ -struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); - -/** - * Constructs a new COption_u32Z containing nothing - */ -struct LDKCOption_u32Z COption_u32Z_none(void); - -/** - * Frees any resources associated with the u32, if we are in the Some state - */ -void COption_u32Z_free(struct LDKCOption_u32Z _res); - -/** - * Creates a new COption_u32Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); - -/** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. - */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); - -/** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. - */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. - */ -void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); - -/** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. - */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); - -/** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. - */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. - */ -void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); - -/** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. - */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); - -/** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. - */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. - */ -void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); - -/** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_SignatureZ_free(struct LDKCVec_SignatureZ _res); - -/** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. - */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); - -/** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. - */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. - */ -void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); - -/** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. - */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); - -/** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. - */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. - */ -void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); - -/** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. - */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); - -/** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. - */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. - */ -void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); - -/** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. - */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); - -/** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. - */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); - -/** - * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. - */ -void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); - -/** - * Creates a new CResult_CVec_SignatureZNoneZ in the success state. - */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o); - -/** - * Creates a new CResult_CVec_SignatureZNoneZ in the error state. - */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); - -/** - * Frees any resources used by the CResult_CVec_SignatureZNoneZ. - */ -void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res); - -/** - * Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); - -/** - * Creates a new CResult_boolLightningErrorZ in the success state. - */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); - -/** - * Creates a new CResult_boolLightningErrorZ in the error state. - */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); - -/** - * Frees any resources used by the CResult_boolLightningErrorZ. - */ -void CResult_boolLightningErrorZ_free(struct LDKCResult_boolLightningErrorZ _res); - -/** - * Creates a new CResult_boolLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_clone(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR orig); - -/** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR orig); - -/** - * Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. - */ -struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); - -/** - * Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. - */ -void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res); - -/** - * Creates a new CResult_NoneLightningErrorZ in the success state. - */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); - -/** - * Creates a new CResult_NoneLightningErrorZ in the error state. - */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); - -/** - * Frees any resources used by the CResult_NoneLightningErrorZ. - */ -void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); - -/** - * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_u8Z_free(struct LDKCVec_u8Z _res); - -/** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. - */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); - -/** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. + * 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. */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e); +typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler { + /** + * A pointer to the opaque Rust object. + * 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. + */ + LDKnativeNetGraphMsgHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKNetGraphMsgHandler; -/** - * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. - */ -void CResult_CVec_u8ZPeerHandleErrorZ_free(struct LDKCResult_CVec_u8ZPeerHandleErrorZ _res); +extern const uintptr_t MAX_BUF_SIZE; -/** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_clone(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR orig); +extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; -/** - * Creates a new CResult_NonePeerHandleErrorZ in the success state. - */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); +extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; -/** - * Creates a new CResult_NonePeerHandleErrorZ in the error state. - */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); +extern const uint16_t BREAKDOWN_TIMEOUT; -/** - * Frees any resources used by the CResult_NonePeerHandleErrorZ. - */ -void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); +extern const uint16_t MIN_CLTV_EXPIRY_DELTA; + +extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; /** - * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the data buffer, if data_is_owned is set and datalen > 0. */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); +void Transaction_free(struct LDKTransaction _res); /** - * Creates a new CResult_boolPeerHandleErrorZ in the success state. + * Frees the data pointed to by script_pubkey. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); +void TxOut_free(struct LDKTxOut _res); /** - * Creates a new CResult_boolPeerHandleErrorZ in the error state. + * Creates a new TxOut which has the same data as `orig` but with a new script buffer. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); +struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_boolPeerHandleErrorZ. + * Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. */ -void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); /** - * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. + * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o); +void CResult_ChannelConfigDecodeErrorZ_free(struct LDKCResult_ChannelConfigDecodeErrorZ _res); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_clone(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. + * Creates a new CResult_OutPointDecodeErrorZ in the success state. */ -void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res); +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LDKOutPoint o); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_OutPointDecodeErrorZ in the error state. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. + * Frees any resources used by the CResult_OutPointDecodeErrorZ. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _res); /** - * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. + * Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_SecretKeyErrorZ in the success state. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); +struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_ok(struct LDKSecretKey o); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_SecretKeyErrorZ in the error state. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_err(enum LDKSecp256k1Error e); /** - * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_SecretKeyErrorZ. */ -void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); +void CResult_SecretKeyErrorZ_free(struct LDKCResult_SecretKeyErrorZ _res); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_PublicKeyErrorZ in the success state. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_PublicKeyErrorZ in the error state. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); /** - * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_PublicKeyErrorZ. */ -void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); +void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. + * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. */ -void CResult_ChannelConfigDecodeErrorZ_free(struct LDKCResult_ChannelConfigDecodeErrorZ _res); +void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_clone(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_u64Z containing a u64 + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. */ -struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); /** - * Constructs a new COption_u64Z containing nothing + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. */ -struct LDKCOption_u64Z COption_u64Z_none(void); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the u64, if we are in the Some state + * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. */ -void COption_u64Z_free(struct LDKCOption_u64Z _res); +void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); /** - * Creates a new COption_u64Z which has the same data as `orig` + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); - -/** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state. - */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_ok(struct LDKDirectionalChannelInfo o); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. + * Creates a new CResult_TxCreationKeysErrorZ in the success state. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_ok(struct LDKTxCreationKeys o); /** - * Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ. + * Creates a new CResult_TxCreationKeysErrorZ in the error state. */ -void CResult_DirectionalChannelInfoDecodeErrorZ_free(struct LDKCResult_DirectionalChannelInfoDecodeErrorZ _res); +struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_err(enum LDKSecp256k1Error e); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_TxCreationKeysErrorZ. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_clone(const struct LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR orig); +void CResult_TxCreationKeysErrorZ_free(struct LDKCResult_TxCreationKeysErrorZ _res); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. + * Constructs a new COption_u32Z containing a u32 */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(struct LDKChannelInfo o); +struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. + * Constructs a new COption_u32Z containing nothing */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_u32Z COption_u32Z_none(void); /** - * Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. + * Frees any resources associated with the u32, if we are in the Some state */ -void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); +void COption_u32Z_free(struct LDKCOption_u32Z _res); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` + * Creates a new COption_u32Z which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. + * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. */ -void CResult_RoutingFeesDecodeErrorZ_free(struct LDKCResult_RoutingFeesDecodeErrorZ _res); +void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_clone(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_NetAddressZ_free(struct LDKCVec_NetAddressZ _res); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_ok(struct LDKNodeAnnouncementInfo o); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. + * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. */ -void CResult_NodeAnnouncementInfoDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res); +void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. */ -void CVec_u64Z_free(struct LDKCVec_u64Z _res); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); /** - * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LDKNodeInfo o); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_NodeInfoDecodeErrorZ in the error state. + * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); /** - * Frees any resources used by the CResult_NodeInfoDecodeErrorZ. + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_NodeInfoDecodeErrorZ_free(struct LDKCResult_NodeInfoDecodeErrorZ _res); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_clone(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR orig); +void CVec_SignatureZ_free(struct LDKCVec_SignatureZ _res); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(struct LDKNetworkGraph o); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. + * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. */ -void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); +void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_usizeTransactionZ from the contained elements. + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. */ -struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); /** - * Frees any resources used by the C2Tuple_usizeTransactionZ. + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. */ -void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. */ -void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); +void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_TxidZ_free(struct LDKCVec_TxidZ _res); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_err(enum LDKChannelMonitorUpdateErr e); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. + * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. */ -void CResult_NoneChannelMonitorUpdateErrZ_free(struct LDKCResult_NoneChannelMonitorUpdateErrZ _res); +void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` + * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR orig); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. */ -void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. */ -void CVec_EventZ_free(struct LDKCVec_EventZ _res); +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); /** - * Creates a new CResult_OutPointDecodeErrorZ in the success state. + * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LDKOutPoint o); +void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); /** - * Creates a new CResult_OutPointDecodeErrorZ in the error state. + * Creates a new CResult_CVec_SignatureZNoneZ in the success state. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o); /** - * Frees any resources used by the CResult_OutPointDecodeErrorZ. + * Creates a new CResult_CVec_SignatureZNoneZ in the error state. */ -void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _res); +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); /** - * Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` + * Frees any resources used by the CResult_CVec_SignatureZNoneZ. + */ +void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res); + +/** + * Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig); /** * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. @@ -8294,12 +7880,6 @@ void CResult_NoneMonitorUpdateErrorZ_free(struct LDKCResult_NoneMonitorUpdateErr */ struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_clone(const struct LDKCResult_NoneMonitorUpdateErrorZ *NONNULL_PTR orig); -/** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const struct LDKC2Tuple_OutPointScriptZ *NONNULL_PTR orig); - /** * Creates a new C2Tuple_OutPointScriptZ from the contained elements. */ @@ -8310,12 +7890,6 @@ struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint */ void C2Tuple_OutPointScriptZ_free(struct LDKC2Tuple_OutPointScriptZ _res); -/** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_clone(const struct LDKC2Tuple_u32ScriptZ *NONNULL_PTR orig); - /** * Creates a new C2Tuple_u32ScriptZ from the contained elements. */ @@ -8346,11 +7920,36 @@ void C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tup */ void CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_EventZ_free(struct LDKCVec_EventZ _res); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); +/** + * Creates a new C2Tuple_usizeTransactionZ from the contained elements. + */ +struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); + +/** + * Frees any resources used by the C2Tuple_usizeTransactionZ. + */ +void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); + /** * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. @@ -8387,6 +7986,32 @@ void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tupl */ void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_TxidZ_free(struct LDKCVec_TxidZ _res); + +/** + * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. + */ +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); + +/** + * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. + */ +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_err(enum LDKChannelMonitorUpdateErr e); + +/** + * Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. + */ +void CResult_NoneChannelMonitorUpdateErrZ_free(struct LDKCResult_NoneChannelMonitorUpdateErrZ _res); + +/** + * Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR orig); + /** * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. */ @@ -8415,354 +8040,468 @@ void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); +void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); /** - * Creates a new CResult_TxOutAccessErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_ok(struct LDKTxOut o); +void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res); /** - * Creates a new CResult_TxOutAccessErrorZ in the error state. + * Creates a new CResult_RouteDecodeErrorZ in the success state. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_err(enum LDKAccessError e); +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute o); /** - * Frees any resources used by the CResult_TxOutAccessErrorZ. + * Creates a new CResult_RouteDecodeErrorZ in the error state. */ -void CResult_TxOutAccessErrorZ_free(struct LDKCResult_TxOutAccessErrorZ _res); +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` + * Frees any resources used by the CResult_RouteDecodeErrorZ. + */ +void CResult_RouteDecodeErrorZ_free(struct LDKCResult_RouteDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR orig); +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ + * Constructs a new COption_u64Z containing a u64 */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o); +struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); /** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing + * Constructs a new COption_u64Z containing nothing */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void); +struct LDKCOption_u64Z COption_u64Z_none(void); /** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state + * Frees any resources associated with the u64, if we are in the Some state */ -void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res); +void COption_u64Z_free(struct LDKCOption_u64Z _res); + +/** + * Creates a new COption_u64Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); + +/** + * Creates a new CResult_RouteLightningErrorZ in the success state. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o); + +/** + * Creates a new CResult_RouteLightningErrorZ in the error state. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); + +/** + * Frees any resources used by the CResult_RouteLightningErrorZ. + */ +void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); + +/** + * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); + +/** + * Creates a new CResult_boolLightningErrorZ in the success state. + */ +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); + +/** + * Creates a new CResult_boolLightningErrorZ in the error state. + */ +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); + +/** + * Frees any resources used by the CResult_boolLightningErrorZ. + */ +void CResult_boolLightningErrorZ_free(struct LDKCResult_boolLightningErrorZ _res); + +/** + * Creates a new CResult_boolLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_clone(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR orig); + +/** + * Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. + */ +struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); + +/** + * Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. + */ +void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res); /** - * Creates a new CResult_NoneAPIErrorZ in the success state. + * Creates a new CResult_NoneLightningErrorZ in the success state. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); /** - * Creates a new CResult_NoneAPIErrorZ in the error state. + * Creates a new CResult_NoneLightningErrorZ in the error state. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); /** - * Frees any resources used by the CResult_NoneAPIErrorZ. + * Frees any resources used by the CResult_NoneLightningErrorZ. */ -void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); +void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); /** - * Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` + * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); +void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); +void CVec_u8Z_free(struct LDKCVec_u8Z _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. */ -void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); /** - * Creates a new CResult_NonePaymentSendFailureZ in the success state. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e); /** - * Creates a new CResult_NonePaymentSendFailureZ in the error state. + * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +void CResult_CVec_u8ZPeerHandleErrorZ_free(struct LDKCResult_CVec_u8ZPeerHandleErrorZ _res); /** - * Frees any resources used by the CResult_NonePaymentSendFailureZ. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_NonePaymentSendFailureZ_free(struct LDKCResult_NonePaymentSendFailureZ _res); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_clone(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_NonePeerHandleErrorZ in the success state. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NonePeerHandleErrorZ in the error state. */ -void CVec_ChannelMonitorZ_free(struct LDKCVec_ChannelMonitorZ _res); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); /** - * Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. + * Frees any resources used by the CResult_NonePeerHandleErrorZ. */ -struct LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b); +void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); /** - * Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. + * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void C2Tuple_BlockHashChannelManagerZ_free(struct LDKC2Tuple_BlockHashChannelManagerZ _res); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. + * Creates a new CResult_boolPeerHandleErrorZ in the success state. */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelManagerZ o); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); /** - * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. + * Creates a new CResult_boolPeerHandleErrorZ in the error state. */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); /** - * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. + * Frees any resources used by the CResult_boolPeerHandleErrorZ. */ -void CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res); +void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. + * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_ok(struct LDKSpendableOutputDescriptor o); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. + * Creates a new CResult_TxOutAccessErrorZ in the success state. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_ok(struct LDKTxOut o); /** - * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. + * Creates a new CResult_TxOutAccessErrorZ in the error state. */ -void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res); +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_err(enum LDKAccessError e); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_TxOutAccessErrorZ. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); +void CResult_TxOutAccessErrorZ_free(struct LDKCResult_TxOutAccessErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); +struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o); /** - * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing */ -void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); +struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); +void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); +void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); /** - * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. + * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state. */ -void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); +struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_ok(struct LDKDirectionalChannelInfo o); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` + * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ. + */ +void CResult_DirectionalChannelInfoDecodeErrorZ_free(struct LDKCResult_DirectionalChannelInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); +struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_clone(const struct LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SignatureNoneZ in the success state. + * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(struct LDKChannelInfo o); /** - * Creates a new CResult_SignatureNoneZ in the error state. + * Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_SignatureNoneZ. + * Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. */ -void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); +void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); /** - * Creates a new CResult_SignatureNoneZ which has the same data as `orig` + * Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SignDecodeErrorZ in the success state. + * Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_ok(struct LDKSign o); +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); /** - * Creates a new CResult_SignDecodeErrorZ in the error state. + * Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_SignDecodeErrorZ. + * Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. */ -void CResult_SignDecodeErrorZ_free(struct LDKCResult_SignDecodeErrorZ _res); +void CResult_RoutingFeesDecodeErrorZ_free(struct LDKCResult_RoutingFeesDecodeErrorZ _res); /** - * Creates a new CResult_SignDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_clone(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_clone(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); +void CVec_NetAddressZ_free(struct LDKCVec_NetAddressZ _res); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_ok(struct LDKNodeAnnouncementInfo o); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. + * Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. */ -void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res); +void CResult_NodeAnnouncementInfoDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); +void CVec_u64Z_free(struct LDKCVec_u64Z _res); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. + * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LDKNodeInfo o); /** - * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. + * Creates a new CResult_NodeInfoDecodeErrorZ in the error state. */ -void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` + * Frees any resources used by the CResult_NodeInfoDecodeErrorZ. + */ +void CResult_NodeInfoDecodeErrorZ_free(struct LDKCResult_NodeInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_clone(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. */ -void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(struct LDKNetworkGraph o); /** - * Creates a new CResult_TransactionNoneZ in the success state. + * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_TransactionNoneZ in the error state. + * Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); +void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); /** - * Frees any resources used by the CResult_TransactionNoneZ. + * Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. */ -void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. */ -void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res); +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_RouteDecodeErrorZ in the success state. + * Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute o); +void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res); /** - * Creates a new CResult_RouteDecodeErrorZ in the error state. + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); /** - * Frees any resources used by the CResult_RouteDecodeErrorZ. + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. */ -void CResult_RouteDecodeErrorZ_free(struct LDKCResult_RouteDecodeErrorZ _res); +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig); +void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. */ -void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); /** - * Creates a new CResult_RouteLightningErrorZ in the success state. + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o); +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_RouteLightningErrorZ in the error state. + * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); +void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); /** - * Frees any resources used by the CResult_RouteLightningErrorZ. + * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); + +/** + * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. */ -void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); +void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); /** * Creates a new CResult_NetAddressu8Z in the success state. @@ -9477,6 +9216,255 @@ void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTime */ struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_ok(struct LDKSpendableOutputDescriptor o); + +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. + */ +void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res); + +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + */ +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); + +/** + * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + */ +void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); + +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); + +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); + +/** + * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. + */ +void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); + +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SignatureNoneZ in the success state. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); + +/** + * Creates a new CResult_SignatureNoneZ in the error state. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); + +/** + * Frees any resources used by the CResult_SignatureNoneZ. + */ +void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); + +/** + * Creates a new CResult_SignatureNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SignDecodeErrorZ in the success state. + */ +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_ok(struct LDKSign o); + +/** + * Creates a new CResult_SignDecodeErrorZ in the error state. + */ +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_SignDecodeErrorZ. + */ +void CResult_SignDecodeErrorZ_free(struct LDKCResult_SignDecodeErrorZ _res); + +/** + * Creates a new CResult_SignDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_clone(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); + +/** + * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. + */ +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o); + +/** + * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. + */ +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); + +/** + * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. + */ +void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res); + +/** + * Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. + */ +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); + +/** + * Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. + */ +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. + */ +void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); + +/** + * Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); + +/** + * Creates a new CResult_TransactionNoneZ in the success state. + */ +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); + +/** + * Creates a new CResult_TransactionNoneZ in the error state. + */ +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); + +/** + * Frees any resources used by the CResult_TransactionNoneZ. + */ +void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); + +/** + * Creates a new CResult_NoneAPIErrorZ in the success state. + */ +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); + +/** + * Creates a new CResult_NoneAPIErrorZ in the error state. + */ +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); + +/** + * Frees any resources used by the CResult_NoneAPIErrorZ. + */ +void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); + +/** + * Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); + +/** + * Creates a new CResult_NonePaymentSendFailureZ in the success state. + */ +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); + +/** + * Creates a new CResult_NonePaymentSendFailureZ in the error state. + */ +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); + +/** + * Frees any resources used by the CResult_NonePaymentSendFailureZ. + */ +void CResult_NonePaymentSendFailureZ_free(struct LDKCResult_NonePaymentSendFailureZ _res); + +/** + * Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ChannelMonitorZ_free(struct LDKCVec_ChannelMonitorZ _res); + +/** + * Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. + */ +struct LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b); + +/** + * Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. + */ +void C2Tuple_BlockHashChannelManagerZ_free(struct LDKC2Tuple_BlockHashChannelManagerZ _res); + +/** + * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. + */ +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelManagerZ o); + +/** + * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. + */ +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. + */ +void CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res); + /** * Frees any resources used by the Event */ diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index 008b0f4..0d5ed8f 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -1,5 +1,65 @@ #include namespace LDK { +class ChannelHandshakeConfig { +private: + LDKChannelHandshakeConfig self; +public: + ChannelHandshakeConfig(const ChannelHandshakeConfig&) = delete; + 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; } + ~ChannelHandshakeConfig() { ChannelHandshakeConfig_free(self); } + ChannelHandshakeConfig& operator=(ChannelHandshakeConfig&& o) { ChannelHandshakeConfig_free(self); self = o.self; memset(&o, 0, sizeof(ChannelHandshakeConfig)); return *this; } + 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&& 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; } + ~ChannelHandshakeLimits() { ChannelHandshakeLimits_free(self); } + ChannelHandshakeLimits& operator=(ChannelHandshakeLimits&& o) { ChannelHandshakeLimits_free(self); self = o.self; memset(&o, 0, sizeof(ChannelHandshakeLimits)); return *this; } + 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&& 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; } + ~ChannelConfig() { ChannelConfig_free(self); } + ChannelConfig& operator=(ChannelConfig&& o) { ChannelConfig_free(self); self = o.self; memset(&o, 0, sizeof(ChannelConfig)); return *this; } + 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&& 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; } + ~UserConfig() { UserConfig_free(self); } + UserConfig& operator=(UserConfig&& o) { UserConfig_free(self); self = o.self; memset(&o, 0, sizeof(UserConfig)); return *this; } + LDKUserConfig* operator &() { return &self; } + LDKUserConfig* operator ->() { return &self; } + const LDKUserConfig* operator &() const { return &self; } + const LDKUserConfig* operator ->() const { return &self; } +}; class APIError { private: LDKAPIError self; @@ -15,6 +75,21 @@ public: const LDKAPIError* operator &() const { return &self; } const LDKAPIError* operator ->() const { return &self; } }; +class OutPoint { +private: + LDKOutPoint self; +public: + OutPoint(const OutPoint&) = delete; + 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; } + ~OutPoint() { OutPoint_free(self); } + OutPoint& operator=(OutPoint&& o) { OutPoint_free(self); self = o.self; memset(&o, 0, sizeof(OutPoint)); return *this; } + LDKOutPoint* operator &() { return &self; } + LDKOutPoint* operator ->() { return &self; } + const LDKOutPoint* operator &() const { return &self; } + const LDKOutPoint* operator ->() const { return &self; } +}; class TxCreationKeys { private: LDKTxCreationKeys self; @@ -165,6 +240,155 @@ public: const LDKTrustedCommitmentTransaction* operator &() const { return &self; } const LDKTrustedCommitmentTransaction* operator ->() const { return &self; } }; +class ChannelMonitorUpdate { +private: + LDKChannelMonitorUpdate self; +public: + ChannelMonitorUpdate(const ChannelMonitorUpdate&) = delete; + 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; } + ~ChannelMonitorUpdate() { ChannelMonitorUpdate_free(self); } + ChannelMonitorUpdate& operator=(ChannelMonitorUpdate&& o) { ChannelMonitorUpdate_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMonitorUpdate)); return *this; } + 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; } + ChannelMonitorUpdateErr& operator=(ChannelMonitorUpdateErr&& o) { self = o.self; memset(&o, 0, sizeof(ChannelMonitorUpdateErr)); return *this; } + 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&& 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; } + ~MonitorUpdateError() { MonitorUpdateError_free(self); } + MonitorUpdateError& operator=(MonitorUpdateError&& o) { MonitorUpdateError_free(self); self = o.self; memset(&o, 0, sizeof(MonitorUpdateError)); return *this; } + 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&& 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; } + ~MonitorEvent() { MonitorEvent_free(self); } + MonitorEvent& operator=(MonitorEvent&& o) { MonitorEvent_free(self); self = o.self; memset(&o, 0, sizeof(MonitorEvent)); return *this; } + 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&& 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; } + ~HTLCUpdate() { HTLCUpdate_free(self); } + HTLCUpdate& operator=(HTLCUpdate&& o) { HTLCUpdate_free(self); self = o.self; memset(&o, 0, sizeof(HTLCUpdate)); return *this; } + 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&& 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; } + ~ChannelMonitor() { ChannelMonitor_free(self); } + ChannelMonitor& operator=(ChannelMonitor&& o) { ChannelMonitor_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMonitor)); return *this; } + LDKChannelMonitor* operator &() { return &self; } + LDKChannelMonitor* operator ->() { return &self; } + const LDKChannelMonitor* operator &() const { return &self; } + const LDKChannelMonitor* operator ->() const { return &self; } +}; +class Persist { +private: + LDKPersist self; +public: + Persist(const Persist&) = delete; + Persist(Persist&& o) : self(o.self) { memset(&o, 0, sizeof(Persist)); } + Persist(LDKPersist&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPersist)); } + operator LDKPersist() && { LDKPersist res = self; memset(&self, 0, sizeof(LDKPersist)); return res; } + ~Persist() { Persist_free(self); } + Persist& operator=(Persist&& o) { Persist_free(self); self = o.self; memset(&o, 0, sizeof(Persist)); return *this; } + LDKPersist* operator &() { return &self; } + LDKPersist* operator ->() { return &self; } + const LDKPersist* operator &() const { return &self; } + const LDKPersist* operator ->() const { return &self; } +}; +class RouteHop { +private: + LDKRouteHop self; +public: + RouteHop(const RouteHop&) = delete; + 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; } + ~RouteHop() { RouteHop_free(self); } + RouteHop& operator=(RouteHop&& o) { RouteHop_free(self); self = o.self; memset(&o, 0, sizeof(RouteHop)); return *this; } + 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&& 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; } + ~Route() { Route_free(self); } + Route& operator=(Route&& o) { Route_free(self); self = o.self; memset(&o, 0, sizeof(Route)); return *this; } + 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&& 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; } + ~RouteHint() { RouteHint_free(self); } + RouteHint& operator=(RouteHint&& o) { RouteHint_free(self); self = o.self; memset(&o, 0, sizeof(RouteHint)); return *this; } + LDKRouteHint* operator &() { return &self; } + LDKRouteHint* operator ->() { return &self; } + const LDKRouteHint* operator &() const { return &self; } + const LDKRouteHint* operator ->() const { return &self; } +}; class IgnoringMessageHandler { private: LDKIgnoringMessageHandler self; @@ -255,125 +479,198 @@ public: const LDKPeerManager* operator &() const { return &self; } const LDKPeerManager* operator ->() const { return &self; } }; -class InitFeatures { +class BroadcasterInterface { private: - LDKInitFeatures self; + LDKBroadcasterInterface self; public: - InitFeatures(const InitFeatures&) = delete; - 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; } - ~InitFeatures() { InitFeatures_free(self); } - InitFeatures& operator=(InitFeatures&& o) { InitFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InitFeatures)); return *this; } - LDKInitFeatures* operator &() { return &self; } - LDKInitFeatures* operator ->() { return &self; } - const LDKInitFeatures* operator &() const { return &self; } - const LDKInitFeatures* operator ->() const { return &self; } + BroadcasterInterface(const BroadcasterInterface&) = delete; + 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; } + ~BroadcasterInterface() { BroadcasterInterface_free(self); } + BroadcasterInterface& operator=(BroadcasterInterface&& o) { BroadcasterInterface_free(self); self = o.self; memset(&o, 0, sizeof(BroadcasterInterface)); return *this; } + LDKBroadcasterInterface* operator &() { return &self; } + LDKBroadcasterInterface* operator ->() { return &self; } + const LDKBroadcasterInterface* operator &() const { return &self; } + const LDKBroadcasterInterface* operator ->() const { return &self; } }; -class NodeFeatures { +class ConfirmationTarget { private: - LDKNodeFeatures self; + LDKConfirmationTarget self; public: - NodeFeatures(const NodeFeatures&) = delete; - 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; } - ~NodeFeatures() { NodeFeatures_free(self); } - NodeFeatures& operator=(NodeFeatures&& o) { NodeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(NodeFeatures)); return *this; } - LDKNodeFeatures* operator &() { return &self; } - LDKNodeFeatures* operator ->() { return &self; } - const LDKNodeFeatures* operator &() const { return &self; } - const LDKNodeFeatures* operator ->() const { return &self; } + 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; } + ConfirmationTarget& operator=(ConfirmationTarget&& o) { self = o.self; memset(&o, 0, sizeof(ConfirmationTarget)); return *this; } + LDKConfirmationTarget* operator &() { return &self; } + LDKConfirmationTarget* operator ->() { return &self; } + const LDKConfirmationTarget* operator &() const { return &self; } + const LDKConfirmationTarget* operator ->() const { return &self; } }; -class ChannelFeatures { +class FeeEstimator { private: - LDKChannelFeatures self; + LDKFeeEstimator self; public: - ChannelFeatures(const ChannelFeatures&) = delete; - 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; } - ~ChannelFeatures() { ChannelFeatures_free(self); } - ChannelFeatures& operator=(ChannelFeatures&& o) { ChannelFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelFeatures)); return *this; } - LDKChannelFeatures* operator &() { return &self; } - LDKChannelFeatures* operator ->() { return &self; } - const LDKChannelFeatures* operator &() const { return &self; } - const LDKChannelFeatures* operator ->() const { return &self; } + FeeEstimator(const FeeEstimator&) = delete; + 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; } + ~FeeEstimator() { FeeEstimator_free(self); } + FeeEstimator& operator=(FeeEstimator&& o) { FeeEstimator_free(self); self = o.self; memset(&o, 0, sizeof(FeeEstimator)); return *this; } + LDKFeeEstimator* operator &() { return &self; } + LDKFeeEstimator* operator ->() { return &self; } + const LDKFeeEstimator* operator &() const { return &self; } + const LDKFeeEstimator* operator ->() const { return &self; } }; -class InvoiceFeatures { +class AccessError { private: - LDKInvoiceFeatures self; + LDKAccessError self; public: - InvoiceFeatures(const InvoiceFeatures&) = delete; - InvoiceFeatures(InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceFeatures)); } - InvoiceFeatures(LDKInvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceFeatures)); } - operator LDKInvoiceFeatures() && { LDKInvoiceFeatures res = self; memset(&self, 0, sizeof(LDKInvoiceFeatures)); return res; } - ~InvoiceFeatures() { InvoiceFeatures_free(self); } - InvoiceFeatures& operator=(InvoiceFeatures&& o) { InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceFeatures)); return *this; } - LDKInvoiceFeatures* operator &() { return &self; } - LDKInvoiceFeatures* operator ->() { return &self; } - const LDKInvoiceFeatures* operator &() const { return &self; } - const LDKInvoiceFeatures* operator ->() const { return &self; } + AccessError(const AccessError&) = delete; + AccessError(AccessError&& o) : self(o.self) { memset(&o, 0, sizeof(AccessError)); } + AccessError(LDKAccessError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAccessError)); } + operator LDKAccessError() && { LDKAccessError res = self; memset(&self, 0, sizeof(LDKAccessError)); return res; } + AccessError& operator=(AccessError&& o) { self = o.self; memset(&o, 0, sizeof(AccessError)); return *this; } + LDKAccessError* operator &() { return &self; } + LDKAccessError* operator ->() { return &self; } + const LDKAccessError* operator &() const { return &self; } + const LDKAccessError* operator ->() const { return &self; } }; -class ChannelHandshakeConfig { +class Access { private: - LDKChannelHandshakeConfig self; + LDKAccess self; public: - ChannelHandshakeConfig(const ChannelHandshakeConfig&) = delete; - 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; } - ~ChannelHandshakeConfig() { ChannelHandshakeConfig_free(self); } - ChannelHandshakeConfig& operator=(ChannelHandshakeConfig&& o) { ChannelHandshakeConfig_free(self); self = o.self; memset(&o, 0, sizeof(ChannelHandshakeConfig)); return *this; } - LDKChannelHandshakeConfig* operator &() { return &self; } - LDKChannelHandshakeConfig* operator ->() { return &self; } - const LDKChannelHandshakeConfig* operator &() const { return &self; } - const LDKChannelHandshakeConfig* operator ->() const { return &self; } + Access(const Access&) = delete; + Access(Access&& o) : self(o.self) { memset(&o, 0, sizeof(Access)); } + Access(LDKAccess&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAccess)); } + operator LDKAccess() && { LDKAccess res = self; memset(&self, 0, sizeof(LDKAccess)); return res; } + ~Access() { Access_free(self); } + Access& operator=(Access&& o) { Access_free(self); self = o.self; memset(&o, 0, sizeof(Access)); return *this; } + LDKAccess* operator &() { return &self; } + LDKAccess* operator ->() { return &self; } + const LDKAccess* operator &() const { return &self; } + const LDKAccess* operator ->() const { return &self; } }; -class ChannelHandshakeLimits { +class Listen { private: - LDKChannelHandshakeLimits self; + LDKListen self; public: - ChannelHandshakeLimits(const ChannelHandshakeLimits&) = delete; - 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; } - ~ChannelHandshakeLimits() { ChannelHandshakeLimits_free(self); } - ChannelHandshakeLimits& operator=(ChannelHandshakeLimits&& o) { ChannelHandshakeLimits_free(self); self = o.self; memset(&o, 0, sizeof(ChannelHandshakeLimits)); return *this; } - LDKChannelHandshakeLimits* operator &() { return &self; } - LDKChannelHandshakeLimits* operator ->() { return &self; } - const LDKChannelHandshakeLimits* operator &() const { return &self; } - const LDKChannelHandshakeLimits* operator ->() const { return &self; } + Listen(const Listen&) = delete; + Listen(Listen&& o) : self(o.self) { memset(&o, 0, sizeof(Listen)); } + Listen(LDKListen&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKListen)); } + operator LDKListen() && { LDKListen res = self; memset(&self, 0, sizeof(LDKListen)); return res; } + ~Listen() { Listen_free(self); } + Listen& operator=(Listen&& o) { Listen_free(self); self = o.self; memset(&o, 0, sizeof(Listen)); return *this; } + LDKListen* operator &() { return &self; } + LDKListen* operator ->() { return &self; } + const LDKListen* operator &() const { return &self; } + const LDKListen* operator ->() const { return &self; } }; -class ChannelConfig { +class Watch { private: - LDKChannelConfig self; + LDKWatch self; public: - ChannelConfig(const ChannelConfig&) = delete; - 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; } - ~ChannelConfig() { ChannelConfig_free(self); } - ChannelConfig& operator=(ChannelConfig&& o) { ChannelConfig_free(self); self = o.self; memset(&o, 0, sizeof(ChannelConfig)); return *this; } - LDKChannelConfig* operator &() { return &self; } - LDKChannelConfig* operator ->() { return &self; } - const LDKChannelConfig* operator &() const { return &self; } - const LDKChannelConfig* operator ->() const { return &self; } + Watch(const Watch&) = delete; + Watch(Watch&& o) : self(o.self) { memset(&o, 0, sizeof(Watch)); } + Watch(LDKWatch&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatch)); } + operator LDKWatch() && { LDKWatch res = self; memset(&self, 0, sizeof(LDKWatch)); return res; } + ~Watch() { Watch_free(self); } + Watch& operator=(Watch&& o) { Watch_free(self); self = o.self; memset(&o, 0, sizeof(Watch)); return *this; } + LDKWatch* operator &() { return &self; } + LDKWatch* operator ->() { return &self; } + const LDKWatch* operator &() const { return &self; } + const LDKWatch* operator ->() const { return &self; } }; -class UserConfig { +class Filter { private: - LDKUserConfig self; + LDKFilter self; public: - UserConfig(const UserConfig&) = delete; - 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; } - ~UserConfig() { UserConfig_free(self); } - UserConfig& operator=(UserConfig&& o) { UserConfig_free(self); self = o.self; memset(&o, 0, sizeof(UserConfig)); return *this; } - LDKUserConfig* operator &() { return &self; } - LDKUserConfig* operator ->() { return &self; } - const LDKUserConfig* operator &() const { return &self; } - const LDKUserConfig* operator ->() const { return &self; } + Filter(const Filter&) = delete; + Filter(Filter&& o) : self(o.self) { memset(&o, 0, sizeof(Filter)); } + Filter(LDKFilter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFilter)); } + operator LDKFilter() && { LDKFilter res = self; memset(&self, 0, sizeof(LDKFilter)); return res; } + ~Filter() { Filter_free(self); } + Filter& operator=(Filter&& o) { Filter_free(self); self = o.self; memset(&o, 0, sizeof(Filter)); return *this; } + LDKFilter* operator &() { return &self; } + LDKFilter* operator ->() { return &self; } + const LDKFilter* operator &() const { return &self; } + const LDKFilter* operator ->() const { return &self; } +}; +class WatchedOutput { +private: + LDKWatchedOutput self; +public: + WatchedOutput(const WatchedOutput&) = delete; + WatchedOutput(WatchedOutput&& o) : self(o.self) { memset(&o, 0, sizeof(WatchedOutput)); } + WatchedOutput(LDKWatchedOutput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatchedOutput)); } + operator LDKWatchedOutput() && { LDKWatchedOutput res = self; memset(&self, 0, sizeof(LDKWatchedOutput)); return res; } + ~WatchedOutput() { WatchedOutput_free(self); } + WatchedOutput& operator=(WatchedOutput&& o) { WatchedOutput_free(self); self = o.self; memset(&o, 0, sizeof(WatchedOutput)); return *this; } + LDKWatchedOutput* operator &() { return &self; } + LDKWatchedOutput* operator ->() { return &self; } + const LDKWatchedOutput* operator &() const { return &self; } + const LDKWatchedOutput* operator ->() const { return &self; } +}; +class Event { +private: + LDKEvent self; +public: + Event(const Event&) = delete; + 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; } + ~Event() { Event_free(self); } + Event& operator=(Event&& o) { Event_free(self); self = o.self; memset(&o, 0, sizeof(Event)); return *this; } + 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&& 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; } + ~MessageSendEvent() { MessageSendEvent_free(self); } + MessageSendEvent& operator=(MessageSendEvent&& o) { MessageSendEvent_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEvent)); return *this; } + 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&& 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; } + ~MessageSendEventsProvider() { MessageSendEventsProvider_free(self); } + MessageSendEventsProvider& operator=(MessageSendEventsProvider&& o) { MessageSendEventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEventsProvider)); return *this; } + 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&& 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; } + ~EventsProvider() { EventsProvider_free(self); } + EventsProvider& operator=(EventsProvider&& o) { EventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(EventsProvider)); return *this; } + LDKEventsProvider* operator &() { return &self; } + LDKEventsProvider* operator ->() { return &self; } + const LDKEventsProvider* operator &() const { return &self; } + const LDKEventsProvider* operator ->() const { return &self; } }; class NetworkGraph { private: @@ -495,616 +792,65 @@ public: const LDKNodeInfo* operator &() const { return &self; } const LDKNodeInfo* operator ->() const { return &self; } }; -class Level { +class InitFeatures { private: - LDKLevel self; + LDKInitFeatures 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; } - Level& operator=(Level&& o) { self = o.self; memset(&o, 0, sizeof(Level)); return *this; } - LDKLevel* operator &() { return &self; } - LDKLevel* operator ->() { return &self; } - const LDKLevel* operator &() const { return &self; } - const LDKLevel* operator ->() const { return &self; } + InitFeatures(const InitFeatures&) = delete; + 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; } + ~InitFeatures() { InitFeatures_free(self); } + InitFeatures& operator=(InitFeatures&& o) { InitFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InitFeatures)); return *this; } + LDKInitFeatures* operator &() { return &self; } + LDKInitFeatures* operator ->() { return &self; } + const LDKInitFeatures* operator &() const { return &self; } + const LDKInitFeatures* operator ->() const { return &self; } }; -class Logger { -private: - LDKLogger self; -public: - Logger(const Logger&) = delete; - 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; } - ~Logger() { Logger_free(self); } - Logger& operator=(Logger&& o) { Logger_free(self); self = o.self; memset(&o, 0, sizeof(Logger)); return *this; } - LDKLogger* operator &() { return &self; } - LDKLogger* operator ->() { return &self; } - const LDKLogger* operator &() const { return &self; } - const LDKLogger* operator ->() const { return &self; } -}; -class ChainMonitor { -private: - LDKChainMonitor self; -public: - ChainMonitor(const ChainMonitor&) = delete; - ChainMonitor(ChainMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChainMonitor)); } - ChainMonitor(LDKChainMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainMonitor)); } - operator LDKChainMonitor() && { LDKChainMonitor res = self; memset(&self, 0, sizeof(LDKChainMonitor)); return res; } - ~ChainMonitor() { ChainMonitor_free(self); } - ChainMonitor& operator=(ChainMonitor&& o) { ChainMonitor_free(self); self = o.self; memset(&o, 0, sizeof(ChainMonitor)); return *this; } - LDKChainMonitor* operator &() { return &self; } - LDKChainMonitor* operator ->() { return &self; } - const LDKChainMonitor* operator &() const { return &self; } - const LDKChainMonitor* operator ->() const { return &self; } -}; -class OutPoint { -private: - LDKOutPoint self; -public: - OutPoint(const OutPoint&) = delete; - 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; } - ~OutPoint() { OutPoint_free(self); } - OutPoint& operator=(OutPoint&& o) { OutPoint_free(self); self = o.self; memset(&o, 0, sizeof(OutPoint)); return *this; } - LDKOutPoint* operator &() { return &self; } - LDKOutPoint* operator ->() { return &self; } - const LDKOutPoint* operator &() const { return &self; } - const LDKOutPoint* operator ->() const { return &self; } -}; -class ChannelMonitorUpdate { -private: - LDKChannelMonitorUpdate self; -public: - ChannelMonitorUpdate(const ChannelMonitorUpdate&) = delete; - 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; } - ~ChannelMonitorUpdate() { ChannelMonitorUpdate_free(self); } - ChannelMonitorUpdate& operator=(ChannelMonitorUpdate&& o) { ChannelMonitorUpdate_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMonitorUpdate)); return *this; } - 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; } - ChannelMonitorUpdateErr& operator=(ChannelMonitorUpdateErr&& o) { self = o.self; memset(&o, 0, sizeof(ChannelMonitorUpdateErr)); return *this; } - 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&& 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; } - ~MonitorUpdateError() { MonitorUpdateError_free(self); } - MonitorUpdateError& operator=(MonitorUpdateError&& o) { MonitorUpdateError_free(self); self = o.self; memset(&o, 0, sizeof(MonitorUpdateError)); return *this; } - 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&& 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; } - ~MonitorEvent() { MonitorEvent_free(self); } - MonitorEvent& operator=(MonitorEvent&& o) { MonitorEvent_free(self); self = o.self; memset(&o, 0, sizeof(MonitorEvent)); return *this; } - 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&& 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; } - ~HTLCUpdate() { HTLCUpdate_free(self); } - HTLCUpdate& operator=(HTLCUpdate&& o) { HTLCUpdate_free(self); self = o.self; memset(&o, 0, sizeof(HTLCUpdate)); return *this; } - 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&& 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; } - ~ChannelMonitor() { ChannelMonitor_free(self); } - ChannelMonitor& operator=(ChannelMonitor&& o) { ChannelMonitor_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMonitor)); return *this; } - LDKChannelMonitor* operator &() { return &self; } - LDKChannelMonitor* operator ->() { return &self; } - const LDKChannelMonitor* operator &() const { return &self; } - const LDKChannelMonitor* operator ->() const { return &self; } -}; -class Persist { -private: - LDKPersist self; -public: - Persist(const Persist&) = delete; - Persist(Persist&& o) : self(o.self) { memset(&o, 0, sizeof(Persist)); } - Persist(LDKPersist&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPersist)); } - operator LDKPersist() && { LDKPersist res = self; memset(&self, 0, sizeof(LDKPersist)); return res; } - ~Persist() { Persist_free(self); } - Persist& operator=(Persist&& o) { Persist_free(self); self = o.self; memset(&o, 0, sizeof(Persist)); return *this; } - LDKPersist* operator &() { return &self; } - LDKPersist* operator ->() { return &self; } - const LDKPersist* operator &() const { return &self; } - const LDKPersist* operator ->() const { return &self; } -}; -class Event { -private: - LDKEvent self; -public: - Event(const Event&) = delete; - 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; } - ~Event() { Event_free(self); } - Event& operator=(Event&& o) { Event_free(self); self = o.self; memset(&o, 0, sizeof(Event)); return *this; } - 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&& 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; } - ~MessageSendEvent() { MessageSendEvent_free(self); } - MessageSendEvent& operator=(MessageSendEvent&& o) { MessageSendEvent_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEvent)); return *this; } - 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&& 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; } - ~MessageSendEventsProvider() { MessageSendEventsProvider_free(self); } - MessageSendEventsProvider& operator=(MessageSendEventsProvider&& o) { MessageSendEventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEventsProvider)); return *this; } - 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&& 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; } - ~EventsProvider() { EventsProvider_free(self); } - EventsProvider& operator=(EventsProvider&& o) { EventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(EventsProvider)); return *this; } - LDKEventsProvider* operator &() { return &self; } - LDKEventsProvider* operator ->() { return &self; } - const LDKEventsProvider* operator &() const { return &self; } - const LDKEventsProvider* operator ->() const { return &self; } -}; -class AccessError { -private: - LDKAccessError self; -public: - AccessError(const AccessError&) = delete; - AccessError(AccessError&& o) : self(o.self) { memset(&o, 0, sizeof(AccessError)); } - AccessError(LDKAccessError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAccessError)); } - operator LDKAccessError() && { LDKAccessError res = self; memset(&self, 0, sizeof(LDKAccessError)); return res; } - AccessError& operator=(AccessError&& o) { self = o.self; memset(&o, 0, sizeof(AccessError)); return *this; } - LDKAccessError* operator &() { return &self; } - LDKAccessError* operator ->() { return &self; } - const LDKAccessError* operator &() const { return &self; } - const LDKAccessError* operator ->() const { return &self; } -}; -class Access { -private: - LDKAccess self; -public: - Access(const Access&) = delete; - Access(Access&& o) : self(o.self) { memset(&o, 0, sizeof(Access)); } - Access(LDKAccess&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAccess)); } - operator LDKAccess() && { LDKAccess res = self; memset(&self, 0, sizeof(LDKAccess)); return res; } - ~Access() { Access_free(self); } - Access& operator=(Access&& o) { Access_free(self); self = o.self; memset(&o, 0, sizeof(Access)); return *this; } - LDKAccess* operator &() { return &self; } - LDKAccess* operator ->() { return &self; } - const LDKAccess* operator &() const { return &self; } - const LDKAccess* operator ->() const { return &self; } -}; -class Listen { -private: - LDKListen self; -public: - Listen(const Listen&) = delete; - Listen(Listen&& o) : self(o.self) { memset(&o, 0, sizeof(Listen)); } - Listen(LDKListen&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKListen)); } - operator LDKListen() && { LDKListen res = self; memset(&self, 0, sizeof(LDKListen)); return res; } - ~Listen() { Listen_free(self); } - Listen& operator=(Listen&& o) { Listen_free(self); self = o.self; memset(&o, 0, sizeof(Listen)); return *this; } - LDKListen* operator &() { return &self; } - LDKListen* operator ->() { return &self; } - const LDKListen* operator &() const { return &self; } - const LDKListen* operator ->() const { return &self; } -}; -class Watch { -private: - LDKWatch self; -public: - Watch(const Watch&) = delete; - Watch(Watch&& o) : self(o.self) { memset(&o, 0, sizeof(Watch)); } - Watch(LDKWatch&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatch)); } - operator LDKWatch() && { LDKWatch res = self; memset(&self, 0, sizeof(LDKWatch)); return res; } - ~Watch() { Watch_free(self); } - Watch& operator=(Watch&& o) { Watch_free(self); self = o.self; memset(&o, 0, sizeof(Watch)); return *this; } - LDKWatch* operator &() { return &self; } - LDKWatch* operator ->() { return &self; } - const LDKWatch* operator &() const { return &self; } - const LDKWatch* operator ->() const { return &self; } -}; -class Filter { -private: - LDKFilter self; -public: - Filter(const Filter&) = delete; - Filter(Filter&& o) : self(o.self) { memset(&o, 0, sizeof(Filter)); } - Filter(LDKFilter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFilter)); } - operator LDKFilter() && { LDKFilter res = self; memset(&self, 0, sizeof(LDKFilter)); return res; } - ~Filter() { Filter_free(self); } - Filter& operator=(Filter&& o) { Filter_free(self); self = o.self; memset(&o, 0, sizeof(Filter)); return *this; } - LDKFilter* operator &() { return &self; } - LDKFilter* operator ->() { return &self; } - const LDKFilter* operator &() const { return &self; } - const LDKFilter* operator ->() const { return &self; } -}; -class WatchedOutput { -private: - LDKWatchedOutput self; -public: - WatchedOutput(const WatchedOutput&) = delete; - WatchedOutput(WatchedOutput&& o) : self(o.self) { memset(&o, 0, sizeof(WatchedOutput)); } - WatchedOutput(LDKWatchedOutput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatchedOutput)); } - operator LDKWatchedOutput() && { LDKWatchedOutput res = self; memset(&self, 0, sizeof(LDKWatchedOutput)); return res; } - ~WatchedOutput() { WatchedOutput_free(self); } - WatchedOutput& operator=(WatchedOutput&& o) { WatchedOutput_free(self); self = o.self; memset(&o, 0, sizeof(WatchedOutput)); return *this; } - LDKWatchedOutput* operator &() { return &self; } - LDKWatchedOutput* operator ->() { return &self; } - const LDKWatchedOutput* operator &() const { return &self; } - const LDKWatchedOutput* operator ->() const { return &self; } -}; -class BroadcasterInterface { -private: - LDKBroadcasterInterface self; -public: - BroadcasterInterface(const BroadcasterInterface&) = delete; - 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; } - ~BroadcasterInterface() { BroadcasterInterface_free(self); } - BroadcasterInterface& operator=(BroadcasterInterface&& o) { BroadcasterInterface_free(self); self = o.self; memset(&o, 0, sizeof(BroadcasterInterface)); return *this; } - LDKBroadcasterInterface* operator &() { return &self; } - LDKBroadcasterInterface* operator ->() { return &self; } - const LDKBroadcasterInterface* operator &() const { return &self; } - const LDKBroadcasterInterface* 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; } - ConfirmationTarget& operator=(ConfirmationTarget&& o) { self = o.self; memset(&o, 0, sizeof(ConfirmationTarget)); return *this; } - 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&& 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; } - ~FeeEstimator() { FeeEstimator_free(self); } - FeeEstimator& operator=(FeeEstimator&& o) { FeeEstimator_free(self); self = o.self; memset(&o, 0, sizeof(FeeEstimator)); return *this; } - LDKFeeEstimator* operator &() { return &self; } - LDKFeeEstimator* operator ->() { return &self; } - const LDKFeeEstimator* operator &() const { return &self; } - const LDKFeeEstimator* operator ->() const { return &self; } -}; -class ChannelManager { -private: - LDKChannelManager self; -public: - ChannelManager(const ChannelManager&) = delete; - 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; } - ~ChannelManager() { ChannelManager_free(self); } - ChannelManager& operator=(ChannelManager&& o) { ChannelManager_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManager)); return *this; } - LDKChannelManager* operator &() { return &self; } - LDKChannelManager* operator ->() { return &self; } - const LDKChannelManager* operator &() const { return &self; } - const LDKChannelManager* operator ->() const { return &self; } -}; -class ChainParameters { -private: - LDKChainParameters self; -public: - ChainParameters(const ChainParameters&) = delete; - ChainParameters(ChainParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChainParameters)); } - ChainParameters(LDKChainParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainParameters)); } - operator LDKChainParameters() && { LDKChainParameters res = self; memset(&self, 0, sizeof(LDKChainParameters)); return res; } - ~ChainParameters() { ChainParameters_free(self); } - ChainParameters& operator=(ChainParameters&& o) { ChainParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChainParameters)); return *this; } - LDKChainParameters* operator &() { return &self; } - LDKChainParameters* operator ->() { return &self; } - const LDKChainParameters* operator &() const { return &self; } - const LDKChainParameters* operator ->() const { return &self; } -}; -class BestBlock { -private: - LDKBestBlock self; -public: - BestBlock(const BestBlock&) = delete; - BestBlock(BestBlock&& o) : self(o.self) { memset(&o, 0, sizeof(BestBlock)); } - BestBlock(LDKBestBlock&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBestBlock)); } - operator LDKBestBlock() && { LDKBestBlock res = self; memset(&self, 0, sizeof(LDKBestBlock)); return res; } - ~BestBlock() { BestBlock_free(self); } - BestBlock& operator=(BestBlock&& o) { BestBlock_free(self); self = o.self; memset(&o, 0, sizeof(BestBlock)); return *this; } - LDKBestBlock* operator &() { return &self; } - LDKBestBlock* operator ->() { return &self; } - const LDKBestBlock* operator &() const { return &self; } - const LDKBestBlock* operator ->() const { return &self; } -}; -class ChannelDetails { -private: - LDKChannelDetails self; -public: - ChannelDetails(const ChannelDetails&) = delete; - 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; } - ~ChannelDetails() { ChannelDetails_free(self); } - ChannelDetails& operator=(ChannelDetails&& o) { ChannelDetails_free(self); self = o.self; memset(&o, 0, sizeof(ChannelDetails)); return *this; } - 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&& 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; } - ~PaymentSendFailure() { PaymentSendFailure_free(self); } - PaymentSendFailure& operator=(PaymentSendFailure&& o) { PaymentSendFailure_free(self); self = o.self; memset(&o, 0, sizeof(PaymentSendFailure)); return *this; } - 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&& 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; } - ~ChannelManagerReadArgs() { ChannelManagerReadArgs_free(self); } - ChannelManagerReadArgs& operator=(ChannelManagerReadArgs&& o) { ChannelManagerReadArgs_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManagerReadArgs)); return *this; } - LDKChannelManagerReadArgs* operator &() { return &self; } - LDKChannelManagerReadArgs* operator ->() { return &self; } - const LDKChannelManagerReadArgs* operator &() const { return &self; } - const LDKChannelManagerReadArgs* operator ->() const { return &self; } -}; -class DelayedPaymentOutputDescriptor { -private: - LDKDelayedPaymentOutputDescriptor self; -public: - DelayedPaymentOutputDescriptor(const DelayedPaymentOutputDescriptor&) = delete; - DelayedPaymentOutputDescriptor(DelayedPaymentOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(DelayedPaymentOutputDescriptor)); } - DelayedPaymentOutputDescriptor(LDKDelayedPaymentOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDelayedPaymentOutputDescriptor)); } - operator LDKDelayedPaymentOutputDescriptor() && { LDKDelayedPaymentOutputDescriptor res = self; memset(&self, 0, sizeof(LDKDelayedPaymentOutputDescriptor)); return res; } - ~DelayedPaymentOutputDescriptor() { DelayedPaymentOutputDescriptor_free(self); } - DelayedPaymentOutputDescriptor& operator=(DelayedPaymentOutputDescriptor&& o) { DelayedPaymentOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(DelayedPaymentOutputDescriptor)); return *this; } - LDKDelayedPaymentOutputDescriptor* operator &() { return &self; } - LDKDelayedPaymentOutputDescriptor* operator ->() { return &self; } - const LDKDelayedPaymentOutputDescriptor* operator &() const { return &self; } - const LDKDelayedPaymentOutputDescriptor* operator ->() const { return &self; } -}; -class StaticPaymentOutputDescriptor { -private: - LDKStaticPaymentOutputDescriptor self; -public: - StaticPaymentOutputDescriptor(const StaticPaymentOutputDescriptor&) = delete; - StaticPaymentOutputDescriptor(StaticPaymentOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(StaticPaymentOutputDescriptor)); } - StaticPaymentOutputDescriptor(LDKStaticPaymentOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKStaticPaymentOutputDescriptor)); } - operator LDKStaticPaymentOutputDescriptor() && { LDKStaticPaymentOutputDescriptor res = self; memset(&self, 0, sizeof(LDKStaticPaymentOutputDescriptor)); return res; } - ~StaticPaymentOutputDescriptor() { StaticPaymentOutputDescriptor_free(self); } - StaticPaymentOutputDescriptor& operator=(StaticPaymentOutputDescriptor&& o) { StaticPaymentOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(StaticPaymentOutputDescriptor)); return *this; } - LDKStaticPaymentOutputDescriptor* operator &() { return &self; } - LDKStaticPaymentOutputDescriptor* operator ->() { return &self; } - const LDKStaticPaymentOutputDescriptor* operator &() const { return &self; } - const LDKStaticPaymentOutputDescriptor* operator ->() const { return &self; } -}; -class SpendableOutputDescriptor { -private: - LDKSpendableOutputDescriptor self; -public: - SpendableOutputDescriptor(const SpendableOutputDescriptor&) = delete; - 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; } - ~SpendableOutputDescriptor() { SpendableOutputDescriptor_free(self); } - SpendableOutputDescriptor& operator=(SpendableOutputDescriptor&& o) { SpendableOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(SpendableOutputDescriptor)); return *this; } - LDKSpendableOutputDescriptor* operator &() { return &self; } - LDKSpendableOutputDescriptor* operator ->() { return &self; } - const LDKSpendableOutputDescriptor* operator &() const { return &self; } - const LDKSpendableOutputDescriptor* operator ->() const { return &self; } -}; -class BaseSign { -private: - LDKBaseSign self; -public: - BaseSign(const BaseSign&) = delete; - BaseSign(BaseSign&& o) : self(o.self) { memset(&o, 0, sizeof(BaseSign)); } - BaseSign(LDKBaseSign&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBaseSign)); } - operator LDKBaseSign() && { LDKBaseSign res = self; memset(&self, 0, sizeof(LDKBaseSign)); return res; } - ~BaseSign() { BaseSign_free(self); } - BaseSign& operator=(BaseSign&& o) { BaseSign_free(self); self = o.self; memset(&o, 0, sizeof(BaseSign)); return *this; } - LDKBaseSign* operator &() { return &self; } - LDKBaseSign* operator ->() { return &self; } - const LDKBaseSign* operator &() const { return &self; } - const LDKBaseSign* operator ->() const { return &self; } -}; -class Sign { -private: - LDKSign self; -public: - Sign(const Sign&) = delete; - Sign(Sign&& o) : self(o.self) { memset(&o, 0, sizeof(Sign)); } - Sign(LDKSign&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSign)); } - operator LDKSign() && { LDKSign res = self; memset(&self, 0, sizeof(LDKSign)); return res; } - ~Sign() { Sign_free(self); } - Sign& operator=(Sign&& o) { Sign_free(self); self = o.self; memset(&o, 0, sizeof(Sign)); return *this; } - LDKSign* operator &() { return &self; } - LDKSign* operator ->() { return &self; } - const LDKSign* operator &() const { return &self; } - const LDKSign* operator ->() const { return &self; } -}; -class KeysInterface { -private: - LDKKeysInterface self; -public: - KeysInterface(const KeysInterface&) = delete; - 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; } - ~KeysInterface() { KeysInterface_free(self); } - KeysInterface& operator=(KeysInterface&& o) { KeysInterface_free(self); self = o.self; memset(&o, 0, sizeof(KeysInterface)); return *this; } - LDKKeysInterface* operator &() { return &self; } - LDKKeysInterface* operator ->() { return &self; } - const LDKKeysInterface* operator &() const { return &self; } - const LDKKeysInterface* operator ->() const { return &self; } -}; -class InMemorySigner { -private: - LDKInMemorySigner self; -public: - InMemorySigner(const InMemorySigner&) = delete; - InMemorySigner(InMemorySigner&& o) : self(o.self) { memset(&o, 0, sizeof(InMemorySigner)); } - InMemorySigner(LDKInMemorySigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInMemorySigner)); } - operator LDKInMemorySigner() && { LDKInMemorySigner res = self; memset(&self, 0, sizeof(LDKInMemorySigner)); return res; } - ~InMemorySigner() { InMemorySigner_free(self); } - InMemorySigner& operator=(InMemorySigner&& o) { InMemorySigner_free(self); self = o.self; memset(&o, 0, sizeof(InMemorySigner)); return *this; } - LDKInMemorySigner* operator &() { return &self; } - LDKInMemorySigner* operator ->() { return &self; } - const LDKInMemorySigner* operator &() const { return &self; } - const LDKInMemorySigner* operator ->() const { return &self; } -}; -class KeysManager { -private: - LDKKeysManager self; -public: - KeysManager(const KeysManager&) = delete; - 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; } - ~KeysManager() { KeysManager_free(self); } - KeysManager& operator=(KeysManager&& o) { KeysManager_free(self); self = o.self; memset(&o, 0, sizeof(KeysManager)); return *this; } - LDKKeysManager* operator &() { return &self; } - LDKKeysManager* operator ->() { return &self; } - const LDKKeysManager* operator &() const { return &self; } - const LDKKeysManager* operator ->() const { return &self; } -}; -class RouteHop { +class NodeFeatures { private: - LDKRouteHop self; + LDKNodeFeatures self; public: - RouteHop(const RouteHop&) = delete; - 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; } - ~RouteHop() { RouteHop_free(self); } - RouteHop& operator=(RouteHop&& o) { RouteHop_free(self); self = o.self; memset(&o, 0, sizeof(RouteHop)); return *this; } - LDKRouteHop* operator &() { return &self; } - LDKRouteHop* operator ->() { return &self; } - const LDKRouteHop* operator &() const { return &self; } - const LDKRouteHop* operator ->() const { return &self; } + NodeFeatures(const NodeFeatures&) = delete; + 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; } + ~NodeFeatures() { NodeFeatures_free(self); } + NodeFeatures& operator=(NodeFeatures&& o) { NodeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(NodeFeatures)); return *this; } + LDKNodeFeatures* operator &() { return &self; } + LDKNodeFeatures* operator ->() { return &self; } + const LDKNodeFeatures* operator &() const { return &self; } + const LDKNodeFeatures* operator ->() const { return &self; } }; -class Route { +class ChannelFeatures { private: - LDKRoute self; + LDKChannelFeatures self; public: - Route(const Route&) = delete; - 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; } - ~Route() { Route_free(self); } - Route& operator=(Route&& o) { Route_free(self); self = o.self; memset(&o, 0, sizeof(Route)); return *this; } - LDKRoute* operator &() { return &self; } - LDKRoute* operator ->() { return &self; } - const LDKRoute* operator &() const { return &self; } - const LDKRoute* operator ->() const { return &self; } + ChannelFeatures(const ChannelFeatures&) = delete; + 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; } + ~ChannelFeatures() { ChannelFeatures_free(self); } + ChannelFeatures& operator=(ChannelFeatures&& o) { ChannelFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelFeatures)); return *this; } + LDKChannelFeatures* operator &() { return &self; } + LDKChannelFeatures* operator ->() { return &self; } + const LDKChannelFeatures* operator &() const { return &self; } + const LDKChannelFeatures* operator ->() const { return &self; } }; -class RouteHint { +class InvoiceFeatures { private: - LDKRouteHint self; + LDKInvoiceFeatures self; public: - RouteHint(const RouteHint&) = delete; - 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; } - ~RouteHint() { RouteHint_free(self); } - RouteHint& operator=(RouteHint&& o) { RouteHint_free(self); self = o.self; memset(&o, 0, sizeof(RouteHint)); return *this; } - LDKRouteHint* operator &() { return &self; } - LDKRouteHint* operator ->() { return &self; } - const LDKRouteHint* operator &() const { return &self; } - const LDKRouteHint* operator ->() const { return &self; } + InvoiceFeatures(const InvoiceFeatures&) = delete; + InvoiceFeatures(InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceFeatures)); } + InvoiceFeatures(LDKInvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceFeatures)); } + operator LDKInvoiceFeatures() && { LDKInvoiceFeatures res = self; memset(&self, 0, sizeof(LDKInvoiceFeatures)); return res; } + ~InvoiceFeatures() { InvoiceFeatures_free(self); } + InvoiceFeatures& operator=(InvoiceFeatures&& o) { InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceFeatures)); return *this; } + LDKInvoiceFeatures* operator &() { return &self; } + LDKInvoiceFeatures* operator ->() { return &self; } + const LDKInvoiceFeatures* operator &() const { return &self; } + const LDKInvoiceFeatures* operator ->() const { return &self; } }; class DecodeError { private: @@ -1676,35 +1422,289 @@ public: const LDKHTLCFailChannelUpdate* operator &() const { return &self; } const LDKHTLCFailChannelUpdate* operator ->() const { return &self; } }; -class ChannelMessageHandler { +class ChannelMessageHandler { +private: + LDKChannelMessageHandler self; +public: + ChannelMessageHandler(const ChannelMessageHandler&) = delete; + 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; } + ~ChannelMessageHandler() { ChannelMessageHandler_free(self); } + ChannelMessageHandler& operator=(ChannelMessageHandler&& o) { ChannelMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMessageHandler)); return *this; } + 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&& 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; } + ~RoutingMessageHandler() { RoutingMessageHandler_free(self); } + RoutingMessageHandler& operator=(RoutingMessageHandler&& o) { RoutingMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(RoutingMessageHandler)); return *this; } + LDKRoutingMessageHandler* operator &() { return &self; } + LDKRoutingMessageHandler* operator ->() { return &self; } + const LDKRoutingMessageHandler* operator &() const { return &self; } + const LDKRoutingMessageHandler* 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; } + Level& operator=(Level&& o) { self = o.self; memset(&o, 0, sizeof(Level)); return *this; } + 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&& 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; } + ~Logger() { Logger_free(self); } + Logger& operator=(Logger&& o) { Logger_free(self); self = o.self; memset(&o, 0, sizeof(Logger)); return *this; } + LDKLogger* operator &() { return &self; } + LDKLogger* operator ->() { return &self; } + const LDKLogger* operator &() const { return &self; } + const LDKLogger* operator ->() const { return &self; } +}; +class DelayedPaymentOutputDescriptor { +private: + LDKDelayedPaymentOutputDescriptor self; +public: + DelayedPaymentOutputDescriptor(const DelayedPaymentOutputDescriptor&) = delete; + DelayedPaymentOutputDescriptor(DelayedPaymentOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(DelayedPaymentOutputDescriptor)); } + DelayedPaymentOutputDescriptor(LDKDelayedPaymentOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDelayedPaymentOutputDescriptor)); } + operator LDKDelayedPaymentOutputDescriptor() && { LDKDelayedPaymentOutputDescriptor res = self; memset(&self, 0, sizeof(LDKDelayedPaymentOutputDescriptor)); return res; } + ~DelayedPaymentOutputDescriptor() { DelayedPaymentOutputDescriptor_free(self); } + DelayedPaymentOutputDescriptor& operator=(DelayedPaymentOutputDescriptor&& o) { DelayedPaymentOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(DelayedPaymentOutputDescriptor)); return *this; } + LDKDelayedPaymentOutputDescriptor* operator &() { return &self; } + LDKDelayedPaymentOutputDescriptor* operator ->() { return &self; } + const LDKDelayedPaymentOutputDescriptor* operator &() const { return &self; } + const LDKDelayedPaymentOutputDescriptor* operator ->() const { return &self; } +}; +class StaticPaymentOutputDescriptor { +private: + LDKStaticPaymentOutputDescriptor self; +public: + StaticPaymentOutputDescriptor(const StaticPaymentOutputDescriptor&) = delete; + StaticPaymentOutputDescriptor(StaticPaymentOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(StaticPaymentOutputDescriptor)); } + StaticPaymentOutputDescriptor(LDKStaticPaymentOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKStaticPaymentOutputDescriptor)); } + operator LDKStaticPaymentOutputDescriptor() && { LDKStaticPaymentOutputDescriptor res = self; memset(&self, 0, sizeof(LDKStaticPaymentOutputDescriptor)); return res; } + ~StaticPaymentOutputDescriptor() { StaticPaymentOutputDescriptor_free(self); } + StaticPaymentOutputDescriptor& operator=(StaticPaymentOutputDescriptor&& o) { StaticPaymentOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(StaticPaymentOutputDescriptor)); return *this; } + LDKStaticPaymentOutputDescriptor* operator &() { return &self; } + LDKStaticPaymentOutputDescriptor* operator ->() { return &self; } + const LDKStaticPaymentOutputDescriptor* operator &() const { return &self; } + const LDKStaticPaymentOutputDescriptor* operator ->() const { return &self; } +}; +class SpendableOutputDescriptor { +private: + LDKSpendableOutputDescriptor self; +public: + SpendableOutputDescriptor(const SpendableOutputDescriptor&) = delete; + 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; } + ~SpendableOutputDescriptor() { SpendableOutputDescriptor_free(self); } + SpendableOutputDescriptor& operator=(SpendableOutputDescriptor&& o) { SpendableOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(SpendableOutputDescriptor)); return *this; } + LDKSpendableOutputDescriptor* operator &() { return &self; } + LDKSpendableOutputDescriptor* operator ->() { return &self; } + const LDKSpendableOutputDescriptor* operator &() const { return &self; } + const LDKSpendableOutputDescriptor* operator ->() const { return &self; } +}; +class BaseSign { +private: + LDKBaseSign self; +public: + BaseSign(const BaseSign&) = delete; + BaseSign(BaseSign&& o) : self(o.self) { memset(&o, 0, sizeof(BaseSign)); } + BaseSign(LDKBaseSign&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBaseSign)); } + operator LDKBaseSign() && { LDKBaseSign res = self; memset(&self, 0, sizeof(LDKBaseSign)); return res; } + ~BaseSign() { BaseSign_free(self); } + BaseSign& operator=(BaseSign&& o) { BaseSign_free(self); self = o.self; memset(&o, 0, sizeof(BaseSign)); return *this; } + LDKBaseSign* operator &() { return &self; } + LDKBaseSign* operator ->() { return &self; } + const LDKBaseSign* operator &() const { return &self; } + const LDKBaseSign* operator ->() const { return &self; } +}; +class Sign { +private: + LDKSign self; +public: + Sign(const Sign&) = delete; + Sign(Sign&& o) : self(o.self) { memset(&o, 0, sizeof(Sign)); } + Sign(LDKSign&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSign)); } + operator LDKSign() && { LDKSign res = self; memset(&self, 0, sizeof(LDKSign)); return res; } + ~Sign() { Sign_free(self); } + Sign& operator=(Sign&& o) { Sign_free(self); self = o.self; memset(&o, 0, sizeof(Sign)); return *this; } + LDKSign* operator &() { return &self; } + LDKSign* operator ->() { return &self; } + const LDKSign* operator &() const { return &self; } + const LDKSign* operator ->() const { return &self; } +}; +class KeysInterface { +private: + LDKKeysInterface self; +public: + KeysInterface(const KeysInterface&) = delete; + 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; } + ~KeysInterface() { KeysInterface_free(self); } + KeysInterface& operator=(KeysInterface&& o) { KeysInterface_free(self); self = o.self; memset(&o, 0, sizeof(KeysInterface)); return *this; } + LDKKeysInterface* operator &() { return &self; } + LDKKeysInterface* operator ->() { return &self; } + const LDKKeysInterface* operator &() const { return &self; } + const LDKKeysInterface* operator ->() const { return &self; } +}; +class InMemorySigner { +private: + LDKInMemorySigner self; +public: + InMemorySigner(const InMemorySigner&) = delete; + InMemorySigner(InMemorySigner&& o) : self(o.self) { memset(&o, 0, sizeof(InMemorySigner)); } + InMemorySigner(LDKInMemorySigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInMemorySigner)); } + operator LDKInMemorySigner() && { LDKInMemorySigner res = self; memset(&self, 0, sizeof(LDKInMemorySigner)); return res; } + ~InMemorySigner() { InMemorySigner_free(self); } + InMemorySigner& operator=(InMemorySigner&& o) { InMemorySigner_free(self); self = o.self; memset(&o, 0, sizeof(InMemorySigner)); return *this; } + LDKInMemorySigner* operator &() { return &self; } + LDKInMemorySigner* operator ->() { return &self; } + const LDKInMemorySigner* operator &() const { return &self; } + const LDKInMemorySigner* operator ->() const { return &self; } +}; +class KeysManager { +private: + LDKKeysManager self; +public: + KeysManager(const KeysManager&) = delete; + 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; } + ~KeysManager() { KeysManager_free(self); } + KeysManager& operator=(KeysManager&& o) { KeysManager_free(self); self = o.self; memset(&o, 0, sizeof(KeysManager)); return *this; } + LDKKeysManager* operator &() { return &self; } + LDKKeysManager* operator ->() { return &self; } + const LDKKeysManager* operator &() const { return &self; } + const LDKKeysManager* operator ->() const { return &self; } +}; +class ChainMonitor { +private: + LDKChainMonitor self; +public: + ChainMonitor(const ChainMonitor&) = delete; + ChainMonitor(ChainMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChainMonitor)); } + ChainMonitor(LDKChainMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainMonitor)); } + operator LDKChainMonitor() && { LDKChainMonitor res = self; memset(&self, 0, sizeof(LDKChainMonitor)); return res; } + ~ChainMonitor() { ChainMonitor_free(self); } + ChainMonitor& operator=(ChainMonitor&& o) { ChainMonitor_free(self); self = o.self; memset(&o, 0, sizeof(ChainMonitor)); return *this; } + LDKChainMonitor* operator &() { return &self; } + LDKChainMonitor* operator ->() { return &self; } + const LDKChainMonitor* operator &() const { return &self; } + const LDKChainMonitor* operator ->() const { return &self; } +}; +class ChannelManager { +private: + LDKChannelManager self; +public: + ChannelManager(const ChannelManager&) = delete; + 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; } + ~ChannelManager() { ChannelManager_free(self); } + ChannelManager& operator=(ChannelManager&& o) { ChannelManager_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManager)); return *this; } + LDKChannelManager* operator &() { return &self; } + LDKChannelManager* operator ->() { return &self; } + const LDKChannelManager* operator &() const { return &self; } + const LDKChannelManager* operator ->() const { return &self; } +}; +class ChainParameters { +private: + LDKChainParameters self; +public: + ChainParameters(const ChainParameters&) = delete; + ChainParameters(ChainParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChainParameters)); } + ChainParameters(LDKChainParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainParameters)); } + operator LDKChainParameters() && { LDKChainParameters res = self; memset(&self, 0, sizeof(LDKChainParameters)); return res; } + ~ChainParameters() { ChainParameters_free(self); } + ChainParameters& operator=(ChainParameters&& o) { ChainParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChainParameters)); return *this; } + LDKChainParameters* operator &() { return &self; } + LDKChainParameters* operator ->() { return &self; } + const LDKChainParameters* operator &() const { return &self; } + const LDKChainParameters* operator ->() const { return &self; } +}; +class BestBlock { +private: + LDKBestBlock self; +public: + BestBlock(const BestBlock&) = delete; + BestBlock(BestBlock&& o) : self(o.self) { memset(&o, 0, sizeof(BestBlock)); } + BestBlock(LDKBestBlock&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBestBlock)); } + operator LDKBestBlock() && { LDKBestBlock res = self; memset(&self, 0, sizeof(LDKBestBlock)); return res; } + ~BestBlock() { BestBlock_free(self); } + BestBlock& operator=(BestBlock&& o) { BestBlock_free(self); self = o.self; memset(&o, 0, sizeof(BestBlock)); return *this; } + LDKBestBlock* operator &() { return &self; } + LDKBestBlock* operator ->() { return &self; } + const LDKBestBlock* operator &() const { return &self; } + const LDKBestBlock* operator ->() const { return &self; } +}; +class ChannelDetails { +private: + LDKChannelDetails self; +public: + ChannelDetails(const ChannelDetails&) = delete; + 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; } + ~ChannelDetails() { ChannelDetails_free(self); } + ChannelDetails& operator=(ChannelDetails&& o) { ChannelDetails_free(self); self = o.self; memset(&o, 0, sizeof(ChannelDetails)); return *this; } + LDKChannelDetails* operator &() { return &self; } + LDKChannelDetails* operator ->() { return &self; } + const LDKChannelDetails* operator &() const { return &self; } + const LDKChannelDetails* operator ->() const { return &self; } +}; +class PaymentSendFailure { private: - LDKChannelMessageHandler self; + LDKPaymentSendFailure self; public: - ChannelMessageHandler(const ChannelMessageHandler&) = delete; - 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; } - ~ChannelMessageHandler() { ChannelMessageHandler_free(self); } - ChannelMessageHandler& operator=(ChannelMessageHandler&& o) { ChannelMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMessageHandler)); return *this; } - LDKChannelMessageHandler* operator &() { return &self; } - LDKChannelMessageHandler* operator ->() { return &self; } - const LDKChannelMessageHandler* operator &() const { return &self; } - const LDKChannelMessageHandler* operator ->() const { return &self; } + PaymentSendFailure(const PaymentSendFailure&) = delete; + 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; } + ~PaymentSendFailure() { PaymentSendFailure_free(self); } + PaymentSendFailure& operator=(PaymentSendFailure&& o) { PaymentSendFailure_free(self); self = o.self; memset(&o, 0, sizeof(PaymentSendFailure)); return *this; } + LDKPaymentSendFailure* operator &() { return &self; } + LDKPaymentSendFailure* operator ->() { return &self; } + const LDKPaymentSendFailure* operator &() const { return &self; } + const LDKPaymentSendFailure* operator ->() const { return &self; } }; -class RoutingMessageHandler { +class ChannelManagerReadArgs { private: - LDKRoutingMessageHandler self; + LDKChannelManagerReadArgs self; public: - RoutingMessageHandler(const RoutingMessageHandler&) = delete; - 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; } - ~RoutingMessageHandler() { RoutingMessageHandler_free(self); } - RoutingMessageHandler& operator=(RoutingMessageHandler&& o) { RoutingMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(RoutingMessageHandler)); return *this; } - LDKRoutingMessageHandler* operator &() { return &self; } - LDKRoutingMessageHandler* operator ->() { return &self; } - const LDKRoutingMessageHandler* operator &() const { return &self; } - const LDKRoutingMessageHandler* operator ->() const { return &self; } + ChannelManagerReadArgs(const ChannelManagerReadArgs&) = delete; + 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; } + ~ChannelManagerReadArgs() { ChannelManagerReadArgs_free(self); } + ChannelManagerReadArgs& operator=(ChannelManagerReadArgs&& o) { ChannelManagerReadArgs_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManagerReadArgs)); return *this; } + LDKChannelManagerReadArgs* operator &() { return &self; } + LDKChannelManagerReadArgs* operator ->() { return &self; } + const LDKChannelManagerReadArgs* operator &() const { return &self; } + const LDKChannelManagerReadArgs* operator ->() const { return &self; } }; class CVec_SpendableOutputDescriptorZ { private: @@ -1781,20 +1781,20 @@ public: const LDKCVec_C2Tuple_u32TxOutZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_u32TxOutZZ* operator ->() const { return &self; } }; -class C2Tuple_SignatureCVec_SignatureZZ { +class CResult_ChannelAnnouncementDecodeErrorZ { private: - LDKC2Tuple_SignatureCVec_SignatureZZ self; + LDKCResult_ChannelAnnouncementDecodeErrorZ self; public: - C2Tuple_SignatureCVec_SignatureZZ(const C2Tuple_SignatureCVec_SignatureZZ&) = delete; - 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; } - ~C2Tuple_SignatureCVec_SignatureZZ() { C2Tuple_SignatureCVec_SignatureZZ_free(self); } - C2Tuple_SignatureCVec_SignatureZZ& operator=(C2Tuple_SignatureCVec_SignatureZZ&& o) { C2Tuple_SignatureCVec_SignatureZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); return *this; } - 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; } + CResult_ChannelAnnouncementDecodeErrorZ(const CResult_ChannelAnnouncementDecodeErrorZ&) = delete; + CResult_ChannelAnnouncementDecodeErrorZ(CResult_ChannelAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelAnnouncementDecodeErrorZ)); } + CResult_ChannelAnnouncementDecodeErrorZ(LDKCResult_ChannelAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ)); } + operator LDKCResult_ChannelAnnouncementDecodeErrorZ() && { LDKCResult_ChannelAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ)); return res; } + ~CResult_ChannelAnnouncementDecodeErrorZ() { CResult_ChannelAnnouncementDecodeErrorZ_free(self); } + CResult_ChannelAnnouncementDecodeErrorZ& operator=(CResult_ChannelAnnouncementDecodeErrorZ&& o) { CResult_ChannelAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelAnnouncementDecodeErrorZ)); return *this; } + LDKCResult_ChannelAnnouncementDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelAnnouncementDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelAnnouncementDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; class CResult_ChannelInfoDecodeErrorZ { private: @@ -1811,20 +1811,20 @@ public: const LDKCResult_ChannelInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelInfoDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_ChannelAnnouncementDecodeErrorZ { +class C2Tuple_SignatureCVec_SignatureZZ { private: - LDKCResult_ChannelAnnouncementDecodeErrorZ self; + LDKC2Tuple_SignatureCVec_SignatureZZ self; public: - CResult_ChannelAnnouncementDecodeErrorZ(const CResult_ChannelAnnouncementDecodeErrorZ&) = delete; - CResult_ChannelAnnouncementDecodeErrorZ(CResult_ChannelAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelAnnouncementDecodeErrorZ)); } - CResult_ChannelAnnouncementDecodeErrorZ(LDKCResult_ChannelAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ)); } - operator LDKCResult_ChannelAnnouncementDecodeErrorZ() && { LDKCResult_ChannelAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ)); return res; } - ~CResult_ChannelAnnouncementDecodeErrorZ() { CResult_ChannelAnnouncementDecodeErrorZ_free(self); } - CResult_ChannelAnnouncementDecodeErrorZ& operator=(CResult_ChannelAnnouncementDecodeErrorZ&& o) { CResult_ChannelAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelAnnouncementDecodeErrorZ)); return *this; } - LDKCResult_ChannelAnnouncementDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelAnnouncementDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelAnnouncementDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelAnnouncementDecodeErrorZ* operator ->() const { return &self; } + C2Tuple_SignatureCVec_SignatureZZ(const C2Tuple_SignatureCVec_SignatureZZ&) = delete; + 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; } + ~C2Tuple_SignatureCVec_SignatureZZ() { C2Tuple_SignatureCVec_SignatureZZ_free(self); } + C2Tuple_SignatureCVec_SignatureZZ& operator=(C2Tuple_SignatureCVec_SignatureZZ&& o) { C2Tuple_SignatureCVec_SignatureZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); return *this; } + 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_u8ZPeerHandleErrorZ { private: @@ -1841,21 +1841,6 @@ public: const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; } }; -class CResult_InvoiceFeaturesDecodeErrorZ { -private: - LDKCResult_InvoiceFeaturesDecodeErrorZ self; -public: - CResult_InvoiceFeaturesDecodeErrorZ(const CResult_InvoiceFeaturesDecodeErrorZ&) = delete; - CResult_InvoiceFeaturesDecodeErrorZ(CResult_InvoiceFeaturesDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceFeaturesDecodeErrorZ)); } - CResult_InvoiceFeaturesDecodeErrorZ(LDKCResult_InvoiceFeaturesDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ)); } - operator LDKCResult_InvoiceFeaturesDecodeErrorZ() && { LDKCResult_InvoiceFeaturesDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ)); return res; } - ~CResult_InvoiceFeaturesDecodeErrorZ() { CResult_InvoiceFeaturesDecodeErrorZ_free(self); } - CResult_InvoiceFeaturesDecodeErrorZ& operator=(CResult_InvoiceFeaturesDecodeErrorZ&& o) { CResult_InvoiceFeaturesDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceFeaturesDecodeErrorZ)); return *this; } - LDKCResult_InvoiceFeaturesDecodeErrorZ* operator &() { return &self; } - LDKCResult_InvoiceFeaturesDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_ChannelMonitorUpdateDecodeErrorZ { private: LDKCResult_ChannelMonitorUpdateDecodeErrorZ self; @@ -1871,6 +1856,21 @@ public: const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_InvoiceFeaturesDecodeErrorZ { +private: + LDKCResult_InvoiceFeaturesDecodeErrorZ self; +public: + CResult_InvoiceFeaturesDecodeErrorZ(const CResult_InvoiceFeaturesDecodeErrorZ&) = delete; + CResult_InvoiceFeaturesDecodeErrorZ(CResult_InvoiceFeaturesDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceFeaturesDecodeErrorZ)); } + CResult_InvoiceFeaturesDecodeErrorZ(LDKCResult_InvoiceFeaturesDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ)); } + operator LDKCResult_InvoiceFeaturesDecodeErrorZ() && { LDKCResult_InvoiceFeaturesDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ)); return res; } + ~CResult_InvoiceFeaturesDecodeErrorZ() { CResult_InvoiceFeaturesDecodeErrorZ_free(self); } + CResult_InvoiceFeaturesDecodeErrorZ& operator=(CResult_InvoiceFeaturesDecodeErrorZ&& o) { CResult_InvoiceFeaturesDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceFeaturesDecodeErrorZ)); return *this; } + LDKCResult_InvoiceFeaturesDecodeErrorZ* operator &() { return &self; } + LDKCResult_InvoiceFeaturesDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator ->() const { return &self; } +}; class COption_u64Z { private: LDKCOption_u64Z self; @@ -2051,21 +2051,6 @@ public: const LDKCOption_C2Tuple_usizeTransactionZZ* operator &() const { return &self; } const LDKCOption_C2Tuple_usizeTransactionZZ* operator ->() const { return &self; } }; -class CResult_TransactionNoneZ { -private: - LDKCResult_TransactionNoneZ self; -public: - CResult_TransactionNoneZ(const CResult_TransactionNoneZ&) = delete; - CResult_TransactionNoneZ(CResult_TransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TransactionNoneZ)); } - CResult_TransactionNoneZ(LDKCResult_TransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TransactionNoneZ)); } - operator LDKCResult_TransactionNoneZ() && { LDKCResult_TransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TransactionNoneZ)); return res; } - ~CResult_TransactionNoneZ() { CResult_TransactionNoneZ_free(self); } - CResult_TransactionNoneZ& operator=(CResult_TransactionNoneZ&& o) { CResult_TransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TransactionNoneZ)); return *this; } - LDKCResult_TransactionNoneZ* operator &() { return &self; } - LDKCResult_TransactionNoneZ* operator ->() { return &self; } - const LDKCResult_TransactionNoneZ* operator &() const { return &self; } - const LDKCResult_TransactionNoneZ* operator ->() const { return &self; } -}; class CResult_PingDecodeErrorZ { private: LDKCResult_PingDecodeErrorZ self; @@ -2081,6 +2066,21 @@ public: const LDKCResult_PingDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PingDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_TransactionNoneZ { +private: + LDKCResult_TransactionNoneZ self; +public: + CResult_TransactionNoneZ(const CResult_TransactionNoneZ&) = delete; + CResult_TransactionNoneZ(CResult_TransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TransactionNoneZ)); } + CResult_TransactionNoneZ(LDKCResult_TransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TransactionNoneZ)); } + operator LDKCResult_TransactionNoneZ() && { LDKCResult_TransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TransactionNoneZ)); return res; } + ~CResult_TransactionNoneZ() { CResult_TransactionNoneZ_free(self); } + CResult_TransactionNoneZ& operator=(CResult_TransactionNoneZ&& o) { CResult_TransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TransactionNoneZ)); return *this; } + LDKCResult_TransactionNoneZ* operator &() { return &self; } + LDKCResult_TransactionNoneZ* operator ->() { return &self; } + const LDKCResult_TransactionNoneZ* operator &() const { return &self; } + const LDKCResult_TransactionNoneZ* operator ->() const { return &self; } +}; class CVec_TransactionOutputsZ { private: LDKCVec_TransactionOutputsZ self; @@ -2171,21 +2171,6 @@ public: const LDKCResult_QueryChannelRangeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_QueryChannelRangeDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_TransactionZ { -private: - LDKCVec_TransactionZ self; -public: - CVec_TransactionZ(const CVec_TransactionZ&) = delete; - 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; } - ~CVec_TransactionZ() { CVec_TransactionZ_free(self); } - CVec_TransactionZ& operator=(CVec_TransactionZ&& o) { CVec_TransactionZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TransactionZ)); return *this; } - 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_TxCreationKeysDecodeErrorZ { private: LDKCResult_TxCreationKeysDecodeErrorZ self; @@ -2201,20 +2186,20 @@ public: const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_ChannelFeaturesDecodeErrorZ { +class CVec_TransactionZ { private: - LDKCResult_ChannelFeaturesDecodeErrorZ self; + LDKCVec_TransactionZ self; public: - CResult_ChannelFeaturesDecodeErrorZ(const CResult_ChannelFeaturesDecodeErrorZ&) = delete; - CResult_ChannelFeaturesDecodeErrorZ(CResult_ChannelFeaturesDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelFeaturesDecodeErrorZ)); } - CResult_ChannelFeaturesDecodeErrorZ(LDKCResult_ChannelFeaturesDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ)); } - operator LDKCResult_ChannelFeaturesDecodeErrorZ() && { LDKCResult_ChannelFeaturesDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ)); return res; } - ~CResult_ChannelFeaturesDecodeErrorZ() { CResult_ChannelFeaturesDecodeErrorZ_free(self); } - CResult_ChannelFeaturesDecodeErrorZ& operator=(CResult_ChannelFeaturesDecodeErrorZ&& o) { CResult_ChannelFeaturesDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelFeaturesDecodeErrorZ)); return *this; } - LDKCResult_ChannelFeaturesDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelFeaturesDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelFeaturesDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelFeaturesDecodeErrorZ* operator ->() const { return &self; } + CVec_TransactionZ(const CVec_TransactionZ&) = delete; + 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; } + ~CVec_TransactionZ() { CVec_TransactionZ_free(self); } + CVec_TransactionZ& operator=(CVec_TransactionZ&& o) { CVec_TransactionZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TransactionZ)); return *this; } + 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 C2Tuple_usizeTransactionZ { private: @@ -2231,20 +2216,35 @@ public: const LDKC2Tuple_usizeTransactionZ* operator &() const { return &self; } const LDKC2Tuple_usizeTransactionZ* operator ->() const { return &self; } }; -class CVec_ChannelMonitorZ { +class CResult_ChannelFeaturesDecodeErrorZ { private: - LDKCVec_ChannelMonitorZ self; + LDKCResult_ChannelFeaturesDecodeErrorZ self; public: - CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete; - 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; } - ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); } - CVec_ChannelMonitorZ& operator=(CVec_ChannelMonitorZ&& o) { CVec_ChannelMonitorZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); return *this; } - LDKCVec_ChannelMonitorZ* operator &() { return &self; } - LDKCVec_ChannelMonitorZ* operator ->() { return &self; } - const LDKCVec_ChannelMonitorZ* operator &() const { return &self; } - const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; } + CResult_ChannelFeaturesDecodeErrorZ(const CResult_ChannelFeaturesDecodeErrorZ&) = delete; + CResult_ChannelFeaturesDecodeErrorZ(CResult_ChannelFeaturesDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelFeaturesDecodeErrorZ)); } + CResult_ChannelFeaturesDecodeErrorZ(LDKCResult_ChannelFeaturesDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ)); } + operator LDKCResult_ChannelFeaturesDecodeErrorZ() && { LDKCResult_ChannelFeaturesDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ)); return res; } + ~CResult_ChannelFeaturesDecodeErrorZ() { CResult_ChannelFeaturesDecodeErrorZ_free(self); } + CResult_ChannelFeaturesDecodeErrorZ& operator=(CResult_ChannelFeaturesDecodeErrorZ&& o) { CResult_ChannelFeaturesDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelFeaturesDecodeErrorZ)); return *this; } + LDKCResult_ChannelFeaturesDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelFeaturesDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelFeaturesDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelFeaturesDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_NodeAnnouncementDecodeErrorZ { +private: + LDKCResult_NodeAnnouncementDecodeErrorZ self; +public: + CResult_NodeAnnouncementDecodeErrorZ(const CResult_NodeAnnouncementDecodeErrorZ&) = delete; + CResult_NodeAnnouncementDecodeErrorZ(CResult_NodeAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NodeAnnouncementDecodeErrorZ)); } + CResult_NodeAnnouncementDecodeErrorZ(LDKCResult_NodeAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ)); } + operator LDKCResult_NodeAnnouncementDecodeErrorZ() && { LDKCResult_NodeAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ)); return res; } + ~CResult_NodeAnnouncementDecodeErrorZ() { CResult_NodeAnnouncementDecodeErrorZ_free(self); } + CResult_NodeAnnouncementDecodeErrorZ& operator=(CResult_NodeAnnouncementDecodeErrorZ&& o) { CResult_NodeAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NodeAnnouncementDecodeErrorZ)); return *this; } + LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() { return &self; } + LDKCResult_NodeAnnouncementDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_NodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; class CResult_UpdateFeeDecodeErrorZ { private: @@ -2261,20 +2261,20 @@ public: const LDKCResult_UpdateFeeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateFeeDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_NodeAnnouncementDecodeErrorZ { +class CVec_ChannelMonitorZ { private: - LDKCResult_NodeAnnouncementDecodeErrorZ self; + LDKCVec_ChannelMonitorZ self; public: - CResult_NodeAnnouncementDecodeErrorZ(const CResult_NodeAnnouncementDecodeErrorZ&) = delete; - CResult_NodeAnnouncementDecodeErrorZ(CResult_NodeAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NodeAnnouncementDecodeErrorZ)); } - CResult_NodeAnnouncementDecodeErrorZ(LDKCResult_NodeAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ)); } - operator LDKCResult_NodeAnnouncementDecodeErrorZ() && { LDKCResult_NodeAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ)); return res; } - ~CResult_NodeAnnouncementDecodeErrorZ() { CResult_NodeAnnouncementDecodeErrorZ_free(self); } - CResult_NodeAnnouncementDecodeErrorZ& operator=(CResult_NodeAnnouncementDecodeErrorZ&& o) { CResult_NodeAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NodeAnnouncementDecodeErrorZ)); return *this; } - LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() { return &self; } - LDKCResult_NodeAnnouncementDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_NodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } + CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete; + 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; } + ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); } + CVec_ChannelMonitorZ& operator=(CVec_ChannelMonitorZ&& o) { CVec_ChannelMonitorZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); return *this; } + 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 CResult_HTLCOutputInCommitmentDecodeErrorZ { private: @@ -2456,20 +2456,20 @@ public: const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; } const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; } }; -class CVec_u8Z { +class CResult_RouteLightningErrorZ { private: - LDKCVec_u8Z self; + LDKCResult_RouteLightningErrorZ self; public: - CVec_u8Z(const CVec_u8Z&) = delete; - 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; } - ~CVec_u8Z() { CVec_u8Z_free(self); } - CVec_u8Z& operator=(CVec_u8Z&& o) { CVec_u8Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u8Z)); return *this; } - LDKCVec_u8Z* operator &() { return &self; } - LDKCVec_u8Z* operator ->() { return &self; } - const LDKCVec_u8Z* operator &() const { return &self; } - const LDKCVec_u8Z* operator ->() const { return &self; } + CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete; + 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; } + ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); } + CResult_RouteLightningErrorZ& operator=(CResult_RouteLightningErrorZ&& o) { CResult_RouteLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); return *this; } + 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 CResult_ChannelPublicKeysDecodeErrorZ { private: @@ -2486,20 +2486,20 @@ public: const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_RouteLightningErrorZ { +class CVec_u8Z { private: - LDKCResult_RouteLightningErrorZ self; + LDKCVec_u8Z self; public: - CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete; - 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; } - ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); } - CResult_RouteLightningErrorZ& operator=(CResult_RouteLightningErrorZ&& o) { CResult_RouteLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); return *this; } - LDKCResult_RouteLightningErrorZ* operator &() { return &self; } - LDKCResult_RouteLightningErrorZ* operator ->() { return &self; } - const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; } - const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; } + CVec_u8Z(const CVec_u8Z&) = delete; + 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; } + ~CVec_u8Z() { CVec_u8Z_free(self); } + CVec_u8Z& operator=(CVec_u8Z&& o) { CVec_u8Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u8Z)); return *this; } + 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_ClosingSignedDecodeErrorZ { private: @@ -2711,6 +2711,21 @@ public: const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_PongDecodeErrorZ { +private: + LDKCResult_PongDecodeErrorZ self; +public: + CResult_PongDecodeErrorZ(const CResult_PongDecodeErrorZ&) = delete; + CResult_PongDecodeErrorZ(CResult_PongDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); } + CResult_PongDecodeErrorZ(LDKCResult_PongDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); } + operator LDKCResult_PongDecodeErrorZ() && { LDKCResult_PongDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); return res; } + ~CResult_PongDecodeErrorZ() { CResult_PongDecodeErrorZ_free(self); } + CResult_PongDecodeErrorZ& operator=(CResult_PongDecodeErrorZ&& o) { CResult_PongDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); return *this; } + LDKCResult_PongDecodeErrorZ* operator &() { return &self; } + LDKCResult_PongDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PongDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PongDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_TxidZ { private: LDKCVec_TxidZ self; @@ -2726,21 +2741,6 @@ public: const LDKCVec_TxidZ* operator &() const { return &self; } const LDKCVec_TxidZ* operator ->() const { return &self; } }; -class CResult_NoneMonitorUpdateErrorZ { -private: - LDKCResult_NoneMonitorUpdateErrorZ self; -public: - CResult_NoneMonitorUpdateErrorZ(const CResult_NoneMonitorUpdateErrorZ&) = delete; - 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; } - ~CResult_NoneMonitorUpdateErrorZ() { CResult_NoneMonitorUpdateErrorZ_free(self); } - CResult_NoneMonitorUpdateErrorZ& operator=(CResult_NoneMonitorUpdateErrorZ&& o) { CResult_NoneMonitorUpdateErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); return *this; } - 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 CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { private: LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ self; @@ -2771,35 +2771,20 @@ public: const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; } const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { -private: - LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ self; -public: - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(const CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&) = delete; - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); } - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); } - operator LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ() && { LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); return res; } - ~CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ() { CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(self); } - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ& operator=(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& o) { CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); return *this; } - LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() { return &self; } - LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() const { return &self; } -}; -class CResult_CVec_CVec_u8ZZNoneZ { +class CResult_NoneMonitorUpdateErrorZ { private: - LDKCResult_CVec_CVec_u8ZZNoneZ self; + LDKCResult_NoneMonitorUpdateErrorZ self; public: - CResult_CVec_CVec_u8ZZNoneZ(const CResult_CVec_CVec_u8ZZNoneZ&) = delete; - CResult_CVec_CVec_u8ZZNoneZ(CResult_CVec_CVec_u8ZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_CVec_u8ZZNoneZ)); } - CResult_CVec_CVec_u8ZZNoneZ(LDKCResult_CVec_CVec_u8ZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ)); } - operator LDKCResult_CVec_CVec_u8ZZNoneZ() && { LDKCResult_CVec_CVec_u8ZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ)); return res; } - ~CResult_CVec_CVec_u8ZZNoneZ() { CResult_CVec_CVec_u8ZZNoneZ_free(self); } - CResult_CVec_CVec_u8ZZNoneZ& operator=(CResult_CVec_CVec_u8ZZNoneZ&& o) { CResult_CVec_CVec_u8ZZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_CVec_u8ZZNoneZ)); return *this; } - LDKCResult_CVec_CVec_u8ZZNoneZ* operator &() { return &self; } - LDKCResult_CVec_CVec_u8ZZNoneZ* operator ->() { return &self; } - const LDKCResult_CVec_CVec_u8ZZNoneZ* operator &() const { return &self; } - const LDKCResult_CVec_CVec_u8ZZNoneZ* operator ->() const { return &self; } + CResult_NoneMonitorUpdateErrorZ(const CResult_NoneMonitorUpdateErrorZ&) = delete; + 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; } + ~CResult_NoneMonitorUpdateErrorZ() { CResult_NoneMonitorUpdateErrorZ_free(self); } + CResult_NoneMonitorUpdateErrorZ& operator=(CResult_NoneMonitorUpdateErrorZ&& o) { CResult_NoneMonitorUpdateErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); return *this; } + 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 CResult_AcceptChannelDecodeErrorZ { private: @@ -2816,20 +2801,35 @@ public: const LDKCResult_AcceptChannelDecodeErrorZ* operator &() const { return &self; } const LDKCResult_AcceptChannelDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_PongDecodeErrorZ { +class CResult_CVec_CVec_u8ZZNoneZ { private: - LDKCResult_PongDecodeErrorZ self; + LDKCResult_CVec_CVec_u8ZZNoneZ self; public: - CResult_PongDecodeErrorZ(const CResult_PongDecodeErrorZ&) = delete; - CResult_PongDecodeErrorZ(CResult_PongDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); } - CResult_PongDecodeErrorZ(LDKCResult_PongDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); } - operator LDKCResult_PongDecodeErrorZ() && { LDKCResult_PongDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); return res; } - ~CResult_PongDecodeErrorZ() { CResult_PongDecodeErrorZ_free(self); } - CResult_PongDecodeErrorZ& operator=(CResult_PongDecodeErrorZ&& o) { CResult_PongDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); return *this; } - LDKCResult_PongDecodeErrorZ* operator &() { return &self; } - LDKCResult_PongDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PongDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PongDecodeErrorZ* operator ->() const { return &self; } + CResult_CVec_CVec_u8ZZNoneZ(const CResult_CVec_CVec_u8ZZNoneZ&) = delete; + CResult_CVec_CVec_u8ZZNoneZ(CResult_CVec_CVec_u8ZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_CVec_u8ZZNoneZ)); } + CResult_CVec_CVec_u8ZZNoneZ(LDKCResult_CVec_CVec_u8ZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ)); } + operator LDKCResult_CVec_CVec_u8ZZNoneZ() && { LDKCResult_CVec_CVec_u8ZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ)); return res; } + ~CResult_CVec_CVec_u8ZZNoneZ() { CResult_CVec_CVec_u8ZZNoneZ_free(self); } + CResult_CVec_CVec_u8ZZNoneZ& operator=(CResult_CVec_CVec_u8ZZNoneZ&& o) { CResult_CVec_CVec_u8ZZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_CVec_u8ZZNoneZ)); return *this; } + LDKCResult_CVec_CVec_u8ZZNoneZ* operator &() { return &self; } + LDKCResult_CVec_CVec_u8ZZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_CVec_u8ZZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_CVec_u8ZZNoneZ* operator ->() const { return &self; } +}; +class CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +private: + LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ self; +public: + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(const CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&) = delete; + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); } + operator LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ() && { LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); return res; } + ~CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ() { CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(self); } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ& operator=(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& o) { CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); return *this; } + LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() { return &self; } + LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() const { return &self; } }; class C2Tuple_BlockHashChannelManagerZ { private: @@ -3251,21 +3251,6 @@ public: const LDKCVec_EventZ* operator &() const { return &self; } const LDKCVec_EventZ* operator ->() const { return &self; } }; -class CVec_MonitorEventZ { -private: - LDKCVec_MonitorEventZ self; -public: - CVec_MonitorEventZ(const CVec_MonitorEventZ&) = delete; - 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; } - ~CVec_MonitorEventZ() { CVec_MonitorEventZ_free(self); } - CVec_MonitorEventZ& operator=(CVec_MonitorEventZ&& o) { CVec_MonitorEventZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_MonitorEventZ)); return *this; } - 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_C2Tuple_u32ScriptZZ { private: LDKCVec_C2Tuple_u32ScriptZZ self; @@ -3281,6 +3266,21 @@ public: const LDKCVec_C2Tuple_u32ScriptZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_u32ScriptZZ* operator ->() const { return &self; } }; +class CVec_MonitorEventZ { +private: + LDKCVec_MonitorEventZ self; +public: + CVec_MonitorEventZ(const CVec_MonitorEventZ&) = delete; + 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; } + ~CVec_MonitorEventZ() { CVec_MonitorEventZ_free(self); } + CVec_MonitorEventZ& operator=(CVec_MonitorEventZ&& o) { CVec_MonitorEventZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_MonitorEventZ)); return *this; } + 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 CResult_NoneChannelMonitorUpdateErrZ { private: LDKCResult_NoneChannelMonitorUpdateErrZ self; @@ -3431,21 +3431,6 @@ public: const LDKCResult_NodeFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeFeaturesDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InMemorySignerDecodeErrorZ { -private: - LDKCResult_InMemorySignerDecodeErrorZ self; -public: - CResult_InMemorySignerDecodeErrorZ(const CResult_InMemorySignerDecodeErrorZ&) = delete; - CResult_InMemorySignerDecodeErrorZ(CResult_InMemorySignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InMemorySignerDecodeErrorZ)); } - CResult_InMemorySignerDecodeErrorZ(LDKCResult_InMemorySignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InMemorySignerDecodeErrorZ)); } - operator LDKCResult_InMemorySignerDecodeErrorZ() && { LDKCResult_InMemorySignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InMemorySignerDecodeErrorZ)); return res; } - ~CResult_InMemorySignerDecodeErrorZ() { CResult_InMemorySignerDecodeErrorZ_free(self); } - CResult_InMemorySignerDecodeErrorZ& operator=(CResult_InMemorySignerDecodeErrorZ&& o) { CResult_InMemorySignerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InMemorySignerDecodeErrorZ)); return *this; } - LDKCResult_InMemorySignerDecodeErrorZ* operator &() { return &self; } - LDKCResult_InMemorySignerDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_InMemorySignerDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_InMemorySignerDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_ReplyShortChannelIdsEndDecodeErrorZ { private: LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ self; @@ -3461,6 +3446,21 @@ public: const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_InMemorySignerDecodeErrorZ { +private: + LDKCResult_InMemorySignerDecodeErrorZ self; +public: + CResult_InMemorySignerDecodeErrorZ(const CResult_InMemorySignerDecodeErrorZ&) = delete; + CResult_InMemorySignerDecodeErrorZ(CResult_InMemorySignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InMemorySignerDecodeErrorZ)); } + CResult_InMemorySignerDecodeErrorZ(LDKCResult_InMemorySignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InMemorySignerDecodeErrorZ)); } + operator LDKCResult_InMemorySignerDecodeErrorZ() && { LDKCResult_InMemorySignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InMemorySignerDecodeErrorZ)); return res; } + ~CResult_InMemorySignerDecodeErrorZ() { CResult_InMemorySignerDecodeErrorZ_free(self); } + CResult_InMemorySignerDecodeErrorZ& operator=(CResult_InMemorySignerDecodeErrorZ&& o) { CResult_InMemorySignerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InMemorySignerDecodeErrorZ)); return *this; } + LDKCResult_InMemorySignerDecodeErrorZ* operator &() { return &self; } + LDKCResult_InMemorySignerDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InMemorySignerDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InMemorySignerDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_u32ScriptZ { private: LDKC2Tuple_u32ScriptZ self; @@ -3536,21 +3536,6 @@ public: const LDKCResult_RouteDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RouteDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_TxOutZ { -private: - LDKCVec_TxOutZ self; -public: - CVec_TxOutZ(const CVec_TxOutZ&) = delete; - CVec_TxOutZ(CVec_TxOutZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TxOutZ)); } - CVec_TxOutZ(LDKCVec_TxOutZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TxOutZ)); } - operator LDKCVec_TxOutZ() && { LDKCVec_TxOutZ res = self; memset(&self, 0, sizeof(LDKCVec_TxOutZ)); return res; } - ~CVec_TxOutZ() { CVec_TxOutZ_free(self); } - CVec_TxOutZ& operator=(CVec_TxOutZ&& o) { CVec_TxOutZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TxOutZ)); return *this; } - LDKCVec_TxOutZ* operator &() { return &self; } - LDKCVec_TxOutZ* operator ->() { return &self; } - const LDKCVec_TxOutZ* operator &() const { return &self; } - const LDKCVec_TxOutZ* operator ->() const { return &self; } -}; class CVec_UpdateFailHTLCZ { private: LDKCVec_UpdateFailHTLCZ self; @@ -3581,4 +3566,19 @@ public: const LDKCResult_FundingLockedDecodeErrorZ* operator &() const { return &self; } const LDKCResult_FundingLockedDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_TxOutZ { +private: + LDKCVec_TxOutZ self; +public: + CVec_TxOutZ(const CVec_TxOutZ&) = delete; + CVec_TxOutZ(CVec_TxOutZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TxOutZ)); } + CVec_TxOutZ(LDKCVec_TxOutZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TxOutZ)); } + operator LDKCVec_TxOutZ() && { LDKCVec_TxOutZ res = self; memset(&self, 0, sizeof(LDKCVec_TxOutZ)); return res; } + ~CVec_TxOutZ() { CVec_TxOutZ_free(self); } + CVec_TxOutZ& operator=(CVec_TxOutZ&& o) { CVec_TxOutZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TxOutZ)); return *this; } + LDKCVec_TxOutZ* operator &() { return &self; } + LDKCVec_TxOutZ* operator ->() { return &self; } + const LDKCVec_TxOutZ* operator &() const { return &self; } + const LDKCVec_TxOutZ* operator ->() const { return &self; } +}; } diff --git a/lightning-c-bindings/include/rust_types.h b/lightning-c-bindings/include/rust_types.h index 26619b5..588c9e4 100644 --- a/lightning-c-bindings/include/rust_types.h +++ b/lightning-c-bindings/include/rust_types.h @@ -10,6 +10,16 @@ #else #define NONNULL_PTR #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 nativeOutPointOpaque; +typedef struct nativeOutPointOpaque LDKnativeOutPoint; struct nativeTxCreationKeysOpaque; typedef struct nativeTxCreationKeysOpaque LDKnativeTxCreationKeys; struct nativeChannelPublicKeysOpaque; @@ -30,6 +40,20 @@ struct nativeCommitmentTransactionOpaque; typedef struct nativeCommitmentTransactionOpaque LDKnativeCommitmentTransaction; struct nativeTrustedCommitmentTransactionOpaque; typedef struct nativeTrustedCommitmentTransactionOpaque LDKnativeTrustedCommitmentTransaction; +struct nativeChannelMonitorUpdateOpaque; +typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate; +struct nativeMonitorUpdateErrorOpaque; +typedef struct nativeMonitorUpdateErrorOpaque LDKnativeMonitorUpdateError; +struct nativeHTLCUpdateOpaque; +typedef struct nativeHTLCUpdateOpaque LDKnativeHTLCUpdate; +struct nativeChannelMonitorOpaque; +typedef struct nativeChannelMonitorOpaque LDKnativeChannelMonitor; +struct nativeRouteHopOpaque; +typedef struct nativeRouteHopOpaque LDKnativeRouteHop; +struct nativeRouteOpaque; +typedef struct nativeRouteOpaque LDKnativeRoute; +struct nativeRouteHintOpaque; +typedef struct nativeRouteHintOpaque LDKnativeRouteHint; struct nativeIgnoringMessageHandlerOpaque; typedef struct nativeIgnoringMessageHandlerOpaque LDKnativeIgnoringMessageHandler; struct nativeErroringMessageHandlerOpaque; @@ -41,22 +65,8 @@ struct nativePeerHandleErrorOpaque; typedef struct nativePeerHandleErrorOpaque LDKnativePeerHandleError; struct nativePeerManagerOpaque; typedef struct nativePeerManagerOpaque LDKnativePeerManager; -struct nativeInitFeaturesOpaque; -typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures; -struct nativeNodeFeaturesOpaque; -typedef struct nativeNodeFeaturesOpaque LDKnativeNodeFeatures; -struct nativeChannelFeaturesOpaque; -typedef struct nativeChannelFeaturesOpaque LDKnativeChannelFeatures; -struct nativeInvoiceFeaturesOpaque; -typedef struct nativeInvoiceFeaturesOpaque LDKnativeInvoiceFeatures; -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 nativeWatchedOutputOpaque; +typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput; struct nativeNetworkGraphOpaque; typedef struct nativeNetworkGraphOpaque LDKnativeNetworkGraph; struct nativeLockedNetworkGraphOpaque; @@ -73,46 +83,14 @@ struct nativeNodeAnnouncementInfoOpaque; typedef struct nativeNodeAnnouncementInfoOpaque LDKnativeNodeAnnouncementInfo; struct nativeNodeInfoOpaque; typedef struct nativeNodeInfoOpaque LDKnativeNodeInfo; -struct nativeChainMonitorOpaque; -typedef struct nativeChainMonitorOpaque LDKnativeChainMonitor; -struct nativeOutPointOpaque; -typedef struct nativeOutPointOpaque LDKnativeOutPoint; -struct nativeChannelMonitorUpdateOpaque; -typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate; -struct nativeMonitorUpdateErrorOpaque; -typedef struct nativeMonitorUpdateErrorOpaque LDKnativeMonitorUpdateError; -struct nativeHTLCUpdateOpaque; -typedef struct nativeHTLCUpdateOpaque LDKnativeHTLCUpdate; -struct nativeChannelMonitorOpaque; -typedef struct nativeChannelMonitorOpaque LDKnativeChannelMonitor; -struct nativeWatchedOutputOpaque; -typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput; -struct nativeChannelManagerOpaque; -typedef struct nativeChannelManagerOpaque LDKnativeChannelManager; -struct nativeChainParametersOpaque; -typedef struct nativeChainParametersOpaque LDKnativeChainParameters; -struct nativeBestBlockOpaque; -typedef struct nativeBestBlockOpaque LDKnativeBestBlock; -struct nativeChannelDetailsOpaque; -typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails; -struct nativeChannelManagerReadArgsOpaque; -typedef struct nativeChannelManagerReadArgsOpaque LDKnativeChannelManagerReadArgs; -struct nativeDelayedPaymentOutputDescriptorOpaque; -typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymentOutputDescriptor; -struct nativeStaticPaymentOutputDescriptorOpaque; -typedef struct nativeStaticPaymentOutputDescriptorOpaque LDKnativeStaticPaymentOutputDescriptor; -struct LDKBaseSign; -typedef struct LDKBaseSign LDKBaseSign; -struct nativeInMemorySignerOpaque; -typedef struct nativeInMemorySignerOpaque LDKnativeInMemorySigner; -struct nativeKeysManagerOpaque; -typedef struct nativeKeysManagerOpaque LDKnativeKeysManager; -struct nativeRouteHopOpaque; -typedef struct nativeRouteHopOpaque LDKnativeRouteHop; -struct nativeRouteOpaque; -typedef struct nativeRouteOpaque LDKnativeRoute; -struct nativeRouteHintOpaque; -typedef struct nativeRouteHintOpaque LDKnativeRouteHint; +struct nativeInitFeaturesOpaque; +typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures; +struct nativeNodeFeaturesOpaque; +typedef struct nativeNodeFeaturesOpaque LDKnativeNodeFeatures; +struct nativeChannelFeaturesOpaque; +typedef struct nativeChannelFeaturesOpaque LDKnativeChannelFeatures; +struct nativeInvoiceFeaturesOpaque; +typedef struct nativeInvoiceFeaturesOpaque LDKnativeInvoiceFeatures; struct nativeDecodeErrorOpaque; typedef struct nativeDecodeErrorOpaque LDKnativeDecodeError; struct nativeInitOpaque; @@ -183,3 +161,25 @@ struct nativeLightningErrorOpaque; typedef struct nativeLightningErrorOpaque LDKnativeLightningError; struct nativeCommitmentUpdateOpaque; typedef struct nativeCommitmentUpdateOpaque LDKnativeCommitmentUpdate; +struct nativeDelayedPaymentOutputDescriptorOpaque; +typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymentOutputDescriptor; +struct nativeStaticPaymentOutputDescriptorOpaque; +typedef struct nativeStaticPaymentOutputDescriptorOpaque LDKnativeStaticPaymentOutputDescriptor; +struct LDKBaseSign; +typedef struct LDKBaseSign LDKBaseSign; +struct nativeInMemorySignerOpaque; +typedef struct nativeInMemorySignerOpaque LDKnativeInMemorySigner; +struct nativeKeysManagerOpaque; +typedef struct nativeKeysManagerOpaque LDKnativeKeysManager; +struct nativeChainMonitorOpaque; +typedef struct nativeChainMonitorOpaque LDKnativeChainMonitor; +struct nativeChannelManagerOpaque; +typedef struct nativeChannelManagerOpaque LDKnativeChannelManager; +struct nativeChainParametersOpaque; +typedef struct nativeChainParametersOpaque LDKnativeChainParameters; +struct nativeBestBlockOpaque; +typedef struct nativeBestBlockOpaque LDKnativeBestBlock; +struct nativeChannelDetailsOpaque; +typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails; +struct nativeChannelManagerReadArgsOpaque; +typedef struct nativeChannelManagerReadArgsOpaque LDKnativeChannelManagerReadArgs; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index ed869b6..a4db218 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -1,4 +1,186 @@ #[repr(C)] +/// The contents of CResult_ChannelConfigDecodeErrorZ +pub union CResult_ChannelConfigDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::util::config::ChannelConfig, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelConfigDecodeErrorZ { + /// The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelConfigDecodeErrorZPtr, + /// Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_ok(o: crate::lightning::util::config::ChannelConfig) -> CResult_ChannelConfigDecodeErrorZ { + CResult_ChannelConfigDecodeErrorZ { + contents: CResult_ChannelConfigDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelConfigDecodeErrorZ { + CResult_ChannelConfigDecodeErrorZ { + contents: CResult_ChannelConfigDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_free(_res: CResult_ChannelConfigDecodeErrorZ) { } +impl Drop for CResult_ChannelConfigDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelConfigDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_ChannelConfigDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_ChannelConfigDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelConfigDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelConfigDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelConfigDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { orig.clone() } +#[repr(C)] +/// The contents of CResult_OutPointDecodeErrorZ +pub union CResult_OutPointDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::chain::transaction::OutPoint, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_OutPointDecodeErrorZ { + /// The contents of this CResult_OutPointDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_OutPointDecodeErrorZPtr, + /// Whether this CResult_OutPointDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_OutPointDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutPointDecodeErrorZ_ok(o: crate::lightning::chain::transaction::OutPoint) -> CResult_OutPointDecodeErrorZ { + CResult_OutPointDecodeErrorZ { + contents: CResult_OutPointDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_OutPointDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutPointDecodeErrorZ { + CResult_OutPointDecodeErrorZ { + contents: CResult_OutPointDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_OutPointDecodeErrorZ. +pub extern "C" fn CResult_OutPointDecodeErrorZ_free(_res: CResult_OutPointDecodeErrorZ) { } +impl Drop for CResult_OutPointDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_OutPointDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_OutPointDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_OutPointDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_OutPointDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OutPointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { orig.clone() } +#[repr(C)] /// The contents of CResult_SecretKeyErrorZ pub union CResult_SecretKeyErrorZPtr { /// A pointer to the contents in the success state. @@ -151,14 +333,14 @@ impl From CResult_TxCreationKeysDecodeErrorZ { +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysDecodeErrorZ { CResult_TxCreationKeysDecodeErrorZ { contents: CResult_TxCreationKeysDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -179,7 +361,7 @@ pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_ok(o: crate::ln::chan_utils } #[no_mangle] /// Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_TxCreationKeysDecodeErrorZ { +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCreationKeysDecodeErrorZ { CResult_TxCreationKeysDecodeErrorZ { contents: CResult_TxCreationKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), @@ -203,8 +385,8 @@ impl Drop for CResult_TxCreationKeysDecodeErrorZ { } } } -impl From> for CResult_TxCreationKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxCreationKeysDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -224,11 +406,11 @@ impl Clone for CResult_TxCreationKeysDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_TxCreationKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_TxCreationKeysDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } @@ -242,14 +424,14 @@ pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCrea pub union CResult_ChannelPublicKeysDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::ChannelPublicKeys, + pub result: *mut crate::lightning::ln::chan_utils::ChannelPublicKeys, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] /// A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::ChannelPublicKeys on success and a crate::ln::msgs::DecodeError on failure. +/// containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_ChannelPublicKeysDecodeErrorZ { /// The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either @@ -260,7 +442,7 @@ pub struct CResult_ChannelPublicKeysDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::ln::chan_utils::ChannelPublicKeys) -> CResult_ChannelPublicKeysDecodeErrorZ { +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelPublicKeys) -> CResult_ChannelPublicKeysDecodeErrorZ { CResult_ChannelPublicKeysDecodeErrorZ { contents: CResult_ChannelPublicKeysDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -270,7 +452,7 @@ pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::ln::chan_ut } #[no_mangle] /// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelPublicKeysDecodeErrorZ { +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelPublicKeysDecodeErrorZ { CResult_ChannelPublicKeysDecodeErrorZ { contents: CResult_ChannelPublicKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), @@ -294,8 +476,8 @@ impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { } } } -impl From> for CResult_ChannelPublicKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelPublicKeysDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -315,11 +497,11 @@ impl Clone for CResult_ChannelPublicKeysDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } @@ -333,14 +515,14 @@ pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_Cha pub union CResult_TxCreationKeysErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::TxCreationKeys, + pub result: *mut crate::lightning::ln::chan_utils::TxCreationKeys, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::c_types::Secp256k1Error, } #[repr(C)] /// A CResult_TxCreationKeysErrorZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::TxCreationKeys on success and a crate::c_types::Secp256k1Error on failure. +/// containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::c_types::Secp256k1Error on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_TxCreationKeysErrorZ { /// The contents of this CResult_TxCreationKeysErrorZ, accessible via either @@ -351,7 +533,7 @@ pub struct CResult_TxCreationKeysErrorZ { } #[no_mangle] /// Creates a new CResult_TxCreationKeysErrorZ in the success state. -pub extern "C" fn CResult_TxCreationKeysErrorZ_ok(o: crate::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysErrorZ { +pub extern "C" fn CResult_TxCreationKeysErrorZ_ok(o: crate::lightning::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysErrorZ { CResult_TxCreationKeysErrorZ { contents: CResult_TxCreationKeysErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -385,8 +567,8 @@ impl Drop for CResult_TxCreationKeysErrorZ { } } } -impl From> for CResult_TxCreationKeysErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxCreationKeysErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -441,14 +623,14 @@ pub extern "C" fn COption_u32Z_clone(orig: &COption_u32Z) -> COption_u32Z { orig pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::HTLCOutputInCommitment, + pub result: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] /// A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::HTLCOutputInCommitment on success and a crate::ln::msgs::DecodeError on failure. +/// containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_HTLCOutputInCommitmentDecodeErrorZ { /// The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either @@ -459,7 +641,7 @@ pub struct CResult_HTLCOutputInCommitmentDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::ln::chan_utils::HTLCOutputInCommitment) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { CResult_HTLCOutputInCommitmentDecodeErrorZ { contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -469,7 +651,7 @@ pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::ln::ch } #[no_mangle] /// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { CResult_HTLCOutputInCommitmentDecodeErrorZ { contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), @@ -493,8 +675,8 @@ impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { } } } -impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -514,11 +696,11 @@ impl Clone for CResult_HTLCOutputInCommitmentDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } @@ -532,14 +714,14 @@ pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResul pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::CounterpartyChannelTransactionParameters, + pub result: *mut crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] /// A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::ln::msgs::DecodeError on failure. +/// containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { /// The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either @@ -550,7 +732,7 @@ pub struct CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o: crate::ln::chan_utils::CounterpartyChannelTransactionParameters) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -560,7 +742,7 @@ pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_o } #[no_mangle] /// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), @@ -584,8 +766,8 @@ impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { } } } -impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -605,11 +787,11 @@ impl Clone for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } @@ -623,14 +805,14 @@ pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_c pub union CResult_ChannelTransactionParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::ChannelTransactionParameters, + pub result: *mut crate::lightning::ln::chan_utils::ChannelTransactionParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] /// A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::ChannelTransactionParameters on success and a crate::ln::msgs::DecodeError on failure. +/// containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_ChannelTransactionParametersDecodeErrorZ { /// The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either @@ -641,7 +823,7 @@ pub struct CResult_ChannelTransactionParametersDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate::ln::chan_utils::ChannelTransactionParameters) -> CResult_ChannelTransactionParametersDecodeErrorZ { +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> CResult_ChannelTransactionParametersDecodeErrorZ { CResult_ChannelTransactionParametersDecodeErrorZ { contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -651,7 +833,7 @@ pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate:: } #[no_mangle] /// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelTransactionParametersDecodeErrorZ { +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTransactionParametersDecodeErrorZ { CResult_ChannelTransactionParametersDecodeErrorZ { contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), @@ -675,8 +857,8 @@ impl Drop for CResult_ChannelTransactionParametersDecodeErrorZ { } } } -impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -696,11 +878,11 @@ impl Clone for CResult_ChannelTransactionParametersDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } @@ -760,14 +942,14 @@ impl Clone for CVec_SignatureZ { pub union CResult_HolderCommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::HolderCommitmentTransaction, + pub result: *mut crate::lightning::ln::chan_utils::HolderCommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] /// A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::HolderCommitmentTransaction on success and a crate::ln::msgs::DecodeError on failure. +/// containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_HolderCommitmentTransactionDecodeErrorZ { /// The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either @@ -778,7 +960,7 @@ pub struct CResult_HolderCommitmentTransactionDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::ln::chan_utils::HolderCommitmentTransaction) -> CResult_HolderCommitmentTransactionDecodeErrorZ { +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> CResult_HolderCommitmentTransactionDecodeErrorZ { CResult_HolderCommitmentTransactionDecodeErrorZ { contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -788,7 +970,7 @@ pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::l } #[no_mangle] /// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_HolderCommitmentTransactionDecodeErrorZ { +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HolderCommitmentTransactionDecodeErrorZ { CResult_HolderCommitmentTransactionDecodeErrorZ { contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), @@ -812,8 +994,8 @@ impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -833,11 +1015,11 @@ impl Clone for CResult_HolderCommitmentTransactionDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } @@ -851,14 +1033,14 @@ pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &C pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::BuiltCommitmentTransaction, + pub result: *mut crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] /// A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::ln::msgs::DecodeError on failure. +/// containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_BuiltCommitmentTransactionDecodeErrorZ { /// The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either @@ -869,7 +1051,7 @@ pub struct CResult_BuiltCommitmentTransactionDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::ln::chan_utils::BuiltCommitmentTransaction) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::BuiltCommitmentTransaction) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { CResult_BuiltCommitmentTransactionDecodeErrorZ { contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -879,7 +1061,7 @@ pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::ln } #[no_mangle] /// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { CResult_BuiltCommitmentTransactionDecodeErrorZ { contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), @@ -903,8 +1085,8 @@ impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -924,11 +1106,11 @@ impl Clone for CResult_BuiltCommitmentTransactionDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } @@ -942,14 +1124,14 @@ pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CR pub union CResult_CommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::CommitmentTransaction, + pub result: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] /// A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::CommitmentTransaction on success and a crate::ln::msgs::DecodeError on failure. +/// containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_CommitmentTransactionDecodeErrorZ { /// The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either @@ -960,7 +1142,7 @@ pub struct CResult_CommitmentTransactionDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::ln::chan_utils::CommitmentTransaction) -> CResult_CommitmentTransactionDecodeErrorZ { +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CommitmentTransaction) -> CResult_CommitmentTransactionDecodeErrorZ { CResult_CommitmentTransactionDecodeErrorZ { contents: CResult_CommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -970,7 +1152,7 @@ pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::ln::cha } #[no_mangle] /// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_CommitmentTransactionDecodeErrorZ { +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentTransactionDecodeErrorZ { CResult_CommitmentTransactionDecodeErrorZ { contents: CResult_CommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), @@ -994,8 +1176,8 @@ impl Drop for CResult_CommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_CommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -1015,11 +1197,11 @@ impl Clone for CResult_CommitmentTransactionDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_CommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } @@ -1033,13 +1215,13 @@ pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult pub union CResult_TrustedCommitmentTransactionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::chan_utils::TrustedCommitmentTransaction, + pub result: *mut crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut std::ffi::c_void, } #[repr(C)] /// A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, -/// containing a crate::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. +/// containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. pub struct CResult_TrustedCommitmentTransactionNoneZ { /// The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either @@ -1050,7 +1232,7 @@ pub struct CResult_TrustedCommitmentTransactionNoneZ { } #[no_mangle] /// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ { +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ { CResult_TrustedCommitmentTransactionNoneZ { contents: CResult_TrustedCommitmentTransactionNoneZPtr { result: Box::into_raw(Box::new(o)), @@ -1081,8 +1263,8 @@ impl Drop for CResult_TrustedCommitmentTransactionNoneZ { } } } -impl From> for CResult_TrustedCommitmentTransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TrustedCommitmentTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; @@ -1186,96 +1368,50 @@ impl Clone for CResult_CVec_SignatureZNoneZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { orig.clone() } #[repr(C)] -/// A dynamically-allocated array of crate::util::events::MessageSendEvents of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MessageSendEventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::util::events::MessageSendEvent, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MessageSendEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::util::events::MessageSendEvent] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_MessageSendEventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } -impl Drop for CVec_MessageSendEventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_MessageSendEventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// The contents of CResult_boolLightningErrorZ -pub union CResult_boolLightningErrorZPtr { +/// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ +pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut bool, + pub result: *mut crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::LightningError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_boolLightningErrorZ represents the result of a fallible operation, -/// containing a bool on success and a crate::ln::msgs::LightningError on failure. +/// A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_boolLightningErrorZ { - /// The contents of this CResult_boolLightningErrorZ, accessible via either +pub struct CResult_ChannelMonitorUpdateDecodeErrorZ { + /// The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_boolLightningErrorZPtr, - /// Whether this CResult_boolLightningErrorZ represents a success state. + pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr, + /// Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_boolLightningErrorZ in the success state. -pub extern "C" fn CResult_boolLightningErrorZ_ok(o: bool) -> CResult_boolLightningErrorZ { - CResult_boolLightningErrorZ { - contents: CResult_boolLightningErrorZPtr { +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ { + CResult_ChannelMonitorUpdateDecodeErrorZ { + contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_boolLightningErrorZ in the error state. -pub extern "C" fn CResult_boolLightningErrorZ_err(e: crate::ln::msgs::LightningError) -> CResult_boolLightningErrorZ { - CResult_boolLightningErrorZ { - contents: CResult_boolLightningErrorZPtr { +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ { + CResult_ChannelMonitorUpdateDecodeErrorZ { + contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_boolLightningErrorZ. -pub extern "C" fn CResult_boolLightningErrorZ_free(_res: CResult_boolLightningErrorZ) { } -impl Drop for CResult_boolLightningErrorZ { +/// Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { } +impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1288,16 +1424,16 @@ impl Drop for CResult_boolLightningErrorZ { } } } -impl From> for CResult_boolLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelMonitorUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_boolLightningErrorZPtr { result } + CResult_ChannelMonitorUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_boolLightningErrorZPtr { err } + CResult_ChannelMonitorUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -1305,205 +1441,158 @@ impl From> f } } } -impl Clone for CResult_boolLightningErrorZ { +impl Clone for CResult_ChannelMonitorUpdateDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_boolLightningErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_boolLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_boolLightningErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_boolLightningErrorZ_clone(orig: &CResult_boolLightningErrorZ) -> CResult_boolLightningErrorZ { orig.clone() } +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { orig.clone() } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - /// The element at position 0 - pub a: crate::ln::msgs::ChannelAnnouncement, - /// The element at position 1 - pub b: crate::ln::msgs::ChannelUpdate, - /// The element at position 2 - pub c: crate::ln::msgs::ChannelUpdate, -} -impl From<(crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate)> for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - fn from (tup: (crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - fn clone(&self) -> Self { - Self { - a: self.a.clone(), - b: self.b.clone(), - c: self.c.clone(), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig: &C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { orig.clone() } -/// Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. -#[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, b, c, } +/// The contents of CResult_HTLCUpdateDecodeErrorZ +pub union CResult_HTLCUpdateDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::chain::channelmonitor::HTLCUpdate, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. -pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res: C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_HTLCUpdateDecodeErrorZ { + /// The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_HTLCUpdateDecodeErrorZPtr, + /// Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::HTLCUpdate) -> CResult_HTLCUpdateDecodeErrorZ { + CResult_HTLCUpdateDecodeErrorZ { + contents: CResult_HTLCUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCUpdateDecodeErrorZ { + CResult_HTLCUpdateDecodeErrorZ { + contents: CResult_HTLCUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res: CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) { } -impl Drop for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { +/// Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_free(_res: CResult_HTLCUpdateDecodeErrorZ) { } +impl Drop for CResult_HTLCUpdateDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::ln::msgs::NodeAnnouncements of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_NodeAnnouncementZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::ln::msgs::NodeAnnouncement, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_NodeAnnouncementZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::NodeAnnouncement] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_NodeAnnouncementZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_NodeAnnouncementZ_free(_res: CVec_NodeAnnouncementZ) { } -impl Drop for CVec_NodeAnnouncementZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl From> for CResult_HTLCUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_HTLCUpdateDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_HTLCUpdateDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_NodeAnnouncementZ { +impl Clone for CResult_HTLCUpdateDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_HTLCUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_HTLCUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_NoneLightningErrorZ -pub union CResult_NoneLightningErrorZPtr { +/// The contents of CResult_NoneMonitorUpdateErrorZ +pub union CResult_NoneMonitorUpdateErrorZPtr { /// Note that this value is always NULL, as there are no contents in the OK variant pub result: *mut std::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::LightningError, + pub err: *mut crate::lightning::chain::channelmonitor::MonitorUpdateError, } #[repr(C)] -/// A CResult_NoneLightningErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::ln::msgs::LightningError on failure. +/// A CResult_NoneMonitorUpdateErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::chain::channelmonitor::MonitorUpdateError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneLightningErrorZ { - /// The contents of this CResult_NoneLightningErrorZ, accessible via either +pub struct CResult_NoneMonitorUpdateErrorZ { + /// The contents of this CResult_NoneMonitorUpdateErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneLightningErrorZPtr, - /// Whether this CResult_NoneLightningErrorZ represents a success state. + pub contents: CResult_NoneMonitorUpdateErrorZPtr, + /// Whether this CResult_NoneMonitorUpdateErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ in the success state. -pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { - CResult_NoneLightningErrorZ { - contents: CResult_NoneLightningErrorZPtr { +/// Creates a new CResult_NoneMonitorUpdateErrorZ in the success state. +pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_ok() -> CResult_NoneMonitorUpdateErrorZ { + CResult_NoneMonitorUpdateErrorZ { + contents: CResult_NoneMonitorUpdateErrorZPtr { result: std::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ in the error state. -pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ { - CResult_NoneLightningErrorZ { - contents: CResult_NoneLightningErrorZPtr { +/// Creates a new CResult_NoneMonitorUpdateErrorZ in the error state. +pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_err(e: crate::lightning::chain::channelmonitor::MonitorUpdateError) -> CResult_NoneMonitorUpdateErrorZ { + CResult_NoneMonitorUpdateErrorZ { + contents: CResult_NoneMonitorUpdateErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NoneLightningErrorZ. -pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { } -impl Drop for CResult_NoneLightningErrorZ { +/// Frees any resources used by the CResult_NoneMonitorUpdateErrorZ. +pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_free(_res: CResult_NoneMonitorUpdateErrorZ) { } +impl Drop for CResult_NoneMonitorUpdateErrorZ { fn drop(&mut self) { if self.result_ok { } else { @@ -1513,16 +1602,16 @@ impl Drop for CResult_NoneLightningErrorZ { } } } -impl From> for CResult_NoneLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneMonitorUpdateErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let _ = unsafe { Box::from_raw(o.contents.result) }; o.contents.result = std::ptr::null_mut(); - CResult_NoneLightningErrorZPtr { result: std::ptr::null_mut() } + CResult_NoneMonitorUpdateErrorZPtr { result: std::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NoneLightningErrorZPtr { err } + CResult_NoneMonitorUpdateErrorZPtr { err } }; Self { contents, @@ -1530,85 +1619,107 @@ impl From> for } } } -impl Clone for CResult_NoneLightningErrorZ { +impl Clone for CResult_NoneMonitorUpdateErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr { + Self { result_ok: true, contents: CResult_NoneMonitorUpdateErrorZPtr { result: std::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneMonitorUpdateErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneMonitorUpdateErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { orig.clone() } +pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_clone(orig: &CResult_NoneMonitorUpdateErrorZ) -> CResult_NoneMonitorUpdateErrorZ { orig.clone() } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PublicKeyZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::PublicKey, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OutPointScriptZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u8Z, } -impl CVec_PublicKeyZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointScriptZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -impl From> for CVec_PublicKeyZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +impl C2Tuple_OutPointScriptZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) { + (self.a, self.b) } } +/// Creates a new C2Tuple_OutPointScriptZ from the contained elements. #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } -impl Drop for CVec_PublicKeyZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; +pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ { + C2Tuple_OutPointScriptZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OutPointScriptZ. +pub extern "C" fn C2Tuple_OutPointScriptZ_free(_res: C2Tuple_OutPointScriptZ) { } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u32ScriptZ { + /// The element at position 0 + pub a: u32, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u8Z, +} +impl From<(u32, crate::c_types::derived::CVec_u8Z)> for C2Tuple_u32ScriptZ { + fn from (tup: (u32, crate::c_types::derived::CVec_u8Z)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_u32ScriptZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::derived::CVec_u8Z) { + (self.a, self.b) } } +/// Creates a new C2Tuple_u32ScriptZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u32ScriptZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32ScriptZ { + C2Tuple_u32ScriptZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u32ScriptZ. +pub extern "C" fn C2Tuple_u32ScriptZ_free(_res: C2Tuple_u32ScriptZ) { } #[repr(C)] -/// A dynamically-allocated array of u8s of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_u8Z { +pub struct CVec_C2Tuple_u32ScriptZZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut u8, + pub data: *mut crate::c_types::derived::C2Tuple_u32ScriptZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_u8Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_u32ScriptZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = std::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32ScriptZ] { unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_u8Z { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_u32ScriptZZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -1616,414 +1727,519 @@ impl From> for CVec_u8Z { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { } -impl Drop for CVec_u8Z { +pub extern "C" fn CVec_C2Tuple_u32ScriptZZ_free(_res: CVec_C2Tuple_u32ScriptZZ) { } +impl Drop for CVec_C2Tuple_u32ScriptZZ { fn drop(&mut self) { if self.datalen == 0 { return; } unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_u8Z { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} #[repr(C)] -/// The contents of CResult_CVec_u8ZPeerHandleErrorZ -pub union CResult_CVec_u8ZPeerHandleErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_u8Z, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::peer_handler::PeerHandleError, +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ, } -#[repr(C)] -/// A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::ln::peer_handler::PeerHandleError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_u8ZPeerHandleErrorZ { - /// The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr, - /// Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. - pub result_ok: bool, +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)> for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } } -#[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ { - CResult_CVec_u8ZPeerHandleErrorZ { - contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) { + (self.a, self.b) } } +/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ { - CResult_CVec_u8ZPeerHandleErrorZ { - contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { a, b, } } + #[no_mangle] -/// Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { } -impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } +/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl From> for CResult_CVec_u8ZPeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_CVec_u8ZPeerHandleErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_CVec_u8ZPeerHandleErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl Clone for CResult_CVec_u8ZPeerHandleErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } +impl From> for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { orig.clone() } -#[repr(C)] -/// The contents of CResult_NonePeerHandleErrorZ -pub union CResult_NonePeerHandleErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut std::ffi::c_void, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::peer_handler::PeerHandleError, +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res: CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ) { } +impl Drop for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } } #[repr(C)] -/// A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::ln::peer_handler::PeerHandleError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePeerHandleErrorZ { - /// The contents of this CResult_NonePeerHandleErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePeerHandleErrorZPtr, - /// Whether this CResult_NonePeerHandleErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MonitorEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ in the success state. -pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ { - CResult_NonePeerHandleErrorZ { - contents: CResult_NonePeerHandleErrorZPtr { - result: std::ptr::null_mut(), - }, - result_ok: true, +impl CVec_MonitorEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ in the error state. -pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ { - CResult_NonePeerHandleErrorZ { - contents: CResult_NonePeerHandleErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl From> for CVec_MonitorEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Frees any resources used by the CResult_NonePeerHandleErrorZ. -pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { } -impl Drop for CResult_NonePeerHandleErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } +impl Drop for CVec_MonitorEventZ { fn drop(&mut self) { - if self.result_ok { - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_NonePeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = std::ptr::null_mut(); - CResult_NonePeerHandleErrorZPtr { result: std::ptr::null_mut() } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NonePeerHandleErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_MonitorEventZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -impl Clone for CResult_NonePeerHandleErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr { - result: std::ptr::null_mut() - } } - } else { - Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_EventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::util::events::Event, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_EventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::events::Event] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_EventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { orig.clone() } -#[repr(C)] -/// The contents of CResult_boolPeerHandleErrorZ -pub union CResult_boolPeerHandleErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut bool, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::peer_handler::PeerHandleError, +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_EventZ_free(_res: CVec_EventZ) { } +impl Drop for CVec_EventZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_EventZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } #[repr(C)] -/// A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, -/// containing a bool on success and a crate::ln::peer_handler::PeerHandleError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_boolPeerHandleErrorZ { - /// The contents of this CResult_boolPeerHandleErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_boolPeerHandleErrorZPtr, - /// Whether this CResult_boolPeerHandleErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TransactionZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Transaction, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TransactionZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TransactionZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ in the success state. -pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ { - CResult_boolPeerHandleErrorZ { - contents: CResult_boolPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { } +impl Drop for CVec_TransactionZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_usizeTransactionZ { + /// The element at position 0 + pub a: usize, + /// The element at position 1 + pub b: crate::c_types::Transaction, +} +impl From<(usize, crate::c_types::Transaction)> for C2Tuple_usizeTransactionZ { + fn from (tup: (usize, crate::c_types::Transaction)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_usizeTransactionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { + (self.a, self.b) } } +/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ in the error state. -pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ { - CResult_boolPeerHandleErrorZ { - contents: CResult_boolPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { + C2Tuple_usizeTransactionZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_usizeTransactionZ. +pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_usizeTransactionZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_usizeTransactionZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_usizeTransactionZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Frees any resources used by the CResult_boolPeerHandleErrorZ. -pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { } -impl Drop for CResult_boolPeerHandleErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } +impl Drop for CVec_C2Tuple_usizeTransactionZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_boolPeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_boolPeerHandleErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_boolPeerHandleErrorZPtr { err } - }; +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u32TxOutZ { + /// The element at position 0 + pub a: u32, + /// The element at position 1 + pub b: crate::c_types::TxOut, +} +impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ { + fn from (tup: (u32, crate::c_types::TxOut)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_boolPeerHandleErrorZ { +impl C2Tuple_u32TxOutZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u32TxOutZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: self.a.clone(), + b: self.b.clone(), } } } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { orig.clone() } -#[repr(C)] -/// The contents of CResult_InitFeaturesDecodeErrorZ -pub union CResult_InitFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::features::InitFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, +pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { orig.clone() } +/// Creates a new C2Tuple_u32TxOutZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ { + C2Tuple_u32TxOutZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u32TxOutZ. +pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { } #[repr(C)] -/// A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::features::InitFeatures on success and a crate::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InitFeaturesDecodeErrorZ { - /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InitFeaturesDecodeErrorZPtr, - /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_u32TxOutZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_u32TxOutZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl From> for CVec_C2Tuple_u32TxOutZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } -impl Drop for CResult_InitFeaturesDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { } +impl Drop for CVec_C2Tuple_u32TxOutZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_InitFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_InitFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_InitFeaturesDecodeErrorZPtr { err } - }; +impl Clone for CVec_C2Tuple_u32TxOutZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } +impl C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TransactionOutputsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TransactionOutputsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TransactionOutputsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TransactionOutputsZ_free(_res: CVec_TransactionOutputsZ) { } +impl Drop for CVec_TransactionOutputsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TxidZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::ThirtyTwoBytes, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TxidZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TxidZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TxidZ_free(_res: CVec_TxidZ) { } +impl Drop for CVec_TxidZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} #[repr(C)] -/// The contents of CResult_NodeFeaturesDecodeErrorZ -pub union CResult_NodeFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::features::NodeFeatures, +/// The contents of CResult_NoneChannelMonitorUpdateErrZ +pub union CResult_NoneChannelMonitorUpdateErrZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut std::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::chain::channelmonitor::ChannelMonitorUpdateErr, } #[repr(C)] -/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::features::NodeFeatures on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_NoneChannelMonitorUpdateErrZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::chain::channelmonitor::ChannelMonitorUpdateErr on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeFeaturesDecodeErrorZ { - /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either +pub struct CResult_NoneChannelMonitorUpdateErrZ { + /// The contents of this CResult_NoneChannelMonitorUpdateErrZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeFeaturesDecodeErrorZPtr, - /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_NoneChannelMonitorUpdateErrZPtr, + /// Whether this CResult_NoneChannelMonitorUpdateErrZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. +pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_ok() -> CResult_NoneChannelMonitorUpdateErrZ { + CResult_NoneChannelMonitorUpdateErrZ { + contents: CResult_NoneChannelMonitorUpdateErrZPtr { + result: std::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. +pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_err(e: crate::lightning::chain::channelmonitor::ChannelMonitorUpdateErr) -> CResult_NoneChannelMonitorUpdateErrZ { + CResult_NoneChannelMonitorUpdateErrZ { + contents: CResult_NoneChannelMonitorUpdateErrZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } -impl Drop for CResult_NodeFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. +pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_free(_res: CResult_NoneChannelMonitorUpdateErrZ) { } +impl Drop for CResult_NoneChannelMonitorUpdateErrZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -2031,16 +2247,16 @@ impl Drop for CResult_NodeFeaturesDecodeErrorZ { } } } -impl From> for CResult_NodeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneChannelMonitorUpdateErrZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_NodeFeaturesDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = std::ptr::null_mut(); + CResult_NoneChannelMonitorUpdateErrZPtr { result: std::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NodeFeaturesDecodeErrorZPtr { err } + CResult_NoneChannelMonitorUpdateErrZPtr { err } }; Self { contents, @@ -2048,51 +2264,98 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneChannelMonitorUpdateErrZPtr { + result: std::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneChannelMonitorUpdateErrZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_clone(orig: &CResult_NoneChannelMonitorUpdateErrZ) -> CResult_NoneChannelMonitorUpdateErrZ { orig.clone() } #[repr(C)] -/// The contents of CResult_ChannelFeaturesDecodeErrorZ -pub union CResult_ChannelFeaturesDecodeErrorZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_BlockHashChannelMonitorZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::chain::channelmonitor::ChannelMonitor, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)> for C2Tuple_BlockHashChannelMonitorZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_BlockHashChannelMonitorZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::chain::channelmonitor::ChannelMonitor) -> C2Tuple_BlockHashChannelMonitorZ { + C2Tuple_BlockHashChannelMonitorZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_free(_res: C2Tuple_BlockHashChannelMonitorZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ +pub union CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::features::ChannelFeatures, + pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::features::ChannelFeatures on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2105,16 +2368,16 @@ impl Drop for CResult_ChannelFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ChannelFeaturesDecodeErrorZPtr { result } + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelFeaturesDecodeErrorZPtr { err } + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err } }; Self { contents, @@ -2123,124 +2386,142 @@ impl From CResult_InvoiceFeaturesDecodeErrorZ { - CResult_InvoiceFeaturesDecodeErrorZ { - contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_RouteHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InvoiceFeaturesDecodeErrorZ { - CResult_InvoiceFeaturesDecodeErrorZ { - contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl From> for CVec_RouteHopZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_free(_res: CResult_InvoiceFeaturesDecodeErrorZ) { } -impl Drop for CResult_InvoiceFeaturesDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } +impl Drop for CVec_RouteHopZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_InvoiceFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_InvoiceFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_InvoiceFeaturesDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_RouteHopZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_CVec_RouteHopZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::CVec_RouteHopZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_CVec_RouteHopZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_RouteHopZ] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_CVec_RouteHopZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_CVec_RouteHopZZ_free(_res: CVec_CVec_RouteHopZZ) { } +impl Drop for CVec_CVec_RouteHopZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_CVec_RouteHopZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } #[repr(C)] -/// The contents of CResult_ChannelConfigDecodeErrorZ -pub union CResult_ChannelConfigDecodeErrorZPtr { +/// The contents of CResult_RouteDecodeErrorZ +pub union CResult_RouteDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::util::config::ChannelConfig, + pub result: *mut crate::lightning::routing::router::Route, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::util::config::ChannelConfig on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_RouteDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelConfigDecodeErrorZ { - /// The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either +pub struct CResult_RouteDecodeErrorZ { + /// The contents of this CResult_RouteDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelConfigDecodeErrorZPtr, - /// Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + pub contents: CResult_RouteDecodeErrorZPtr, + /// Whether this CResult_RouteDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_ok(o: crate::util::config::ChannelConfig) -> CResult_ChannelConfigDecodeErrorZ { - CResult_ChannelConfigDecodeErrorZ { - contents: CResult_ChannelConfigDecodeErrorZPtr { +/// Creates a new CResult_RouteDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteDecodeErrorZ { + CResult_RouteDecodeErrorZ { + contents: CResult_RouteDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelConfigDecodeErrorZ { - CResult_ChannelConfigDecodeErrorZ { - contents: CResult_ChannelConfigDecodeErrorZPtr { +/// Creates a new CResult_RouteDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ { + CResult_RouteDecodeErrorZ { + contents: CResult_RouteDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_free(_res: CResult_ChannelConfigDecodeErrorZ) { } -impl Drop for CResult_ChannelConfigDecodeErrorZ { +/// Frees any resources used by the CResult_RouteDecodeErrorZ. +pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { } +impl Drop for CResult_RouteDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2253,16 +2534,16 @@ impl Drop for CResult_ChannelConfigDecodeErrorZ { } } } -impl From> for CResult_ChannelConfigDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ChannelConfigDecodeErrorZPtr { result } + CResult_RouteDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelConfigDecodeErrorZPtr { err } + CResult_RouteDecodeErrorZPtr { err } }; Self { contents, @@ -2270,23 +2551,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelConfigDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelConfigDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { orig.clone() } #[repr(C)] #[derive(Clone)] /// An enum which can either contain a u64 or not @@ -2322,50 +2603,142 @@ pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { } /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { orig.clone() } #[repr(C)] -/// The contents of CResult_DirectionalChannelInfoDecodeErrorZ -pub union CResult_DirectionalChannelInfoDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChannelDetailsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::channelmanager::ChannelDetails, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_ChannelDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::ChannelDetails] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_ChannelDetailsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { } +impl Drop for CVec_ChannelDetailsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_ChannelDetailsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_RouteHintZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::routing::router::RouteHint, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_RouteHintZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_RouteHintZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } +impl Drop for CVec_RouteHintZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_RouteHintZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_RouteLightningErrorZ +pub union CResult_RouteLightningErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::routing::network_graph::DirectionalChannelInfo, + pub result: *mut crate::lightning::routing::router::Route, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::LightningError, } #[repr(C)] -/// A CResult_DirectionalChannelInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::routing::network_graph::DirectionalChannelInfo on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_RouteLightningErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DirectionalChannelInfoDecodeErrorZ { - /// The contents of this CResult_DirectionalChannelInfoDecodeErrorZ, accessible via either +pub struct CResult_RouteLightningErrorZ { + /// The contents of this CResult_RouteLightningErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DirectionalChannelInfoDecodeErrorZPtr, - /// Whether this CResult_DirectionalChannelInfoDecodeErrorZ represents a success state. + pub contents: CResult_RouteLightningErrorZPtr, + /// Whether this CResult_RouteLightningErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_ok(o: crate::routing::network_graph::DirectionalChannelInfo) -> CResult_DirectionalChannelInfoDecodeErrorZ { - CResult_DirectionalChannelInfoDecodeErrorZ { - contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { +/// Creates a new CResult_RouteLightningErrorZ in the success state. +pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteLightningErrorZ { + CResult_RouteLightningErrorZ { + contents: CResult_RouteLightningErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_DirectionalChannelInfoDecodeErrorZ { - CResult_DirectionalChannelInfoDecodeErrorZ { - contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { +/// Creates a new CResult_RouteLightningErrorZ in the error state. +pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ { + CResult_RouteLightningErrorZ { + contents: CResult_RouteLightningErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ. -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_free(_res: CResult_DirectionalChannelInfoDecodeErrorZ) { } -impl Drop for CResult_DirectionalChannelInfoDecodeErrorZ { +/// Frees any resources used by the CResult_RouteLightningErrorZ. +pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { } +impl Drop for CResult_RouteLightningErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2378,16 +2751,16 @@ impl Drop for CResult_DirectionalChannelInfoDecodeErrorZ { } } } -impl From> for CResult_DirectionalChannelInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_DirectionalChannelInfoDecodeErrorZPtr { result } + CResult_RouteLightningErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_DirectionalChannelInfoDecodeErrorZPtr { err } + CResult_RouteLightningErrorZPtr { err } }; Self { contents, @@ -2395,159 +2768,114 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig: &CResult_DirectionalChannelInfoDecodeErrorZ) -> CResult_DirectionalChannelInfoDecodeErrorZ { orig.clone() } -#[repr(C)] -/// The contents of CResult_ChannelInfoDecodeErrorZ -pub union CResult_ChannelInfoDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::routing::network_graph::ChannelInfo, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { orig.clone() } #[repr(C)] -/// A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::routing::network_graph::ChannelInfo on success and a crate::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelInfoDecodeErrorZ { - /// The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelInfoDecodeErrorZPtr, - /// Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MessageSendEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::util::events::MessageSendEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_ok(o: crate::routing::network_graph::ChannelInfo) -> CResult_ChannelInfoDecodeErrorZ { - CResult_ChannelInfoDecodeErrorZ { - contents: CResult_ChannelInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_MessageSendEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelInfoDecodeErrorZ { - CResult_ChannelInfoDecodeErrorZ { - contents: CResult_ChannelInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::events::MessageSendEvent] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_free(_res: CResult_ChannelInfoDecodeErrorZ) { } -impl Drop for CResult_ChannelInfoDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } +impl From> for CVec_MessageSendEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } -impl From> for CResult_ChannelInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ChannelInfoDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelInfoDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } +impl Drop for CVec_MessageSendEventZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_ChannelInfoDecodeErrorZ { +impl Clone for CVec_MessageSendEventZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_clone(orig: &CResult_ChannelInfoDecodeErrorZ) -> CResult_ChannelInfoDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_RoutingFeesDecodeErrorZ -pub union CResult_RoutingFeesDecodeErrorZPtr { +/// The contents of CResult_boolLightningErrorZ +pub union CResult_boolLightningErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::routing::network_graph::RoutingFees, + pub result: *mut bool, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::LightningError, } #[repr(C)] -/// A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::routing::network_graph::RoutingFees on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_boolLightningErrorZ represents the result of a fallible operation, +/// containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RoutingFeesDecodeErrorZ { - /// The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either +pub struct CResult_boolLightningErrorZ { + /// The contents of this CResult_boolLightningErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RoutingFeesDecodeErrorZPtr, - /// Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. + pub contents: CResult_boolLightningErrorZPtr, + /// Whether this CResult_boolLightningErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_ok(o: crate::routing::network_graph::RoutingFees) -> CResult_RoutingFeesDecodeErrorZ { - CResult_RoutingFeesDecodeErrorZ { - contents: CResult_RoutingFeesDecodeErrorZPtr { +/// Creates a new CResult_boolLightningErrorZ in the success state. +pub extern "C" fn CResult_boolLightningErrorZ_ok(o: bool) -> CResult_boolLightningErrorZ { + CResult_boolLightningErrorZ { + contents: CResult_boolLightningErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_RoutingFeesDecodeErrorZ { - CResult_RoutingFeesDecodeErrorZ { - contents: CResult_RoutingFeesDecodeErrorZPtr { +/// Creates a new CResult_boolLightningErrorZ in the error state. +pub extern "C" fn CResult_boolLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_boolLightningErrorZ { + CResult_boolLightningErrorZ { + contents: CResult_boolLightningErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_free(_res: CResult_RoutingFeesDecodeErrorZ) { } -impl Drop for CResult_RoutingFeesDecodeErrorZ { +/// Frees any resources used by the CResult_boolLightningErrorZ. +pub extern "C" fn CResult_boolLightningErrorZ_free(_res: CResult_boolLightningErrorZ) { } +impl Drop for CResult_boolLightningErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2560,16 +2888,16 @@ impl Drop for CResult_RoutingFeesDecodeErrorZ { } } } -impl From> for CResult_RoutingFeesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_boolLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_RoutingFeesDecodeErrorZPtr { result } + CResult_boolLightningErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_RoutingFeesDecodeErrorZPtr { err } + CResult_boolLightningErrorZPtr { err } }; Self { contents, @@ -2577,47 +2905,93 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RoutingFeesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_boolLightningErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RoutingFeesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_boolLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_boolLightningErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_clone(orig: &CResult_RoutingFeesDecodeErrorZ) -> CResult_RoutingFeesDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_boolLightningErrorZ_clone(orig: &CResult_boolLightningErrorZ) -> CResult_boolLightningErrorZ { orig.clone() } +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + /// The element at position 0 + pub a: crate::lightning::ln::msgs::ChannelAnnouncement, + /// The element at position 1 + pub b: crate::lightning::ln::msgs::ChannelUpdate, + /// The element at position 2 + pub c: crate::lightning::ln::msgs::ChannelUpdate, +} +impl From<(crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate)> for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + fn from (tup: (crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } + } +} +impl C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + fn clone(&self) -> Self { + Self { + a: self.a.clone(), + b: self.b.clone(), + c: self.c.clone(), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig: &C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { orig.clone() } +/// Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a: crate::lightning::ln::msgs::ChannelAnnouncement, b: crate::lightning::ln::msgs::ChannelUpdate, c: crate::lightning::ln::msgs::ChannelUpdate) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. +pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res: C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::ln::msgs::NetAddresss of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_NetAddressZ { +pub struct CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::ln::msgs::NetAddress, + pub data: *mut crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_NetAddressZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = std::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::NetAddress] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ] { unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_NetAddressZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -2625,14 +2999,14 @@ impl From> for CVec_NetAddressZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_NetAddressZ_free(_res: CVec_NetAddressZ) { } -impl Drop for CVec_NetAddressZ { +pub extern "C" fn CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res: CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) { } +impl Drop for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { fn drop(&mut self) { if self.datalen == 0 { return; } unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_NetAddressZ { +impl Clone for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -2641,55 +3015,97 @@ impl Clone for CVec_NetAddressZ { } } #[repr(C)] -/// The contents of CResult_NodeAnnouncementInfoDecodeErrorZ -pub union CResult_NodeAnnouncementInfoDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::routing::network_graph::NodeAnnouncementInfo, +/// A dynamically-allocated array of crate::lightning::ln::msgs::NodeAnnouncements of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_NodeAnnouncementZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::msgs::NodeAnnouncement, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_NodeAnnouncementZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::NodeAnnouncement] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_NodeAnnouncementZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_NodeAnnouncementZ_free(_res: CVec_NodeAnnouncementZ) { } +impl Drop for CVec_NodeAnnouncementZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_NodeAnnouncementZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_NoneLightningErrorZ +pub union CResult_NoneLightningErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut std::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::LightningError, } #[repr(C)] -/// A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::routing::network_graph::NodeAnnouncementInfo on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_NoneLightningErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeAnnouncementInfoDecodeErrorZ { - /// The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either +pub struct CResult_NoneLightningErrorZ { + /// The contents of this CResult_NoneLightningErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr, - /// Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. + pub contents: CResult_NoneLightningErrorZPtr, + /// Whether this CResult_NoneLightningErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o: crate::routing::network_graph::NodeAnnouncementInfo) -> CResult_NodeAnnouncementInfoDecodeErrorZ { - CResult_NodeAnnouncementInfoDecodeErrorZ { - contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneLightningErrorZ in the success state. +pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { + CResult_NoneLightningErrorZ { + contents: CResult_NoneLightningErrorZPtr { + result: std::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_NodeAnnouncementInfoDecodeErrorZ { - CResult_NodeAnnouncementInfoDecodeErrorZ { - contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { +/// Creates a new CResult_NoneLightningErrorZ in the error state. +pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ { + CResult_NoneLightningErrorZ { + contents: CResult_NoneLightningErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res: CResult_NodeAnnouncementInfoDecodeErrorZ) { } -impl Drop for CResult_NodeAnnouncementInfoDecodeErrorZ { +/// Frees any resources used by the CResult_NoneLightningErrorZ. +pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { } +impl Drop for CResult_NoneLightningErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -2697,16 +3113,16 @@ impl Drop for CResult_NodeAnnouncementInfoDecodeErrorZ { } } } -impl From> for CResult_NodeAnnouncementInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_NodeAnnouncementInfoDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = std::ptr::null_mut(); + CResult_NoneLightningErrorZPtr { result: std::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NodeAnnouncementInfoDecodeErrorZPtr { err } + CResult_NoneLightningErrorZPtr { err } }; Self { contents, @@ -2714,47 +3130,85 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr { + result: std::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> CResult_NodeAnnouncementInfoDecodeErrorZ { orig.clone() } +/// Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { orig.clone() } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PublicKeyZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::PublicKey, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_PublicKeyZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_PublicKeyZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } +impl Drop for CVec_PublicKeyZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} #[repr(C)] -/// A dynamically-allocated array of u64s of arbitrary size. +/// A dynamically-allocated array of u8s of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_u64Z { +pub struct CVec_u8Z { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut u64, + pub data: *mut u8, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_u64Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_u8Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = std::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] { unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_u64Z { - fn from(v: Vec) -> Self { +impl From> for CVec_u8Z { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -2762,14 +3216,14 @@ impl From> for CVec_u64Z { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } -impl Drop for CVec_u64Z { +pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { } +impl Drop for CVec_u8Z { fn drop(&mut self) { if self.datalen == 0 { return; } unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_u64Z { +impl Clone for CVec_u8Z { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -2778,50 +3232,50 @@ impl Clone for CVec_u64Z { } } #[repr(C)] -/// The contents of CResult_NodeInfoDecodeErrorZ -pub union CResult_NodeInfoDecodeErrorZPtr { +/// The contents of CResult_CVec_u8ZPeerHandleErrorZ +pub union CResult_CVec_u8ZPeerHandleErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::routing::network_graph::NodeInfo, + pub result: *mut crate::c_types::derived::CVec_u8Z, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::routing::network_graph::NodeInfo on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeInfoDecodeErrorZ { - /// The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either +pub struct CResult_CVec_u8ZPeerHandleErrorZ { + /// The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeInfoDecodeErrorZPtr, - /// Whether this CResult_NodeInfoDecodeErrorZ represents a success state. + pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr, + /// Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_ok(o: crate::routing::network_graph::NodeInfo) -> CResult_NodeInfoDecodeErrorZ { - CResult_NodeInfoDecodeErrorZ { - contents: CResult_NodeInfoDecodeErrorZPtr { +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ { + CResult_CVec_u8ZPeerHandleErrorZ { + contents: CResult_CVec_u8ZPeerHandleErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_NodeInfoDecodeErrorZ { - CResult_NodeInfoDecodeErrorZ { - contents: CResult_NodeInfoDecodeErrorZPtr { +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ { + CResult_CVec_u8ZPeerHandleErrorZ { + contents: CResult_CVec_u8ZPeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NodeInfoDecodeErrorZ. -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_free(_res: CResult_NodeInfoDecodeErrorZ) { } -impl Drop for CResult_NodeInfoDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { } +impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2834,16 +3288,16 @@ impl Drop for CResult_NodeInfoDecodeErrorZ { } } } -impl From> for CResult_NodeInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_u8ZPeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_NodeInfoDecodeErrorZPtr { result } + CResult_CVec_u8ZPeerHandleErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NodeInfoDecodeErrorZPtr { err } + CResult_CVec_u8ZPeerHandleErrorZPtr { err } }; Self { contents, @@ -2851,73 +3305,69 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NodeInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NodeInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_clone(orig: &CResult_NodeInfoDecodeErrorZ) -> CResult_NodeInfoDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_NetworkGraphDecodeErrorZ -pub union CResult_NetworkGraphDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::routing::network_graph::NetworkGraph, +/// The contents of CResult_NonePeerHandleErrorZ +pub union CResult_NonePeerHandleErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut std::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::routing::network_graph::NetworkGraph on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NetworkGraphDecodeErrorZ { - /// The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either +pub struct CResult_NonePeerHandleErrorZ { + /// The contents of this CResult_NonePeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NetworkGraphDecodeErrorZPtr, - /// Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. + pub contents: CResult_NonePeerHandleErrorZPtr, + /// Whether this CResult_NonePeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. -pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_ok(o: crate::routing::network_graph::NetworkGraph) -> CResult_NetworkGraphDecodeErrorZ { - CResult_NetworkGraphDecodeErrorZ { - contents: CResult_NetworkGraphDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NonePeerHandleErrorZ in the success state. +pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ { + CResult_NonePeerHandleErrorZ { + contents: CResult_NonePeerHandleErrorZPtr { + result: std::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. -pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_NetworkGraphDecodeErrorZ { - CResult_NetworkGraphDecodeErrorZ { - contents: CResult_NetworkGraphDecodeErrorZPtr { +/// Creates a new CResult_NonePeerHandleErrorZ in the error state. +pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ { + CResult_NonePeerHandleErrorZ { + contents: CResult_NonePeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. -pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_free(_res: CResult_NetworkGraphDecodeErrorZ) { } -impl Drop for CResult_NetworkGraphDecodeErrorZ { +/// Frees any resources used by the CResult_NonePeerHandleErrorZ. +pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { } +impl Drop for CResult_NonePeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -2925,16 +3375,16 @@ impl Drop for CResult_NetworkGraphDecodeErrorZ { } } } -impl From> for CResult_NetworkGraphDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NonePeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_NetworkGraphDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = std::ptr::null_mut(); + CResult_NonePeerHandleErrorZPtr { result: std::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NetworkGraphDecodeErrorZPtr { err } + CResult_NonePeerHandleErrorZPtr { err } }; Self { contents, @@ -2942,175 +3392,73 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NetworkGraphDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr { + result: std::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_NetworkGraphDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_clone(orig: &CResult_NetworkGraphDecodeErrorZ) -> CResult_NetworkGraphDecodeErrorZ { orig.clone() } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_usizeTransactionZ { - /// The element at position 0 - pub a: usize, - /// The element at position 1 - pub b: crate::c_types::Transaction, -} -impl From<(usize, crate::c_types::Transaction)> for C2Tuple_usizeTransactionZ { - fn from (tup: (usize, crate::c_types::Transaction)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_usizeTransactionZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { - (self.a, self.b) - } -} -/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { - C2Tuple_usizeTransactionZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_usizeTransactionZ. -pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_usizeTransactionZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_usizeTransactionZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_usizeTransactionZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } -impl Drop for CVec_C2Tuple_usizeTransactionZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_TxidZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ThirtyTwoBytes, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_TxidZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_TxidZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TxidZ_free(_res: CVec_TxidZ) { } -impl Drop for CVec_TxidZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -#[repr(C)] -/// The contents of CResult_NoneChannelMonitorUpdateErrZ -pub union CResult_NoneChannelMonitorUpdateErrZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut std::ffi::c_void, +pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { orig.clone() } +#[repr(C)] +/// The contents of CResult_boolPeerHandleErrorZ +pub union CResult_boolPeerHandleErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut bool, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::chain::channelmonitor::ChannelMonitorUpdateErr, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_NoneChannelMonitorUpdateErrZ represents the result of a fallible operation, -/// containing a () on success and a crate::chain::channelmonitor::ChannelMonitorUpdateErr on failure. +/// A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, +/// containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneChannelMonitorUpdateErrZ { - /// The contents of this CResult_NoneChannelMonitorUpdateErrZ, accessible via either +pub struct CResult_boolPeerHandleErrorZ { + /// The contents of this CResult_boolPeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneChannelMonitorUpdateErrZPtr, - /// Whether this CResult_NoneChannelMonitorUpdateErrZ represents a success state. + pub contents: CResult_boolPeerHandleErrorZPtr, + /// Whether this CResult_boolPeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. -pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_ok() -> CResult_NoneChannelMonitorUpdateErrZ { - CResult_NoneChannelMonitorUpdateErrZ { - contents: CResult_NoneChannelMonitorUpdateErrZPtr { - result: std::ptr::null_mut(), +/// Creates a new CResult_boolPeerHandleErrorZ in the success state. +pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ { + CResult_boolPeerHandleErrorZ { + contents: CResult_boolPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. -pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_err(e: crate::chain::channelmonitor::ChannelMonitorUpdateErr) -> CResult_NoneChannelMonitorUpdateErrZ { - CResult_NoneChannelMonitorUpdateErrZ { - contents: CResult_NoneChannelMonitorUpdateErrZPtr { +/// Creates a new CResult_boolPeerHandleErrorZ in the error state. +pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ { + CResult_boolPeerHandleErrorZ { + contents: CResult_boolPeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. -pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_free(_res: CResult_NoneChannelMonitorUpdateErrZ) { } -impl Drop for CResult_NoneChannelMonitorUpdateErrZ { +/// Frees any resources used by the CResult_boolPeerHandleErrorZ. +pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { } +impl Drop for CResult_boolPeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -3118,16 +3466,16 @@ impl Drop for CResult_NoneChannelMonitorUpdateErrZ { } } } -impl From> for CResult_NoneChannelMonitorUpdateErrZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_boolPeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = std::ptr::null_mut(); - CResult_NoneChannelMonitorUpdateErrZPtr { result: std::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_boolPeerHandleErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NoneChannelMonitorUpdateErrZPtr { err } + CResult_boolPeerHandleErrorZPtr { err } }; Self { contents, @@ -3135,160 +3483,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneChannelMonitorUpdateErrZPtr { - result: std::ptr::null_mut() + Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneChannelMonitorUpdateErrZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` +/// Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_clone(orig: &CResult_NoneChannelMonitorUpdateErrZ) -> CResult_NoneChannelMonitorUpdateErrZ { orig.clone() } -#[repr(C)] -/// A dynamically-allocated array of crate::chain::channelmonitor::MonitorEvents of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MonitorEventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::chain::channelmonitor::MonitorEvent, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MonitorEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::chain::channelmonitor::MonitorEvent] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_MonitorEventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } -impl Drop for CVec_MonitorEventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_MonitorEventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::util::events::Events of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_EventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::util::events::Event, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_EventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::util::events::Event] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_EventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_EventZ_free(_res: CVec_EventZ) { } -impl Drop for CVec_EventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_EventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_OutPointDecodeErrorZ -pub union CResult_OutPointDecodeErrorZPtr { +/// The contents of CResult_TxOutAccessErrorZ +pub union CResult_TxOutAccessErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::chain::transaction::OutPoint, + pub result: *mut crate::c_types::TxOut, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::chain::AccessError, } #[repr(C)] -/// A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::chain::transaction::OutPoint on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_TxOutAccessErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::TxOut on success and a crate::lightning::chain::AccessError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OutPointDecodeErrorZ { - /// The contents of this CResult_OutPointDecodeErrorZ, accessible via either +pub struct CResult_TxOutAccessErrorZ { + /// The contents of this CResult_TxOutAccessErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OutPointDecodeErrorZPtr, - /// Whether this CResult_OutPointDecodeErrorZ represents a success state. + pub contents: CResult_TxOutAccessErrorZPtr, + /// Whether this CResult_TxOutAccessErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ in the success state. -pub extern "C" fn CResult_OutPointDecodeErrorZ_ok(o: crate::chain::transaction::OutPoint) -> CResult_OutPointDecodeErrorZ { - CResult_OutPointDecodeErrorZ { - contents: CResult_OutPointDecodeErrorZPtr { +/// Creates a new CResult_TxOutAccessErrorZ in the success state. +pub extern "C" fn CResult_TxOutAccessErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutAccessErrorZ { + CResult_TxOutAccessErrorZ { + contents: CResult_TxOutAccessErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ in the error state. -pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_OutPointDecodeErrorZ { - CResult_OutPointDecodeErrorZ { - contents: CResult_OutPointDecodeErrorZPtr { +/// Creates a new CResult_TxOutAccessErrorZ in the error state. +pub extern "C" fn CResult_TxOutAccessErrorZ_err(e: crate::lightning::chain::AccessError) -> CResult_TxOutAccessErrorZ { + CResult_TxOutAccessErrorZ { + contents: CResult_TxOutAccessErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_OutPointDecodeErrorZ. -pub extern "C" fn CResult_OutPointDecodeErrorZ_free(_res: CResult_OutPointDecodeErrorZ) { } -impl Drop for CResult_OutPointDecodeErrorZ { +/// Frees any resources used by the CResult_TxOutAccessErrorZ. +pub extern "C" fn CResult_TxOutAccessErrorZ_free(_res: CResult_TxOutAccessErrorZ) { } +impl Drop for CResult_TxOutAccessErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3301,85 +3557,160 @@ impl Drop for CResult_OutPointDecodeErrorZ { } } } -impl From> for CResult_OutPointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_OutPointDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_OutPointDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl From> for CResult_TxOutAccessErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_TxOutAccessErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_TxOutAccessErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxOutAccessErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxOutAccessErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxOutAccessErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxOutAccessErrorZ_clone(orig: &CResult_TxOutAccessErrorZ) -> CResult_TxOutAccessErrorZ { orig.clone() } +#[repr(C)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not +pub enum COption_C2Tuple_usizeTransactionZZ { + /// When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ + Some(crate::c_types::derived::C2Tuple_usizeTransactionZ), + /// When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing + None +} +impl COption_C2Tuple_usizeTransactionZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::Some(_) = self { true } else { false } + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_usizeTransactionZ { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ +pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_some(o: crate::c_types::derived::C2Tuple_usizeTransactionZ) -> COption_C2Tuple_usizeTransactionZZ { + COption_C2Tuple_usizeTransactionZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing +pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_none() -> COption_C2Tuple_usizeTransactionZZ { + COption_C2Tuple_usizeTransactionZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state +pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_free(_res: COption_C2Tuple_usizeTransactionZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_SpendableOutputDescriptorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::keysinterface::SpendableOutputDescriptor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_SpendableOutputDescriptorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::keysinterface::SpendableOutputDescriptor] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_SpendableOutputDescriptorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } +impl Drop for CVec_SpendableOutputDescriptorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_OutPointDecodeErrorZ { +impl Clone for CVec_SpendableOutputDescriptorZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_OutPointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ -pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// The contents of CResult_DirectionalChannelInfoDecodeErrorZ +pub union CResult_DirectionalChannelInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::chain::channelmonitor::ChannelMonitorUpdate, + pub result: *mut crate::lightning::routing::network_graph::DirectionalChannelInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_DirectionalChannelInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::network_graph::DirectionalChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelMonitorUpdateDecodeErrorZ { - /// The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either +pub struct CResult_DirectionalChannelInfoDecodeErrorZ { + /// The contents of this CResult_DirectionalChannelInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr, - /// Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + pub contents: CResult_DirectionalChannelInfoDecodeErrorZPtr, + /// Whether this CResult_DirectionalChannelInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ { - CResult_ChannelMonitorUpdateDecodeErrorZ { - contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_ok(o: crate::lightning::routing::network_graph::DirectionalChannelInfo) -> CResult_DirectionalChannelInfoDecodeErrorZ { + CResult_DirectionalChannelInfoDecodeErrorZ { + contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ { - CResult_ChannelMonitorUpdateDecodeErrorZ { - contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DirectionalChannelInfoDecodeErrorZ { + CResult_DirectionalChannelInfoDecodeErrorZ { + contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { } -impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ. +pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_free(_res: CResult_DirectionalChannelInfoDecodeErrorZ) { } +impl Drop for CResult_DirectionalChannelInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3392,16 +3723,16 @@ impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { } } } -impl From> for CResult_ChannelMonitorUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DirectionalChannelInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ChannelMonitorUpdateDecodeErrorZPtr { result } + CResult_DirectionalChannelInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelMonitorUpdateDecodeErrorZPtr { err } + CResult_DirectionalChannelInfoDecodeErrorZPtr { err } }; Self { contents, @@ -3409,68 +3740,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig: &CResult_DirectionalChannelInfoDecodeErrorZ) -> CResult_DirectionalChannelInfoDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_HTLCUpdateDecodeErrorZ -pub union CResult_HTLCUpdateDecodeErrorZPtr { +/// The contents of CResult_ChannelInfoDecodeErrorZ +pub union CResult_ChannelInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::chain::channelmonitor::HTLCUpdate, + pub result: *mut crate::lightning::routing::network_graph::ChannelInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::chain::channelmonitor::HTLCUpdate on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::network_graph::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HTLCUpdateDecodeErrorZ { - /// The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either +pub struct CResult_ChannelInfoDecodeErrorZ { + /// The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HTLCUpdateDecodeErrorZPtr, - /// Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. + pub contents: CResult_ChannelInfoDecodeErrorZPtr, + /// Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_ok(o: crate::chain::channelmonitor::HTLCUpdate) -> CResult_HTLCUpdateDecodeErrorZ { - CResult_HTLCUpdateDecodeErrorZ { - contents: CResult_HTLCUpdateDecodeErrorZPtr { +/// Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_ok(o: crate::lightning::routing::network_graph::ChannelInfo) -> CResult_ChannelInfoDecodeErrorZ { + CResult_ChannelInfoDecodeErrorZ { + contents: CResult_ChannelInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_HTLCUpdateDecodeErrorZ { - CResult_HTLCUpdateDecodeErrorZ { - contents: CResult_HTLCUpdateDecodeErrorZPtr { +/// Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelInfoDecodeErrorZ { + CResult_ChannelInfoDecodeErrorZ { + contents: CResult_ChannelInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_free(_res: CResult_HTLCUpdateDecodeErrorZ) { } -impl Drop for CResult_HTLCUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_free(_res: CResult_ChannelInfoDecodeErrorZ) { } +impl Drop for CResult_ChannelInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3483,16 +3814,16 @@ impl Drop for CResult_HTLCUpdateDecodeErrorZ { } } } -impl From> for CResult_HTLCUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_HTLCUpdateDecodeErrorZPtr { result } + CResult_ChannelInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_HTLCUpdateDecodeErrorZPtr { err } + CResult_ChannelInfoDecodeErrorZPtr { err } }; Self { contents, @@ -3500,69 +3831,73 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HTLCUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HTLCUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_clone(orig: &CResult_ChannelInfoDecodeErrorZ) -> CResult_ChannelInfoDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_NoneMonitorUpdateErrorZ -pub union CResult_NoneMonitorUpdateErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut std::ffi::c_void, +/// The contents of CResult_RoutingFeesDecodeErrorZ +pub union CResult_RoutingFeesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::network_graph::RoutingFees, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::chain::channelmonitor::MonitorUpdateError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneMonitorUpdateErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::chain::channelmonitor::MonitorUpdateError on failure. +/// A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::network_graph::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneMonitorUpdateErrorZ { - /// The contents of this CResult_NoneMonitorUpdateErrorZ, accessible via either +pub struct CResult_RoutingFeesDecodeErrorZ { + /// The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneMonitorUpdateErrorZPtr, - /// Whether this CResult_NoneMonitorUpdateErrorZ represents a success state. + pub contents: CResult_RoutingFeesDecodeErrorZPtr, + /// Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneMonitorUpdateErrorZ in the success state. -pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_ok() -> CResult_NoneMonitorUpdateErrorZ { - CResult_NoneMonitorUpdateErrorZ { - contents: CResult_NoneMonitorUpdateErrorZPtr { - result: std::ptr::null_mut(), +/// Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_ok(o: crate::lightning::routing::network_graph::RoutingFees) -> CResult_RoutingFeesDecodeErrorZ { + CResult_RoutingFeesDecodeErrorZ { + contents: CResult_RoutingFeesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneMonitorUpdateErrorZ in the error state. -pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_err(e: crate::chain::channelmonitor::MonitorUpdateError) -> CResult_NoneMonitorUpdateErrorZ { - CResult_NoneMonitorUpdateErrorZ { - contents: CResult_NoneMonitorUpdateErrorZPtr { +/// Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RoutingFeesDecodeErrorZ { + CResult_RoutingFeesDecodeErrorZ { + contents: CResult_RoutingFeesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NoneMonitorUpdateErrorZ. -pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_free(_res: CResult_NoneMonitorUpdateErrorZ) { } -impl Drop for CResult_NoneMonitorUpdateErrorZ { +/// Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_free(_res: CResult_RoutingFeesDecodeErrorZ) { } +impl Drop for CResult_RoutingFeesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -3570,16 +3905,16 @@ impl Drop for CResult_NoneMonitorUpdateErrorZ { } } } -impl From> for CResult_NoneMonitorUpdateErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RoutingFeesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = std::ptr::null_mut(); - CResult_NoneMonitorUpdateErrorZPtr { result: std::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_RoutingFeesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NoneMonitorUpdateErrorZPtr { err } + CResult_RoutingFeesDecodeErrorZPtr { err } }; Self { contents, @@ -3587,131 +3922,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneMonitorUpdateErrorZPtr { - result: std::ptr::null_mut() + Self { result_ok: true, contents: CResult_RoutingFeesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneMonitorUpdateErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_NoneMonitorUpdateErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_clone(orig: &CResult_NoneMonitorUpdateErrorZ) -> CResult_NoneMonitorUpdateErrorZ { orig.clone() } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_OutPointScriptZ { - /// The element at position 0 - pub a: crate::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_u8Z, -} -impl From<(crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointScriptZ { - fn from (tup: (crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_OutPointScriptZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_OutPointScriptZ { - fn clone(&self) -> Self { - Self { - a: self.a.clone(), - b: self.b.clone(), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_OutPointScriptZ_clone(orig: &C2Tuple_OutPointScriptZ) -> C2Tuple_OutPointScriptZ { orig.clone() } -/// Creates a new C2Tuple_OutPointScriptZ from the contained elements. -#[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, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_OutPointScriptZ. -pub extern "C" fn C2Tuple_OutPointScriptZ_free(_res: C2Tuple_OutPointScriptZ) { } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u32ScriptZ { - /// The element at position 0 - pub a: u32, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_u8Z, -} -impl From<(u32, crate::c_types::derived::CVec_u8Z)> for C2Tuple_u32ScriptZ { - fn from (tup: (u32, crate::c_types::derived::CVec_u8Z)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_u32ScriptZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::derived::CVec_u8Z) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u32ScriptZ { - fn clone(&self) -> Self { - Self { - a: self.a.clone(), - b: self.b.clone(), + Self { result_ok: false, contents: CResult_RoutingFeesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { orig.clone() } -/// Creates a new C2Tuple_u32ScriptZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u32ScriptZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32ScriptZ { - C2Tuple_u32ScriptZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u32ScriptZ. -pub extern "C" fn C2Tuple_u32ScriptZ_free(_res: C2Tuple_u32ScriptZ) { } +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_clone(orig: &CResult_RoutingFeesDecodeErrorZ) -> CResult_RoutingFeesDecodeErrorZ { orig.clone() } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_u32ScriptZZ { +pub struct CVec_NetAddressZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_u32ScriptZ, + pub data: *mut crate::lightning::ln::msgs::NetAddress, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_u32ScriptZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_NetAddressZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = std::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32ScriptZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::NetAddress] { unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_u32ScriptZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_NetAddressZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3719,14 +3970,14 @@ impl From> for CVec_C2Tuple_u32 } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_u32ScriptZZ_free(_res: CVec_C2Tuple_u32ScriptZZ) { } -impl Drop for CVec_C2Tuple_u32ScriptZZ { +pub extern "C" fn CVec_NetAddressZ_free(_res: CVec_NetAddressZ) { } +impl Drop for CVec_NetAddressZ { fn drop(&mut self) { if self.datalen == 0 { return; } unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_u32ScriptZZ { +impl Clone for CVec_NetAddressZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3735,59 +3986,120 @@ impl Clone for CVec_C2Tuple_u32ScriptZZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ, +/// The contents of CResult_NodeAnnouncementInfoDecodeErrorZ +pub union CResult_NodeAnnouncementInfoDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::network_graph::NodeAnnouncementInfo, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)> for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +#[repr(C)] +/// A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::network_graph::NodeAnnouncementInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NodeAnnouncementInfoDecodeErrorZ { + /// The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr, + /// Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o: crate::lightning::routing::network_graph::NodeAnnouncementInfo) -> CResult_NodeAnnouncementInfoDecodeErrorZ { + CResult_NodeAnnouncementInfoDecodeErrorZ { + contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) { - (self.a, self.b) +#[no_mangle] +/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementInfoDecodeErrorZ { + CResult_NodeAnnouncementInfoDecodeErrorZ { + contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { a, b, } +/// Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res: CResult_NodeAnnouncementInfoDecodeErrorZ) { } +impl Drop for CResult_NodeAnnouncementInfoDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NodeAnnouncementInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_NodeAnnouncementInfoDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_NodeAnnouncementInfoDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NodeAnnouncementInfoDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } } - #[no_mangle] -/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) { } +/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> CResult_NodeAnnouncementInfoDecodeErrorZ { orig.clone() } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. +/// A dynamically-allocated array of u64s of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { +pub struct CVec_u64Z { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ, + pub data: *mut u64, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_u64Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = std::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_u64Z { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3795,282 +4107,396 @@ impl From> f } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res: CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ) { } -impl Drop for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { +pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } +impl Drop for CVec_u64Z { fn drop(&mut self) { if self.datalen == 0 { return; } unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } +impl Clone for CVec_u64Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] -/// A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_TransactionZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Transaction, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// The contents of CResult_NodeInfoDecodeErrorZ +pub union CResult_NodeInfoDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::network_graph::NodeInfo, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::network_graph::NodeInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NodeInfoDecodeErrorZ { + /// The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NodeInfoDecodeErrorZPtr, + /// Whether this CResult_NodeInfoDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NodeInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_ok(o: crate::lightning::routing::network_graph::NodeInfo) -> CResult_NodeInfoDecodeErrorZ { + CResult_NodeInfoDecodeErrorZ { + contents: CResult_NodeInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NodeInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeInfoDecodeErrorZ { + CResult_NodeInfoDecodeErrorZ { + contents: CResult_NodeInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_NodeInfoDecodeErrorZ. +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_free(_res: CResult_NodeInfoDecodeErrorZ) { } +impl Drop for CResult_NodeInfoDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NodeInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_NodeInfoDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_NodeInfoDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NodeInfoDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NodeInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NodeInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_clone(orig: &CResult_NodeInfoDecodeErrorZ) -> CResult_NodeInfoDecodeErrorZ { orig.clone() } +#[repr(C)] +/// The contents of CResult_NetworkGraphDecodeErrorZ +pub union CResult_NetworkGraphDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::network_graph::NetworkGraph, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::network_graph::NetworkGraph on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NetworkGraphDecodeErrorZ { + /// The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NetworkGraphDecodeErrorZPtr, + /// Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_TransactionZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_ok(o: crate::lightning::routing::network_graph::NetworkGraph) -> CResult_NetworkGraphDecodeErrorZ { + CResult_NetworkGraphDecodeErrorZ { + contents: CResult_NetworkGraphDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_TransactionZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NetworkGraphDecodeErrorZ { + CResult_NetworkGraphDecodeErrorZ { + contents: CResult_NetworkGraphDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { } -impl Drop for CVec_TransactionZ { +/// Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_free(_res: CResult_NetworkGraphDecodeErrorZ) { } +impl Drop for CResult_NetworkGraphDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u32TxOutZ { - /// The element at position 0 - pub a: u32, - /// The element at position 1 - pub b: crate::c_types::TxOut, -} -impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ { - fn from (tup: (u32, crate::c_types::TxOut)) -> Self { +impl From> for CResult_NetworkGraphDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_NetworkGraphDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_NetworkGraphDecodeErrorZPtr { err } + }; Self { - a: tup.0, - b: tup.1, + contents, + result_ok: o.result_ok, } } } -impl C2Tuple_u32TxOutZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u32TxOutZ { +impl Clone for CResult_NetworkGraphDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: self.a.clone(), - b: self.b.clone(), + if self.result_ok { + Self { result_ok: true, contents: CResult_NetworkGraphDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NetworkGraphDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { orig.clone() } -/// Creates a new C2Tuple_u32TxOutZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ { - C2Tuple_u32TxOutZ { a, b, } +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_clone(orig: &CResult_NetworkGraphDecodeErrorZ) -> CResult_NetworkGraphDecodeErrorZ { orig.clone() } +#[repr(C)] +/// The contents of CResult_InitFeaturesDecodeErrorZ +pub union CResult_InitFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::InitFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u32TxOutZ. -pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_u32TxOutZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InitFeaturesDecodeErrorZ { + /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InitFeaturesDecodeErrorZPtr, + /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_C2Tuple_u32TxOutZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_C2Tuple_u32TxOutZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { } -impl Drop for CVec_C2Tuple_u32TxOutZZ { +/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } +impl Drop for CResult_InitFeaturesDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C2Tuple_u32TxOutZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self { +impl From> for CResult_InitFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_InitFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_InitFeaturesDecodeErrorZPtr { err } + }; Self { - a: tup.0, - b: tup.1, + contents, + result_ok: o.result_ok, } } } -impl C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) { - (self.a, self.b) - } -} -/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { a, b, } +#[repr(C)] +/// The contents of CResult_NodeFeaturesDecodeErrorZ +pub union CResult_NodeFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::NodeFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_TransactionOutputsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NodeFeaturesDecodeErrorZ { + /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NodeFeaturesDecodeErrorZPtr, + /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_TransactionOutputsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_TransactionOutputsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TransactionOutputsZ_free(_res: CVec_TransactionOutputsZ) { } -impl Drop for CVec_TransactionOutputsZ { +/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } +impl Drop for CResult_NodeFeaturesDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlockHashChannelMonitorZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::chain::channelmonitor::ChannelMonitor, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::chain::channelmonitor::ChannelMonitor)> for C2Tuple_BlockHashChannelMonitorZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::chain::channelmonitor::ChannelMonitor)) -> Self { +impl From> for CResult_NodeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_NodeFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_NodeFeaturesDecodeErrorZPtr { err } + }; Self { - a: tup.0, - b: tup.1, + contents, + result_ok: o.result_ok, } } } -impl C2Tuple_BlockHashChannelMonitorZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::chain::channelmonitor::ChannelMonitor) { - (self.a, self.b) - } -} -/// Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::chain::channelmonitor::ChannelMonitor) -> C2Tuple_BlockHashChannelMonitorZ { - C2Tuple_BlockHashChannelMonitorZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_free(_res: C2Tuple_BlockHashChannelMonitorZ) { } #[repr(C)] -/// The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ -pub union CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// The contents of CResult_ChannelFeaturesDecodeErrorZ +pub union CResult_ChannelFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, + pub result: *mut crate::lightning::ln::features::ChannelFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either +pub struct CResult_ChannelFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. + pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4083,16 +4509,16 @@ impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { } } } -impl From> for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result } + CResult_ChannelFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err } + CResult_ChannelFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -4101,96 +4527,124 @@ impl From Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::chain::keysinterface::SpendableOutputDescriptor] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } +#[repr(C)] +/// A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InvoiceFeaturesDecodeErrorZ { + /// The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InvoiceFeaturesDecodeErrorZPtr, + /// Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InvoiceFeatures) -> CResult_InvoiceFeaturesDecodeErrorZ { + CResult_InvoiceFeaturesDecodeErrorZ { + contents: CResult_InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_SpendableOutputDescriptorZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceFeaturesDecodeErrorZ { + CResult_InvoiceFeaturesDecodeErrorZ { + contents: CResult_InvoiceFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } -impl Drop for CVec_SpendableOutputDescriptorZ { +/// Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_free(_res: CResult_InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_InvoiceFeaturesDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -impl Clone for CVec_SpendableOutputDescriptorZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +impl From> for CResult_InvoiceFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_InvoiceFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_InvoiceFeaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } #[repr(C)] -/// The contents of CResult_TxOutAccessErrorZ -pub union CResult_TxOutAccessErrorZPtr { +/// The contents of CResult_NetAddressu8Z +pub union CResult_NetAddressu8ZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::TxOut, + pub result: *mut crate::lightning::ln::msgs::NetAddress, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::chain::AccessError, + pub err: *mut u8, } #[repr(C)] -/// A CResult_TxOutAccessErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::TxOut on success and a crate::chain::AccessError on failure. +/// A CResult_NetAddressu8Z represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::NetAddress on success and a u8 on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxOutAccessErrorZ { - /// The contents of this CResult_TxOutAccessErrorZ, accessible via either +pub struct CResult_NetAddressu8Z { + /// The contents of this CResult_NetAddressu8Z, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxOutAccessErrorZPtr, - /// Whether this CResult_TxOutAccessErrorZ represents a success state. + pub contents: CResult_NetAddressu8ZPtr, + /// Whether this CResult_NetAddressu8Z represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxOutAccessErrorZ in the success state. -pub extern "C" fn CResult_TxOutAccessErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutAccessErrorZ { - CResult_TxOutAccessErrorZ { - contents: CResult_TxOutAccessErrorZPtr { +/// Creates a new CResult_NetAddressu8Z in the success state. +pub extern "C" fn CResult_NetAddressu8Z_ok(o: crate::lightning::ln::msgs::NetAddress) -> CResult_NetAddressu8Z { + CResult_NetAddressu8Z { + contents: CResult_NetAddressu8ZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxOutAccessErrorZ in the error state. -pub extern "C" fn CResult_TxOutAccessErrorZ_err(e: crate::chain::AccessError) -> CResult_TxOutAccessErrorZ { - CResult_TxOutAccessErrorZ { - contents: CResult_TxOutAccessErrorZPtr { +/// Creates a new CResult_NetAddressu8Z in the error state. +pub extern "C" fn CResult_NetAddressu8Z_err(e: u8) -> CResult_NetAddressu8Z { + CResult_NetAddressu8Z { + contents: CResult_NetAddressu8ZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_TxOutAccessErrorZ. -pub extern "C" fn CResult_TxOutAccessErrorZ_free(_res: CResult_TxOutAccessErrorZ) { } -impl Drop for CResult_TxOutAccessErrorZ { +/// Frees any resources used by the CResult_NetAddressu8Z. +pub extern "C" fn CResult_NetAddressu8Z_free(_res: CResult_NetAddressu8Z) { } +impl Drop for CResult_NetAddressu8Z { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4203,16 +4657,16 @@ impl Drop for CResult_TxOutAccessErrorZ { } } } -impl From> for CResult_TxOutAccessErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NetAddressu8Z { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_TxOutAccessErrorZPtr { result } + CResult_NetAddressu8ZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_TxOutAccessErrorZPtr { err } + CResult_NetAddressu8ZPtr { err } }; Self { contents, @@ -4220,98 +4674,73 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxOutAccessErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_TxOutAccessErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxOutAccessErrorZ_clone(orig: &CResult_TxOutAccessErrorZ) -> CResult_TxOutAccessErrorZ { orig.clone() } -#[repr(C)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not -pub enum COption_C2Tuple_usizeTransactionZZ { - /// When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ - Some(crate::c_types::derived::C2Tuple_usizeTransactionZ), - /// When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing - None -} -impl COption_C2Tuple_usizeTransactionZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::Some(_) = self { true } else { false } - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_usizeTransactionZ { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ -pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_some(o: crate::c_types::derived::C2Tuple_usizeTransactionZ) -> COption_C2Tuple_usizeTransactionZZ { - COption_C2Tuple_usizeTransactionZZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing -pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_none() -> COption_C2Tuple_usizeTransactionZZ { - COption_C2Tuple_usizeTransactionZZ::None + Self { result_ok: true, contents: CResult_NetAddressu8ZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NetAddressu8ZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } } #[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state -pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_free(_res: COption_C2Tuple_usizeTransactionZZ) { } +/// Creates a new CResult_NetAddressu8Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NetAddressu8Z_clone(orig: &CResult_NetAddressu8Z) -> CResult_NetAddressu8Z { orig.clone() } #[repr(C)] -/// The contents of CResult_NoneAPIErrorZ -pub union CResult_NoneAPIErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut std::ffi::c_void, +/// The contents of CResult_CResult_NetAddressu8ZDecodeErrorZ +pub union CResult_CResult_NetAddressu8ZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CResult_NetAddressu8Z, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::util::errors::APIError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneAPIErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::util::errors::APIError on failure. +/// A CResult_CResult_NetAddressu8ZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CResult_NetAddressu8Z on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneAPIErrorZ { - /// The contents of this CResult_NoneAPIErrorZ, accessible via either +pub struct CResult_CResult_NetAddressu8ZDecodeErrorZ { + /// The contents of this CResult_CResult_NetAddressu8ZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneAPIErrorZPtr, - /// Whether this CResult_NoneAPIErrorZ represents a success state. + pub contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr, + /// Whether this CResult_CResult_NetAddressu8ZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneAPIErrorZ in the success state. -pub extern "C" fn CResult_NoneAPIErrorZ_ok() -> CResult_NoneAPIErrorZ { - CResult_NoneAPIErrorZ { - contents: CResult_NoneAPIErrorZPtr { - result: std::ptr::null_mut(), +/// Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the success state. +pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o: crate::c_types::derived::CResult_NetAddressu8Z) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { + CResult_CResult_NetAddressu8ZDecodeErrorZ { + contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneAPIErrorZ in the error state. -pub extern "C" fn CResult_NoneAPIErrorZ_err(e: crate::util::errors::APIError) -> CResult_NoneAPIErrorZ { - CResult_NoneAPIErrorZ { - contents: CResult_NoneAPIErrorZPtr { +/// Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the error state. +pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { + CResult_CResult_NetAddressu8ZDecodeErrorZ { + contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NoneAPIErrorZ. -pub extern "C" fn CResult_NoneAPIErrorZ_free(_res: CResult_NoneAPIErrorZ) { } -impl Drop for CResult_NoneAPIErrorZ { +/// Frees any resources used by the CResult_CResult_NetAddressu8ZDecodeErrorZ. +pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res: CResult_CResult_NetAddressu8ZDecodeErrorZ) { } +impl Drop for CResult_CResult_NetAddressu8ZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -4319,16 +4748,16 @@ impl Drop for CResult_NoneAPIErrorZ { } } } -impl From> for CResult_NoneAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CResult_NetAddressu8ZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = std::ptr::null_mut(); - CResult_NoneAPIErrorZPtr { result: std::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_CResult_NetAddressu8ZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NoneAPIErrorZPtr { err } + CResult_CResult_NetAddressu8ZDecodeErrorZPtr { err } }; Self { contents, @@ -4336,139 +4765,47 @@ impl From> for C } } } -impl Clone for CResult_NoneAPIErrorZ { +impl Clone for CResult_CResult_NetAddressu8ZDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneAPIErrorZPtr { - result: std::ptr::null_mut() + Self { result_ok: true, contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneAPIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` +/// Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneAPIErrorZ_clone(orig: &CResult_NoneAPIErrorZ) -> CResult_NoneAPIErrorZ { orig.clone() } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_CResult_NoneAPIErrorZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::CResult_NoneAPIErrorZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_CResult_NoneAPIErrorZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CResult_NoneAPIErrorZ] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_CResult_NoneAPIErrorZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_CResult_NoneAPIErrorZZ_free(_res: CVec_CResult_NoneAPIErrorZZ) { } -impl Drop for CVec_CResult_NoneAPIErrorZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_CResult_NoneAPIErrorZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::util::errors::APIErrors of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_APIErrorZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::util::errors::APIError, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_APIErrorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::util::errors::APIError] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_APIErrorZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_APIErrorZ_free(_res: CVec_APIErrorZ) { } -impl Drop for CVec_APIErrorZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_APIErrorZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig: &CResult_CResult_NetAddressu8ZDecodeErrorZ) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { orig.clone() } #[repr(C)] -/// A dynamically-allocated array of crate::ln::channelmanager::ChannelDetailss of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_ChannelDetailsZ { +pub struct CVec_UpdateAddHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::ln::channelmanager::ChannelDetails, + pub data: *mut crate::lightning::ln::msgs::UpdateAddHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_ChannelDetailsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateAddHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = std::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::channelmanager::ChannelDetails] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateAddHTLC] { unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_ChannelDetailsZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateAddHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -4476,132 +4813,45 @@ impl From> for CVec_ChannelDetail } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { } -impl Drop for CVec_ChannelDetailsZ { +pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { } +impl Drop for CVec_UpdateAddHTLCZ { fn drop(&mut self) { if self.datalen == 0 { return; } unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_ChannelDetailsZ { +impl Clone for CVec_UpdateAddHTLCZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); Self::from(res) - } -} -#[repr(C)] -/// The contents of CResult_NonePaymentSendFailureZ -pub union CResult_NonePaymentSendFailureZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut std::ffi::c_void, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::channelmanager::PaymentSendFailure, -} -#[repr(C)] -/// A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, -/// containing a () on success and a crate::ln::channelmanager::PaymentSendFailure on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePaymentSendFailureZ { - /// The contents of this CResult_NonePaymentSendFailureZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePaymentSendFailureZPtr, - /// Whether this CResult_NonePaymentSendFailureZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ in the success state. -pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ { - CResult_NonePaymentSendFailureZ { - contents: CResult_NonePaymentSendFailureZPtr { - result: std::ptr::null_mut(), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ in the error state. -pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::ln::channelmanager::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ { - CResult_NonePaymentSendFailureZ { - contents: CResult_NonePaymentSendFailureZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -#[no_mangle] -/// Frees any resources used by the CResult_NonePaymentSendFailureZ. -pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { } -impl Drop for CResult_NonePaymentSendFailureZ { - fn drop(&mut self) { - if self.result_ok { - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_NonePaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = std::ptr::null_mut(); - CResult_NonePaymentSendFailureZPtr { result: std::ptr::null_mut() } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NonePaymentSendFailureZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_NonePaymentSendFailureZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr { - result: std::ptr::null_mut() - } } - } else { - Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { orig.clone() } + } +} #[repr(C)] -/// A dynamically-allocated array of crate::chain::channelmonitor::ChannelMonitors of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_ChannelMonitorZ { +pub struct CVec_UpdateFulfillHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::chain::channelmonitor::ChannelMonitor, + pub data: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_ChannelMonitorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateFulfillHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = std::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::chain::channelmonitor::ChannelMonitor] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFulfillHTLC] { unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_ChannelMonitorZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateFulfillHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -4609,162 +4859,158 @@ impl From> for CVec_ChannelMon } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { } -impl Drop for CVec_ChannelMonitorZ { +pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { } +impl Drop for CVec_UpdateFulfillHTLCZ { fn drop(&mut self) { if self.datalen == 0 { return; } unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } +impl Clone for CVec_UpdateFulfillHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlockHashChannelManagerZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::ln::channelmanager::ChannelManager, +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UpdateFailHTLCZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::msgs::UpdateFailHTLC, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl From<(crate::c_types::ThirtyTwoBytes, crate::ln::channelmanager::ChannelManager)> for C2Tuple_BlockHashChannelManagerZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::ln::channelmanager::ChannelManager)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl CVec_UpdateFailHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailHTLC] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl C2Tuple_BlockHashChannelManagerZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::ln::channelmanager::ChannelManager) { - (self.a, self.b) +impl From> for CVec_UpdateFailHTLCZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } -/// Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::ln::channelmanager::ChannelManager) -> C2Tuple_BlockHashChannelManagerZ { - C2Tuple_BlockHashChannelManagerZ { a, b, } +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { } +impl Drop for CVec_UpdateFailHTLCZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. -pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_free(_res: C2Tuple_BlockHashChannelManagerZ) { } -#[repr(C)] -/// The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ -pub union CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, +impl Clone for CVec_UpdateFailHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } #[repr(C)] -/// A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UpdateFailMalformedHTLCZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_UpdateFailMalformedHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailMalformedHTLC] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl From> for CVec_UpdateFailMalformedHTLCZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { } +impl Drop for CVec_UpdateFailMalformedHTLCZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_UpdateFailMalformedHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } #[repr(C)] -/// The contents of CResult_SpendableOutputDescriptorDecodeErrorZ -pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr { +/// The contents of CResult_AcceptChannelDecodeErrorZ +pub union CResult_AcceptChannelDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::chain::keysinterface::SpendableOutputDescriptor, + pub result: *mut crate::lightning::ln::msgs::AcceptChannel, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::chain::keysinterface::SpendableOutputDescriptor on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SpendableOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either +pub struct CResult_AcceptChannelDecodeErrorZ { + /// The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. + pub contents: CResult_AcceptChannelDecodeErrorZPtr, + /// Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::chain::keysinterface::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ { - CResult_SpendableOutputDescriptorDecodeErrorZ { - contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannel) -> CResult_AcceptChannelDecodeErrorZ { + CResult_AcceptChannelDecodeErrorZ { + contents: CResult_AcceptChannelDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ { - CResult_SpendableOutputDescriptorDecodeErrorZ { - contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelDecodeErrorZ { + CResult_AcceptChannelDecodeErrorZ { + contents: CResult_AcceptChannelDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_free(_res: CResult_AcceptChannelDecodeErrorZ) { } +impl Drop for CResult_AcceptChannelDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4777,16 +5023,16 @@ impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { } } } -impl From> for CResult_SpendableOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_AcceptChannelDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_SpendableOutputDescriptorDecodeErrorZPtr { result } + CResult_AcceptChannelDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_SpendableOutputDescriptorDecodeErrorZPtr { err } + CResult_AcceptChannelDecodeErrorZPtr { err } }; Self { contents, @@ -4794,128 +5040,90 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_AcceptChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_AcceptChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { orig.clone() } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_SignatureCVec_SignatureZZ { - /// The element at position 0 - pub a: crate::c_types::Signature, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_SignatureZ, -} -impl From<(crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)> for C2Tuple_SignatureCVec_SignatureZZ { - fn from (tup: (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_SignatureCVec_SignatureZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_SignatureCVec_SignatureZZ { - fn clone(&self) -> Self { - Self { - a: self.a.clone(), - b: self.b.clone(), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { orig.clone() } -/// Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. -#[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, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. -pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_free(_res: C2Tuple_SignatureCVec_SignatureZZ) { } +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ -pub union CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { +/// The contents of CResult_AnnouncementSignaturesDecodeErrorZ +pub union CResult_AnnouncementSignaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut std::ffi::c_void, + pub result: *mut crate::lightning::ln::msgs::AnnouncementSignatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. +/// A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - /// The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either +pub struct CResult_AnnouncementSignaturesDecodeErrorZ { + /// The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr, - /// Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. + pub contents: CResult_AnnouncementSignaturesDecodeErrorZPtr, + /// Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AnnouncementSignatures) -> CResult_AnnouncementSignaturesDecodeErrorZ { + CResult_AnnouncementSignaturesDecodeErrorZ { + contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - err: std::ptr::null_mut(), +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AnnouncementSignaturesDecodeErrorZ { + CResult_AnnouncementSignaturesDecodeErrorZ { + contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) { } -impl Drop for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { +/// Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_free(_res: CResult_AnnouncementSignaturesDecodeErrorZ) { } +impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_AnnouncementSignaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result } + CResult_AnnouncementSignaturesDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = std::ptr::null_mut(); - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: std::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_AnnouncementSignaturesDecodeErrorZPtr { err } }; Self { contents, @@ -4923,86 +5131,90 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - err: std::ptr::null_mut() + Self { result_ok: false, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { orig.clone() } +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_SignatureNoneZ -pub union CResult_SignatureNoneZPtr { +/// The contents of CResult_ChannelReestablishDecodeErrorZ +pub union CResult_ChannelReestablishDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Signature, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut std::ffi::c_void, + pub result: *mut crate::lightning::ln::msgs::ChannelReestablish, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SignatureNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::Signature on success and a () on failure. +/// A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SignatureNoneZ { - /// The contents of this CResult_SignatureNoneZ, accessible via either +pub struct CResult_ChannelReestablishDecodeErrorZ { + /// The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SignatureNoneZPtr, - /// Whether this CResult_SignatureNoneZ represents a success state. + pub contents: CResult_ChannelReestablishDecodeErrorZPtr, + /// Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ in the success state. -pub extern "C" fn CResult_SignatureNoneZ_ok(o: crate::c_types::Signature) -> CResult_SignatureNoneZ { - CResult_SignatureNoneZ { - contents: CResult_SignatureNoneZPtr { +/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ { + CResult_ChannelReestablishDecodeErrorZ { + contents: CResult_ChannelReestablishDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ in the error state. -pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ { - CResult_SignatureNoneZ { - contents: CResult_SignatureNoneZPtr { - err: std::ptr::null_mut(), +/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ { + CResult_ChannelReestablishDecodeErrorZ { + contents: CResult_ChannelReestablishDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_SignatureNoneZ. -pub extern "C" fn CResult_SignatureNoneZ_free(_res: CResult_SignatureNoneZ) { } -impl Drop for CResult_SignatureNoneZ { +/// Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { } +impl Drop for CResult_ChannelReestablishDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_SignatureNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelReestablishDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_SignatureNoneZPtr { result } + CResult_ChannelReestablishDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = std::ptr::null_mut(); - CResult_SignatureNoneZPtr { err: std::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_ChannelReestablishDecodeErrorZPtr { err } }; Self { contents, @@ -5010,68 +5222,68 @@ impl From> for CResu } } } -impl Clone for CResult_SignatureNoneZ { +impl Clone for CResult_ChannelReestablishDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SignatureNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SignatureNoneZPtr { - err: std::ptr::null_mut() + Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ which has the same data as `orig` +/// Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { orig.clone() } +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_SignDecodeErrorZ -pub union CResult_SignDecodeErrorZPtr { +/// The contents of CResult_ClosingSignedDecodeErrorZ +pub union CResult_ClosingSignedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::chain::keysinterface::Sign, + pub result: *mut crate::lightning::ln::msgs::ClosingSigned, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SignDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::chain::keysinterface::Sign on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SignDecodeErrorZ { - /// The contents of this CResult_SignDecodeErrorZ, accessible via either +pub struct CResult_ClosingSignedDecodeErrorZ { + /// The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SignDecodeErrorZPtr, - /// Whether this CResult_SignDecodeErrorZ represents a success state. + pub contents: CResult_ClosingSignedDecodeErrorZPtr, + /// Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SignDecodeErrorZ in the success state. -pub extern "C" fn CResult_SignDecodeErrorZ_ok(o: crate::chain::keysinterface::Sign) -> CResult_SignDecodeErrorZ { - CResult_SignDecodeErrorZ { - contents: CResult_SignDecodeErrorZPtr { +/// Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSigned) -> CResult_ClosingSignedDecodeErrorZ { + CResult_ClosingSignedDecodeErrorZ { + contents: CResult_ClosingSignedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SignDecodeErrorZ in the error state. -pub extern "C" fn CResult_SignDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_SignDecodeErrorZ { - CResult_SignDecodeErrorZ { - contents: CResult_SignDecodeErrorZPtr { +/// Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedDecodeErrorZ { + CResult_ClosingSignedDecodeErrorZ { + contents: CResult_ClosingSignedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_SignDecodeErrorZ. -pub extern "C" fn CResult_SignDecodeErrorZ_free(_res: CResult_SignDecodeErrorZ) { } -impl Drop for CResult_SignDecodeErrorZ { +/// Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_free(_res: CResult_ClosingSignedDecodeErrorZ) { } +impl Drop for CResult_ClosingSignedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5084,16 +5296,16 @@ impl Drop for CResult_SignDecodeErrorZ { } } } -impl From> for CResult_SignDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ClosingSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_SignDecodeErrorZPtr { result } + CResult_ClosingSignedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_SignDecodeErrorZPtr { err } + CResult_ClosingSignedDecodeErrorZPtr { err } }; Self { contents, @@ -5101,132 +5313,90 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SignDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ClosingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SignDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ClosingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SignDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SignDecodeErrorZ_clone(orig: &CResult_SignDecodeErrorZ) -> CResult_SignDecodeErrorZ { orig.clone() } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_CVec_u8ZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::CVec_u8Z, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_CVec_u8ZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_u8Z] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_CVec_u8ZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_CVec_u8ZZ_free(_res: CVec_CVec_u8ZZ) { } -impl Drop for CVec_CVec_u8ZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_CVec_u8ZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_CVec_CVec_u8ZZNoneZ -pub union CResult_CVec_CVec_u8ZZNoneZPtr { +/// The contents of CResult_CommitmentSignedDecodeErrorZ +pub union CResult_CommitmentSignedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_CVec_u8ZZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut std::ffi::c_void, + pub result: *mut crate::lightning::ln::msgs::CommitmentSigned, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. +/// A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_CVec_u8ZZNoneZ { - /// The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either +pub struct CResult_CommitmentSignedDecodeErrorZ { + /// The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_CVec_u8ZZNoneZPtr, - /// Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + pub contents: CResult_CommitmentSignedDecodeErrorZPtr, + /// Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_ok(o: crate::c_types::derived::CVec_CVec_u8ZZ) -> CResult_CVec_CVec_u8ZZNoneZ { - CResult_CVec_CVec_u8ZZNoneZ { - contents: CResult_CVec_CVec_u8ZZNoneZPtr { +/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSigned) -> CResult_CommitmentSignedDecodeErrorZ { + CResult_CommitmentSignedDecodeErrorZ { + contents: CResult_CommitmentSignedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNoneZ { - CResult_CVec_CVec_u8ZZNoneZ { - contents: CResult_CVec_CVec_u8ZZNoneZPtr { - err: std::ptr::null_mut(), +/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedDecodeErrorZ { + CResult_CommitmentSignedDecodeErrorZ { + contents: CResult_CommitmentSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_free(_res: CResult_CVec_CVec_u8ZZNoneZ) { } -impl Drop for CResult_CVec_CVec_u8ZZNoneZ { +/// Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_free(_res: CResult_CommitmentSignedDecodeErrorZ) { } +impl Drop for CResult_CommitmentSignedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_CVec_CVec_u8ZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CommitmentSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_CVec_CVec_u8ZZNoneZPtr { result } + CResult_CommitmentSignedDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = std::ptr::null_mut(); - CResult_CVec_CVec_u8ZZNoneZPtr { err: std::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_CommitmentSignedDecodeErrorZPtr { err } }; Self { contents, @@ -5234,68 +5404,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_CVec_u8ZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CommitmentSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_CVec_u8ZZNoneZPtr { - err: std::ptr::null_mut() + Self { result_ok: false, contents: CResult_CommitmentSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` +/// Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { orig.clone() } +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_InMemorySignerDecodeErrorZ -pub union CResult_InMemorySignerDecodeErrorZPtr { +/// The contents of CResult_FundingCreatedDecodeErrorZ +pub union CResult_FundingCreatedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::chain::keysinterface::InMemorySigner, + pub result: *mut crate::lightning::ln::msgs::FundingCreated, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::chain::keysinterface::InMemorySigner on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InMemorySignerDecodeErrorZ { - /// The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either +pub struct CResult_FundingCreatedDecodeErrorZ { + /// The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InMemorySignerDecodeErrorZPtr, - /// Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. + pub contents: CResult_FundingCreatedDecodeErrorZPtr, + /// Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::chain::keysinterface::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { - CResult_InMemorySignerDecodeErrorZ { - contents: CResult_InMemorySignerDecodeErrorZPtr { +/// Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingCreated) -> CResult_FundingCreatedDecodeErrorZ { + CResult_FundingCreatedDecodeErrorZ { + contents: CResult_FundingCreatedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { - CResult_InMemorySignerDecodeErrorZ { - contents: CResult_InMemorySignerDecodeErrorZPtr { +/// Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingCreatedDecodeErrorZ { + CResult_FundingCreatedDecodeErrorZ { + contents: CResult_FundingCreatedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } -impl Drop for CResult_InMemorySignerDecodeErrorZ { +/// Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_free(_res: CResult_FundingCreatedDecodeErrorZ) { } +impl Drop for CResult_FundingCreatedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5308,16 +5478,16 @@ impl Drop for CResult_InMemorySignerDecodeErrorZ { } } } -impl From> for CResult_InMemorySignerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_FundingCreatedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_InMemorySignerDecodeErrorZPtr { result } + CResult_FundingCreatedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_InMemorySignerDecodeErrorZPtr { err } + CResult_FundingCreatedDecodeErrorZPtr { err } }; Self { contents, @@ -5325,132 +5495,90 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_FundingCreatedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_FundingCreatedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { orig.clone() } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_TxOutZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::TxOut, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_TxOutZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_TxOutZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { } -impl Drop for CVec_TxOutZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_TxOutZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_TransactionNoneZ -pub union CResult_TransactionNoneZPtr { +/// The contents of CResult_FundingSignedDecodeErrorZ +pub union CResult_FundingSignedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Transaction, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut std::ffi::c_void, + pub result: *mut crate::lightning::ln::msgs::FundingSigned, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TransactionNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::Transaction on success and a () on failure. +/// A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TransactionNoneZ { - /// The contents of this CResult_TransactionNoneZ, accessible via either +pub struct CResult_FundingSignedDecodeErrorZ { + /// The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TransactionNoneZPtr, - /// Whether this CResult_TransactionNoneZ represents a success state. + pub contents: CResult_FundingSignedDecodeErrorZPtr, + /// Whether this CResult_FundingSignedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TransactionNoneZ in the success state. -pub extern "C" fn CResult_TransactionNoneZ_ok(o: crate::c_types::Transaction) -> CResult_TransactionNoneZ { - CResult_TransactionNoneZ { - contents: CResult_TransactionNoneZPtr { +/// Creates a new CResult_FundingSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingSigned) -> CResult_FundingSignedDecodeErrorZ { + CResult_FundingSignedDecodeErrorZ { + contents: CResult_FundingSignedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TransactionNoneZ in the error state. -pub extern "C" fn CResult_TransactionNoneZ_err() -> CResult_TransactionNoneZ { - CResult_TransactionNoneZ { - contents: CResult_TransactionNoneZPtr { - err: std::ptr::null_mut(), +/// Creates a new CResult_FundingSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingSignedDecodeErrorZ { + CResult_FundingSignedDecodeErrorZ { + contents: CResult_FundingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_TransactionNoneZ. -pub extern "C" fn CResult_TransactionNoneZ_free(_res: CResult_TransactionNoneZ) { } -impl Drop for CResult_TransactionNoneZ { +/// Frees any resources used by the CResult_FundingSignedDecodeErrorZ. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_free(_res: CResult_FundingSignedDecodeErrorZ) { } +impl Drop for CResult_FundingSignedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_TransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_FundingSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_TransactionNoneZPtr { result } + CResult_FundingSignedDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = std::ptr::null_mut(); - CResult_TransactionNoneZPtr { err: std::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_FundingSignedDecodeErrorZPtr { err } }; Self { contents, @@ -5458,143 +5586,68 @@ impl From> for CRe } } } -#[repr(C)] -/// A dynamically-allocated array of crate::routing::router::RouteHops of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHopZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::routing::router::RouteHop, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RouteHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::routing::router::RouteHop] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RouteHopZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } -impl Drop for CVec_RouteHopZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHopZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_CVec_RouteHopZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::CVec_RouteHopZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_CVec_RouteHopZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_RouteHopZ] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_CVec_RouteHopZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_CVec_RouteHopZZ_free(_res: CVec_CVec_RouteHopZZ) { } -impl Drop for CVec_CVec_RouteHopZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_CVec_RouteHopZZ { +impl Clone for CResult_FundingSignedDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_FundingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_FundingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_RouteDecodeErrorZ -pub union CResult_RouteDecodeErrorZPtr { +/// The contents of CResult_FundingLockedDecodeErrorZ +pub union CResult_FundingLockedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::routing::router::Route, + pub result: *mut crate::lightning::ln::msgs::FundingLocked, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::routing::router::Route on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_FundingLockedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingLocked on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteDecodeErrorZ { - /// The contents of this CResult_RouteDecodeErrorZ, accessible via either +pub struct CResult_FundingLockedDecodeErrorZ { + /// The contents of this CResult_FundingLockedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteDecodeErrorZPtr, - /// Whether this CResult_RouteDecodeErrorZ represents a success state. + pub contents: CResult_FundingLockedDecodeErrorZPtr, + /// Whether this CResult_FundingLockedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::routing::router::Route) -> CResult_RouteDecodeErrorZ { - CResult_RouteDecodeErrorZ { - contents: CResult_RouteDecodeErrorZPtr { +/// Creates a new CResult_FundingLockedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingLockedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingLocked) -> CResult_FundingLockedDecodeErrorZ { + CResult_FundingLockedDecodeErrorZ { + contents: CResult_FundingLockedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ { - CResult_RouteDecodeErrorZ { - contents: CResult_RouteDecodeErrorZPtr { +/// Creates a new CResult_FundingLockedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingLockedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingLockedDecodeErrorZ { + CResult_FundingLockedDecodeErrorZ { + contents: CResult_FundingLockedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_RouteDecodeErrorZ. -pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { } -impl Drop for CResult_RouteDecodeErrorZ { +/// Frees any resources used by the CResult_FundingLockedDecodeErrorZ. +pub extern "C" fn CResult_FundingLockedDecodeErrorZ_free(_res: CResult_FundingLockedDecodeErrorZ) { } +impl Drop for CResult_FundingLockedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5607,16 +5660,16 @@ impl Drop for CResult_RouteDecodeErrorZ { } } } -impl From> for CResult_RouteDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_FundingLockedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_RouteDecodeErrorZPtr { result } + CResult_FundingLockedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_RouteDecodeErrorZPtr { err } + CResult_FundingLockedDecodeErrorZPtr { err } }; Self { contents, @@ -5624,114 +5677,159 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_FundingLockedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_FundingLockedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_FundingLockedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_FundingLockedDecodeErrorZ_clone(orig: &CResult_FundingLockedDecodeErrorZ) -> CResult_FundingLockedDecodeErrorZ { orig.clone() } #[repr(C)] -/// A dynamically-allocated array of crate::routing::router::RouteHints of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHintZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::routing::router::RouteHint, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// The contents of CResult_InitDecodeErrorZ +pub union CResult_InitDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Init, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl CVec_RouteHintZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::routing::router::RouteHint] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } +#[repr(C)] +/// A CResult_InitDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InitDecodeErrorZ { + /// The contents of this CResult_InitDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InitDecodeErrorZPtr, + /// Whether this CResult_InitDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Init) -> CResult_InitDecodeErrorZ { + CResult_InitDecodeErrorZ { + contents: CResult_InitDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_RouteHintZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ { + CResult_InitDecodeErrorZ { + contents: CResult_InitDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } -impl Drop for CVec_RouteHintZ { +/// Frees any resources used by the CResult_InitDecodeErrorZ. +pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { } +impl Drop for CResult_InitDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -impl Clone for CVec_RouteHintZ { +impl From> for CResult_InitDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_InitDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_InitDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_InitDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_RouteLightningErrorZ -pub union CResult_RouteLightningErrorZPtr { +/// The contents of CResult_OpenChannelDecodeErrorZ +pub union CResult_OpenChannelDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::routing::router::Route, + pub result: *mut crate::lightning::ln::msgs::OpenChannel, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::LightningError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteLightningErrorZ represents the result of a fallible operation, -/// containing a crate::routing::router::Route on success and a crate::ln::msgs::LightningError on failure. +/// A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteLightningErrorZ { - /// The contents of this CResult_RouteLightningErrorZ, accessible via either +pub struct CResult_OpenChannelDecodeErrorZ { + /// The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteLightningErrorZPtr, - /// Whether this CResult_RouteLightningErrorZ represents a success state. + pub contents: CResult_OpenChannelDecodeErrorZPtr, + /// Whether this CResult_OpenChannelDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ in the success state. -pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::routing::router::Route) -> CResult_RouteLightningErrorZ { - CResult_RouteLightningErrorZ { - contents: CResult_RouteLightningErrorZPtr { +/// Creates a new CResult_OpenChannelDecodeErrorZ in the success state. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannel) -> CResult_OpenChannelDecodeErrorZ { + CResult_OpenChannelDecodeErrorZ { + contents: CResult_OpenChannelDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ in the error state. -pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ { - CResult_RouteLightningErrorZ { - contents: CResult_RouteLightningErrorZPtr { +/// Creates a new CResult_OpenChannelDecodeErrorZ in the error state. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelDecodeErrorZ { + CResult_OpenChannelDecodeErrorZ { + contents: CResult_OpenChannelDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_RouteLightningErrorZ. -pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { } -impl Drop for CResult_RouteLightningErrorZ { +/// Frees any resources used by the CResult_OpenChannelDecodeErrorZ. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_free(_res: CResult_OpenChannelDecodeErrorZ) { } +impl Drop for CResult_OpenChannelDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5744,16 +5842,16 @@ impl Drop for CResult_RouteLightningErrorZ { } } } -impl From> for CResult_RouteLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OpenChannelDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_RouteLightningErrorZPtr { result } + CResult_OpenChannelDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_RouteLightningErrorZPtr { err } + CResult_OpenChannelDecodeErrorZPtr { err } }; Self { contents, @@ -5761,68 +5859,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OpenChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OpenChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` +/// Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { orig.clone() } +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_NetAddressu8Z -pub union CResult_NetAddressu8ZPtr { +/// The contents of CResult_RevokeAndACKDecodeErrorZ +pub union CResult_RevokeAndACKDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::NetAddress, + pub result: *mut crate::lightning::ln::msgs::RevokeAndACK, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut u8, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NetAddressu8Z represents the result of a fallible operation, -/// containing a crate::ln::msgs::NetAddress on success and a u8 on failure. +/// A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NetAddressu8Z { - /// The contents of this CResult_NetAddressu8Z, accessible via either +pub struct CResult_RevokeAndACKDecodeErrorZ { + /// The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NetAddressu8ZPtr, - /// Whether this CResult_NetAddressu8Z represents a success state. + pub contents: CResult_RevokeAndACKDecodeErrorZPtr, + /// Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NetAddressu8Z in the success state. -pub extern "C" fn CResult_NetAddressu8Z_ok(o: crate::ln::msgs::NetAddress) -> CResult_NetAddressu8Z { - CResult_NetAddressu8Z { - contents: CResult_NetAddressu8ZPtr { +/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_ok(o: crate::lightning::ln::msgs::RevokeAndACK) -> CResult_RevokeAndACKDecodeErrorZ { + CResult_RevokeAndACKDecodeErrorZ { + contents: CResult_RevokeAndACKDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NetAddressu8Z in the error state. -pub extern "C" fn CResult_NetAddressu8Z_err(e: u8) -> CResult_NetAddressu8Z { - CResult_NetAddressu8Z { - contents: CResult_NetAddressu8ZPtr { +/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevokeAndACKDecodeErrorZ { + CResult_RevokeAndACKDecodeErrorZ { + contents: CResult_RevokeAndACKDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NetAddressu8Z. -pub extern "C" fn CResult_NetAddressu8Z_free(_res: CResult_NetAddressu8Z) { } -impl Drop for CResult_NetAddressu8Z { +/// Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_free(_res: CResult_RevokeAndACKDecodeErrorZ) { } +impl Drop for CResult_RevokeAndACKDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5835,16 +5933,16 @@ impl Drop for CResult_NetAddressu8Z { } } } -impl From> for CResult_NetAddressu8Z { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RevokeAndACKDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_NetAddressu8ZPtr { result } + CResult_RevokeAndACKDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NetAddressu8ZPtr { err } + CResult_RevokeAndACKDecodeErrorZPtr { err } }; Self { contents, @@ -5852,68 +5950,68 @@ impl From> for CRe } } } -impl Clone for CResult_NetAddressu8Z { +impl Clone for CResult_RevokeAndACKDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NetAddressu8ZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RevokeAndACKDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NetAddressu8ZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_RevokeAndACKDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NetAddressu8Z which has the same data as `orig` +/// Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NetAddressu8Z_clone(orig: &CResult_NetAddressu8Z) -> CResult_NetAddressu8Z { orig.clone() } +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_CResult_NetAddressu8ZDecodeErrorZ -pub union CResult_CResult_NetAddressu8ZDecodeErrorZPtr { +/// The contents of CResult_ShutdownDecodeErrorZ +pub union CResult_ShutdownDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CResult_NetAddressu8Z, + pub result: *mut crate::lightning::ln::msgs::Shutdown, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CResult_NetAddressu8ZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CResult_NetAddressu8Z on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CResult_NetAddressu8ZDecodeErrorZ { - /// The contents of this CResult_CResult_NetAddressu8ZDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr, - /// Whether this CResult_CResult_NetAddressu8ZDecodeErrorZ represents a success state. +pub struct CResult_ShutdownDecodeErrorZ { + /// The contents of this CResult_ShutdownDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ShutdownDecodeErrorZPtr, + /// Whether this CResult_ShutdownDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the success state. -pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o: crate::c_types::derived::CResult_NetAddressu8Z) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { - CResult_CResult_NetAddressu8ZDecodeErrorZ { - contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr { +/// Creates a new CResult_ShutdownDecodeErrorZ in the success state. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Shutdown) -> CResult_ShutdownDecodeErrorZ { + CResult_ShutdownDecodeErrorZ { + contents: CResult_ShutdownDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the error state. -pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { - CResult_CResult_NetAddressu8ZDecodeErrorZ { - contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr { +/// Creates a new CResult_ShutdownDecodeErrorZ in the error state. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownDecodeErrorZ { + CResult_ShutdownDecodeErrorZ { + contents: CResult_ShutdownDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_CResult_NetAddressu8ZDecodeErrorZ. -pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res: CResult_CResult_NetAddressu8ZDecodeErrorZ) { } -impl Drop for CResult_CResult_NetAddressu8ZDecodeErrorZ { +/// Frees any resources used by the CResult_ShutdownDecodeErrorZ. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_free(_res: CResult_ShutdownDecodeErrorZ) { } +impl Drop for CResult_ShutdownDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5926,16 +6024,16 @@ impl Drop for CResult_CResult_NetAddressu8ZDecodeErrorZ { } } } -impl From> for CResult_CResult_NetAddressu8ZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_CResult_NetAddressu8ZDecodeErrorZPtr { result } + CResult_ShutdownDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_CResult_NetAddressu8ZDecodeErrorZPtr { err } + CResult_ShutdownDecodeErrorZPtr { err } }; Self { contents, @@ -5943,252 +6041,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ShutdownDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CResult_NetAddressu8ZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ShutdownDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig: &CResult_CResult_NetAddressu8ZDecodeErrorZ) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { orig.clone() } -#[repr(C)] -/// A dynamically-allocated array of crate::ln::msgs::UpdateAddHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateAddHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::ln::msgs::UpdateAddHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateAddHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::UpdateAddHTLC] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateAddHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { } -impl Drop for CVec_UpdateAddHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateAddHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::ln::msgs::UpdateFulfillHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFulfillHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::ln::msgs::UpdateFulfillHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFulfillHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::UpdateFulfillHTLC] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFulfillHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { } -impl Drop for CVec_UpdateFulfillHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFulfillHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::ln::msgs::UpdateFailHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFailHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::ln::msgs::UpdateFailHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFailHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::UpdateFailHTLC] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFailHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { } -impl Drop for CVec_UpdateFailHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFailHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFailMalformedHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::ln::msgs::UpdateFailMalformedHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFailMalformedHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::ln::msgs::UpdateFailMalformedHTLC] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFailMalformedHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { } -impl Drop for CVec_UpdateFailMalformedHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFailMalformedHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_AcceptChannelDecodeErrorZ -pub union CResult_AcceptChannelDecodeErrorZPtr { +/// The contents of CResult_UpdateFailHTLCDecodeErrorZ +pub union CResult_UpdateFailHTLCDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::AcceptChannel, + pub result: *mut crate::lightning::ln::msgs::UpdateFailHTLC, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::AcceptChannel on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AcceptChannelDecodeErrorZ { - /// The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either +pub struct CResult_UpdateFailHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AcceptChannelDecodeErrorZPtr, - /// Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + pub contents: CResult_UpdateFailHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_ok(o: crate::ln::msgs::AcceptChannel) -> CResult_AcceptChannelDecodeErrorZ { - CResult_AcceptChannelDecodeErrorZ { - contents: CResult_AcceptChannelDecodeErrorZPtr { +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailHTLC) -> CResult_UpdateFailHTLCDecodeErrorZ { + CResult_UpdateFailHTLCDecodeErrorZ { + contents: CResult_UpdateFailHTLCDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_AcceptChannelDecodeErrorZ { - CResult_AcceptChannelDecodeErrorZ { - contents: CResult_AcceptChannelDecodeErrorZPtr { +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailHTLCDecodeErrorZ { + CResult_UpdateFailHTLCDecodeErrorZ { + contents: CResult_UpdateFailHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_free(_res: CResult_AcceptChannelDecodeErrorZ) { } -impl Drop for CResult_AcceptChannelDecodeErrorZ { +/// Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_free(_res: CResult_UpdateFailHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6201,16 +6115,16 @@ impl Drop for CResult_AcceptChannelDecodeErrorZ { } } } -impl From> for CResult_AcceptChannelDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateFailHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_AcceptChannelDecodeErrorZPtr { result } + CResult_UpdateFailHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_AcceptChannelDecodeErrorZPtr { err } + CResult_UpdateFailHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -6218,68 +6132,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AcceptChannelDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AcceptChannelDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_AnnouncementSignaturesDecodeErrorZ -pub union CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ +pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::AnnouncementSignatures, + pub result: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::AnnouncementSignatures on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AnnouncementSignaturesDecodeErrorZ { - /// The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AnnouncementSignaturesDecodeErrorZPtr, - /// Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. +pub struct CResult_UpdateFailMalformedHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_ok(o: crate::ln::msgs::AnnouncementSignatures) -> CResult_AnnouncementSignaturesDecodeErrorZ { - CResult_AnnouncementSignaturesDecodeErrorZ { - contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { + CResult_UpdateFailMalformedHTLCDecodeErrorZ { + contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_AnnouncementSignaturesDecodeErrorZ { - CResult_AnnouncementSignaturesDecodeErrorZ { - contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { + CResult_UpdateFailMalformedHTLCDecodeErrorZ { + contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_free(_res: CResult_AnnouncementSignaturesDecodeErrorZ) { } -impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { +/// Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res: CResult_UpdateFailMalformedHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6292,16 +6206,16 @@ impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { } } } -impl From> for CResult_AnnouncementSignaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateFailMalformedHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_AnnouncementSignaturesDecodeErrorZPtr { result } + CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_AnnouncementSignaturesDecodeErrorZPtr { err } + CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -6309,68 +6223,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_ChannelReestablishDecodeErrorZ -pub union CResult_ChannelReestablishDecodeErrorZPtr { +/// The contents of CResult_UpdateFeeDecodeErrorZ +pub union CResult_UpdateFeeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::ChannelReestablish, + pub result: *mut crate::lightning::ln::msgs::UpdateFee, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::ChannelReestablish on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelReestablishDecodeErrorZ { - /// The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either +pub struct CResult_UpdateFeeDecodeErrorZ { + /// The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelReestablishDecodeErrorZPtr, - /// Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + pub contents: CResult_UpdateFeeDecodeErrorZPtr, + /// Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ { - CResult_ChannelReestablishDecodeErrorZ { - contents: CResult_ChannelReestablishDecodeErrorZPtr { +/// Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFee) -> CResult_UpdateFeeDecodeErrorZ { + CResult_UpdateFeeDecodeErrorZ { + contents: CResult_UpdateFeeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ { - CResult_ChannelReestablishDecodeErrorZ { - contents: CResult_ChannelReestablishDecodeErrorZPtr { +/// Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFeeDecodeErrorZ { + CResult_UpdateFeeDecodeErrorZ { + contents: CResult_UpdateFeeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { } -impl Drop for CResult_ChannelReestablishDecodeErrorZ { +/// Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_free(_res: CResult_UpdateFeeDecodeErrorZ) { } +impl Drop for CResult_UpdateFeeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6383,16 +6297,16 @@ impl Drop for CResult_ChannelReestablishDecodeErrorZ { } } } -impl From> for CResult_ChannelReestablishDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateFeeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ChannelReestablishDecodeErrorZPtr { result } + CResult_UpdateFeeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelReestablishDecodeErrorZPtr { err } + CResult_UpdateFeeDecodeErrorZPtr { err } }; Self { contents, @@ -6400,68 +6314,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateFeeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UpdateFeeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_ClosingSignedDecodeErrorZ -pub union CResult_ClosingSignedDecodeErrorZPtr { +/// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ +pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::ClosingSigned, + pub result: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::ClosingSigned on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ClosingSignedDecodeErrorZ { - /// The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either +pub struct CResult_UpdateFulfillHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClosingSignedDecodeErrorZPtr, - /// Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + pub contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_ok(o: crate::ln::msgs::ClosingSigned) -> CResult_ClosingSignedDecodeErrorZ { - CResult_ClosingSignedDecodeErrorZ { - contents: CResult_ClosingSignedDecodeErrorZPtr { +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFulfillHTLC) -> CResult_UpdateFulfillHTLCDecodeErrorZ { + CResult_UpdateFulfillHTLCDecodeErrorZ { + contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ClosingSignedDecodeErrorZ { - CResult_ClosingSignedDecodeErrorZ { - contents: CResult_ClosingSignedDecodeErrorZPtr { +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFulfillHTLCDecodeErrorZ { + CResult_UpdateFulfillHTLCDecodeErrorZ { + contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_free(_res: CResult_ClosingSignedDecodeErrorZ) { } -impl Drop for CResult_ClosingSignedDecodeErrorZ { +/// Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res: CResult_UpdateFulfillHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6474,16 +6388,16 @@ impl Drop for CResult_ClosingSignedDecodeErrorZ { } } } -impl From> for CResult_ClosingSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateFulfillHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ClosingSignedDecodeErrorZPtr { result } + CResult_UpdateFulfillHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ClosingSignedDecodeErrorZPtr { err } + CResult_UpdateFulfillHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -6491,68 +6405,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClosingSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ClosingSignedDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_CommitmentSignedDecodeErrorZ -pub union CResult_CommitmentSignedDecodeErrorZPtr { +/// The contents of CResult_UpdateAddHTLCDecodeErrorZ +pub union CResult_UpdateAddHTLCDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::CommitmentSigned, + pub result: *mut crate::lightning::ln::msgs::UpdateAddHTLC, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::CommitmentSigned on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CommitmentSignedDecodeErrorZ { - /// The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either +pub struct CResult_UpdateAddHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CommitmentSignedDecodeErrorZPtr, - /// Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + pub contents: CResult_UpdateAddHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_ok(o: crate::ln::msgs::CommitmentSigned) -> CResult_CommitmentSignedDecodeErrorZ { - CResult_CommitmentSignedDecodeErrorZ { - contents: CResult_CommitmentSignedDecodeErrorZPtr { +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateAddHTLC) -> CResult_UpdateAddHTLCDecodeErrorZ { + CResult_UpdateAddHTLCDecodeErrorZ { + contents: CResult_UpdateAddHTLCDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_CommitmentSignedDecodeErrorZ { - CResult_CommitmentSignedDecodeErrorZ { - contents: CResult_CommitmentSignedDecodeErrorZPtr { +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateAddHTLCDecodeErrorZ { + CResult_UpdateAddHTLCDecodeErrorZ { + contents: CResult_UpdateAddHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_free(_res: CResult_CommitmentSignedDecodeErrorZ) { } -impl Drop for CResult_CommitmentSignedDecodeErrorZ { +/// Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_free(_res: CResult_UpdateAddHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6565,16 +6479,16 @@ impl Drop for CResult_CommitmentSignedDecodeErrorZ { } } } -impl From> for CResult_CommitmentSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateAddHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_CommitmentSignedDecodeErrorZPtr { result } + CResult_UpdateAddHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_CommitmentSignedDecodeErrorZPtr { err } + CResult_UpdateAddHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -6582,68 +6496,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CommitmentSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CommitmentSignedDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_FundingCreatedDecodeErrorZ -pub union CResult_FundingCreatedDecodeErrorZPtr { +/// The contents of CResult_PingDecodeErrorZ +pub union CResult_PingDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::FundingCreated, + pub result: *mut crate::lightning::ln::msgs::Ping, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::FundingCreated on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_PingDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingCreatedDecodeErrorZ { - /// The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either +pub struct CResult_PingDecodeErrorZ { + /// The contents of this CResult_PingDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingCreatedDecodeErrorZPtr, - /// Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + pub contents: CResult_PingDecodeErrorZPtr, + /// Whether this CResult_PingDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_ok(o: crate::ln::msgs::FundingCreated) -> CResult_FundingCreatedDecodeErrorZ { - CResult_FundingCreatedDecodeErrorZ { - contents: CResult_FundingCreatedDecodeErrorZPtr { +/// Creates a new CResult_PingDecodeErrorZ in the success state. +pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Ping) -> CResult_PingDecodeErrorZ { + CResult_PingDecodeErrorZ { + contents: CResult_PingDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_FundingCreatedDecodeErrorZ { - CResult_FundingCreatedDecodeErrorZ { - contents: CResult_FundingCreatedDecodeErrorZPtr { +/// Creates a new CResult_PingDecodeErrorZ in the error state. +pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ { + CResult_PingDecodeErrorZ { + contents: CResult_PingDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_free(_res: CResult_FundingCreatedDecodeErrorZ) { } -impl Drop for CResult_FundingCreatedDecodeErrorZ { +/// Frees any resources used by the CResult_PingDecodeErrorZ. +pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { } +impl Drop for CResult_PingDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6656,16 +6570,16 @@ impl Drop for CResult_FundingCreatedDecodeErrorZ { } } } -impl From> for CResult_FundingCreatedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PingDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_FundingCreatedDecodeErrorZPtr { result } + CResult_PingDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_FundingCreatedDecodeErrorZPtr { err } + CResult_PingDecodeErrorZPtr { err } }; Self { contents, @@ -6673,68 +6587,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingCreatedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingCreatedDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_FundingSignedDecodeErrorZ -pub union CResult_FundingSignedDecodeErrorZPtr { +/// The contents of CResult_PongDecodeErrorZ +pub union CResult_PongDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::FundingSigned, + pub result: *mut crate::lightning::ln::msgs::Pong, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::FundingSigned on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_PongDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingSignedDecodeErrorZ { - /// The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either +pub struct CResult_PongDecodeErrorZ { + /// The contents of this CResult_PongDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingSignedDecodeErrorZPtr, - /// Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + pub contents: CResult_PongDecodeErrorZPtr, + /// Whether this CResult_PongDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_ok(o: crate::ln::msgs::FundingSigned) -> CResult_FundingSignedDecodeErrorZ { - CResult_FundingSignedDecodeErrorZ { - contents: CResult_FundingSignedDecodeErrorZPtr { +/// Creates a new CResult_PongDecodeErrorZ in the success state. +pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Pong) -> CResult_PongDecodeErrorZ { + CResult_PongDecodeErrorZ { + contents: CResult_PongDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_FundingSignedDecodeErrorZ { - CResult_FundingSignedDecodeErrorZ { - contents: CResult_FundingSignedDecodeErrorZPtr { +/// Creates a new CResult_PongDecodeErrorZ in the error state. +pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ { + CResult_PongDecodeErrorZ { + contents: CResult_PongDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_FundingSignedDecodeErrorZ. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_free(_res: CResult_FundingSignedDecodeErrorZ) { } -impl Drop for CResult_FundingSignedDecodeErrorZ { +/// Frees any resources used by the CResult_PongDecodeErrorZ. +pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { } +impl Drop for CResult_PongDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6747,16 +6661,16 @@ impl Drop for CResult_FundingSignedDecodeErrorZ { } } } -impl From> for CResult_FundingSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PongDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_FundingSignedDecodeErrorZPtr { result } + CResult_PongDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_FundingSignedDecodeErrorZPtr { err } + CResult_PongDecodeErrorZPtr { err } }; Self { contents, @@ -6764,68 +6678,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingSignedDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_FundingLockedDecodeErrorZ -pub union CResult_FundingLockedDecodeErrorZPtr { +/// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ +pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::FundingLocked, + pub result: *mut crate::lightning::ln::msgs::UnsignedChannelAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingLockedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::FundingLocked on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingLockedDecodeErrorZ { - /// The contents of this CResult_FundingLockedDecodeErrorZ, accessible via either +pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ { + /// The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingLockedDecodeErrorZPtr, - /// Whether this CResult_FundingLockedDecodeErrorZ represents a success state. + pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr, + /// Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingLockedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingLockedDecodeErrorZ_ok(o: crate::ln::msgs::FundingLocked) -> CResult_FundingLockedDecodeErrorZ { - CResult_FundingLockedDecodeErrorZ { - contents: CResult_FundingLockedDecodeErrorZPtr { +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { + CResult_UnsignedChannelAnnouncementDecodeErrorZ { + contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingLockedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingLockedDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_FundingLockedDecodeErrorZ { - CResult_FundingLockedDecodeErrorZ { - contents: CResult_FundingLockedDecodeErrorZPtr { +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { + CResult_UnsignedChannelAnnouncementDecodeErrorZ { + contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_FundingLockedDecodeErrorZ. -pub extern "C" fn CResult_FundingLockedDecodeErrorZ_free(_res: CResult_FundingLockedDecodeErrorZ) { } -impl Drop for CResult_FundingLockedDecodeErrorZ { +/// Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { } +impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6838,16 +6752,16 @@ impl Drop for CResult_FundingLockedDecodeErrorZ { } } } -impl From> for CResult_FundingLockedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnsignedChannelAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_FundingLockedDecodeErrorZPtr { result } + CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_FundingLockedDecodeErrorZPtr { err } + CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -6855,68 +6769,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingLockedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingLockedDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingLockedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingLockedDecodeErrorZ_clone(orig: &CResult_FundingLockedDecodeErrorZ) -> CResult_FundingLockedDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_InitDecodeErrorZ -pub union CResult_InitDecodeErrorZPtr { +/// The contents of CResult_ChannelAnnouncementDecodeErrorZ +pub union CResult_ChannelAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::Init, + pub result: *mut crate::lightning::ln::msgs::ChannelAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InitDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::Init on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InitDecodeErrorZ { - /// The contents of this CResult_InitDecodeErrorZ, accessible via either +pub struct CResult_ChannelAnnouncementDecodeErrorZ { + /// The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InitDecodeErrorZPtr, - /// Whether this CResult_InitDecodeErrorZ represents a success state. + pub contents: CResult_ChannelAnnouncementDecodeErrorZPtr, + /// Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::ln::msgs::Init) -> CResult_InitDecodeErrorZ { - CResult_InitDecodeErrorZ { - contents: CResult_InitDecodeErrorZPtr { +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelAnnouncement) -> CResult_ChannelAnnouncementDecodeErrorZ { + CResult_ChannelAnnouncementDecodeErrorZ { + contents: CResult_ChannelAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ { - CResult_InitDecodeErrorZ { - contents: CResult_InitDecodeErrorZPtr { +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelAnnouncementDecodeErrorZ { + CResult_ChannelAnnouncementDecodeErrorZ { + contents: CResult_ChannelAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_InitDecodeErrorZ. -pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { } -impl Drop for CResult_InitDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_free(_res: CResult_ChannelAnnouncementDecodeErrorZ) { } +impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6929,16 +6843,16 @@ impl Drop for CResult_InitDecodeErrorZ { } } } -impl From> for CResult_InitDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_InitDecodeErrorZPtr { result } + CResult_ChannelAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_InitDecodeErrorZPtr { err } + CResult_ChannelAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -6946,68 +6860,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_OpenChannelDecodeErrorZ -pub union CResult_OpenChannelDecodeErrorZPtr { +/// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ +pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::OpenChannel, + pub result: *mut crate::lightning::ln::msgs::UnsignedChannelUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::OpenChannel on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OpenChannelDecodeErrorZ { - /// The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either +pub struct CResult_UnsignedChannelUpdateDecodeErrorZ { + /// The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OpenChannelDecodeErrorZPtr, - /// Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr, + /// Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ in the success state. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_ok(o: crate::ln::msgs::OpenChannel) -> CResult_OpenChannelDecodeErrorZ { - CResult_OpenChannelDecodeErrorZ { - contents: CResult_OpenChannelDecodeErrorZPtr { +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ { + CResult_UnsignedChannelUpdateDecodeErrorZ { + contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ in the error state. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_OpenChannelDecodeErrorZ { - CResult_OpenChannelDecodeErrorZ { - contents: CResult_OpenChannelDecodeErrorZPtr { +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ { + CResult_UnsignedChannelUpdateDecodeErrorZ { + contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_OpenChannelDecodeErrorZ. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_free(_res: CResult_OpenChannelDecodeErrorZ) { } -impl Drop for CResult_OpenChannelDecodeErrorZ { +/// Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { } +impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7020,16 +6934,16 @@ impl Drop for CResult_OpenChannelDecodeErrorZ { } } } -impl From> for CResult_OpenChannelDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnsignedChannelUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_OpenChannelDecodeErrorZPtr { result } + CResult_UnsignedChannelUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_OpenChannelDecodeErrorZPtr { err } + CResult_UnsignedChannelUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -7037,68 +6951,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OpenChannelDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OpenChannelDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_RevokeAndACKDecodeErrorZ -pub union CResult_RevokeAndACKDecodeErrorZPtr { +/// The contents of CResult_ChannelUpdateDecodeErrorZ +pub union CResult_ChannelUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::RevokeAndACK, + pub result: *mut crate::lightning::ln::msgs::ChannelUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::RevokeAndACK on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RevokeAndACKDecodeErrorZ { - /// The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either +pub struct CResult_ChannelUpdateDecodeErrorZ { + /// The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RevokeAndACKDecodeErrorZPtr, - /// Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + pub contents: CResult_ChannelUpdateDecodeErrorZPtr, + /// Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_ok(o: crate::ln::msgs::RevokeAndACK) -> CResult_RevokeAndACKDecodeErrorZ { - CResult_RevokeAndACKDecodeErrorZ { - contents: CResult_RevokeAndACKDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelUpdate) -> CResult_ChannelUpdateDecodeErrorZ { + CResult_ChannelUpdateDecodeErrorZ { + contents: CResult_ChannelUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_RevokeAndACKDecodeErrorZ { - CResult_RevokeAndACKDecodeErrorZ { - contents: CResult_RevokeAndACKDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateDecodeErrorZ { + CResult_ChannelUpdateDecodeErrorZ { + contents: CResult_ChannelUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_free(_res: CResult_RevokeAndACKDecodeErrorZ) { } -impl Drop for CResult_RevokeAndACKDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_free(_res: CResult_ChannelUpdateDecodeErrorZ) { } +impl Drop for CResult_ChannelUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7111,16 +7025,16 @@ impl Drop for CResult_RevokeAndACKDecodeErrorZ { } } } -impl From> for CResult_RevokeAndACKDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_RevokeAndACKDecodeErrorZPtr { result } + CResult_ChannelUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_RevokeAndACKDecodeErrorZPtr { err } + CResult_ChannelUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -7128,68 +7042,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RevokeAndACKDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RevokeAndACKDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_ShutdownDecodeErrorZ -pub union CResult_ShutdownDecodeErrorZPtr { +/// The contents of CResult_ErrorMessageDecodeErrorZ +pub union CResult_ErrorMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::Shutdown, + pub result: *mut crate::lightning::ln::msgs::ErrorMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::Shutdown on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownDecodeErrorZ { - /// The contents of this CResult_ShutdownDecodeErrorZ, accessible via either +pub struct CResult_ErrorMessageDecodeErrorZ { + /// The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownDecodeErrorZPtr, - /// Whether this CResult_ShutdownDecodeErrorZ represents a success state. + pub contents: CResult_ErrorMessageDecodeErrorZPtr, + /// Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ in the success state. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_ok(o: crate::ln::msgs::Shutdown) -> CResult_ShutdownDecodeErrorZ { - CResult_ShutdownDecodeErrorZ { - contents: CResult_ShutdownDecodeErrorZPtr { +/// Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ { + CResult_ErrorMessageDecodeErrorZ { + contents: CResult_ErrorMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ in the error state. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ShutdownDecodeErrorZ { - CResult_ShutdownDecodeErrorZ { - contents: CResult_ShutdownDecodeErrorZPtr { +/// Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ { + CResult_ErrorMessageDecodeErrorZ { + contents: CResult_ErrorMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownDecodeErrorZ. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_free(_res: CResult_ShutdownDecodeErrorZ) { } -impl Drop for CResult_ShutdownDecodeErrorZ { +/// Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { } +impl Drop for CResult_ErrorMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7202,16 +7116,16 @@ impl Drop for CResult_ShutdownDecodeErrorZ { } } } -impl From> for CResult_ShutdownDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ErrorMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ShutdownDecodeErrorZPtr { result } + CResult_ErrorMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ShutdownDecodeErrorZPtr { err } + CResult_ErrorMessageDecodeErrorZPtr { err } }; Self { contents, @@ -7219,68 +7133,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_UpdateFailHTLCDecodeErrorZ -pub union CResult_UpdateFailHTLCDecodeErrorZPtr { +/// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ +pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::UpdateFailHTLC, + pub result: *mut crate::lightning::ln::msgs::UnsignedNodeAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::UpdateFailHTLC on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFailHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either +pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ { + /// The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFailHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr, + /// Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_ok(o: crate::ln::msgs::UpdateFailHTLC) -> CResult_UpdateFailHTLCDecodeErrorZ { - CResult_UpdateFailHTLCDecodeErrorZ { - contents: CResult_UpdateFailHTLCDecodeErrorZPtr { +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { + CResult_UnsignedNodeAnnouncementDecodeErrorZ { + contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UpdateFailHTLCDecodeErrorZ { - CResult_UpdateFailHTLCDecodeErrorZ { - contents: CResult_UpdateFailHTLCDecodeErrorZPtr { +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { + CResult_UnsignedNodeAnnouncementDecodeErrorZ { + contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_free(_res: CResult_UpdateFailHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { } +impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7293,16 +7207,16 @@ impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFailHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnsignedNodeAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_UpdateFailHTLCDecodeErrorZPtr { result } + CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_UpdateFailHTLCDecodeErrorZPtr { err } + CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -7310,68 +7224,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ -pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// The contents of CResult_NodeAnnouncementDecodeErrorZ +pub union CResult_NodeAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::UpdateFailMalformedHTLC, + pub result: *mut crate::lightning::ln::msgs::NodeAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::UpdateFailMalformedHTLC on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFailMalformedHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either +pub struct CResult_NodeAnnouncementDecodeErrorZ { + /// The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + pub contents: CResult_NodeAnnouncementDecodeErrorZPtr, + /// Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o: crate::ln::msgs::UpdateFailMalformedHTLC) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { - CResult_UpdateFailMalformedHTLCDecodeErrorZ { - contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NodeAnnouncement) -> CResult_NodeAnnouncementDecodeErrorZ { + CResult_NodeAnnouncementDecodeErrorZ { + contents: CResult_NodeAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { - CResult_UpdateFailMalformedHTLCDecodeErrorZ { - contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementDecodeErrorZ { + CResult_NodeAnnouncementDecodeErrorZ { + contents: CResult_NodeAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res: CResult_UpdateFailMalformedHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_free(_res: CResult_NodeAnnouncementDecodeErrorZ) { } +impl Drop for CResult_NodeAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7384,16 +7298,16 @@ impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFailMalformedHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NodeAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result } + CResult_NodeAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err } + CResult_NodeAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -7401,68 +7315,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NodeAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_UpdateFeeDecodeErrorZ -pub union CResult_UpdateFeeDecodeErrorZPtr { +/// The contents of CResult_QueryShortChannelIdsDecodeErrorZ +pub union CResult_QueryShortChannelIdsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::UpdateFee, + pub result: *mut crate::lightning::ln::msgs::QueryShortChannelIds, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::UpdateFee on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFeeDecodeErrorZ { - /// The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either +pub struct CResult_QueryShortChannelIdsDecodeErrorZ { + /// The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFeeDecodeErrorZPtr, - /// Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr, + /// Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_ok(o: crate::ln::msgs::UpdateFee) -> CResult_UpdateFeeDecodeErrorZ { - CResult_UpdateFeeDecodeErrorZ { - contents: CResult_UpdateFeeDecodeErrorZPtr { +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ { + CResult_QueryShortChannelIdsDecodeErrorZ { + contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UpdateFeeDecodeErrorZ { - CResult_UpdateFeeDecodeErrorZ { - contents: CResult_UpdateFeeDecodeErrorZPtr { +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ { + CResult_QueryShortChannelIdsDecodeErrorZ { + contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_free(_res: CResult_UpdateFeeDecodeErrorZ) { } -impl Drop for CResult_UpdateFeeDecodeErrorZ { +/// Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { } +impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7475,16 +7389,16 @@ impl Drop for CResult_UpdateFeeDecodeErrorZ { } } } -impl From> for CResult_UpdateFeeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_QueryShortChannelIdsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_UpdateFeeDecodeErrorZPtr { result } + CResult_QueryShortChannelIdsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_UpdateFeeDecodeErrorZPtr { err } + CResult_QueryShortChannelIdsDecodeErrorZPtr { err } }; Self { contents, @@ -7492,68 +7406,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFeeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFeeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ -pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ +pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::UpdateFulfillHTLC, + pub result: *mut crate::lightning::ln::msgs::ReplyShortChannelIdsEnd, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::UpdateFulfillHTLC on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFulfillHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either +pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ { + /// The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr, + /// Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o: crate::ln::msgs::UpdateFulfillHTLC) -> CResult_UpdateFulfillHTLCDecodeErrorZ { - CResult_UpdateFulfillHTLCDecodeErrorZ { - contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { + CResult_ReplyShortChannelIdsEndDecodeErrorZ { + contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UpdateFulfillHTLCDecodeErrorZ { - CResult_UpdateFulfillHTLCDecodeErrorZ { - contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { + CResult_ReplyShortChannelIdsEndDecodeErrorZ { + contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res: CResult_UpdateFulfillHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { } +impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7566,16 +7480,16 @@ impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFulfillHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ReplyShortChannelIdsEndDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_UpdateFulfillHTLCDecodeErrorZPtr { result } + CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_UpdateFulfillHTLCDecodeErrorZPtr { err } + CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err } }; Self { contents, @@ -7583,68 +7497,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_UpdateAddHTLCDecodeErrorZ -pub union CResult_UpdateAddHTLCDecodeErrorZPtr { +/// The contents of CResult_QueryChannelRangeDecodeErrorZ +pub union CResult_QueryChannelRangeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::UpdateAddHTLC, + pub result: *mut crate::lightning::ln::msgs::QueryChannelRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::UpdateAddHTLC on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateAddHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either +pub struct CResult_QueryChannelRangeDecodeErrorZ { + /// The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateAddHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + pub contents: CResult_QueryChannelRangeDecodeErrorZPtr, + /// Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_ok(o: crate::ln::msgs::UpdateAddHTLC) -> CResult_UpdateAddHTLCDecodeErrorZ { - CResult_UpdateAddHTLCDecodeErrorZ { - contents: CResult_UpdateAddHTLCDecodeErrorZPtr { +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ { + CResult_QueryChannelRangeDecodeErrorZ { + contents: CResult_QueryChannelRangeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UpdateAddHTLCDecodeErrorZ { - CResult_UpdateAddHTLCDecodeErrorZ { - contents: CResult_UpdateAddHTLCDecodeErrorZPtr { +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ { + CResult_QueryChannelRangeDecodeErrorZ { + contents: CResult_QueryChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_free(_res: CResult_UpdateAddHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { } +impl Drop for CResult_QueryChannelRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7657,16 +7571,16 @@ impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateAddHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_QueryChannelRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_UpdateAddHTLCDecodeErrorZPtr { result } + CResult_QueryChannelRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_UpdateAddHTLCDecodeErrorZPtr { err } + CResult_QueryChannelRangeDecodeErrorZPtr { err } }; Self { contents, @@ -7674,68 +7588,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_PingDecodeErrorZ -pub union CResult_PingDecodeErrorZPtr { +/// The contents of CResult_ReplyChannelRangeDecodeErrorZ +pub union CResult_ReplyChannelRangeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::Ping, + pub result: *mut crate::lightning::ln::msgs::ReplyChannelRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PingDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::Ping on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PingDecodeErrorZ { - /// The contents of this CResult_PingDecodeErrorZ, accessible via either +pub struct CResult_ReplyChannelRangeDecodeErrorZ { + /// The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PingDecodeErrorZPtr, - /// Whether this CResult_PingDecodeErrorZ represents a success state. + pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr, + /// Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ in the success state. -pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::ln::msgs::Ping) -> CResult_PingDecodeErrorZ { - CResult_PingDecodeErrorZ { - contents: CResult_PingDecodeErrorZPtr { +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ { + CResult_ReplyChannelRangeDecodeErrorZ { + contents: CResult_ReplyChannelRangeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ in the error state. -pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ { - CResult_PingDecodeErrorZ { - contents: CResult_PingDecodeErrorZPtr { +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ { + CResult_ReplyChannelRangeDecodeErrorZ { + contents: CResult_ReplyChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_PingDecodeErrorZ. -pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { } -impl Drop for CResult_PingDecodeErrorZ { +/// Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { } +impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7748,16 +7662,16 @@ impl Drop for CResult_PingDecodeErrorZ { } } } -impl From> for CResult_PingDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ReplyChannelRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_PingDecodeErrorZPtr { result } + CResult_ReplyChannelRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_PingDecodeErrorZPtr { err } + CResult_ReplyChannelRangeDecodeErrorZPtr { err } }; Self { contents, @@ -7765,68 +7679,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_PongDecodeErrorZ -pub union CResult_PongDecodeErrorZPtr { +/// The contents of CResult_GossipTimestampFilterDecodeErrorZ +pub union CResult_GossipTimestampFilterDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::Pong, + pub result: *mut crate::lightning::ln::msgs::GossipTimestampFilter, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PongDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::Pong on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PongDecodeErrorZ { - /// The contents of this CResult_PongDecodeErrorZ, accessible via either +pub struct CResult_GossipTimestampFilterDecodeErrorZ { + /// The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PongDecodeErrorZPtr, - /// Whether this CResult_PongDecodeErrorZ represents a success state. + pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr, + /// Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ in the success state. -pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::ln::msgs::Pong) -> CResult_PongDecodeErrorZ { - CResult_PongDecodeErrorZ { - contents: CResult_PongDecodeErrorZPtr { +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::lightning::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ { + CResult_GossipTimestampFilterDecodeErrorZ { + contents: CResult_GossipTimestampFilterDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ in the error state. -pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ { - CResult_PongDecodeErrorZ { - contents: CResult_PongDecodeErrorZPtr { +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ { + CResult_GossipTimestampFilterDecodeErrorZ { + contents: CResult_GossipTimestampFilterDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_PongDecodeErrorZ. -pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { } -impl Drop for CResult_PongDecodeErrorZ { +/// Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { } +impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7839,16 +7753,16 @@ impl Drop for CResult_PongDecodeErrorZ { } } } -impl From> for CResult_PongDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_GossipTimestampFilterDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_PongDecodeErrorZPtr { result } + CResult_GossipTimestampFilterDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_PongDecodeErrorZPtr { err } + CResult_GossipTimestampFilterDecodeErrorZPtr { err } }; Self { contents, @@ -7856,68 +7770,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ -pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// The contents of CResult_SpendableOutputDescriptorDecodeErrorZ +pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::UnsignedChannelAnnouncement, + pub result: *mut crate::lightning::chain::keysinterface::SpendableOutputDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::UnsignedChannelAnnouncement on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ { - /// The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_SpendableOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr, - /// Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { - CResult_UnsignedChannelAnnouncementDecodeErrorZ { - contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ { + CResult_SpendableOutputDescriptorDecodeErrorZ { + contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { - CResult_UnsignedChannelAnnouncementDecodeErrorZ { - contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ { + CResult_SpendableOutputDescriptorDecodeErrorZ { + contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { } -impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7930,16 +7844,16 @@ impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { } } } -impl From> for CResult_UnsignedChannelAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SpendableOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result } + CResult_SpendableOutputDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err } + CResult_SpendableOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -7947,90 +7861,128 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_ChannelAnnouncementDecodeErrorZ -pub union CResult_ChannelAnnouncementDecodeErrorZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_SignatureCVec_SignatureZZ { + /// The element at position 0 + pub a: crate::c_types::Signature, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_SignatureZ, +} +impl From<(crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)> for C2Tuple_SignatureCVec_SignatureZZ { + fn from (tup: (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_SignatureCVec_SignatureZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_SignatureCVec_SignatureZZ { + fn clone(&self) -> Self { + Self { + a: self.a.clone(), + b: self.b.clone(), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { orig.clone() } +/// Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. +#[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, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. +pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_free(_res: C2Tuple_SignatureCVec_SignatureZZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ +pub union CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::ChannelAnnouncement, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut std::ffi::c_void, } #[repr(C)] -/// A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::ChannelAnnouncement on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelAnnouncementDecodeErrorZ { - /// The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + /// The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelAnnouncementDecodeErrorZPtr, - /// Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr, + /// Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_ok(o: crate::ln::msgs::ChannelAnnouncement) -> CResult_ChannelAnnouncementDecodeErrorZ { - CResult_ChannelAnnouncementDecodeErrorZ { - contents: CResult_ChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelAnnouncementDecodeErrorZ { - CResult_ChannelAnnouncementDecodeErrorZ { - contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + err: std::ptr::null_mut(), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_free(_res: CResult_ChannelAnnouncementDecodeErrorZ) { } -impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) { } +impl Drop for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ChannelAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ChannelAnnouncementDecodeErrorZPtr { result } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelAnnouncementDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = std::ptr::null_mut(); + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: std::ptr::null_mut() } }; Self { contents, @@ -8038,90 +7990,86 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + err: std::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { orig.clone() } #[repr(C)] -/// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ -pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// The contents of CResult_SignatureNoneZ +pub union CResult_SignatureNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::UnsignedChannelUpdate, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub result: *mut crate::c_types::Signature, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut std::ffi::c_void, } #[repr(C)] -/// A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::UnsignedChannelUpdate on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_SignatureNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::Signature on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedChannelUpdateDecodeErrorZ { - /// The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either +pub struct CResult_SignatureNoneZ { + /// The contents of this CResult_SignatureNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr, - /// Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + pub contents: CResult_SignatureNoneZPtr, + /// Whether this CResult_SignatureNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ { - CResult_UnsignedChannelUpdateDecodeErrorZ { - contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_SignatureNoneZ in the success state. +pub extern "C" fn CResult_SignatureNoneZ_ok(o: crate::c_types::Signature) -> CResult_SignatureNoneZ { + CResult_SignatureNoneZ { + contents: CResult_SignatureNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ { - CResult_UnsignedChannelUpdateDecodeErrorZ { - contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_SignatureNoneZ in the error state. +pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ { + CResult_SignatureNoneZ { + contents: CResult_SignatureNoneZPtr { + err: std::ptr::null_mut(), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { } -impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_SignatureNoneZ. +pub extern "C" fn CResult_SignatureNoneZ_free(_res: CResult_SignatureNoneZ) { } +impl Drop for CResult_SignatureNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_UnsignedChannelUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignatureNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_UnsignedChannelUpdateDecodeErrorZPtr { result } + CResult_SignatureNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_UnsignedChannelUpdateDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = std::ptr::null_mut(); + CResult_SignatureNoneZPtr { err: std::ptr::null_mut() } }; Self { contents, @@ -8129,68 +8077,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SignatureNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SignatureNoneZPtr { + err: std::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SignatureNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { orig.clone() } #[repr(C)] -/// The contents of CResult_ChannelUpdateDecodeErrorZ -pub union CResult_ChannelUpdateDecodeErrorZPtr { +/// The contents of CResult_SignDecodeErrorZ +pub union CResult_SignDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::ChannelUpdate, + pub result: *mut crate::lightning::chain::keysinterface::Sign, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::ChannelUpdate on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_SignDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelUpdateDecodeErrorZ { - /// The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either +pub struct CResult_SignDecodeErrorZ { + /// The contents of this CResult_SignDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelUpdateDecodeErrorZPtr, - /// Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. + pub contents: CResult_SignDecodeErrorZPtr, + /// Whether this CResult_SignDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_ok(o: crate::ln::msgs::ChannelUpdate) -> CResult_ChannelUpdateDecodeErrorZ { - CResult_ChannelUpdateDecodeErrorZ { - contents: CResult_ChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_SignDecodeErrorZ in the success state. +pub extern "C" fn CResult_SignDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::Sign) -> CResult_SignDecodeErrorZ { + CResult_SignDecodeErrorZ { + contents: CResult_SignDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelUpdateDecodeErrorZ { - CResult_ChannelUpdateDecodeErrorZ { - contents: CResult_ChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_SignDecodeErrorZ in the error state. +pub extern "C" fn CResult_SignDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SignDecodeErrorZ { + CResult_SignDecodeErrorZ { + contents: CResult_SignDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_free(_res: CResult_ChannelUpdateDecodeErrorZ) { } -impl Drop for CResult_ChannelUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_SignDecodeErrorZ. +pub extern "C" fn CResult_SignDecodeErrorZ_free(_res: CResult_SignDecodeErrorZ) { } +impl Drop for CResult_SignDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8203,16 +8151,16 @@ impl Drop for CResult_ChannelUpdateDecodeErrorZ { } } } -impl From> for CResult_ChannelUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ChannelUpdateDecodeErrorZPtr { result } + CResult_SignDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelUpdateDecodeErrorZPtr { err } + CResult_SignDecodeErrorZPtr { err } }; Self { contents, @@ -8220,90 +8168,132 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SignDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SignDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SignDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_SignDecodeErrorZ_clone(orig: &CResult_SignDecodeErrorZ) -> CResult_SignDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_ErrorMessageDecodeErrorZ -pub union CResult_ErrorMessageDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_CVec_u8ZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::CVec_u8Z, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_CVec_u8ZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_u8Z] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_CVec_u8ZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_CVec_u8ZZ_free(_res: CVec_CVec_u8ZZ) { } +impl Drop for CVec_CVec_u8ZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_CVec_u8ZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CVec_CVec_u8ZZNoneZ +pub union CResult_CVec_CVec_u8ZZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::ErrorMessage, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_CVec_u8ZZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut std::ffi::c_void, } #[repr(C)] -/// A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::ErrorMessage on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ErrorMessageDecodeErrorZ { - /// The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either +pub struct CResult_CVec_CVec_u8ZZNoneZ { + /// The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ErrorMessageDecodeErrorZPtr, - /// Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + pub contents: CResult_CVec_CVec_u8ZZNoneZPtr, + /// Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ { - CResult_ErrorMessageDecodeErrorZ { - contents: CResult_ErrorMessageDecodeErrorZPtr { +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_ok(o: crate::c_types::derived::CVec_CVec_u8ZZ) -> CResult_CVec_CVec_u8ZZNoneZ { + CResult_CVec_CVec_u8ZZNoneZ { + contents: CResult_CVec_CVec_u8ZZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ { - CResult_ErrorMessageDecodeErrorZ { - contents: CResult_ErrorMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNoneZ { + CResult_CVec_CVec_u8ZZNoneZ { + contents: CResult_CVec_CVec_u8ZZNoneZPtr { + err: std::ptr::null_mut(), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { } -impl Drop for CResult_ErrorMessageDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_free(_res: CResult_CVec_CVec_u8ZZNoneZ) { } +impl Drop for CResult_CVec_CVec_u8ZZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ErrorMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_CVec_u8ZZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ErrorMessageDecodeErrorZPtr { result } + CResult_CVec_CVec_u8ZZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ErrorMessageDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = std::ptr::null_mut(); + CResult_CVec_CVec_u8ZZNoneZPtr { err: std::ptr::null_mut() } }; Self { contents, @@ -8311,68 +8301,68 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_CVec_u8ZZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_CVec_u8ZZNoneZPtr { + err: std::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { orig.clone() } #[repr(C)] -/// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ -pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// The contents of CResult_InMemorySignerDecodeErrorZ +pub union CResult_InMemorySignerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::UnsignedNodeAnnouncement, + pub result: *mut crate::lightning::chain::keysinterface::InMemorySigner, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::UnsignedNodeAnnouncement on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ { - /// The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_InMemorySignerDecodeErrorZ { + /// The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr, - /// Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_InMemorySignerDecodeErrorZPtr, + /// Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { - CResult_UnsignedNodeAnnouncementDecodeErrorZ { - contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { - CResult_UnsignedNodeAnnouncementDecodeErrorZ { - contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { } -impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } +impl Drop for CResult_InMemorySignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8385,16 +8375,16 @@ impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { } } } -impl From> for CResult_UnsignedNodeAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InMemorySignerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result } + CResult_InMemorySignerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err } + CResult_InMemorySignerDecodeErrorZPtr { err } }; Self { contents, @@ -8402,90 +8392,132 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { orig.clone() } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TxOutZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::TxOut, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TxOutZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TxOutZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { } +impl Drop for CVec_TxOutZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_TxOutZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_NodeAnnouncementDecodeErrorZ -pub union CResult_NodeAnnouncementDecodeErrorZPtr { +/// The contents of CResult_TransactionNoneZ +pub union CResult_TransactionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::NodeAnnouncement, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub result: *mut crate::c_types::Transaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut std::ffi::c_void, } #[repr(C)] -/// A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::NodeAnnouncement on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_TransactionNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::Transaction on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeAnnouncementDecodeErrorZ { - /// The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_TransactionNoneZ { + /// The contents of this CResult_TransactionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeAnnouncementDecodeErrorZPtr, - /// Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_TransactionNoneZPtr, + /// Whether this CResult_TransactionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_ok(o: crate::ln::msgs::NodeAnnouncement) -> CResult_NodeAnnouncementDecodeErrorZ { - CResult_NodeAnnouncementDecodeErrorZ { - contents: CResult_NodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_TransactionNoneZ in the success state. +pub extern "C" fn CResult_TransactionNoneZ_ok(o: crate::c_types::Transaction) -> CResult_TransactionNoneZ { + CResult_TransactionNoneZ { + contents: CResult_TransactionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_NodeAnnouncementDecodeErrorZ { - CResult_NodeAnnouncementDecodeErrorZ { - contents: CResult_NodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TransactionNoneZ in the error state. +pub extern "C" fn CResult_TransactionNoneZ_err() -> CResult_TransactionNoneZ { + CResult_TransactionNoneZ { + contents: CResult_TransactionNoneZPtr { + err: std::ptr::null_mut(), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_free(_res: CResult_NodeAnnouncementDecodeErrorZ) { } -impl Drop for CResult_NodeAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_TransactionNoneZ. +pub extern "C" fn CResult_TransactionNoneZ_free(_res: CResult_TransactionNoneZ) { } +impl Drop for CResult_TransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_NodeAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_NodeAnnouncementDecodeErrorZPtr { result } + CResult_TransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_NodeAnnouncementDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = std::ptr::null_mut(); + CResult_TransactionNoneZPtr { err: std::ptr::null_mut() } }; Self { contents, @@ -8493,73 +8525,52 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NodeAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_NodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_QueryShortChannelIdsDecodeErrorZ -pub union CResult_QueryShortChannelIdsDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::QueryShortChannelIds, +/// The contents of CResult_NoneAPIErrorZ +pub union CResult_NoneAPIErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut std::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::util::errors::APIError, } #[repr(C)] -/// A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::QueryShortChannelIds on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_NoneAPIErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::util::errors::APIError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_QueryShortChannelIdsDecodeErrorZ { - /// The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either +pub struct CResult_NoneAPIErrorZ { + /// The contents of this CResult_NoneAPIErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr, - /// Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. + pub contents: CResult_NoneAPIErrorZPtr, + /// Whether this CResult_NoneAPIErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ { - CResult_QueryShortChannelIdsDecodeErrorZ { - contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneAPIErrorZ in the success state. +pub extern "C" fn CResult_NoneAPIErrorZ_ok() -> CResult_NoneAPIErrorZ { + CResult_NoneAPIErrorZ { + contents: CResult_NoneAPIErrorZPtr { + result: std::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ { - CResult_QueryShortChannelIdsDecodeErrorZ { - contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { +/// Creates a new CResult_NoneAPIErrorZ in the error state. +pub extern "C" fn CResult_NoneAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_NoneAPIErrorZ { + CResult_NoneAPIErrorZ { + contents: CResult_NoneAPIErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { } -impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { +/// Frees any resources used by the CResult_NoneAPIErrorZ. +pub extern "C" fn CResult_NoneAPIErrorZ_free(_res: CResult_NoneAPIErrorZ) { } +impl Drop for CResult_NoneAPIErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -8567,16 +8578,16 @@ impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { } } } -impl From> for CResult_QueryShortChannelIdsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneAPIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_QueryShortChannelIdsDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = std::ptr::null_mut(); + CResult_NoneAPIErrorZPtr { result: std::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_QueryShortChannelIdsDecodeErrorZPtr { err } + CResult_NoneAPIErrorZPtr { err } }; Self { contents, @@ -8584,164 +8595,161 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneAPIErrorZPtr { + result: std::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneAPIErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { orig.clone() } -#[repr(C)] -/// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ -pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::ReplyShortChannelIdsEnd, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_NoneAPIErrorZ_clone(orig: &CResult_NoneAPIErrorZ) -> CResult_NoneAPIErrorZ { orig.clone() } #[repr(C)] -/// A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ { - /// The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr, - /// Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_CResult_NoneAPIErrorZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::CResult_NoneAPIErrorZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { - CResult_ReplyShortChannelIdsEndDecodeErrorZ { - contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_CResult_NoneAPIErrorZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CResult_NoneAPIErrorZ] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { - CResult_ReplyShortChannelIdsEndDecodeErrorZ { - contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl From> for CVec_CResult_NoneAPIErrorZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { } -impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_CResult_NoneAPIErrorZZ_free(_res: CVec_CResult_NoneAPIErrorZZ) { } +impl Drop for CVec_CResult_NoneAPIErrorZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_CResult_NoneAPIErrorZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_APIErrorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::util::errors::APIError, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_APIErrorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::errors::APIError] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_APIErrorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } -impl From> for CResult_ReplyShortChannelIdsEndDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_APIErrorZ_free(_res: CVec_APIErrorZ) { } +impl Drop for CVec_APIErrorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_ReplyShortChannelIdsEndDecodeErrorZ { +impl Clone for CVec_APIErrorZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { orig.clone() } #[repr(C)] -/// The contents of CResult_QueryChannelRangeDecodeErrorZ -pub union CResult_QueryChannelRangeDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::QueryChannelRange, +/// The contents of CResult_NonePaymentSendFailureZ +pub union CResult_NonePaymentSendFailureZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut std::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::channelmanager::PaymentSendFailure, } #[repr(C)] -/// A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::QueryChannelRange on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_QueryChannelRangeDecodeErrorZ { - /// The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either +pub struct CResult_NonePaymentSendFailureZ { + /// The contents of this CResult_NonePaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_QueryChannelRangeDecodeErrorZPtr, - /// Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. + pub contents: CResult_NonePaymentSendFailureZPtr, + /// Whether this CResult_NonePaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ { - CResult_QueryChannelRangeDecodeErrorZ { - contents: CResult_QueryChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NonePaymentSendFailureZ in the success state. +pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ { + CResult_NonePaymentSendFailureZ { + contents: CResult_NonePaymentSendFailureZPtr { + result: std::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ { - CResult_QueryChannelRangeDecodeErrorZ { - contents: CResult_QueryChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_NonePaymentSendFailureZ in the error state. +pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::channelmanager::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ { + CResult_NonePaymentSendFailureZ { + contents: CResult_NonePaymentSendFailureZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { } -impl Drop for CResult_QueryChannelRangeDecodeErrorZ { +/// Frees any resources used by the CResult_NonePaymentSendFailureZ. +pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { } +impl Drop for CResult_NonePaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -8749,16 +8757,16 @@ impl Drop for CResult_QueryChannelRangeDecodeErrorZ { } } } -impl From> for CResult_QueryChannelRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NonePaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_QueryChannelRangeDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = std::ptr::null_mut(); + CResult_NonePaymentSendFailureZPtr { result: std::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_QueryChannelRangeDecodeErrorZPtr { err } + CResult_NonePaymentSendFailureZPtr { err } }; Self { contents, @@ -8766,159 +8774,136 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr { + result: std::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { orig.clone() } -#[repr(C)] -/// The contents of CResult_ReplyChannelRangeDecodeErrorZ -pub union CResult_ReplyChannelRangeDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::ReplyChannelRange, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { orig.clone() } #[repr(C)] -/// A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::ReplyChannelRange on success and a crate::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ReplyChannelRangeDecodeErrorZ { - /// The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr, - /// Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChannelMonitorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::ChannelMonitor, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ { - CResult_ReplyChannelRangeDecodeErrorZ { - contents: CResult_ReplyChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_ChannelMonitorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::ChannelMonitor] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ { - CResult_ReplyChannelRangeDecodeErrorZ { - contents: CResult_ReplyChannelRangeDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl From> for CVec_ChannelMonitorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { } -impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { } +impl Drop for CVec_ChannelMonitorZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_ReplyChannelRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ReplyChannelRangeDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ReplyChannelRangeDecodeErrorZPtr { err } - }; +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_BlockHashChannelManagerZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::ln::channelmanager::ChannelManager, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)> for C2Tuple_BlockHashChannelManagerZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_ReplyChannelRangeDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } +impl C2Tuple_BlockHashChannelManagerZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager) { + (self.a, self.b) } } +/// Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { orig.clone() } +pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::channelmanager::ChannelManager) -> C2Tuple_BlockHashChannelManagerZ { + C2Tuple_BlockHashChannelManagerZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. +pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_free(_res: C2Tuple_BlockHashChannelManagerZ) { } #[repr(C)] -/// The contents of CResult_GossipTimestampFilterDecodeErrorZ -pub union CResult_GossipTimestampFilterDecodeErrorZPtr { +/// The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ +pub union CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::ln::msgs::GossipTimestampFilter, + pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::ln::msgs::GossipTimestampFilter on success and a crate::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_GossipTimestampFilterDecodeErrorZ { - /// The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr, - /// Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ { - CResult_GossipTimestampFilterDecodeErrorZ { - contents: CResult_GossipTimestampFilterDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ { - CResult_GossipTimestampFilterDecodeErrorZ { - contents: CResult_GossipTimestampFilterDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -/// Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { } -impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8931,16 +8916,16 @@ impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { } } } -impl From> for CResult_GossipTimestampFilterDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_GossipTimestampFilterDecodeErrorZPtr { result } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_GossipTimestampFilterDecodeErrorZPtr { err } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err } }; Self { contents, @@ -8948,20 +8933,3 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { orig.clone() } diff --git a/lightning-c-bindings/src/chain/chaininterface.rs b/lightning-c-bindings/src/chain/chaininterface.rs deleted file mode 100644 index f14123d..0000000 --- a/lightning-c-bindings/src/chain/chaininterface.rs +++ /dev/null @@ -1,169 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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::*; - -/// An interface to send a transaction to the Bitcoin network. -#[repr(C)] -pub struct BroadcasterInterface { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -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_vec(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); - } - } -} -/// 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, - } - } -} -/// Creates a copy of the ConfirmationTarget -#[no_mangle] -pub extern "C" fn ConfirmationTarget_clone(orig: &ConfirmationTarget) -> ConfirmationTarget { - orig.clone() -} -/// 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 chain events, P2P events, or timer events). -#[repr(C)] -pub struct FeeEstimator { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -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); - } - } -} -/// Minimum relay fee as required by bitcoin network mempool policy. - -#[no_mangle] -pub static MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = lightning::chain::chaininterface::MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; diff --git a/lightning-c-bindings/src/chain/chainmonitor.rs b/lightning-c-bindings/src/chain/chainmonitor.rs deleted file mode 100644 index 7848acc..0000000 --- a/lightning-c-bindings/src/chain/chainmonitor.rs +++ /dev/null @@ -1,250 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Logic to connect off-chain channel management with on-chain transaction monitoring. -//! -//! [`ChainMonitor`] is an implementation of [`chain::Watch`] used both to process blocks and to -//! update [`ChannelMonitor`]s accordingly. If any on-chain events need further processing, it will -//! make those available as [`MonitorEvent`]s to be consumed. -//! -//! [`ChainMonitor`] is parameterized by an optional chain source, which must implement the -//! [`chain::Filter`] trait. This provides a mechanism to signal new relevant outputs back to light -//! clients, such that transactions spending those outputs are included in block data. -//! -//! [`ChainMonitor`] may be used directly to monitor channels locally or as a part of a distributed -//! setup to monitor channels remotely. In the latter case, a custom [`chain::Watch`] implementation -//! would be responsible for routing each update to a remote server and for retrieving monitor -//! events. The remote server would make use of [`ChainMonitor`] for block processing and for -//! servicing [`ChannelMonitor`] updates from the client. - -use std::ffi::c_void; -use bitcoin::hashes::Hash; -use crate::c_types::*; - - -use lightning::chain::chainmonitor::ChainMonitor as nativeChainMonitorImport; -type nativeChainMonitor = nativeChainMonitorImport; - -/// An implementation of [`chain::Watch`] for monitoring channels. -/// -/// Connected and disconnected blocks must be provided to `ChainMonitor` as documented by -/// [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally -/// or used independently to monitor channels remotely. See the [module-level documentation] for -/// details. -/// -/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager -/// [module-level documentation]: crate::chain::chainmonitor -#[must_use] -#[repr(C)] -pub struct ChainMonitor { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChainMonitor, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChainMonitor { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChainMonitor>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChainMonitor, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChainMonitor_free(this_obj: ChainMonitor) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ChainMonitor_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainMonitor); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl ChainMonitor { - pub(crate) fn take_inner(mut self) -> *mut nativeChainMonitor { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel and reacting accordingly based on transactions in the connected block. See -/// [`ChannelMonitor::block_connected`] for details. Any HTLCs that were resolved on chain will -/// be returned by [`chain::Watch::release_pending_monitor_events`]. -/// -/// Calls back to [`chain::Filter`] if any monitor indicated new outputs to watch. Subsequent -/// calls must not exclude any transactions matching the new outputs nor any in-block -/// descendants of such transactions. It is not necessary to re-fetch the block to obtain -/// updated `txdata`. -#[no_mangle] -pub extern "C" fn ChainMonitor_block_connected(this_arg: &ChainMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { - let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) -} - -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel and reacting accordingly to newly confirmed transactions. For details, see -/// [`ChannelMonitor::transactions_confirmed`]. -/// -/// Used instead of [`block_connected`] by clients that are notified of transactions rather than -/// blocks. May be called before or after [`update_best_block`] for transactions in the -/// corresponding block. See [`update_best_block`] for further calling expectations. -/// -/// [`block_connected`]: Self::block_connected -/// [`update_best_block`]: Self::update_best_block -#[no_mangle] -pub extern "C" fn ChainMonitor_transactions_confirmed(this_arg: &ChainMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { - let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - unsafe { &*this_arg.inner }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) -} - -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel and reacting accordingly based on the new chain tip. For details, see -/// [`ChannelMonitor::update_best_block`]. -/// -/// Used instead of [`block_connected`] by clients that are notified of transactions rather than -/// blocks. May be called before or after [`transactions_confirmed`] for the corresponding -/// block. -/// -/// Must be called after new blocks become available for the most recent block. Intermediary -/// blocks, however, may be safely skipped. In the event of a chain re-organization, this only -/// needs to be called for the most recent block assuming `transaction_unconfirmed` is called -/// for any affected transactions. -/// -/// [`block_connected`]: Self::block_connected -/// [`transactions_confirmed`]: Self::transactions_confirmed -/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed -#[no_mangle] -pub extern "C" fn ChainMonitor_update_best_block(this_arg: &ChainMonitor, header: *const [u8; 80], mut height: u32) { - unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) -} - -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for -/// details. -#[no_mangle] -pub extern "C" fn ChainMonitor_block_disconnected(this_arg: &ChainMonitor, header: *const [u8; 80], mut disconnected_height: u32) { - unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), disconnected_height) -} - -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel based on transactions unconfirmed as a result of a chain reorganization. See -/// [`ChannelMonitor::transaction_unconfirmed`] for details. -/// -/// Used instead of [`block_disconnected`] by clients that are notified of transactions rather -/// than blocks. May be called before or after [`update_best_block`] for transactions in the -/// corresponding block. See [`update_best_block`] for further calling expectations. -/// -/// [`block_disconnected`]: Self::block_disconnected -/// [`update_best_block`]: Self::update_best_block -#[no_mangle] -pub extern "C" fn ChainMonitor_transaction_unconfirmed(this_arg: &ChainMonitor, txid: *const [u8; 32]) { - unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) -} - -/// Returns the set of txids that should be monitored for re-organization out of the chain. -#[must_use] -#[no_mangle] -pub extern "C" fn ChainMonitor_get_relevant_txids(this_arg: &ChainMonitor) -> crate::c_types::derived::CVec_TxidZ { - let mut ret = unsafe { &*this_arg.inner }.get_relevant_txids(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; - local_ret.into() -} - -/// Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. -/// -/// When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor -/// will call back to it indicating transactions and outputs of interest. This allows clients to -/// pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may -/// always need to fetch full blocks absent another means for determining which blocks contain -/// transactions relevant to the watched channels. -#[must_use] -#[no_mangle] -pub extern "C" fn ChainMonitor_new(chain_source: *mut crate::chain::Filter, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut feeest: crate::chain::chaininterface::FeeEstimator, mut persister: crate::chain::channelmonitor::Persist) -> ChainMonitor { - let mut local_chain_source = if chain_source == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_source) } }) }; - let mut ret = lightning::chain::chainmonitor::ChainMonitor::new(local_chain_source, broadcaster, logger, feeest, persister); - ChainMonitor { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -impl From for crate::chain::Watch { - fn from(obj: nativeChainMonitor) -> Self { - let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = ChainMonitor_as_Watch(&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(ChainMonitor_free_void); - ret - } -} -/// Constructs a new Watch which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is -#[no_mangle] -pub extern "C" fn ChainMonitor_as_Watch(this_arg: &ChainMonitor) -> crate::chain::Watch { - crate::chain::Watch { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - watch_channel: ChainMonitor_Watch_watch_channel, - update_channel: ChainMonitor_Watch_update_channel, - release_pending_monitor_events: ChainMonitor_Watch_release_pending_monitor_events, - } -} - -#[must_use] -extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_outpoint: crate::chain::transaction::OutPoint, mut monitor: crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ { - let mut ret = >::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_outpoint.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::ChannelMonitorUpdateErr::native_into(e) }).into() }; - local_ret -} -#[must_use] -extern "C" fn ChainMonitor_Watch_update_channel(this_arg: *const c_void, mut funding_txo: crate::chain::transaction::OutPoint, mut update: crate::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ { - let mut ret = >::update_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(update.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::ChannelMonitorUpdateErr::native_into(e) }).into() }; - local_ret -} -#[must_use] -extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ { - let mut ret = >::release_pending_monitor_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent::native_into(item) }); }; - local_ret.into() -} - -impl From for crate::util::events::EventsProvider { - fn from(obj: nativeChainMonitor) -> Self { - let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = ChainMonitor_as_EventsProvider(&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(ChainMonitor_free_void); - ret - } -} -/// Constructs a new EventsProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn ChainMonitor_as_EventsProvider(this_arg: &ChainMonitor) -> 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: ChainMonitor_EventsProvider_get_and_clear_pending_events, - } -} - -#[must_use] -extern "C" fn ChainMonitor_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ { - let mut ret = >::get_and_clear_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); }; - local_ret.into() -} - diff --git a/lightning-c-bindings/src/chain/channelmonitor.rs b/lightning-c-bindings/src/chain/channelmonitor.rs deleted file mode 100644 index 8d9402e..0000000 --- a/lightning-c-bindings/src/chain/channelmonitor.rs +++ /dev/null @@ -1,825 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 [`chain::Watch`] 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::chain::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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelMonitorUpdate, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelMonitorUpdate { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelMonitorUpdate>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelMonitorUpdate_free(this_obj: 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_inner(mut self) -> *mut nativeChannelMonitorUpdate { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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, with one exception specified below. -/// -/// 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. -/// -/// The only instance where update_id values are not strictly increasing is the case where we -/// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See -/// its docs for more details. -#[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, with one exception specified below. -/// -/// 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. -/// -/// The only instance where update_id values are not strictly increasing is the case where we -/// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See -/// its docs for more details. -#[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; -} -impl Clone for ChannelMonitorUpdate { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelMonitorUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ChannelMonitorUpdate -pub extern "C" fn ChannelMonitorUpdate_clone(orig: &ChannelMonitorUpdate) -> ChannelMonitorUpdate { - orig.clone() -} -/// If: -/// (1) a channel has been force closed and -/// (2) we receive a preimage from a forward link that allows us to spend an HTLC output on -/// this channel's (the backward link's) broadcasted commitment transaction -/// then we allow the `ChannelManager` to send a `ChannelMonitorUpdate` with this update ID, -/// with the update providing said payment preimage. No other update types are allowed after -/// force-close. - -#[no_mangle] -pub static CLOSED_CHANNEL_UPDATE_ID: u64 = lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID; -#[no_mangle] -/// Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read -pub extern "C" fn ChannelMonitorUpdate_write(obj: &ChannelMonitorUpdate) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelMonitorUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitorUpdate) }) -} -#[no_mangle] -/// Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write -pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelMonitorUpdateDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -/// 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 counterparty. 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). - /// - /// At reception of this error, ChannelManager will force-close the channel and return at - /// least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at - /// least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel - /// update must be rejected. - /// - /// This failure may also signal a failure to update the local persisted copy of one of - /// the channel monitor instance. - /// - /// Note that even when you fail a holder commitment transaction update, you must store the - /// update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor - /// broadcasts it (e.g distributed channel-monitor deployment) - /// - /// In case of distributed watchtowers deployment, the new version must be written to disk, as - /// state may have been stored but rejected due to a block forcing a commitment broadcast. This - /// storage is used to claim outputs of rejected state confirmed onchain by another watchtower, - /// lagging behind on block processing. - PermanentFailure, -} -use lightning::chain::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, - } - } -} -/// Creates a copy of the ChannelMonitorUpdateErr -#[no_mangle] -pub extern "C" fn ChannelMonitorUpdateErr_clone(orig: &ChannelMonitorUpdateErr) -> ChannelMonitorUpdateErr { - orig.clone() -} - -use lightning::chain::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 developer-readable error message. -#[must_use] -#[repr(C)] -pub struct MonitorUpdateError { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeMonitorUpdateError, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for MonitorUpdateError { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeMonitorUpdateError>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn MonitorUpdateError_free(this_obj: 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_inner(mut self) -> *mut nativeMonitorUpdateError { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -impl Clone for MonitorUpdateError { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeMonitorUpdateError>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 MonitorUpdateError_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeMonitorUpdateError)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the MonitorUpdateError -pub extern "C" fn MonitorUpdateError_clone(orig: &MonitorUpdateError) -> MonitorUpdateError { - orig.clone() -} -/// An event to be processed by the ChannelManager. -#[must_use] -#[derive(Clone)] -#[repr(C)] -pub enum MonitorEvent { - /// A monitor event containing an HTLCUpdate. - HTLCEvent(crate::chain::channelmonitor::HTLCUpdate), - /// A monitor event that the Channel's commitment transaction was broadcasted. - CommitmentTxBroadcasted(crate::chain::transaction::OutPoint), -} -use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEvent; -impl MonitorEvent { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeMonitorEvent { - match self { - MonitorEvent::HTLCEvent (ref a, ) => { - let mut a_nonref = (*a).clone(); - nativeMonitorEvent::HTLCEvent ( - *unsafe { Box::from_raw(a_nonref.take_inner()) }, - ) - }, - MonitorEvent::CommitmentTxBroadcasted (ref a, ) => { - let mut a_nonref = (*a).clone(); - nativeMonitorEvent::CommitmentTxBroadcasted ( - *unsafe { Box::from_raw(a_nonref.take_inner()) }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeMonitorEvent { - match self { - MonitorEvent::HTLCEvent (mut a, ) => { - nativeMonitorEvent::HTLCEvent ( - *unsafe { Box::from_raw(a.take_inner()) }, - ) - }, - MonitorEvent::CommitmentTxBroadcasted (mut a, ) => { - nativeMonitorEvent::CommitmentTxBroadcasted ( - *unsafe { Box::from_raw(a.take_inner()) }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeMonitorEvent) -> Self { - match native { - nativeMonitorEvent::HTLCEvent (ref a, ) => { - let mut a_nonref = (*a).clone(); - MonitorEvent::HTLCEvent ( - crate::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, - ) - }, - nativeMonitorEvent::CommitmentTxBroadcasted (ref a, ) => { - let mut a_nonref = (*a).clone(); - MonitorEvent::CommitmentTxBroadcasted ( - crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeMonitorEvent) -> Self { - match native { - nativeMonitorEvent::HTLCEvent (mut a, ) => { - MonitorEvent::HTLCEvent ( - crate::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(a)), is_owned: true }, - ) - }, - nativeMonitorEvent::CommitmentTxBroadcasted (mut a, ) => { - MonitorEvent::CommitmentTxBroadcasted ( - crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(a)), is_owned: true }, - ) - }, - } - } -} -/// Frees any resources used by the MonitorEvent -#[no_mangle] -pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { } -/// Creates a copy of the MonitorEvent -#[no_mangle] -pub extern "C" fn MonitorEvent_clone(orig: &MonitorEvent) -> MonitorEvent { - orig.clone() -} - -use lightning::chain::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport; -type nativeHTLCUpdate = nativeHTLCUpdateImport; - -/// 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. -#[must_use] -#[repr(C)] -pub struct HTLCUpdate { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeHTLCUpdate, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for HTLCUpdate { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeHTLCUpdate>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn HTLCUpdate_free(this_obj: 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_inner(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: if <*mut nativeHTLCUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { - 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] -/// Creates a copy of the HTLCUpdate -pub extern "C" fn HTLCUpdate_clone(orig: &HTLCUpdate) -> HTLCUpdate { - orig.clone() -} -#[no_mangle] -/// Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read -pub extern "C" fn HTLCUpdate_write(obj: &HTLCUpdate) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn HTLCUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCUpdate) }) -} -#[no_mangle] -/// Read a HTLCUpdate from a byte array, created by HTLCUpdate_write -pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HTLCUpdateDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport; -type nativeChannelMonitor = nativeChannelMonitorImport; - -/// 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. -/// -/// Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which -/// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along -/// the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the -/// returned block hash and the the current chain and then reconnecting blocks to get to the -/// best chain) upon deserializing the object! -#[must_use] -#[repr(C)] -pub struct ChannelMonitor { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelMonitor, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelMonitor { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelMonitor>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelMonitor_free(this_obj: 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_inner(mut self) -> *mut nativeChannelMonitor { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -#[no_mangle] -/// Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read -pub extern "C" fn ChannelMonitor_write(obj: &ChannelMonitor) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelMonitor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitor) }) -} -/// 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: &ChannelMonitor, updates: &crate::chain::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::chain::chaininterface::FeeEstimator, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ { - let mut ret = unsafe { &*this_arg.inner }.update_monitor(unsafe { &*updates.inner }, broadcaster, fee_estimator, logger); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::MonitorUpdateError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - 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 (mut orig_ret_0, mut orig_ret_1) = ret; let mut local_ret = (crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(orig_ret_0)), is_owned: true }, orig_ret_1.into_bytes().into()).into(); - local_ret -} - -/// Gets a list of txids, with their output scripts (in the order they appear in the -/// transaction), which we must learn about spends of via block_connected(). -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelMonitor_get_outputs_to_watch(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - let mut ret = unsafe { &*this_arg.inner }.get_outputs_to_watch(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, orig_orig_ret_0_1_0_1.into_bytes().into()).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; - local_ret.into() -} - -/// Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly -/// calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs -/// have been registered. -#[no_mangle] -pub extern "C" fn ChannelMonitor_load_outputs_to_watch(this_arg: &ChannelMonitor, filter: &crate::chain::Filter) { - unsafe { &*this_arg.inner }.load_outputs_to_watch(filter) -} - -/// Get the list of HTLCs who's status has been updated on chain. This should be called by -/// ChannelManager via [`chain::Watch::release_pending_monitor_events`]. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ { - let mut ret = unsafe { &*this_arg.inner }.get_and_clear_pending_monitor_events(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent::native_into(item) }); }; - 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 ChainMonitor::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: &ChannelMonitor) -> crate::c_types::derived::CVec_EventZ { - let mut ret = unsafe { &*this_arg.inner }.get_and_clear_pending_events(); - let mut local_ret = Vec::new(); for mut 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 holder state if its copy of -/// the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of -/// fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows -/// a higher revocation secret than the holder commitment number we are aware of. Broadcasting these -/// transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to -/// broadcast them if counterparty 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_holder_commitment_txn(this_arg: &ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ { - let mut ret = unsafe { &*this_arg.inner }.get_latest_holder_commitment_txn(logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); }; - local_ret.into() -} - -/// Processes transactions in a newly connected block, which may result in any of the following: -/// - update the monitor's state against resolved HTLCs -/// - punish the counterparty in the case of seeing a revoked commitment transaction -/// - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration -/// - detect settled outputs for later spending -/// - schedule and bump any in-flight claims -/// -/// Returns any new outputs to watch from `txdata`; after called, these are also included in -/// [`get_outputs_to_watch`]. -/// -/// [`get_outputs_to_watch`]: #method.get_outputs_to_watch -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelMonitor_block_connected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { - let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - let mut ret = unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; - local_ret.into() -} - -/// Determines if the disconnected block contained any transactions of interest and updates -/// appropriately. -#[no_mangle] -pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) { - unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger) -} - -/// Processes transactions confirmed in a block with the given header and height, returning new -/// outputs to watch. See [`block_connected`] for details. -/// -/// Used instead of [`block_connected`] by clients that are notified of transactions rather than -/// blocks. May be called before or after [`update_best_block`] for transactions in the -/// corresponding block. See [`update_best_block`] for further calling expectations. -/// -/// [`block_connected`]: Self::block_connected -/// [`update_best_block`]: Self::update_best_block -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelMonitor_transactions_confirmed(this_arg: &ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { - let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - let mut ret = unsafe { &*this_arg.inner }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; - local_ret.into() -} - -/// Processes a transaction that was reorganized out of the chain. -/// -/// Used instead of [`block_disconnected`] by clients that are notified of transactions rather -/// than blocks. May be called before or after [`update_best_block`] for transactions in the -/// corresponding block. See [`update_best_block`] for further calling expectations. -/// -/// [`block_disconnected`]: Self::block_disconnected -/// [`update_best_block`]: Self::update_best_block -#[no_mangle] -pub extern "C" fn ChannelMonitor_transaction_unconfirmed(this_arg: &ChannelMonitor, txid: *const [u8; 32], mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) { - unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap(), broadcaster, fee_estimator, logger) -} - -/// Updates the monitor with the current best chain tip, returning new outputs to watch. See -/// [`block_connected`] for details. -/// -/// Used instead of [`block_connected`] by clients that are notified of transactions rather than -/// blocks. May be called before or after [`transactions_confirmed`] for the corresponding -/// block. -/// -/// Must be called after new blocks become available for the most recent block. Intermediary -/// blocks, however, may be safely skipped. In the event of a chain re-organization, this only -/// needs to be called for the most recent block assuming `transaction_unconfirmed` is called -/// for any affected transactions. -/// -/// [`block_connected`]: Self::block_connected -/// [`transactions_confirmed`]: Self::transactions_confirmed -/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelMonitor_update_best_block(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { - let mut ret = unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; - local_ret.into() -} - -/// Returns the set of txids that should be monitored for re-organization out of the chain. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_TxidZ { - let mut ret = unsafe { &*this_arg.inner }.get_relevant_txids(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; - local_ret.into() -} - -/// `Persist` defines behavior for persisting channel monitors: this could mean -/// writing once to disk, and/or uploading to one or more backup services. -/// -/// Note that for every new monitor, you **must** persist the new `ChannelMonitor` -/// to disk/backups. And, on every update, you **must** persist either the -/// `ChannelMonitorUpdate` or the updated monitor itself. Otherwise, there is risk -/// of situations such as revoking a transaction, then crashing before this -/// revocation can be persisted, then unintentionally broadcasting a revoked -/// transaction and losing money. This is a risk because previous channel states -/// are toxic, so it's important that whatever channel state is persisted is -/// kept up-to-date. -#[repr(C)] -pub struct Persist { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Persist a new channel's data. The data can be stored any way you want, but - /// the identifier provided by Rust-Lightning is the channel's outpoint (and - /// it is up to you to maintain a correct mapping between the outpoint and the - /// stored channel data). Note that you **must** persist every new monitor to - /// disk. See the `Persist` trait documentation for more details. - /// - /// See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, - /// and [`ChannelMonitorUpdateErr`] for requirements when returning errors. - #[must_use] - pub persist_new_channel: extern "C" fn (this_arg: *const c_void, id: crate::chain::transaction::OutPoint, data: &crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, - /// Update one channel's data. The provided `ChannelMonitor` has already - /// applied the given update. - /// - /// Note that on every update, you **must** persist either the - /// `ChannelMonitorUpdate` or the updated monitor itself to disk/backups. See - /// the `Persist` trait documentation for more details. - /// - /// If an implementer chooses to persist the updates only, they need to make - /// sure that all the updates are applied to the `ChannelMonitors` *before* - /// the set of channel monitors is given to the `ChannelManager` - /// deserialization routine. See [`ChannelMonitor::update_monitor`] for - /// applying a monitor update to a monitor. If full `ChannelMonitors` are - /// persisted, then there is no need to persist individual updates. - /// - /// Note that there could be a performance tradeoff between persisting complete - /// channel monitors on every update vs. persisting only updates and applying - /// them in batches. The size of each monitor grows `O(number of state updates)` - /// whereas updates are small and `O(1)`. - /// - /// See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, - /// [`ChannelMonitorUpdate::write`] for writing out an update, and - /// [`ChannelMonitorUpdateErr`] for requirements when returning errors. - #[must_use] - pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, id: crate::chain::transaction::OutPoint, update: &crate::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for Persist {} -unsafe impl Sync for Persist {} - -use lightning::chain::channelmonitor::Persist as rustPersist; -impl rustPersist for Persist { - fn persist_new_channel(&self, id: lightning::chain::transaction::OutPoint, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { - let mut ret = (self.persist_new_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; - local_ret - } - fn update_persisted_channel(&self, id: lightning::chain::transaction::OutPoint, update: &lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { - let mut ret = (self.update_persisted_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (update as *const _) as *mut _ }, is_owned: false }, &crate::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).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 Persist { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn Persist_free(this_ptr: Persist) { } -impl Drop for Persist { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -#[no_mangle] -/// Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg: &crate::chain::keysinterface::KeysInterface) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - let arg_conv = arg; - let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::chain::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(orig_res_0_1)), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} diff --git a/lightning-c-bindings/src/chain/keysinterface.rs b/lightning-c-bindings/src/chain/keysinterface.rs deleted file mode 100644 index 5c50e53..0000000 --- a/lightning-c-bindings/src/chain/keysinterface.rs +++ /dev/null @@ -1,1481 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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::*; - - -use lightning::chain::keysinterface::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport; -type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptorImport; - -/// Information about a spendable output to a P2WSH script. See -/// SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. -#[must_use] -#[repr(C)] -pub struct DelayedPaymentOutputDescriptor { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeDelayedPaymentOutputDescriptor, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DelayedPaymentOutputDescriptor { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_free(this_obj: DelayedPaymentOutputDescriptor) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn DelayedPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDelayedPaymentOutputDescriptor); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl DelayedPaymentOutputDescriptor { - pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The outpoint which is spendable -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::chain::transaction::OutPoint { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; - crate::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// The outpoint which is spendable -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::chain::transaction::OutPoint) { - unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Per commitment point to derive delayed_payment_key by key holder -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> 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)) -} -/// Per commitment point to derive delayed_payment_key by key holder -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { - unsafe { &mut *this_ptr.inner }.per_commitment_point = val.into_rust(); -} -/// The nSequence value which must be set in the spending input to satisfy the OP_CSV in -/// the witness_script. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay; - (*inner_val) -} -/// The nSequence value which must be set in the spending input to satisfy the OP_CSV in -/// the witness_script. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_to_self_delay(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u16) { - unsafe { &mut *this_ptr.inner }.to_self_delay = val; -} -/// The output which is referenced by the given outpoint -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { - unsafe { &mut *this_ptr.inner }.output = val.into_rust(); -} -/// The revocation point specific to the commitment transaction which was broadcast. Used to -/// derive the witnessScript for this output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_pubkey; - crate::c_types::PublicKey::from_rust(&(*inner_val)) -} -/// The revocation point specific to the commitment transaction which was broadcast. Used to -/// derive the witnessScript for this output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { - unsafe { &mut *this_ptr.inner }.revocation_pubkey = val.into_rust(); -} -/// Arbitrary identification information returned by a call to -/// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in -/// the channel to spend the output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id; - &(*inner_val) -} -/// Arbitrary identification information returned by a call to -/// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in -/// the channel to spend the output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.channel_keys_id = val.data; -} -/// The value of the channel which this output originated from, possibly indirectly. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis; - (*inner_val) -} -/// The value of the channel which this output originated from, possibly indirectly. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) { - unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val; -} -/// Constructs a new DelayedPaymentOutputDescriptor given each field -#[must_use] -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::c_types::PublicKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor { - DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(nativeDelayedPaymentOutputDescriptor { - outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - per_commitment_point: per_commitment_point_arg.into_rust(), - to_self_delay: to_self_delay_arg, - output: output_arg.into_rust(), - revocation_pubkey: revocation_pubkey_arg.into_rust(), - channel_keys_id: channel_keys_id_arg.data, - channel_value_satoshis: channel_value_satoshis_arg, - })), is_owned: true } -} -impl Clone for DelayedPaymentOutputDescriptor { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 DelayedPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDelayedPaymentOutputDescriptor)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the DelayedPaymentOutputDescriptor -pub extern "C" fn DelayedPaymentOutputDescriptor_clone(orig: &DelayedPaymentOutputDescriptor) -> DelayedPaymentOutputDescriptor { - orig.clone() -} - -use lightning::chain::keysinterface::StaticPaymentOutputDescriptor as nativeStaticPaymentOutputDescriptorImport; -type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorImport; - -/// Information about a spendable output to our \"payment key\". See -/// SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this. -#[must_use] -#[repr(C)] -pub struct StaticPaymentOutputDescriptor { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeStaticPaymentOutputDescriptor, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for StaticPaymentOutputDescriptor { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_free(this_obj: StaticPaymentOutputDescriptor) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn StaticPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeStaticPaymentOutputDescriptor); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl StaticPaymentOutputDescriptor { - pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The outpoint which is spendable -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::chain::transaction::OutPoint { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; - crate::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// The outpoint which is spendable -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_outpoint(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::chain::transaction::OutPoint) { - unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The output which is referenced by the given outpoint -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { - unsafe { &mut *this_ptr.inner }.output = val.into_rust(); -} -/// Arbitrary identification information returned by a call to -/// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in -/// the channel to spend the output. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id; - &(*inner_val) -} -/// Arbitrary identification information returned by a call to -/// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in -/// the channel to spend the output. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.channel_keys_id = val.data; -} -/// The value of the channel which this transactions spends. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis; - (*inner_val) -} -/// The value of the channel which this transactions spends. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: u64) { - unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val; -} -/// Constructs a new StaticPaymentOutputDescriptor given each field -#[must_use] -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_new(mut outpoint_arg: crate::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> StaticPaymentOutputDescriptor { - StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(nativeStaticPaymentOutputDescriptor { - outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - output: output_arg.into_rust(), - channel_keys_id: channel_keys_id_arg.data, - channel_value_satoshis: channel_value_satoshis_arg, - })), is_owned: true } -} -impl Clone for StaticPaymentOutputDescriptor { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 StaticPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeStaticPaymentOutputDescriptor)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the StaticPaymentOutputDescriptor -pub extern "C" fn StaticPaymentOutputDescriptor_clone(orig: &StaticPaymentOutputDescriptor) -> StaticPaymentOutputDescriptor { - orig.clone() -} -/// 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 directly, either from - /// `get_destination_script()` or `get_shutdown_pubkey()`, thus you should already know how to - /// spend it. No secret keys are provided as rust-lightning was never given any key. - /// 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 { - /// The outpoint which is spendable - outpoint: crate::chain::transaction::OutPoint, - /// The output which is referenced by the given 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: - /// (MINIMALIF standard rule) - /// - /// 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 - /// Sign::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 - /// Sign::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 Sign::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. - DelayedPaymentOutput(crate::chain::keysinterface::DelayedPaymentOutputDescriptor), - /// An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which - /// corresponds to the public key in Sign::pubkeys().payment_point). - /// The witness in the spending input, is, thus, simply: - /// - /// - /// These are generally the result of our counterparty having broadcast the current state, - /// allowing us to claim the non-HTLC-encumbered outputs immediately. - StaticPaymentOutput(crate::chain::keysinterface::StaticPaymentOutputDescriptor), -} -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_inner()) }, - output: output_nonref.into_rust(), - } - }, - SpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { - let mut a_nonref = (*a).clone(); - nativeSpendableOutputDescriptor::DelayedPaymentOutput ( - *unsafe { Box::from_raw(a_nonref.take_inner()) }, - ) - }, - SpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { - let mut a_nonref = (*a).clone(); - nativeSpendableOutputDescriptor::StaticPaymentOutput ( - *unsafe { Box::from_raw(a_nonref.take_inner()) }, - ) - }, - } - } - #[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_inner()) }, - output: output.into_rust(), - } - }, - SpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { - nativeSpendableOutputDescriptor::DelayedPaymentOutput ( - *unsafe { Box::from_raw(a.take_inner()) }, - ) - }, - SpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { - nativeSpendableOutputDescriptor::StaticPaymentOutput ( - *unsafe { Box::from_raw(a.take_inner()) }, - ) - }, - } - } - #[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::DelayedPaymentOutput (ref a, ) => { - let mut a_nonref = (*a).clone(); - SpendableOutputDescriptor::DelayedPaymentOutput ( - crate::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, - ) - }, - nativeSpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { - let mut a_nonref = (*a).clone(); - SpendableOutputDescriptor::StaticPaymentOutput ( - crate::chain::keysinterface::StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, - ) - }, - } - } - #[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::DelayedPaymentOutput (mut a, ) => { - SpendableOutputDescriptor::DelayedPaymentOutput ( - crate::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a)), is_owned: true }, - ) - }, - nativeSpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { - SpendableOutputDescriptor::StaticPaymentOutput ( - crate::chain::keysinterface::StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a)), is_owned: true }, - ) - }, - } - } -} -/// Frees any resources used by the SpendableOutputDescriptor -#[no_mangle] -pub extern "C" fn SpendableOutputDescriptor_free(this_ptr: SpendableOutputDescriptor) { } -/// Creates a copy of the SpendableOutputDescriptor -#[no_mangle] -pub extern "C" fn SpendableOutputDescriptor_clone(orig: &SpendableOutputDescriptor) -> SpendableOutputDescriptor { - orig.clone() -} -#[no_mangle] -/// Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read -pub extern "C" fn SpendableOutputDescriptor_write(obj: &SpendableOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write -pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpendableOutputDescriptorDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -/// A trait to sign lightning channel transactions as described in BOLT 3. -/// -/// Signing services could be implemented on a hardware wallet. In this case, -/// the current Sign 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. -#[repr(C)] -pub struct BaseSign { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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. - #[must_use] - pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes, - /// Gets the holder's 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, - /// Gets an arbitrary identifier describing the set of keys which are provided back to you in - /// some SpendableOutputDescriptor types. This should be sufficient to identify this - /// Sign object uniquely and lookup or re-derive its keys. - #[must_use] - pub channel_keys_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions. - /// - /// Note that if signing fails or is rejected, the channel will be force-closed. - #[must_use] - pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, - /// Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. - /// This will only ever be called with a non-revoked commitment_tx. This will be called with the - /// latest commitment_tx when we initiate a force-close. - /// This will be called with the previous latest, just to get claiming HTLC signatures, if we are - /// reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to - /// the latest. - /// This may be called multiple times for the same transaction. - /// - /// An external signer implementation should check that the commitment has not been revoked. - /// - /// May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. - #[must_use] - pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, - /// 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 _holder_ secret key and does - /// not allow the spending of any funds by itself (you need our holder 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 counterparty's 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_counterparty_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 counterparty static channel data, including basepoints, - /// counterparty_selected/holder_selected_contest_delay and funding outpoint. - /// This is done as soon as the funding outpoint is known. Since these are static channel data, - /// they MUST NOT be allowed to change to different values once set. - /// - /// channel_parameters.is_populated() MUST be true. - /// - /// We bind holder_selected_contest_delay late here for API convenience. - /// - /// Will be called before any signatures are applied. - pub ready_channel: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::ln::chan_utils::ChannelTransactionParameters), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for BaseSign {} - -use lightning::chain::keysinterface::BaseSign as rustBaseSign; -impl rustBaseSign for BaseSign { - fn get_per_commitment_point(&self, idx: u64, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> 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 channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.channel_keys_id)(self.this_arg); - ret.data - } - fn sign_counterparty_commitment(&self, commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { - let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::ln::chan_utils::CommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); - 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_commitment_and_htlcs(&self, commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { - let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); - 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_transaction(&self, justice_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_key: &bitcoin::secp256k1::key::SecretKey, htlc: &Option, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - 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_vec(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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_counterparty_htlc_transaction(&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) -> Result { - let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx); - let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_closing_transaction(&self, closing_tx: &bitcoin::blockdata::transaction::Transaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - 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_vec(local_closing_tx)); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_channel_announcement(&self, msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn ready_channel(&mut self, channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.ready_channel)(self.this_arg, &crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (channel_parameters 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 BaseSign { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn BaseSign_free(this_ptr: BaseSign) { } -impl Drop for BaseSign { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A cloneable signer. -/// -/// Although we require signers to be cloneable, it may be useful for developers to be able to use -/// signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait, -/// which implies Sized, into this derived trait. -#[repr(C)] -pub struct Sign { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Implementation of BaseSign for this object. - pub BaseSign: crate::chain::keysinterface::BaseSign, - /// Creates a copy of the BaseSign, for a copy of this Sign. - /// Because BaseSign doesn't natively support copying itself, you have to provide a full copy implementation here. - pub BaseSign_clone: extern "C" fn (orig_BaseSign: &BaseSign) -> BaseSign, - /// Serialize the object into a byte array - pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, - /// Creates a copy of the object pointed to by this_arg, for a copy of this Sign. - /// Note that the ultimate copy of the Sign will have all function pointers the same as the original. - /// May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new Sign. - pub clone: Option *mut c_void>, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -impl lightning::chain::keysinterface::BaseSign for Sign { - fn get_per_commitment_point(&self, idx: u64, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::key::PublicKey { - let mut ret = (self.BaseSign.get_per_commitment_point)(self.this_arg, idx); - ret.into_rust() - } - fn release_commitment_secret(&self, idx: u64) -> [u8; 32] { - let mut ret = (self.BaseSign.release_commitment_secret)(self.this_arg, idx); - ret.data - } - fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { - if let Some(f) = self.BaseSign.set_pubkeys { - (f)(&self.BaseSign); - } - unsafe { &*self.BaseSign.pubkeys.inner } - } - fn channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.BaseSign.channel_keys_id)(self.this_arg); - ret.data - } - fn sign_counterparty_commitment(&self, commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { - let mut ret = (self.BaseSign.sign_counterparty_commitment)(self.this_arg, &crate::ln::chan_utils::CommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); - 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_commitment_and_htlcs(&self, commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { - let mut ret = (self.BaseSign.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); - 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_transaction(&self, justice_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_key: &bitcoin::secp256k1::key::SecretKey, htlc: &Option, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - 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.BaseSign.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_counterparty_htlc_transaction(&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) -> Result { - let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx); - let mut ret = (self.BaseSign.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_closing_transaction(&self, closing_tx: &bitcoin::blockdata::transaction::Transaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut local_closing_tx = ::bitcoin::consensus::encode::serialize(closing_tx); - let mut ret = (self.BaseSign.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_closing_tx)); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_channel_announcement(&self, msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.BaseSign.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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn ready_channel(&mut self, channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.BaseSign.ready_channel)(self.this_arg, &crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (channel_parameters as *const _) as *mut _ }, is_owned: false }) - } -} -unsafe impl Send for Sign {} -impl lightning::util::ser::Writeable for Sign { - fn write(&self, w: &mut W) -> Result<(), ::std::io::Error> { - let vec = (self.write)(self.this_arg); - w.write_all(vec.as_slice()) - } -} -#[no_mangle] -/// Creates a copy of a Sign -pub extern "C" fn Sign_clone(orig: &Sign) -> Sign { - Sign { - this_arg: if let Some(f) = orig.clone { (f)(orig.this_arg) } else { orig.this_arg }, - BaseSign: (orig.BaseSign_clone)(&orig.BaseSign), - BaseSign_clone: orig.BaseSign_clone, - write: Clone::clone(&orig.write), - clone: Clone::clone(&orig.clone), - free: Clone::clone(&orig.free), - } -} -impl Clone for Sign { - fn clone(&self) -> Self { - Sign_clone(self) - } -} - -use lightning::chain::keysinterface::Sign as rustSign; -impl rustSign for Sign { -} - -// 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 Sign { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn Sign_free(this_ptr: Sign) { } -impl Drop for Sign { - 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 { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Get node secret key (aka node_id or network_key). - /// - /// This method must return the same value each time it is called. - #[must_use] - pub get_node_secret: extern "C" fn (this_arg: *const c_void) -> crate::c_types::SecretKey, - /// Get a script pubkey which we send funds to when claiming on-chain contestable outputs. - /// - /// This method should return a different value each time it is called, to avoid linking - /// on-chain funds across channels as controlled to the same user. - #[must_use] - pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, - /// Get a public key which we will send funds to (in the form of a P2WPKH output) when closing - /// a channel. - /// - /// This method should return a different value each time it is called, to avoid linking - /// on-chain funds across channels as controlled to the same user. - #[must_use] - pub get_shutdown_pubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::PublicKey, - /// Get a new set of Sign for per-channel secrets. These MUST be unique even if you - /// restarted with some stale data! - /// - /// This method must return a different value each time it is called. - #[must_use] - pub get_channel_signer: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::Sign, - /// 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. - /// - /// This method must return a different value each time it is called. - #[must_use] - pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// Reads a `Signer` for this `KeysInterface` from the given input stream. - /// This is only called during deserialization of other objects which contain - /// `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). - /// The bytes are exactly those which `::write()` writes, and - /// contain no versioning scheme. You may wish to include your own version prefix and ensure - /// you've read all of the provided bytes to ensure no corruption occurred. - #[must_use] - pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for KeysInterface {} -unsafe impl Sync for KeysInterface {} - -use lightning::chain::keysinterface::KeysInterface as rustKeysInterface; -impl rustKeysInterface for KeysInterface { - type Signer = crate::chain::keysinterface::Sign; - 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_signer(&self, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::Sign { - let mut ret = (self.get_channel_signer)(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 - } - fn read_chan_signer(&self, reader: &[u8]) -> Result { - let mut local_reader = crate::c_types::u8slice::from_slice(reader); - let mut ret = (self.read_chan_signer)(self.this_arg, local_reader); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; - 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 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::InMemorySigner as nativeInMemorySignerImport; -type nativeInMemorySigner = nativeInMemorySignerImport; - -/// A simple implementation of Sign that just keeps the private keys in memory. -/// -/// This implementation performs no policy checks and is insufficient by itself as -/// a secure external signer. -#[must_use] -#[repr(C)] -pub struct InMemorySigner { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeInMemorySigner, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for InMemorySigner { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInMemorySigner>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InMemorySigner_free(this_obj: InMemorySigner) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn InMemorySigner_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInMemorySigner); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl InMemorySigner { - pub(crate) fn take_inner(mut self) -> *mut nativeInMemorySigner { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Private key of anchor tx -#[no_mangle] -pub extern "C" fn InMemorySigner_get_funding_key(this_ptr: &InMemorySigner) -> *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 InMemorySigner_set_funding_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *this_ptr.inner }.funding_key = val.into_rust(); -} -/// Holder secret key for blinded revocation pubkey -#[no_mangle] -pub extern "C" fn InMemorySigner_get_revocation_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_base_key; - (*inner_val).as_ref() -} -/// Holder secret key for blinded revocation pubkey -#[no_mangle] -pub extern "C" fn InMemorySigner_set_revocation_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *this_ptr.inner }.revocation_base_key = val.into_rust(); -} -/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions -#[no_mangle] -pub extern "C" fn InMemorySigner_get_payment_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key; - (*inner_val).as_ref() -} -/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions -#[no_mangle] -pub extern "C" fn InMemorySigner_set_payment_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *this_ptr.inner }.payment_key = val.into_rust(); -} -/// Holder secret key used in HTLC tx -#[no_mangle] -pub extern "C" fn InMemorySigner_get_delayed_payment_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_base_key; - (*inner_val).as_ref() -} -/// Holder secret key used in HTLC tx -#[no_mangle] -pub extern "C" fn InMemorySigner_set_delayed_payment_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *this_ptr.inner }.delayed_payment_base_key = val.into_rust(); -} -/// Holder htlc secret key used in commitment tx htlc outputs -#[no_mangle] -pub extern "C" fn InMemorySigner_get_htlc_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_base_key; - (*inner_val).as_ref() -} -/// Holder htlc secret key used in commitment tx htlc outputs -#[no_mangle] -pub extern "C" fn InMemorySigner_set_htlc_base_key(this_ptr: &mut InMemorySigner, 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 InMemorySigner_get_commitment_seed(this_ptr: &InMemorySigner) -> *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 InMemorySigner_set_commitment_seed(this_ptr: &mut InMemorySigner, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.commitment_seed = val.data; -} -impl Clone for InMemorySigner { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInMemorySigner>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 InMemorySigner_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemorySigner)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InMemorySigner -pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner { - orig.clone() -} -/// Create a new InMemorySigner -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_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 channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::chain::keysinterface::InMemorySigner { - let mut ret = lightning::chain::keysinterface::InMemorySigner::new(secp256k1::SECP256K1, 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, channel_keys_id.data); - crate::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Counterparty pubkeys. -/// Will panic if ready_channel wasn't called. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_counterparty_pubkeys(this_arg: &InMemorySigner) -> crate::ln::chan_utils::ChannelPublicKeys { - let mut ret = unsafe { &*this_arg.inner }.counterparty_pubkeys(); - crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// The contest_delay value specified by our counterparty and applied on holder-broadcastable -/// transactions, ie the amount of time that we have to wait to recover our funds if we -/// broadcast a transaction. -/// Will panic if ready_channel wasn't called. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_counterparty_selected_contest_delay(this_arg: &InMemorySigner) -> u16 { - let mut ret = unsafe { &*this_arg.inner }.counterparty_selected_contest_delay(); - ret -} - -/// The contest_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 ready_channel wasn't called. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_holder_selected_contest_delay(this_arg: &InMemorySigner) -> u16 { - let mut ret = unsafe { &*this_arg.inner }.holder_selected_contest_delay(); - ret -} - -/// Whether the holder is the initiator -/// Will panic if ready_channel wasn't called. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_is_outbound(this_arg: &InMemorySigner) -> bool { - let mut ret = unsafe { &*this_arg.inner }.is_outbound(); - ret -} - -/// Funding outpoint -/// Will panic if ready_channel wasn't called. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_funding_outpoint(this_arg: &InMemorySigner) -> crate::chain::transaction::OutPoint { - let mut ret = unsafe { &*this_arg.inner }.funding_outpoint(); - crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or -/// building transactions. -/// -/// Will panic if ready_channel wasn't called. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &InMemorySigner) -> crate::ln::chan_utils::ChannelTransactionParameters { - let mut ret = unsafe { &*this_arg.inner }.get_channel_parameters(); - crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// Sign the single input of spend_tx at index `input_idx` which spends the output -/// described by descriptor, returning the witness stack for the input. -/// -/// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, -/// or is not spending the outpoint described by `descriptor.outpoint`. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { - let mut ret = unsafe { &*this_arg.inner }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} - -/// Sign the single input of spend_tx at index `input_idx` which spends the output -/// described by descriptor, returning the witness stack for the input. -/// -/// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, -/// is not spending the outpoint described by `descriptor.outpoint`, or does not have a -/// sequence set to `descriptor.to_self_delay`. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { - let mut ret = unsafe { &*this_arg.inner }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} - -impl From for crate::chain::keysinterface::BaseSign { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = InMemorySigner_as_BaseSign(&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(InMemorySigner_free_void); - ret - } -} -/// Constructs a new BaseSign which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_BaseSign(this_arg: &InMemorySigner) -> crate::chain::keysinterface::BaseSign { - crate::chain::keysinterface::BaseSign { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_BaseSign_get_per_commitment_point, - release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret, - - pubkeys: crate::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true }, - set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys), - channel_keys_id: InMemorySigner_BaseSign_channel_keys_id, - sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment, - sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs, - sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction, - sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction, - sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement, - ready_channel: InMemorySigner_BaseSign_ready_channel, - } -} - -#[must_use] -extern "C" fn InMemorySigner_BaseSign_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { - let mut ret = >::get_per_commitment_point(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, secp256k1::SECP256K1); - crate::c_types::PublicKey::from_rust(&ret) -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_pubkeys(this_arg: *const c_void) -> crate::ln::chan_utils::ChannelPublicKeys { - let mut ret = >::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); - crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} -extern "C" fn InMemorySigner_BaseSign_set_pubkeys(trait_self_arg: &BaseSign) { - // 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 BaseSign as *mut BaseSign) }.pubkeys = InMemorySigner_BaseSign_pubkeys(trait_self_arg.this_arg); - } -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::channel_keys_id(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut ret = >::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, unsafe { &*commitment_tx.inner }, secp256k1::SECP256K1); - 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 mut 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 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut ret = >::sign_holder_commitment_and_htlcs(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, unsafe { &*commitment_tx.inner }, secp256k1::SECP256K1); - 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 mut 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 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_sign_justice_transaction(this_arg: *const c_void, mut 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 = >::sign_justice_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), &local_htlc, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_counterparty_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_sign_closing_transaction(this_arg: *const c_void, mut closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &closing_tx.into_bitcoin(), secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_BaseSign_sign_channel_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_channel_announcement(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, unsafe { &*msg.inner }, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} -extern "C" fn InMemorySigner_BaseSign_ready_channel(this_arg: *mut c_void, channel_parameters: &crate::ln::chan_utils::ChannelTransactionParameters) { - >::ready_channel(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, unsafe { &*channel_parameters.inner }) -} - -impl From for crate::chain::keysinterface::Sign { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = InMemorySigner_as_Sign(&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(InMemorySigner_free_void); - ret - } -} -/// Constructs a new Sign which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_Sign(this_arg: &InMemorySigner) -> crate::chain::keysinterface::Sign { - crate::chain::keysinterface::Sign { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - BaseSign: crate::chain::keysinterface::BaseSign { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_BaseSign_get_per_commitment_point, - release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret, - - pubkeys: crate::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true }, - set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys), - channel_keys_id: InMemorySigner_BaseSign_channel_keys_id, - sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment, - sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs, - sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction, - sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction, - sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement, - ready_channel: InMemorySigner_BaseSign_ready_channel, - }, - BaseSign_clone: InMemorySigner_BaseSign_clone, - write: InMemorySigner_write_void, - clone: Some(InMemorySigner_clone_void), - } -} - -extern "C" fn InMemorySigner_BaseSign_clone(orig: &crate::chain::keysinterface::BaseSign) -> crate::chain::keysinterface::BaseSign { - crate::chain::keysinterface::BaseSign { - this_arg: orig.this_arg, - free: None, - get_per_commitment_point: InMemorySigner_BaseSign_get_per_commitment_point, - release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret, - - pubkeys: crate::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true }, - set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys), - channel_keys_id: InMemorySigner_BaseSign_channel_keys_id, - sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment, - sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs, - sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction, - sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction, - sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement, - ready_channel: InMemorySigner_BaseSign_ready_channel, - } -} - -#[no_mangle] -/// Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read -pub extern "C" fn InMemorySigner_write(obj: &InMemorySigner) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemorySigner) }) -} -#[no_mangle] -/// Read a InMemorySigner from a byte array, created by InMemorySigner_write -pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeKeysManager, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for KeysManager { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeKeysManager>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn KeysManager_free(this_obj: 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_inner(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 starting_time_secs: u64, mut starting_time_nanos: u32) -> KeysManager { - let mut ret = lightning::chain::keysinterface::KeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos); - KeysManager { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Derive an old Sign containing per-channel secrets based on a key derivation parameters. -/// -/// Key derivation parameters are accessible through a per-channel secrets -/// Sign::channel_keys_id 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, params: *const [u8; 32]) -> crate::chain::keysinterface::InMemorySigner { - let mut ret = unsafe { &*this_arg.inner }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); - crate::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Creates a Transaction which spends the given descriptors to the given outputs, plus an -/// output to the given change destination (if sufficient change value remains). The -/// transaction will have a feerate, at least, of the given value. -/// -/// Returns `Err(())` if the output value is greater than the input value minus required fee or -/// if a descriptor was duplicated. -/// -/// We do not enforce that outputs meet the dust limit or that any output scripts are standard. -/// -/// May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used -/// this KeysManager or one of the `InMemorySigner` created by this KeysManager. -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; - let mut ret = unsafe { &*this_arg.inner }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&o); crate::c_types::Transaction::from_vec(local_ret_0) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} - -impl From for crate::chain::keysinterface::KeysInterface { - fn from(obj: nativeKeysManager) -> Self { - let mut rust_obj = KeysManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = KeysManager_as_KeysInterface(&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(KeysManager_free_void); - ret - } -} -/// Constructs a new KeysInterface which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is -#[no_mangle] -pub extern "C" fn KeysManager_as_KeysInterface(this_arg: &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_signer: KeysManager_KeysInterface_get_channel_signer, - get_secure_random_bytes: KeysManager_KeysInterface_get_secure_random_bytes, - read_chan_signer: KeysManager_KeysInterface_read_chan_signer, - } -} - -#[must_use] -extern "C" fn KeysManager_KeysInterface_get_node_secret(this_arg: *const c_void) -> crate::c_types::SecretKey { - let mut ret = >::get_node_secret(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - 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 = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - 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 = >::get_shutdown_pubkey(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::c_types::PublicKey::from_rust(&ret) -} -#[must_use] -extern "C" fn KeysManager_KeysInterface_get_channel_signer(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::chain::keysinterface::Sign { - let mut ret = >::get_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, _inbound, channel_value_satoshis); - ret.into() -} -#[must_use] -extern "C" fn KeysManager_KeysInterface_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn KeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ { - let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, reader.to_slice()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - diff --git a/lightning-c-bindings/src/chain/mod.rs b/lightning-c-bindings/src/chain/mod.rs deleted file mode 100644 index 26ea054..0000000 --- a/lightning-c-bindings/src/chain/mod.rs +++ /dev/null @@ -1,432 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 chainmonitor; -pub mod channelmonitor; -pub mod transaction; -pub mod keysinterface; -/// An error when accessing the chain via [`Access`]. -#[must_use] -#[derive(Clone)] -#[repr(C)] -pub enum AccessError { - /// The requested chain is unknown. - UnknownChain, - /// The requested transaction doesn't exist or hasn't confirmed. - UnknownTx, -} -use lightning::chain::AccessError as nativeAccessError; -impl AccessError { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeAccessError { - match self { - AccessError::UnknownChain => nativeAccessError::UnknownChain, - AccessError::UnknownTx => nativeAccessError::UnknownTx, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeAccessError { - match self { - AccessError::UnknownChain => nativeAccessError::UnknownChain, - AccessError::UnknownTx => nativeAccessError::UnknownTx, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeAccessError) -> Self { - match native { - nativeAccessError::UnknownChain => AccessError::UnknownChain, - nativeAccessError::UnknownTx => AccessError::UnknownTx, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeAccessError) -> Self { - match native { - nativeAccessError::UnknownChain => AccessError::UnknownChain, - nativeAccessError::UnknownTx => AccessError::UnknownTx, - } - } -} -/// Creates a copy of the AccessError -#[no_mangle] -pub extern "C" fn AccessError_clone(orig: &AccessError) -> AccessError { - orig.clone() -} -/// The `Access` trait defines behavior for accessing chain data and state, such as blocks and -/// UTXOs. -#[repr(C)] -pub struct Access { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. - /// Returns an error if `genesis_hash` is for a different chain or if such a transaction output - /// is unknown. - /// - /// [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id - #[must_use] - pub get_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: *const [u8; 32], short_channel_id: u64) -> crate::c_types::derived::CResult_TxOutAccessErrorZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for Access {} -unsafe impl Sync for Access {} - -use lightning::chain::Access as rustAccess; -impl rustAccess for Access { - fn get_utxo(&self, genesis_hash: &bitcoin::hash_types::BlockHash, short_channel_id: u64) -> Result { - let mut ret = (self.get_utxo)(self.this_arg, genesis_hash.as_inner(), short_channel_id); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).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 Access { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn Access_free(this_ptr: Access) { } -impl Drop for Access { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// The `Listen` trait is used to be notified of when blocks have been connected or disconnected -/// from the chain. -/// -/// Useful when needing to replay chain data upon startup or as new chain events occur. -#[repr(C)] -pub struct Listen { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Notifies the listener that a block was added at the given height. - pub block_connected: extern "C" fn (this_arg: *const c_void, block: crate::c_types::u8slice, height: u32), - /// Notifies the listener that a block was removed at the given height. - pub block_disconnected: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], height: u32), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} - -use lightning::chain::Listen as rustListen; -impl rustListen for Listen { - fn block_connected(&self, block: &bitcoin::blockdata::block::Block, height: u32) { - let mut local_block = ::bitcoin::consensus::encode::serialize(block); - (self.block_connected)(self.this_arg, crate::c_types::u8slice::from_slice(&local_block), height) - } - fn block_disconnected(&self, header: &bitcoin::blockdata::block::BlockHeader, 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, 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 Listen { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn Listen_free(this_ptr: Listen) { } -impl Drop for Listen { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as -/// blocks are connected and disconnected. -/// -/// Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are -/// responsible for maintaining a set of monitors such that they can be updated accordingly as -/// channel state changes and HTLCs are resolved. See method documentation for specific -/// requirements. -/// -/// Implementations **must** ensure that updates are successfully applied and persisted upon method -/// completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down -/// without taking any further action such as persisting the current state. -/// -/// If an implementation maintains multiple instances of a channel's monitor (e.g., by storing -/// backup copies), then it must ensure that updates are applied across all instances. Otherwise, it -/// could result in a revoked transaction being broadcast, allowing the counterparty to claim all -/// funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle -/// multiple instances. -/// -/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor -/// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr -/// [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure -#[repr(C)] -pub struct Watch { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Watches a channel identified by `funding_txo` using `monitor`. - /// - /// Implementations are responsible for watching the chain for the funding transaction along - /// with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means - /// calling [`block_connected`] and [`block_disconnected`] on the monitor. - /// - /// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch - /// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected - /// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected - #[must_use] - pub watch_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, - /// Updates a channel identified by `funding_txo` by applying `update` to its monitor. - /// - /// Implementations must call [`update_monitor`] with the given update. See - /// [`ChannelMonitorUpdateErr`] for invariants around returning an error. - /// - /// [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor - /// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr - #[must_use] - pub update_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, update: crate::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, - /// Returns any monitor events since the last call. Subsequent calls must only return new - /// events. - #[must_use] - pub release_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for Watch {} -unsafe impl Sync for Watch {} - -use lightning::chain::Watch as rustWatch; -impl rustWatch for Watch { - fn watch_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { - let mut ret = (self.watch_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::chain::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(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; - local_ret - } - fn update_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, update: lightning::chain::channelmonitor::ChannelMonitorUpdate) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { - let mut ret = (self.update_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::chain::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(update)), is_owned: true }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; - local_ret - } - fn release_pending_monitor_events(&self) -> Vec { - let mut ret = (self.release_pending_monitor_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 Watch { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn Watch_free(this_ptr: Watch) { } -impl Drop for Watch { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// The `Filter` trait defines behavior for indicating chain activity of interest pertaining to -/// channels. -/// -/// This is useful in order to have a [`Watch`] implementation convey to a chain source which -/// transactions to be notified of. Notification may take the form of pre-filtering blocks or, in -/// the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If -/// receiving full blocks from a chain source, any further filtering is unnecessary. -/// -/// After an output has been registered, subsequent block retrievals from the chain source must not -/// exclude any transactions matching the new criteria nor any in-block descendants of such -/// transactions. -/// -/// Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` -/// should not block on I/O. Implementations should instead queue the newly monitored data to be -/// processed later. Then, in order to block until the data has been processed, any [`Watch`] -/// invocation that has called the `Filter` must return [`TemporaryFailure`]. -/// -/// [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure -/// [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki -/// [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki -#[repr(C)] -pub struct Filter { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as - /// a spending condition. - pub register_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pubkey: crate::c_types::u8slice), - /// Registers interest in spends of a transaction output. - /// - /// Optionally, when `output.block_hash` is set, should return any transaction spending the - /// output that is found in the corresponding block along with its index. - /// - /// This return value is useful for Electrum clients in order to supply in-block descendant - /// transactions which otherwise were not included. This is not necessary for other clients if - /// such descendant transactions were already included (e.g., when a BIP 157 client provides the - /// full block). - #[must_use] - pub register_output: extern "C" fn (this_arg: *const c_void, output: crate::chain::WatchedOutput) -> crate::c_types::derived::COption_C2Tuple_usizeTransactionZZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for Filter {} -unsafe impl Sync for Filter {} - -use lightning::chain::Filter as rustFilter; -impl rustFilter for Filter { - fn register_tx(&self, txid: &bitcoin::hash_types::Txid, script_pubkey: &bitcoin::blockdata::script::Script) { - (self.register_tx)(self.this_arg, txid.as_inner(), crate::c_types::u8slice::from_slice(&script_pubkey[..])) - } - fn register_output(&self, output: lightning::chain::WatchedOutput) -> Option<(usize, bitcoin::blockdata::transaction::Transaction)> { - let mut ret = (self.register_output)(self.this_arg, crate::chain::WatchedOutput { inner: Box::into_raw(Box::new(output)), is_owned: true }); - let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_bitcoin()); local_ret_0 }) } else { None }; - 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 Filter { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn Filter_free(this_ptr: Filter) { } -impl Drop for Filter { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} - -use lightning::chain::WatchedOutput as nativeWatchedOutputImport; -type nativeWatchedOutput = nativeWatchedOutputImport; - -/// A transaction output watched by a [`ChannelMonitor`] for spends on-chain. -/// -/// Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction -/// spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via -/// the return value of [`Filter::register_output`]. -/// -/// If `block_hash` is `Some`, this indicates the output was created in the corresponding block and -/// may have been spent there. See [`Filter::register_output`] for details. -/// -/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor -/// [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected -#[must_use] -#[repr(C)] -pub struct WatchedOutput { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeWatchedOutput, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for WatchedOutput { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeWatchedOutput>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn WatchedOutput_free(this_obj: WatchedOutput) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn WatchedOutput_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWatchedOutput); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl WatchedOutput { - pub(crate) fn take_inner(mut self) -> *mut nativeWatchedOutput { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// First block where the transaction output may have been spent. -#[no_mangle] -pub extern "C" fn WatchedOutput_get_block_hash(this_ptr: &WatchedOutput) -> crate::c_types::ThirtyTwoBytes { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.block_hash; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (inner_val.unwrap()).into_inner() } } }; - local_inner_val -} -/// First block where the transaction output may have been spent. -#[no_mangle] -pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut val: crate::c_types::ThirtyTwoBytes) { - let mut local_val = if val.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap() }) }; - unsafe { &mut *this_ptr.inner }.block_hash = local_val; -} -/// Outpoint identifying the transaction output. -#[no_mangle] -pub extern "C" fn WatchedOutput_get_outpoint(this_ptr: &WatchedOutput) -> crate::chain::transaction::OutPoint { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; - crate::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// Outpoint identifying the transaction output. -#[no_mangle] -pub extern "C" fn WatchedOutput_set_outpoint(this_ptr: &mut WatchedOutput, mut val: crate::chain::transaction::OutPoint) { - unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Spending condition of the transaction output. -#[no_mangle] -pub extern "C" fn WatchedOutput_get_script_pubkey(this_ptr: &WatchedOutput) -> crate::c_types::u8slice { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.script_pubkey; - crate::c_types::u8slice::from_slice(&(*inner_val)[..]) -} -/// Spending condition of the transaction output. -#[no_mangle] -pub extern "C" fn WatchedOutput_set_script_pubkey(this_ptr: &mut WatchedOutput, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *this_ptr.inner }.script_pubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust()); -} -/// Constructs a new WatchedOutput given each field -#[must_use] -#[no_mangle] -pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::ThirtyTwoBytes, mut outpoint_arg: crate::chain::transaction::OutPoint, mut script_pubkey_arg: crate::c_types::derived::CVec_u8Z) -> WatchedOutput { - let mut local_block_hash_arg = if block_hash_arg.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&block_hash_arg.data[..]).unwrap() }) }; - WatchedOutput { inner: Box::into_raw(Box::new(nativeWatchedOutput { - block_hash: local_block_hash_arg, - outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - script_pubkey: ::bitcoin::blockdata::script::Script::from(script_pubkey_arg.into_rust()), - })), is_owned: true } -} diff --git a/lightning-c-bindings/src/chain/transaction.rs b/lightning-c-bindings/src/chain/transaction.rs deleted file mode 100644 index cf9fdee..0000000 --- a/lightning-c-bindings/src/chain/transaction.rs +++ /dev/null @@ -1,136 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Types describing on-chain transactions. - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeOutPoint, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for OutPoint { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeOutPoint>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn OutPoint_free(this_obj: 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_inner(mut self) -> *mut nativeOutPoint { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -/// Constructs a new OutPoint given each field -#[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 } -} -impl Clone for OutPoint { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeOutPoint>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the OutPoint -pub extern "C" fn OutPoint_clone(orig: &OutPoint) -> OutPoint { - orig.clone() -} -/// 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] -/// Serialize the OutPoint object into a byte array which can be read by OutPoint_read -pub extern "C" fn OutPoint_write(obj: &OutPoint) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn OutPoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOutPoint) }) -} -#[no_mangle] -/// Read a OutPoint from a byte array, created by OutPoint_write -pub extern "C" fn OutPoint_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OutPointDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} diff --git a/lightning-c-bindings/src/lib.rs b/lightning-c-bindings/src/lib.rs index 9fffc70..bb89e18 100644 --- a/lightning-c-bindings/src/lib.rs +++ b/lightning-c-bindings/src/lib.rs @@ -6,15 +6,7 @@ // license as that which applies to the original source files from which this // source was automatically generated. -//!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. +//! C Bindings #![allow(unknown_lints)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] @@ -27,7 +19,4 @@ #![deny(missing_docs)] pub mod c_types; pub mod bitcoin; -pub mod util; -pub mod chain; -pub mod ln; -pub mod routing; +pub mod lightning; diff --git a/lightning-c-bindings/src/lightning/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs new file mode 100644 index 0000000..9b8e84b --- /dev/null +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -0,0 +1,169 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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::*; + +/// An interface to send a transaction to the Bitcoin network. +#[repr(C)] +pub struct BroadcasterInterface { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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), + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +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_vec(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); + } + } +} +/// 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, + } + } +} +/// Creates a copy of the ConfirmationTarget +#[no_mangle] +pub extern "C" fn ConfirmationTarget_clone(orig: &ConfirmationTarget) -> ConfirmationTarget { + orig.clone() +} +/// 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 chain events, P2P events, or timer events). +#[repr(C)] +pub struct FeeEstimator { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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::lightning::chain::chaininterface::ConfirmationTarget) -> u32, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +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::lightning::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); + } + } +} +/// Minimum relay fee as required by bitcoin network mempool policy. + +#[no_mangle] +pub static MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = lightning::chain::chaininterface::MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; diff --git a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs new file mode 100644 index 0000000..3e237df --- /dev/null +++ b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs @@ -0,0 +1,250 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Logic to connect off-chain channel management with on-chain transaction monitoring. +//! +//! [`ChainMonitor`] is an implementation of [`chain::Watch`] used both to process blocks and to +//! update [`ChannelMonitor`]s accordingly. If any on-chain events need further processing, it will +//! make those available as [`MonitorEvent`]s to be consumed. +//! +//! [`ChainMonitor`] is parameterized by an optional chain source, which must implement the +//! [`chain::Filter`] trait. This provides a mechanism to signal new relevant outputs back to light +//! clients, such that transactions spending those outputs are included in block data. +//! +//! [`ChainMonitor`] may be used directly to monitor channels locally or as a part of a distributed +//! setup to monitor channels remotely. In the latter case, a custom [`chain::Watch`] implementation +//! would be responsible for routing each update to a remote server and for retrieving monitor +//! events. The remote server would make use of [`ChainMonitor`] for block processing and for +//! servicing [`ChannelMonitor`] updates from the client. + +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + + +use lightning::chain::chainmonitor::ChainMonitor as nativeChainMonitorImport; +type nativeChainMonitor = nativeChainMonitorImport; + +/// An implementation of [`chain::Watch`] for monitoring channels. +/// +/// Connected and disconnected blocks must be provided to `ChainMonitor` as documented by +/// [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally +/// or used independently to monitor channels remotely. See the [module-level documentation] for +/// details. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +/// [module-level documentation]: crate::chain::chainmonitor +#[must_use] +#[repr(C)] +pub struct ChainMonitor { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChainMonitor, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChainMonitor { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChainMonitor>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChainMonitor, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChainMonitor_free(this_obj: ChainMonitor) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ChainMonitor_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainMonitor); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ChainMonitor { + pub(crate) fn take_inner(mut self) -> *mut nativeChainMonitor { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view +/// of a channel and reacting accordingly based on transactions in the connected block. See +/// [`ChannelMonitor::block_connected`] for details. Any HTLCs that were resolved on chain will +/// be returned by [`chain::Watch::release_pending_monitor_events`]. +/// +/// Calls back to [`chain::Filter`] if any monitor indicated new outputs to watch. Subsequent +/// calls must not exclude any transactions matching the new outputs nor any in-block +/// descendants of such transactions. It is not necessary to re-fetch the block to obtain +/// updated `txdata`. +#[no_mangle] +pub extern "C" fn ChainMonitor_block_connected(this_arg: &ChainMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) +} + +/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view +/// of a channel and reacting accordingly to newly confirmed transactions. For details, see +/// [`ChannelMonitor::transactions_confirmed`]. +/// +/// Used instead of [`block_connected`] by clients that are notified of transactions rather than +/// blocks. May be called before or after [`update_best_block`] for transactions in the +/// corresponding block. See [`update_best_block`] for further calling expectations. +/// +/// [`block_connected`]: Self::block_connected +/// [`update_best_block`]: Self::update_best_block +#[no_mangle] +pub extern "C" fn ChainMonitor_transactions_confirmed(this_arg: &ChainMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + unsafe { &*this_arg.inner }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) +} + +/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view +/// of a channel and reacting accordingly based on the new chain tip. For details, see +/// [`ChannelMonitor::update_best_block`]. +/// +/// Used instead of [`block_connected`] by clients that are notified of transactions rather than +/// blocks. May be called before or after [`transactions_confirmed`] for the corresponding +/// block. +/// +/// Must be called after new blocks become available for the most recent block. Intermediary +/// blocks, however, may be safely skipped. In the event of a chain re-organization, this only +/// needs to be called for the most recent block assuming `transaction_unconfirmed` is called +/// for any affected transactions. +/// +/// [`block_connected`]: Self::block_connected +/// [`transactions_confirmed`]: Self::transactions_confirmed +/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed +#[no_mangle] +pub extern "C" fn ChainMonitor_update_best_block(this_arg: &ChainMonitor, header: *const [u8; 80], mut height: u32) { + unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +} + +/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view +/// of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for +/// details. +#[no_mangle] +pub extern "C" fn ChainMonitor_block_disconnected(this_arg: &ChainMonitor, header: *const [u8; 80], mut disconnected_height: u32) { + unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), disconnected_height) +} + +/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view +/// of a channel based on transactions unconfirmed as a result of a chain reorganization. See +/// [`ChannelMonitor::transaction_unconfirmed`] for details. +/// +/// Used instead of [`block_disconnected`] by clients that are notified of transactions rather +/// than blocks. May be called before or after [`update_best_block`] for transactions in the +/// corresponding block. See [`update_best_block`] for further calling expectations. +/// +/// [`block_disconnected`]: Self::block_disconnected +/// [`update_best_block`]: Self::update_best_block +#[no_mangle] +pub extern "C" fn ChainMonitor_transaction_unconfirmed(this_arg: &ChainMonitor, txid: *const [u8; 32]) { + unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) +} + +/// Returns the set of txids that should be monitored for re-organization out of the chain. +#[must_use] +#[no_mangle] +pub extern "C" fn ChainMonitor_get_relevant_txids(this_arg: &ChainMonitor) -> crate::c_types::derived::CVec_TxidZ { + let mut ret = unsafe { &*this_arg.inner }.get_relevant_txids(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; + local_ret.into() +} + +/// Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. +/// +/// When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor +/// will call back to it indicating transactions and outputs of interest. This allows clients to +/// pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may +/// always need to fetch full blocks absent another means for determining which blocks contain +/// transactions relevant to the watched channels. +#[must_use] +#[no_mangle] +pub extern "C" fn ChainMonitor_new(chain_source: *mut crate::lightning::chain::Filter, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut logger: crate::lightning::util::logger::Logger, mut feeest: crate::lightning::chain::chaininterface::FeeEstimator, mut persister: crate::lightning::chain::channelmonitor::Persist) -> ChainMonitor { + let mut local_chain_source = if chain_source == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_source) } }) }; + let mut ret = lightning::chain::chainmonitor::ChainMonitor::new(local_chain_source, broadcaster, logger, feeest, persister); + ChainMonitor { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +impl From for crate::lightning::chain::Watch { + fn from(obj: nativeChainMonitor) -> Self { + let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChainMonitor_as_Watch(&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(ChainMonitor_free_void); + ret + } +} +/// Constructs a new Watch which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChainMonitor_as_Watch(this_arg: &ChainMonitor) -> crate::lightning::chain::Watch { + crate::lightning::chain::Watch { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + watch_channel: ChainMonitor_Watch_watch_channel, + update_channel: ChainMonitor_Watch_update_channel, + release_pending_monitor_events: ChainMonitor_Watch_release_pending_monitor_events, + } +} + +#[must_use] +extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_outpoint: crate::lightning::chain::transaction::OutPoint, mut monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ { + let mut ret = >::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_outpoint.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::chain::channelmonitor::ChannelMonitorUpdateErr::native_into(e) }).into() }; + local_ret +} +#[must_use] +extern "C" fn ChainMonitor_Watch_update_channel(this_arg: *const c_void, mut funding_txo: crate::lightning::chain::transaction::OutPoint, mut update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ { + let mut ret = >::update_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(update.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::chain::channelmonitor::ChannelMonitorUpdateErr::native_into(e) }).into() }; + local_ret +} +#[must_use] +extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ { + let mut ret = >::release_pending_monitor_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::chain::channelmonitor::MonitorEvent::native_into(item) }); }; + local_ret.into() +} + +impl From for crate::lightning::util::events::EventsProvider { + fn from(obj: nativeChainMonitor) -> Self { + let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChainMonitor_as_EventsProvider(&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(ChainMonitor_free_void); + ret + } +} +/// Constructs a new EventsProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChainMonitor_as_EventsProvider(this_arg: &ChainMonitor) -> crate::lightning::util::events::EventsProvider { + crate::lightning::util::events::EventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_events: ChainMonitor_EventsProvider_get_and_clear_pending_events, + } +} + +#[must_use] +extern "C" fn ChainMonitor_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ { + let mut ret = >::get_and_clear_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::Event::native_into(item) }); }; + local_ret.into() +} + diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs new file mode 100644 index 0000000..2c4c5c3 --- /dev/null +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -0,0 +1,825 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 [`chain::Watch`] 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::chain::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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelMonitorUpdate, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelMonitorUpdate { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelMonitorUpdate>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelMonitorUpdate_free(this_obj: 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_inner(mut self) -> *mut nativeChannelMonitorUpdate { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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, with one exception specified below. +/// +/// 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. +/// +/// The only instance where update_id values are not strictly increasing is the case where we +/// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See +/// its docs for more details. +#[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, with one exception specified below. +/// +/// 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. +/// +/// The only instance where update_id values are not strictly increasing is the case where we +/// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See +/// its docs for more details. +#[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; +} +impl Clone for ChannelMonitorUpdate { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelMonitorUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ChannelMonitorUpdate +pub extern "C" fn ChannelMonitorUpdate_clone(orig: &ChannelMonitorUpdate) -> ChannelMonitorUpdate { + orig.clone() +} +/// If: +/// (1) a channel has been force closed and +/// (2) we receive a preimage from a forward link that allows us to spend an HTLC output on +/// this channel's (the backward link's) broadcasted commitment transaction +/// then we allow the `ChannelManager` to send a `ChannelMonitorUpdate` with this update ID, +/// with the update providing said payment preimage. No other update types are allowed after +/// force-close. + +#[no_mangle] +pub static CLOSED_CHANNEL_UPDATE_ID: u64 = lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID; +#[no_mangle] +/// Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read +pub extern "C" fn ChannelMonitorUpdate_write(obj: &ChannelMonitorUpdate) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelMonitorUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitorUpdate) }) +} +#[no_mangle] +/// Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write +pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelMonitorUpdateDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +/// 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 counterparty. 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). + /// + /// At reception of this error, ChannelManager will force-close the channel and return at + /// least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at + /// least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel + /// update must be rejected. + /// + /// This failure may also signal a failure to update the local persisted copy of one of + /// the channel monitor instance. + /// + /// Note that even when you fail a holder commitment transaction update, you must store the + /// update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor + /// broadcasts it (e.g distributed channel-monitor deployment) + /// + /// In case of distributed watchtowers deployment, the new version must be written to disk, as + /// state may have been stored but rejected due to a block forcing a commitment broadcast. This + /// storage is used to claim outputs of rejected state confirmed onchain by another watchtower, + /// lagging behind on block processing. + PermanentFailure, +} +use lightning::chain::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, + } + } +} +/// Creates a copy of the ChannelMonitorUpdateErr +#[no_mangle] +pub extern "C" fn ChannelMonitorUpdateErr_clone(orig: &ChannelMonitorUpdateErr) -> ChannelMonitorUpdateErr { + orig.clone() +} + +use lightning::chain::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 developer-readable error message. +#[must_use] +#[repr(C)] +pub struct MonitorUpdateError { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeMonitorUpdateError, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for MonitorUpdateError { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeMonitorUpdateError>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn MonitorUpdateError_free(this_obj: 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_inner(mut self) -> *mut nativeMonitorUpdateError { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for MonitorUpdateError { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeMonitorUpdateError>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 MonitorUpdateError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeMonitorUpdateError)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the MonitorUpdateError +pub extern "C" fn MonitorUpdateError_clone(orig: &MonitorUpdateError) -> MonitorUpdateError { + orig.clone() +} +/// An event to be processed by the ChannelManager. +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum MonitorEvent { + /// A monitor event containing an HTLCUpdate. + HTLCEvent(crate::lightning::chain::channelmonitor::HTLCUpdate), + /// A monitor event that the Channel's commitment transaction was broadcasted. + CommitmentTxBroadcasted(crate::lightning::chain::transaction::OutPoint), +} +use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEvent; +impl MonitorEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMonitorEvent { + match self { + MonitorEvent::HTLCEvent (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeMonitorEvent::HTLCEvent ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + MonitorEvent::CommitmentTxBroadcasted (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeMonitorEvent::CommitmentTxBroadcasted ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMonitorEvent { + match self { + MonitorEvent::HTLCEvent (mut a, ) => { + nativeMonitorEvent::HTLCEvent ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + MonitorEvent::CommitmentTxBroadcasted (mut a, ) => { + nativeMonitorEvent::CommitmentTxBroadcasted ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeMonitorEvent) -> Self { + match native { + nativeMonitorEvent::HTLCEvent (ref a, ) => { + let mut a_nonref = (*a).clone(); + MonitorEvent::HTLCEvent ( + crate::lightning::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeMonitorEvent::CommitmentTxBroadcasted (ref a, ) => { + let mut a_nonref = (*a).clone(); + MonitorEvent::CommitmentTxBroadcasted ( + crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMonitorEvent) -> Self { + match native { + nativeMonitorEvent::HTLCEvent (mut a, ) => { + MonitorEvent::HTLCEvent ( + crate::lightning::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeMonitorEvent::CommitmentTxBroadcasted (mut a, ) => { + MonitorEvent::CommitmentTxBroadcasted ( + crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the MonitorEvent +#[no_mangle] +pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { } +/// Creates a copy of the MonitorEvent +#[no_mangle] +pub extern "C" fn MonitorEvent_clone(orig: &MonitorEvent) -> MonitorEvent { + orig.clone() +} + +use lightning::chain::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport; +type nativeHTLCUpdate = nativeHTLCUpdateImport; + +/// 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. +#[must_use] +#[repr(C)] +pub struct HTLCUpdate { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeHTLCUpdate, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for HTLCUpdate { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeHTLCUpdate>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn HTLCUpdate_free(this_obj: 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_inner(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: if <*mut nativeHTLCUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + 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] +/// Creates a copy of the HTLCUpdate +pub extern "C" fn HTLCUpdate_clone(orig: &HTLCUpdate) -> HTLCUpdate { + orig.clone() +} +#[no_mangle] +/// Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read +pub extern "C" fn HTLCUpdate_write(obj: &HTLCUpdate) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn HTLCUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCUpdate) }) +} +#[no_mangle] +/// Read a HTLCUpdate from a byte array, created by HTLCUpdate_write +pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HTLCUpdateDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport; +type nativeChannelMonitor = nativeChannelMonitorImport; + +/// 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. +/// +/// Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which +/// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along +/// the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the +/// returned block hash and the the current chain and then reconnecting blocks to get to the +/// best chain) upon deserializing the object! +#[must_use] +#[repr(C)] +pub struct ChannelMonitor { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelMonitor, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelMonitor { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelMonitor>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelMonitor_free(this_obj: 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_inner(mut self) -> *mut nativeChannelMonitor { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +#[no_mangle] +/// Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read +pub extern "C" fn ChannelMonitor_write(obj: &ChannelMonitor) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelMonitor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitor) }) +} +/// 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: &ChannelMonitor, updates: &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::lightning::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::lightning::chain::chaininterface::FeeEstimator, logger: &crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ { + let mut ret = unsafe { &*this_arg.inner }.update_monitor(unsafe { &*updates.inner }, broadcaster, fee_estimator, logger); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::chain::channelmonitor::MonitorUpdateError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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 (mut orig_ret_0, mut orig_ret_1) = ret; let mut local_ret = (crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(orig_ret_0)), is_owned: true }, orig_ret_1.into_bytes().into()).into(); + local_ret +} + +/// Gets a list of txids, with their output scripts (in the order they appear in the +/// transaction), which we must learn about spends of via block_connected(). +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_get_outputs_to_watch(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + let mut ret = unsafe { &*this_arg.inner }.get_outputs_to_watch(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, orig_orig_ret_0_1_0_1.into_bytes().into()).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + local_ret.into() +} + +/// Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly +/// calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs +/// have been registered. +#[no_mangle] +pub extern "C" fn ChannelMonitor_load_outputs_to_watch(this_arg: &ChannelMonitor, filter: &crate::lightning::chain::Filter) { + unsafe { &*this_arg.inner }.load_outputs_to_watch(filter) +} + +/// Get the list of HTLCs who's status has been updated on chain. This should be called by +/// ChannelManager via [`chain::Watch::release_pending_monitor_events`]. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ { + let mut ret = unsafe { &*this_arg.inner }.get_and_clear_pending_monitor_events(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::chain::channelmonitor::MonitorEvent::native_into(item) }); }; + 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 ChainMonitor::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: &ChannelMonitor) -> crate::c_types::derived::CVec_EventZ { + let mut ret = unsafe { &*this_arg.inner }.get_and_clear_pending_events(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::Event::native_into(item) }); }; + local_ret.into() +} + +/// Used by ChannelManager deserialization to broadcast the latest holder state if its copy of +/// the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of +/// fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows +/// a higher revocation secret than the holder commitment number we are aware of. Broadcasting these +/// transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to +/// broadcast them if counterparty 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_holder_commitment_txn(this_arg: &ChannelMonitor, logger: &crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ { + let mut ret = unsafe { &*this_arg.inner }.get_latest_holder_commitment_txn(logger); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); }; + local_ret.into() +} + +/// Processes transactions in a newly connected block, which may result in any of the following: +/// - update the monitor's state against resolved HTLCs +/// - punish the counterparty in the case of seeing a revoked commitment transaction +/// - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration +/// - detect settled outputs for later spending +/// - schedule and bump any in-flight claims +/// +/// Returns any new outputs to watch from `txdata`; after called, these are also included in +/// [`get_outputs_to_watch`]. +/// +/// [`get_outputs_to_watch`]: #method.get_outputs_to_watch +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_block_connected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + let mut ret = unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + local_ret.into() +} + +/// Determines if the disconnected block contained any transactions of interest and updates +/// appropriately. +#[no_mangle] +pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) { + unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger) +} + +/// Processes transactions confirmed in a block with the given header and height, returning new +/// outputs to watch. See [`block_connected`] for details. +/// +/// Used instead of [`block_connected`] by clients that are notified of transactions rather than +/// blocks. May be called before or after [`update_best_block`] for transactions in the +/// corresponding block. See [`update_best_block`] for further calling expectations. +/// +/// [`block_connected`]: Self::block_connected +/// [`update_best_block`]: Self::update_best_block +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_transactions_confirmed(this_arg: &ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + let mut ret = unsafe { &*this_arg.inner }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + local_ret.into() +} + +/// Processes a transaction that was reorganized out of the chain. +/// +/// Used instead of [`block_disconnected`] by clients that are notified of transactions rather +/// than blocks. May be called before or after [`update_best_block`] for transactions in the +/// corresponding block. See [`update_best_block`] for further calling expectations. +/// +/// [`block_disconnected`]: Self::block_disconnected +/// [`update_best_block`]: Self::update_best_block +#[no_mangle] +pub extern "C" fn ChannelMonitor_transaction_unconfirmed(this_arg: &ChannelMonitor, txid: *const [u8; 32], mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) { + unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap(), broadcaster, fee_estimator, logger) +} + +/// Updates the monitor with the current best chain tip, returning new outputs to watch. See +/// [`block_connected`] for details. +/// +/// Used instead of [`block_connected`] by clients that are notified of transactions rather than +/// blocks. May be called before or after [`transactions_confirmed`] for the corresponding +/// block. +/// +/// Must be called after new blocks become available for the most recent block. Intermediary +/// blocks, however, may be safely skipped. In the event of a chain re-organization, this only +/// needs to be called for the most recent block assuming `transaction_unconfirmed` is called +/// for any affected transactions. +/// +/// [`block_connected`]: Self::block_connected +/// [`transactions_confirmed`]: Self::transactions_confirmed +/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_update_best_block(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { + let mut ret = unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + local_ret.into() +} + +/// Returns the set of txids that should be monitored for re-organization out of the chain. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_TxidZ { + let mut ret = unsafe { &*this_arg.inner }.get_relevant_txids(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; + local_ret.into() +} + +/// `Persist` defines behavior for persisting channel monitors: this could mean +/// writing once to disk, and/or uploading to one or more backup services. +/// +/// Note that for every new monitor, you **must** persist the new `ChannelMonitor` +/// to disk/backups. And, on every update, you **must** persist either the +/// `ChannelMonitorUpdate` or the updated monitor itself. Otherwise, there is risk +/// of situations such as revoking a transaction, then crashing before this +/// revocation can be persisted, then unintentionally broadcasting a revoked +/// transaction and losing money. This is a risk because previous channel states +/// are toxic, so it's important that whatever channel state is persisted is +/// kept up-to-date. +#[repr(C)] +pub struct Persist { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Persist a new channel's data. The data can be stored any way you want, but + /// the identifier provided by Rust-Lightning is the channel's outpoint (and + /// it is up to you to maintain a correct mapping between the outpoint and the + /// stored channel data). Note that you **must** persist every new monitor to + /// disk. See the `Persist` trait documentation for more details. + /// + /// See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, + /// and [`ChannelMonitorUpdateErr`] for requirements when returning errors. + #[must_use] + pub persist_new_channel: extern "C" fn (this_arg: *const c_void, id: crate::lightning::chain::transaction::OutPoint, data: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, + /// Update one channel's data. The provided `ChannelMonitor` has already + /// applied the given update. + /// + /// Note that on every update, you **must** persist either the + /// `ChannelMonitorUpdate` or the updated monitor itself to disk/backups. See + /// the `Persist` trait documentation for more details. + /// + /// If an implementer chooses to persist the updates only, they need to make + /// sure that all the updates are applied to the `ChannelMonitors` *before* + /// the set of channel monitors is given to the `ChannelManager` + /// deserialization routine. See [`ChannelMonitor::update_monitor`] for + /// applying a monitor update to a monitor. If full `ChannelMonitors` are + /// persisted, then there is no need to persist individual updates. + /// + /// Note that there could be a performance tradeoff between persisting complete + /// channel monitors on every update vs. persisting only updates and applying + /// them in batches. The size of each monitor grows `O(number of state updates)` + /// whereas updates are small and `O(1)`. + /// + /// See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, + /// [`ChannelMonitorUpdate::write`] for writing out an update, and + /// [`ChannelMonitorUpdateErr`] for requirements when returning errors. + #[must_use] + pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, id: crate::lightning::chain::transaction::OutPoint, update: &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for Persist {} +unsafe impl Sync for Persist {} + +use lightning::chain::channelmonitor::Persist as rustPersist; +impl rustPersist for Persist { + fn persist_new_channel(&self, id: lightning::chain::transaction::OutPoint, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { + let mut ret = (self.persist_new_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } + fn update_persisted_channel(&self, id: lightning::chain::transaction::OutPoint, update: &lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { + let mut ret = (self.update_persisted_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (update as *const _) as *mut _ }, is_owned: false }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).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 Persist { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn Persist_free(this_ptr: Persist) { } +impl Drop for Persist { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +#[no_mangle] +/// Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg: &crate::lightning::chain::keysinterface::KeysInterface) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + let arg_conv = arg; + let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(orig_res_0_1)), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/chain/keysinterface.rs b/lightning-c-bindings/src/lightning/chain/keysinterface.rs new file mode 100644 index 0000000..dae2a63 --- /dev/null +++ b/lightning-c-bindings/src/lightning/chain/keysinterface.rs @@ -0,0 +1,1481 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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::*; + + +use lightning::chain::keysinterface::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport; +type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptorImport; + +/// Information about a spendable output to a P2WSH script. See +/// SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. +#[must_use] +#[repr(C)] +pub struct DelayedPaymentOutputDescriptor { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeDelayedPaymentOutputDescriptor, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for DelayedPaymentOutputDescriptor { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_free(this_obj: DelayedPaymentOutputDescriptor) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn DelayedPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDelayedPaymentOutputDescriptor); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl DelayedPaymentOutputDescriptor { + pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The outpoint which is spendable +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// The outpoint which is spendable +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Per commitment point to derive delayed_payment_key by key holder +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> 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)) +} +/// Per commitment point to derive delayed_payment_key by key holder +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { + unsafe { &mut *this_ptr.inner }.per_commitment_point = val.into_rust(); +} +/// The nSequence value which must be set in the spending input to satisfy the OP_CSV in +/// the witness_script. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay; + (*inner_val) +} +/// The nSequence value which must be set in the spending input to satisfy the OP_CSV in +/// the witness_script. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_to_self_delay(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u16) { + unsafe { &mut *this_ptr.inner }.to_self_delay = val; +} +/// The output which is referenced by the given outpoint +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { + unsafe { &mut *this_ptr.inner }.output = val.into_rust(); +} +/// The revocation point specific to the commitment transaction which was broadcast. Used to +/// derive the witnessScript for this output. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_pubkey; + crate::c_types::PublicKey::from_rust(&(*inner_val)) +} +/// The revocation point specific to the commitment transaction which was broadcast. Used to +/// derive the witnessScript for this output. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { + unsafe { &mut *this_ptr.inner }.revocation_pubkey = val.into_rust(); +} +/// Arbitrary identification information returned by a call to +/// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in +/// the channel to spend the output. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id; + &(*inner_val) +} +/// Arbitrary identification information returned by a call to +/// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in +/// the channel to spend the output. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.channel_keys_id = val.data; +} +/// The value of the channel which this output originated from, possibly indirectly. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis; + (*inner_val) +} +/// The value of the channel which this output originated from, possibly indirectly. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) { + unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val; +} +/// Constructs a new DelayedPaymentOutputDescriptor given each field +#[must_use] +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::c_types::PublicKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor { + DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(nativeDelayedPaymentOutputDescriptor { + outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, + per_commitment_point: per_commitment_point_arg.into_rust(), + to_self_delay: to_self_delay_arg, + output: output_arg.into_rust(), + revocation_pubkey: revocation_pubkey_arg.into_rust(), + channel_keys_id: channel_keys_id_arg.data, + channel_value_satoshis: channel_value_satoshis_arg, + })), is_owned: true } +} +impl Clone for DelayedPaymentOutputDescriptor { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 DelayedPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDelayedPaymentOutputDescriptor)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the DelayedPaymentOutputDescriptor +pub extern "C" fn DelayedPaymentOutputDescriptor_clone(orig: &DelayedPaymentOutputDescriptor) -> DelayedPaymentOutputDescriptor { + orig.clone() +} + +use lightning::chain::keysinterface::StaticPaymentOutputDescriptor as nativeStaticPaymentOutputDescriptorImport; +type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorImport; + +/// Information about a spendable output to our \"payment key\". See +/// SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this. +#[must_use] +#[repr(C)] +pub struct StaticPaymentOutputDescriptor { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeStaticPaymentOutputDescriptor, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for StaticPaymentOutputDescriptor { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_free(this_obj: StaticPaymentOutputDescriptor) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn StaticPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeStaticPaymentOutputDescriptor); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl StaticPaymentOutputDescriptor { + pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The outpoint which is spendable +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// The outpoint which is spendable +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_set_outpoint(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The output which is referenced by the given outpoint +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { + unsafe { &mut *this_ptr.inner }.output = val.into_rust(); +} +/// Arbitrary identification information returned by a call to +/// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in +/// the channel to spend the output. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id; + &(*inner_val) +} +/// Arbitrary identification information returned by a call to +/// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in +/// the channel to spend the output. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.channel_keys_id = val.data; +} +/// The value of the channel which this transactions spends. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis; + (*inner_val) +} +/// The value of the channel which this transactions spends. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: u64) { + unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val; +} +/// Constructs a new StaticPaymentOutputDescriptor given each field +#[must_use] +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> StaticPaymentOutputDescriptor { + StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(nativeStaticPaymentOutputDescriptor { + outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, + output: output_arg.into_rust(), + channel_keys_id: channel_keys_id_arg.data, + channel_value_satoshis: channel_value_satoshis_arg, + })), is_owned: true } +} +impl Clone for StaticPaymentOutputDescriptor { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 StaticPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeStaticPaymentOutputDescriptor)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the StaticPaymentOutputDescriptor +pub extern "C" fn StaticPaymentOutputDescriptor_clone(orig: &StaticPaymentOutputDescriptor) -> StaticPaymentOutputDescriptor { + orig.clone() +} +/// 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 directly, either from + /// `get_destination_script()` or `get_shutdown_pubkey()`, thus you should already know how to + /// spend it. No secret keys are provided as rust-lightning was never given any key. + /// 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 { + /// The outpoint which is spendable + outpoint: crate::lightning::chain::transaction::OutPoint, + /// The output which is referenced by the given 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: + /// (MINIMALIF standard rule) + /// + /// 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 + /// Sign::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 + /// Sign::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 Sign::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. + DelayedPaymentOutput(crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor), + /// An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which + /// corresponds to the public key in Sign::pubkeys().payment_point). + /// The witness in the spending input, is, thus, simply: + /// + /// + /// These are generally the result of our counterparty having broadcast the current state, + /// allowing us to claim the non-HTLC-encumbered outputs immediately. + StaticPaymentOutput(crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor), +} +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_inner()) }, + output: output_nonref.into_rust(), + } + }, + SpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeSpendableOutputDescriptor::DelayedPaymentOutput ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + SpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeSpendableOutputDescriptor::StaticPaymentOutput ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[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_inner()) }, + output: output.into_rust(), + } + }, + SpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { + nativeSpendableOutputDescriptor::DelayedPaymentOutput ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + SpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { + nativeSpendableOutputDescriptor::StaticPaymentOutput ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[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::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint_nonref)), is_owned: true }, + output: crate::c_types::TxOut::from_rust(output_nonref), + } + }, + nativeSpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { + let mut a_nonref = (*a).clone(); + SpendableOutputDescriptor::DelayedPaymentOutput ( + crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeSpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { + let mut a_nonref = (*a).clone(); + SpendableOutputDescriptor::StaticPaymentOutput ( + crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeSpendableOutputDescriptor) -> Self { + match native { + nativeSpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => { + SpendableOutputDescriptor::StaticOutput { + outpoint: crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint)), is_owned: true }, + output: crate::c_types::TxOut::from_rust(output), + } + }, + nativeSpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { + SpendableOutputDescriptor::DelayedPaymentOutput ( + crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeSpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { + SpendableOutputDescriptor::StaticPaymentOutput ( + crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the SpendableOutputDescriptor +#[no_mangle] +pub extern "C" fn SpendableOutputDescriptor_free(this_ptr: SpendableOutputDescriptor) { } +/// Creates a copy of the SpendableOutputDescriptor +#[no_mangle] +pub extern "C" fn SpendableOutputDescriptor_clone(orig: &SpendableOutputDescriptor) -> SpendableOutputDescriptor { + orig.clone() +} +#[no_mangle] +/// Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read +pub extern "C" fn SpendableOutputDescriptor_write(obj: &SpendableOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write +pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpendableOutputDescriptorDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +/// A trait to sign lightning channel transactions as described in BOLT 3. +/// +/// Signing services could be implemented on a hardware wallet. In this case, +/// the current Sign 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. +#[repr(C)] +pub struct BaseSign { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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. + #[must_use] + pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes, + /// Gets the holder's channel public keys and basepoints + pub pubkeys: crate::lightning::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, + /// Gets an arbitrary identifier describing the set of keys which are provided back to you in + /// some SpendableOutputDescriptor types. This should be sufficient to identify this + /// Sign object uniquely and lookup or re-derive its keys. + #[must_use] + pub channel_keys_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, + /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions. + /// + /// Note that if signing fails or is rejected, the channel will be force-closed. + #[must_use] + pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, + /// Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. + /// This will only ever be called with a non-revoked commitment_tx. This will be called with the + /// latest commitment_tx when we initiate a force-close. + /// This will be called with the previous latest, just to get claiming HTLC signatures, if we are + /// reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to + /// the latest. + /// This may be called multiple times for the same transaction. + /// + /// An external signer implementation should check that the commitment has not been revoked. + /// + /// May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. + #[must_use] + pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, + /// 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 _holder_ secret key and does + /// not allow the spending of any funds by itself (you need our holder 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::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Create a signature for a claiming transaction for a HTLC output on a counterparty's 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_counterparty_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::lightning::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::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Set the counterparty static channel data, including basepoints, + /// counterparty_selected/holder_selected_contest_delay and funding outpoint. + /// This is done as soon as the funding outpoint is known. Since these are static channel data, + /// they MUST NOT be allowed to change to different values once set. + /// + /// channel_parameters.is_populated() MUST be true. + /// + /// We bind holder_selected_contest_delay late here for API convenience. + /// + /// Will be called before any signatures are applied. + pub ready_channel: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters), + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for BaseSign {} + +use lightning::chain::keysinterface::BaseSign as rustBaseSign; +impl rustBaseSign for BaseSign { + fn get_per_commitment_point(&self, idx: u64, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> 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 channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.channel_keys_id)(self.this_arg); + ret.data + } + fn sign_counterparty_commitment(&self, commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { + let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); + 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_holder_commitment_and_htlcs(&self, commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { + let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); + 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_justice_transaction(&self, justice_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_key: &bitcoin::secp256k1::key::SecretKey, htlc: &Option, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut local_justice_tx = ::bitcoin::consensus::encode::serialize(justice_tx); + let mut local_htlc = &crate::lightning::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_vec(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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_counterparty_htlc_transaction(&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) -> Result { + let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx); + let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_closing_transaction(&self, closing_tx: &bitcoin::blockdata::transaction::Transaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + 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_vec(local_closing_tx)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_channel_announcement(&self, msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_channel_announcement)(self.this_arg, &crate::lightning::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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn ready_channel(&mut self, channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.ready_channel)(self.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (channel_parameters 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 BaseSign { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn BaseSign_free(this_ptr: BaseSign) { } +impl Drop for BaseSign { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// A cloneable signer. +/// +/// Although we require signers to be cloneable, it may be useful for developers to be able to use +/// signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait, +/// which implies Sized, into this derived trait. +#[repr(C)] +pub struct Sign { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Implementation of BaseSign for this object. + pub BaseSign: crate::lightning::chain::keysinterface::BaseSign, + /// Creates a copy of the BaseSign, for a copy of this Sign. + /// Because BaseSign doesn't natively support copying itself, you have to provide a full copy implementation here. + pub BaseSign_clone: extern "C" fn (orig_BaseSign: &BaseSign) -> BaseSign, + /// Serialize the object into a byte array + pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, + /// Creates a copy of the object pointed to by this_arg, for a copy of this Sign. + /// Note that the ultimate copy of the Sign will have all function pointers the same as the original. + /// May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new Sign. + pub clone: Option *mut c_void>, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +impl lightning::chain::keysinterface::BaseSign for Sign { + fn get_per_commitment_point(&self, idx: u64, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::key::PublicKey { + let mut ret = (self.BaseSign.get_per_commitment_point)(self.this_arg, idx); + ret.into_rust() + } + fn release_commitment_secret(&self, idx: u64) -> [u8; 32] { + let mut ret = (self.BaseSign.release_commitment_secret)(self.this_arg, idx); + ret.data + } + fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { + if let Some(f) = self.BaseSign.set_pubkeys { + (f)(&self.BaseSign); + } + unsafe { &*self.BaseSign.pubkeys.inner } + } + fn channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.BaseSign.channel_keys_id)(self.this_arg); + ret.data + } + fn sign_counterparty_commitment(&self, commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { + let mut ret = (self.BaseSign.sign_counterparty_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); + 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_holder_commitment_and_htlcs(&self, commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { + let mut ret = (self.BaseSign.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); + 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_justice_transaction(&self, justice_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_key: &bitcoin::secp256k1::key::SecretKey, htlc: &Option, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut local_justice_tx = ::bitcoin::consensus::encode::serialize(justice_tx); + let mut local_htlc = &crate::lightning::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.BaseSign.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_counterparty_htlc_transaction(&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) -> Result { + let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx); + let mut ret = (self.BaseSign.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_closing_transaction(&self, closing_tx: &bitcoin::blockdata::transaction::Transaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut local_closing_tx = ::bitcoin::consensus::encode::serialize(closing_tx); + let mut ret = (self.BaseSign.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_closing_tx)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_channel_announcement(&self, msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.BaseSign.sign_channel_announcement)(self.this_arg, &crate::lightning::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(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn ready_channel(&mut self, channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.BaseSign.ready_channel)(self.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (channel_parameters as *const _) as *mut _ }, is_owned: false }) + } +} +unsafe impl Send for Sign {} +impl lightning::util::ser::Writeable for Sign { + fn write(&self, w: &mut W) -> Result<(), ::std::io::Error> { + let vec = (self.write)(self.this_arg); + w.write_all(vec.as_slice()) + } +} +#[no_mangle] +/// Creates a copy of a Sign +pub extern "C" fn Sign_clone(orig: &Sign) -> Sign { + Sign { + this_arg: if let Some(f) = orig.clone { (f)(orig.this_arg) } else { orig.this_arg }, + BaseSign: (orig.BaseSign_clone)(&orig.BaseSign), + BaseSign_clone: orig.BaseSign_clone, + write: Clone::clone(&orig.write), + clone: Clone::clone(&orig.clone), + free: Clone::clone(&orig.free), + } +} +impl Clone for Sign { + fn clone(&self) -> Self { + Sign_clone(self) + } +} + +use lightning::chain::keysinterface::Sign as rustSign; +impl rustSign for Sign { +} + +// 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 Sign { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn Sign_free(this_ptr: Sign) { } +impl Drop for Sign { + 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 { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Get node secret key (aka node_id or network_key). + /// + /// This method must return the same value each time it is called. + #[must_use] + pub get_node_secret: extern "C" fn (this_arg: *const c_void) -> crate::c_types::SecretKey, + /// Get a script pubkey which we send funds to when claiming on-chain contestable outputs. + /// + /// This method should return a different value each time it is called, to avoid linking + /// on-chain funds across channels as controlled to the same user. + #[must_use] + pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, + /// Get a public key which we will send funds to (in the form of a P2WPKH output) when closing + /// a channel. + /// + /// This method should return a different value each time it is called, to avoid linking + /// on-chain funds across channels as controlled to the same user. + #[must_use] + pub get_shutdown_pubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::PublicKey, + /// Get a new set of Sign for per-channel secrets. These MUST be unique even if you + /// restarted with some stale data! + /// + /// This method must return a different value each time it is called. + #[must_use] + pub get_channel_signer: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64) -> crate::lightning::chain::keysinterface::Sign, + /// 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. + /// + /// This method must return a different value each time it is called. + #[must_use] + pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, + /// Reads a `Signer` for this `KeysInterface` from the given input stream. + /// This is only called during deserialization of other objects which contain + /// `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). + /// The bytes are exactly those which `::write()` writes, and + /// contain no versioning scheme. You may wish to include your own version prefix and ensure + /// you've read all of the provided bytes to ensure no corruption occurred. + #[must_use] + pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for KeysInterface {} +unsafe impl Sync for KeysInterface {} + +use lightning::chain::keysinterface::KeysInterface as rustKeysInterface; +impl rustKeysInterface for KeysInterface { + type Signer = crate::lightning::chain::keysinterface::Sign; + 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_signer(&self, inbound: bool, channel_value_satoshis: u64) -> crate::lightning::chain::keysinterface::Sign { + let mut ret = (self.get_channel_signer)(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 + } + fn read_chan_signer(&self, reader: &[u8]) -> Result { + let mut local_reader = crate::c_types::u8slice::from_slice(reader); + let mut ret = (self.read_chan_signer)(self.this_arg, local_reader); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + 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 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::InMemorySigner as nativeInMemorySignerImport; +type nativeInMemorySigner = nativeInMemorySignerImport; + +/// A simple implementation of Sign that just keeps the private keys in memory. +/// +/// This implementation performs no policy checks and is insufficient by itself as +/// a secure external signer. +#[must_use] +#[repr(C)] +pub struct InMemorySigner { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeInMemorySigner, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for InMemorySigner { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInMemorySigner>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InMemorySigner_free(this_obj: InMemorySigner) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn InMemorySigner_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInMemorySigner); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl InMemorySigner { + pub(crate) fn take_inner(mut self) -> *mut nativeInMemorySigner { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Private key of anchor tx +#[no_mangle] +pub extern "C" fn InMemorySigner_get_funding_key(this_ptr: &InMemorySigner) -> *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 InMemorySigner_set_funding_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *this_ptr.inner }.funding_key = val.into_rust(); +} +/// Holder secret key for blinded revocation pubkey +#[no_mangle] +pub extern "C" fn InMemorySigner_get_revocation_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_base_key; + (*inner_val).as_ref() +} +/// Holder secret key for blinded revocation pubkey +#[no_mangle] +pub extern "C" fn InMemorySigner_set_revocation_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *this_ptr.inner }.revocation_base_key = val.into_rust(); +} +/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions +#[no_mangle] +pub extern "C" fn InMemorySigner_get_payment_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key; + (*inner_val).as_ref() +} +/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions +#[no_mangle] +pub extern "C" fn InMemorySigner_set_payment_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *this_ptr.inner }.payment_key = val.into_rust(); +} +/// Holder secret key used in HTLC tx +#[no_mangle] +pub extern "C" fn InMemorySigner_get_delayed_payment_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_base_key; + (*inner_val).as_ref() +} +/// Holder secret key used in HTLC tx +#[no_mangle] +pub extern "C" fn InMemorySigner_set_delayed_payment_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *this_ptr.inner }.delayed_payment_base_key = val.into_rust(); +} +/// Holder htlc secret key used in commitment tx htlc outputs +#[no_mangle] +pub extern "C" fn InMemorySigner_get_htlc_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_base_key; + (*inner_val).as_ref() +} +/// Holder htlc secret key used in commitment tx htlc outputs +#[no_mangle] +pub extern "C" fn InMemorySigner_set_htlc_base_key(this_ptr: &mut InMemorySigner, 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 InMemorySigner_get_commitment_seed(this_ptr: &InMemorySigner) -> *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 InMemorySigner_set_commitment_seed(this_ptr: &mut InMemorySigner, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.commitment_seed = val.data; +} +impl Clone for InMemorySigner { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInMemorySigner>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 InMemorySigner_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemorySigner)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InMemorySigner +pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner { + orig.clone() +} +/// Create a new InMemorySigner +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_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 channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::InMemorySigner { + let mut ret = lightning::chain::keysinterface::InMemorySigner::new(secp256k1::SECP256K1, 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, channel_keys_id.data); + crate::lightning::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Counterparty pubkeys. +/// Will panic if ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_counterparty_pubkeys(this_arg: &InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { + let mut ret = unsafe { &*this_arg.inner }.counterparty_pubkeys(); + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// The contest_delay value specified by our counterparty and applied on holder-broadcastable +/// transactions, ie the amount of time that we have to wait to recover our funds if we +/// broadcast a transaction. +/// Will panic if ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_counterparty_selected_contest_delay(this_arg: &InMemorySigner) -> u16 { + let mut ret = unsafe { &*this_arg.inner }.counterparty_selected_contest_delay(); + ret +} + +/// The contest_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 ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_holder_selected_contest_delay(this_arg: &InMemorySigner) -> u16 { + let mut ret = unsafe { &*this_arg.inner }.holder_selected_contest_delay(); + ret +} + +/// Whether the holder is the initiator +/// Will panic if ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_is_outbound(this_arg: &InMemorySigner) -> bool { + let mut ret = unsafe { &*this_arg.inner }.is_outbound(); + ret +} + +/// Funding outpoint +/// Will panic if ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_funding_outpoint(this_arg: &InMemorySigner) -> crate::lightning::chain::transaction::OutPoint { + let mut ret = unsafe { &*this_arg.inner }.funding_outpoint(); + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or +/// building transactions. +/// +/// Will panic if ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters { + let mut ret = unsafe { &*this_arg.inner }.get_channel_parameters(); + crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// Sign the single input of spend_tx at index `input_idx` which spends the output +/// described by descriptor, returning the witness stack for the input. +/// +/// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, +/// or is not spending the outpoint described by `descriptor.outpoint`. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { + let mut ret = unsafe { &*this_arg.inner }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} + +/// Sign the single input of spend_tx at index `input_idx` which spends the output +/// described by descriptor, returning the witness stack for the input. +/// +/// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, +/// is not spending the outpoint described by `descriptor.outpoint`, or does not have a +/// sequence set to `descriptor.to_self_delay`. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { + let mut ret = unsafe { &*this_arg.inner }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} + +impl From for crate::lightning::chain::keysinterface::BaseSign { + fn from(obj: nativeInMemorySigner) -> Self { + let mut rust_obj = InMemorySigner { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = InMemorySigner_as_BaseSign(&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(InMemorySigner_free_void); + ret + } +} +/// Constructs a new BaseSign which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is +#[no_mangle] +pub extern "C" fn InMemorySigner_as_BaseSign(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::BaseSign { + crate::lightning::chain::keysinterface::BaseSign { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_per_commitment_point: InMemorySigner_BaseSign_get_per_commitment_point, + release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret, + + pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true }, + set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys), + channel_keys_id: InMemorySigner_BaseSign_channel_keys_id, + sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment, + sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs, + sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction, + sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction, + sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction, + sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement, + ready_channel: InMemorySigner_BaseSign_ready_channel, + } +} + +#[must_use] +extern "C" fn InMemorySigner_BaseSign_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { + let mut ret = >::get_per_commitment_point(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, secp256k1::SECP256K1); + crate::c_types::PublicKey::from_rust(&ret) +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx); + crate::c_types::ThirtyTwoBytes { data: ret } +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_pubkeys(this_arg: *const c_void) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { + let mut ret = >::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} +extern "C" fn InMemorySigner_BaseSign_set_pubkeys(trait_self_arg: &BaseSign) { + // 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 BaseSign as *mut BaseSign) }.pubkeys = InMemorySigner_BaseSign_pubkeys(trait_self_arg.this_arg); + } +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::channel_keys_id(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + crate::c_types::ThirtyTwoBytes { data: ret } +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + let mut ret = >::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, unsafe { &*commitment_tx.inner }, secp256k1::SECP256K1); + 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 mut 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 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + let mut ret = >::sign_holder_commitment_and_htlcs(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, unsafe { &*commitment_tx.inner }, secp256k1::SECP256K1); + 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 mut 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 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_sign_justice_transaction(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::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 = >::sign_justice_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), &local_htlc, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_counterparty_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_sign_closing_transaction(this_arg: *const c_void, mut closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &closing_tx.into_bitcoin(), secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_BaseSign_sign_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_channel_announcement(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, unsafe { &*msg.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} +extern "C" fn InMemorySigner_BaseSign_ready_channel(this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters) { + >::ready_channel(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, unsafe { &*channel_parameters.inner }) +} + +impl From for crate::lightning::chain::keysinterface::Sign { + fn from(obj: nativeInMemorySigner) -> Self { + let mut rust_obj = InMemorySigner { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = InMemorySigner_as_Sign(&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(InMemorySigner_free_void); + ret + } +} +/// Constructs a new Sign which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is +#[no_mangle] +pub extern "C" fn InMemorySigner_as_Sign(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::Sign { + crate::lightning::chain::keysinterface::Sign { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + BaseSign: crate::lightning::chain::keysinterface::BaseSign { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_per_commitment_point: InMemorySigner_BaseSign_get_per_commitment_point, + release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret, + + pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true }, + set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys), + channel_keys_id: InMemorySigner_BaseSign_channel_keys_id, + sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment, + sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs, + sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction, + sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction, + sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction, + sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement, + ready_channel: InMemorySigner_BaseSign_ready_channel, + }, + BaseSign_clone: InMemorySigner_BaseSign_clone, + write: InMemorySigner_write_void, + clone: Some(InMemorySigner_clone_void), + } +} + +extern "C" fn InMemorySigner_BaseSign_clone(orig: &crate::lightning::chain::keysinterface::BaseSign) -> crate::lightning::chain::keysinterface::BaseSign { + crate::lightning::chain::keysinterface::BaseSign { + this_arg: orig.this_arg, + free: None, + get_per_commitment_point: InMemorySigner_BaseSign_get_per_commitment_point, + release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret, + + pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true }, + set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys), + channel_keys_id: InMemorySigner_BaseSign_channel_keys_id, + sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment, + sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs, + sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction, + sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction, + sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction, + sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement, + ready_channel: InMemorySigner_BaseSign_ready_channel, + } +} + +#[no_mangle] +/// Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read +pub extern "C" fn InMemorySigner_write(obj: &InMemorySigner) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemorySigner) }) +} +#[no_mangle] +/// Read a InMemorySigner from a byte array, created by InMemorySigner_write +pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeKeysManager, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for KeysManager { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeKeysManager>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn KeysManager_free(this_obj: 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_inner(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 starting_time_secs: u64, mut starting_time_nanos: u32) -> KeysManager { + let mut ret = lightning::chain::keysinterface::KeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos); + KeysManager { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Derive an old Sign containing per-channel secrets based on a key derivation parameters. +/// +/// Key derivation parameters are accessible through a per-channel secrets +/// Sign::channel_keys_id 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, params: *const [u8; 32]) -> crate::lightning::chain::keysinterface::InMemorySigner { + let mut ret = unsafe { &*this_arg.inner }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); + crate::lightning::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Creates a Transaction which spends the given descriptors to the given outputs, plus an +/// output to the given change destination (if sufficient change value remains). The +/// transaction will have a feerate, at least, of the given value. +/// +/// Returns `Err(())` if the output value is greater than the input value minus required fee or +/// if a descriptor was duplicated. +/// +/// We do not enforce that outputs meet the dust limit or that any output scripts are standard. +/// +/// May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used +/// this KeysManager or one of the `InMemorySigner` created by this KeysManager. +#[must_use] +#[no_mangle] +pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ { + let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; + let mut ret = unsafe { &*this_arg.inner }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&o); crate::c_types::Transaction::from_vec(local_ret_0) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} + +impl From for crate::lightning::chain::keysinterface::KeysInterface { + fn from(obj: nativeKeysManager) -> Self { + let mut rust_obj = KeysManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = KeysManager_as_KeysInterface(&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(KeysManager_free_void); + ret + } +} +/// Constructs a new KeysInterface which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is +#[no_mangle] +pub extern "C" fn KeysManager_as_KeysInterface(this_arg: &KeysManager) -> crate::lightning::chain::keysinterface::KeysInterface { + crate::lightning::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_signer: KeysManager_KeysInterface_get_channel_signer, + get_secure_random_bytes: KeysManager_KeysInterface_get_secure_random_bytes, + read_chan_signer: KeysManager_KeysInterface_read_chan_signer, + } +} + +#[must_use] +extern "C" fn KeysManager_KeysInterface_get_node_secret(this_arg: *const c_void) -> crate::c_types::SecretKey { + let mut ret = >::get_node_secret(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + 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 = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + 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 = >::get_shutdown_pubkey(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + crate::c_types::PublicKey::from_rust(&ret) +} +#[must_use] +extern "C" fn KeysManager_KeysInterface_get_channel_signer(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::lightning::chain::keysinterface::Sign { + let mut ret = >::get_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, _inbound, channel_value_satoshis); + ret.into() +} +#[must_use] +extern "C" fn KeysManager_KeysInterface_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + crate::c_types::ThirtyTwoBytes { data: ret } +} +#[must_use] +extern "C" fn KeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ { + let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, reader.to_slice()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning/chain/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs new file mode 100644 index 0000000..adc5984 --- /dev/null +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -0,0 +1,432 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 chainmonitor; +pub mod channelmonitor; +pub mod transaction; +pub mod keysinterface; +/// An error when accessing the chain via [`Access`]. +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum AccessError { + /// The requested chain is unknown. + UnknownChain, + /// The requested transaction doesn't exist or hasn't confirmed. + UnknownTx, +} +use lightning::chain::AccessError as nativeAccessError; +impl AccessError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeAccessError { + match self { + AccessError::UnknownChain => nativeAccessError::UnknownChain, + AccessError::UnknownTx => nativeAccessError::UnknownTx, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeAccessError { + match self { + AccessError::UnknownChain => nativeAccessError::UnknownChain, + AccessError::UnknownTx => nativeAccessError::UnknownTx, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeAccessError) -> Self { + match native { + nativeAccessError::UnknownChain => AccessError::UnknownChain, + nativeAccessError::UnknownTx => AccessError::UnknownTx, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeAccessError) -> Self { + match native { + nativeAccessError::UnknownChain => AccessError::UnknownChain, + nativeAccessError::UnknownTx => AccessError::UnknownTx, + } + } +} +/// Creates a copy of the AccessError +#[no_mangle] +pub extern "C" fn AccessError_clone(orig: &AccessError) -> AccessError { + orig.clone() +} +/// The `Access` trait defines behavior for accessing chain data and state, such as blocks and +/// UTXOs. +#[repr(C)] +pub struct Access { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. + /// Returns an error if `genesis_hash` is for a different chain or if such a transaction output + /// is unknown. + /// + /// [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id + #[must_use] + pub get_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: *const [u8; 32], short_channel_id: u64) -> crate::c_types::derived::CResult_TxOutAccessErrorZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for Access {} +unsafe impl Sync for Access {} + +use lightning::chain::Access as rustAccess; +impl rustAccess for Access { + fn get_utxo(&self, genesis_hash: &bitcoin::hash_types::BlockHash, short_channel_id: u64) -> Result { + let mut ret = (self.get_utxo)(self.this_arg, genesis_hash.as_inner(), short_channel_id); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).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 Access { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn Access_free(this_ptr: Access) { } +impl Drop for Access { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// The `Listen` trait is used to be notified of when blocks have been connected or disconnected +/// from the chain. +/// +/// Useful when needing to replay chain data upon startup or as new chain events occur. +#[repr(C)] +pub struct Listen { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Notifies the listener that a block was added at the given height. + pub block_connected: extern "C" fn (this_arg: *const c_void, block: crate::c_types::u8slice, height: u32), + /// Notifies the listener that a block was removed at the given height. + pub block_disconnected: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], height: u32), + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} + +use lightning::chain::Listen as rustListen; +impl rustListen for Listen { + fn block_connected(&self, block: &bitcoin::blockdata::block::Block, height: u32) { + let mut local_block = ::bitcoin::consensus::encode::serialize(block); + (self.block_connected)(self.this_arg, crate::c_types::u8slice::from_slice(&local_block), height) + } + fn block_disconnected(&self, header: &bitcoin::blockdata::block::BlockHeader, 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, 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 Listen { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn Listen_free(this_ptr: Listen) { } +impl Drop for Listen { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as +/// blocks are connected and disconnected. +/// +/// Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are +/// responsible for maintaining a set of monitors such that they can be updated accordingly as +/// channel state changes and HTLCs are resolved. See method documentation for specific +/// requirements. +/// +/// Implementations **must** ensure that updates are successfully applied and persisted upon method +/// completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down +/// without taking any further action such as persisting the current state. +/// +/// If an implementation maintains multiple instances of a channel's monitor (e.g., by storing +/// backup copies), then it must ensure that updates are applied across all instances. Otherwise, it +/// could result in a revoked transaction being broadcast, allowing the counterparty to claim all +/// funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle +/// multiple instances. +/// +/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor +/// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr +/// [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure +#[repr(C)] +pub struct Watch { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Watches a channel identified by `funding_txo` using `monitor`. + /// + /// Implementations are responsible for watching the chain for the funding transaction along + /// with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means + /// calling [`block_connected`] and [`block_disconnected`] on the monitor. + /// + /// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch + /// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected + /// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected + #[must_use] + pub watch_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::lightning::chain::transaction::OutPoint, monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, + /// Updates a channel identified by `funding_txo` by applying `update` to its monitor. + /// + /// Implementations must call [`update_monitor`] with the given update. See + /// [`ChannelMonitorUpdateErr`] for invariants around returning an error. + /// + /// [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + /// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr + #[must_use] + pub update_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::lightning::chain::transaction::OutPoint, update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, + /// Returns any monitor events since the last call. Subsequent calls must only return new + /// events. + #[must_use] + pub release_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for Watch {} +unsafe impl Sync for Watch {} + +use lightning::chain::Watch as rustWatch; +impl rustWatch for Watch { + fn watch_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { + let mut ret = (self.watch_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::lightning::chain::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(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } + fn update_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, update: lightning::chain::channelmonitor::ChannelMonitorUpdate) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { + let mut ret = (self.update_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(update)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } + fn release_pending_monitor_events(&self) -> Vec { + let mut ret = (self.release_pending_monitor_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 Watch { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn Watch_free(this_ptr: Watch) { } +impl Drop for Watch { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// The `Filter` trait defines behavior for indicating chain activity of interest pertaining to +/// channels. +/// +/// This is useful in order to have a [`Watch`] implementation convey to a chain source which +/// transactions to be notified of. Notification may take the form of pre-filtering blocks or, in +/// the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If +/// receiving full blocks from a chain source, any further filtering is unnecessary. +/// +/// After an output has been registered, subsequent block retrievals from the chain source must not +/// exclude any transactions matching the new criteria nor any in-block descendants of such +/// transactions. +/// +/// Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` +/// should not block on I/O. Implementations should instead queue the newly monitored data to be +/// processed later. Then, in order to block until the data has been processed, any [`Watch`] +/// invocation that has called the `Filter` must return [`TemporaryFailure`]. +/// +/// [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure +/// [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki +/// [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki +#[repr(C)] +pub struct Filter { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as + /// a spending condition. + pub register_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pubkey: crate::c_types::u8slice), + /// Registers interest in spends of a transaction output. + /// + /// Optionally, when `output.block_hash` is set, should return any transaction spending the + /// output that is found in the corresponding block along with its index. + /// + /// This return value is useful for Electrum clients in order to supply in-block descendant + /// transactions which otherwise were not included. This is not necessary for other clients if + /// such descendant transactions were already included (e.g., when a BIP 157 client provides the + /// full block). + #[must_use] + pub register_output: extern "C" fn (this_arg: *const c_void, output: crate::lightning::chain::WatchedOutput) -> crate::c_types::derived::COption_C2Tuple_usizeTransactionZZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for Filter {} +unsafe impl Sync for Filter {} + +use lightning::chain::Filter as rustFilter; +impl rustFilter for Filter { + fn register_tx(&self, txid: &bitcoin::hash_types::Txid, script_pubkey: &bitcoin::blockdata::script::Script) { + (self.register_tx)(self.this_arg, txid.as_inner(), crate::c_types::u8slice::from_slice(&script_pubkey[..])) + } + fn register_output(&self, output: lightning::chain::WatchedOutput) -> Option<(usize, bitcoin::blockdata::transaction::Transaction)> { + let mut ret = (self.register_output)(self.this_arg, crate::lightning::chain::WatchedOutput { inner: Box::into_raw(Box::new(output)), is_owned: true }); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_bitcoin()); local_ret_0 }) } else { None }; + 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 Filter { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn Filter_free(this_ptr: Filter) { } +impl Drop for Filter { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} + +use lightning::chain::WatchedOutput as nativeWatchedOutputImport; +type nativeWatchedOutput = nativeWatchedOutputImport; + +/// A transaction output watched by a [`ChannelMonitor`] for spends on-chain. +/// +/// Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction +/// spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via +/// the return value of [`Filter::register_output`]. +/// +/// If `block_hash` is `Some`, this indicates the output was created in the corresponding block and +/// may have been spent there. See [`Filter::register_output`] for details. +/// +/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor +/// [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected +#[must_use] +#[repr(C)] +pub struct WatchedOutput { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeWatchedOutput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for WatchedOutput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeWatchedOutput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn WatchedOutput_free(this_obj: WatchedOutput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn WatchedOutput_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWatchedOutput); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl WatchedOutput { + pub(crate) fn take_inner(mut self) -> *mut nativeWatchedOutput { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// First block where the transaction output may have been spent. +#[no_mangle] +pub extern "C" fn WatchedOutput_get_block_hash(this_ptr: &WatchedOutput) -> crate::c_types::ThirtyTwoBytes { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.block_hash; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (inner_val.unwrap()).into_inner() } } }; + local_inner_val +} +/// First block where the transaction output may have been spent. +#[no_mangle] +pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut val: crate::c_types::ThirtyTwoBytes) { + let mut local_val = if val.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap() }) }; + unsafe { &mut *this_ptr.inner }.block_hash = local_val; +} +/// Outpoint identifying the transaction output. +#[no_mangle] +pub extern "C" fn WatchedOutput_get_outpoint(this_ptr: &WatchedOutput) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Outpoint identifying the transaction output. +#[no_mangle] +pub extern "C" fn WatchedOutput_set_outpoint(this_ptr: &mut WatchedOutput, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Spending condition of the transaction output. +#[no_mangle] +pub extern "C" fn WatchedOutput_get_script_pubkey(this_ptr: &WatchedOutput) -> crate::c_types::u8slice { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.script_pubkey; + crate::c_types::u8slice::from_slice(&(*inner_val)[..]) +} +/// Spending condition of the transaction output. +#[no_mangle] +pub extern "C" fn WatchedOutput_set_script_pubkey(this_ptr: &mut WatchedOutput, mut val: crate::c_types::derived::CVec_u8Z) { + unsafe { &mut *this_ptr.inner }.script_pubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust()); +} +/// Constructs a new WatchedOutput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::ThirtyTwoBytes, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut script_pubkey_arg: crate::c_types::derived::CVec_u8Z) -> WatchedOutput { + let mut local_block_hash_arg = if block_hash_arg.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&block_hash_arg.data[..]).unwrap() }) }; + WatchedOutput { inner: Box::into_raw(Box::new(nativeWatchedOutput { + block_hash: local_block_hash_arg, + outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, + script_pubkey: ::bitcoin::blockdata::script::Script::from(script_pubkey_arg.into_rust()), + })), is_owned: true } +} diff --git a/lightning-c-bindings/src/lightning/chain/transaction.rs b/lightning-c-bindings/src/lightning/chain/transaction.rs new file mode 100644 index 0000000..db30cdf --- /dev/null +++ b/lightning-c-bindings/src/lightning/chain/transaction.rs @@ -0,0 +1,136 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Types describing on-chain transactions. + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeOutPoint, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for OutPoint { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOutPoint>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OutPoint_free(this_obj: 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_inner(mut self) -> *mut nativeOutPoint { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +/// Constructs a new OutPoint given each field +#[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 } +} +impl Clone for OutPoint { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOutPoint>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the OutPoint +pub extern "C" fn OutPoint_clone(orig: &OutPoint) -> OutPoint { + orig.clone() +} +/// 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] +/// Serialize the OutPoint object into a byte array which can be read by OutPoint_read +pub extern "C" fn OutPoint_write(obj: &OutPoint) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn OutPoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOutPoint) }) +} +#[no_mangle] +/// Read a OutPoint from a byte array, created by OutPoint_write +pub extern "C" fn OutPoint_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OutPointDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs new file mode 100644 index 0000000..fe989bd --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -0,0 +1,1504 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Various utilities for building scripts and deriving keys related to channels. These are +//! largely of interest for those implementing chain::keysinterface::Sign 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(mut per_commitment_point: crate::c_types::PublicKey, base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeyErrorZ { + let mut ret = lightning::ln::chan_utils::derive_private_key(secp256k1::SECP256K1, &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) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; + 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(mut per_commitment_point: crate::c_types::PublicKey, mut base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeyErrorZ { + let mut ret = lightning::ln::chan_utils::derive_public_key(secp256k1::SECP256K1, &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) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; + local_ret +} + +/// Derives a per-commitment-transaction revocation key from its constituent parts. +/// +/// Only the cheating participant owns a valid witness to propagate a revoked +/// commitment transaction, thus per_commitment_secret always come from cheater +/// and revocation_base_secret always come from punisher, which is the broadcaster +/// of the transaction spending with this key knowledge. +/// +/// 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], countersignatory_revocation_base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeyErrorZ { + let mut ret = lightning::ln::chan_utils::derive_private_revocation_key(secp256k1::SECP256K1, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_secret}[..]).unwrap(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *countersignatory_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) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; + 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. +/// +/// Only the cheating participant owns a valid witness to propagate a revoked +/// commitment transaction, thus per_commitment_point always come from cheater +/// and revocation_base_point always come from punisher, which is the broadcaster +/// of the transaction spending with this key knowledge. +/// +/// 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(mut per_commitment_point: crate::c_types::PublicKey, mut countersignatory_revocation_base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeyErrorZ { + let mut ret = lightning::ln::chan_utils::derive_public_revocation_key(secp256k1::SECP256K1, &per_commitment_point.into_rust(), &countersignatory_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) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; + 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. +/// +/// A broadcaster key is provided from potential broadcaster of the computed transaction. +/// A countersignatory key is coming from a protocol participant unable to broadcast the +/// transaction. +/// +/// 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 +/// CommitmentTransaction.trust().keys() because we trusted the source of the +/// pre-calculated keys. +#[must_use] +#[repr(C)] +pub struct TxCreationKeys { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeTxCreationKeys, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxCreationKeys { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxCreationKeys>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxCreationKeys_free(this_obj: 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_inner(mut self) -> *mut nativeTxCreationKeys { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The broadcaster's 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 broadcaster's 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 broadcaster 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 broadcaster 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(); +} +/// Broadcaster's HTLC Key +#[no_mangle] +pub extern "C" fn TxCreationKeys_get_broadcaster_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_htlc_key; + crate::c_types::PublicKey::from_rust(&(*inner_val)) +} +/// Broadcaster's HTLC Key +#[no_mangle] +pub extern "C" fn TxCreationKeys_set_broadcaster_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { + unsafe { &mut *this_ptr.inner }.broadcaster_htlc_key = val.into_rust(); +} +/// Countersignatory's HTLC Key +#[no_mangle] +pub extern "C" fn TxCreationKeys_get_countersignatory_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.countersignatory_htlc_key; + crate::c_types::PublicKey::from_rust(&(*inner_val)) +} +/// Countersignatory's HTLC Key +#[no_mangle] +pub extern "C" fn TxCreationKeys_set_countersignatory_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { + unsafe { &mut *this_ptr.inner }.countersignatory_htlc_key = val.into_rust(); +} +/// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) +#[no_mangle] +pub extern "C" fn TxCreationKeys_get_broadcaster_delayed_payment_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key; + crate::c_types::PublicKey::from_rust(&(*inner_val)) +} +/// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) +#[no_mangle] +pub extern "C" fn TxCreationKeys_set_broadcaster_delayed_payment_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { + unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key = val.into_rust(); +} +/// Constructs a new TxCreationKeys given each field +#[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 broadcaster_htlc_key_arg: crate::c_types::PublicKey, mut countersignatory_htlc_key_arg: crate::c_types::PublicKey, mut broadcaster_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(), + broadcaster_htlc_key: broadcaster_htlc_key_arg.into_rust(), + countersignatory_htlc_key: countersignatory_htlc_key_arg.into_rust(), + broadcaster_delayed_payment_key: broadcaster_delayed_payment_key_arg.into_rust(), + })), is_owned: true } +} +impl Clone for TxCreationKeys { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxCreationKeys>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the TxCreationKeys +pub extern "C" fn TxCreationKeys_clone(orig: &TxCreationKeys) -> TxCreationKeys { + orig.clone() +} +#[no_mangle] +/// Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read +pub extern "C" fn TxCreationKeys_write(obj: &TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn TxCreationKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxCreationKeys) }) +} +#[no_mangle] +/// Read a TxCreationKeys from a byte array, created by TxCreationKeys_write +pub extern "C" fn TxCreationKeys_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCreationKeysDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelPublicKeys, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelPublicKeys { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelPublicKeys>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelPublicKeys_free(this_obj: 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_inner(mut self) -> *mut nativeChannelPublicKeys { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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 on which the non-broadcaster (ie the countersignatory) receives an immediately +/// spendable primary channel balance on the broadcaster's commitment transaction. 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 on which the non-broadcaster (ie the countersignatory) receives an immediately +/// spendable primary channel balance on the broadcaster's commitment transaction. 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(); +} +/// Constructs a new ChannelPublicKeys given each field +#[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 } +} +impl Clone for ChannelPublicKeys { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelPublicKeys>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ChannelPublicKeys +pub extern "C" fn ChannelPublicKeys_clone(orig: &ChannelPublicKeys) -> ChannelPublicKeys { + orig.clone() +} +#[no_mangle] +/// Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read +pub extern "C" fn ChannelPublicKeys_write(obj: &ChannelPublicKeys) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelPublicKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelPublicKeys) }) +} +#[no_mangle] +/// Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write +pub extern "C" fn ChannelPublicKeys_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelPublicKeysDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +/// Create per-state keys from channel base points and the per-commitment point. +/// Key set is asymmetric and can't be used as part of counter-signatory set of transactions. +#[must_use] +#[no_mangle] +pub extern "C" fn TxCreationKeys_derive_new(mut per_commitment_point: crate::c_types::PublicKey, mut broadcaster_delayed_payment_base: crate::c_types::PublicKey, mut broadcaster_htlc_base: crate::c_types::PublicKey, mut countersignatory_revocation_base: crate::c_types::PublicKey, mut countersignatory_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysErrorZ { + let mut ret = lightning::ln::chan_utils::TxCreationKeys::derive_new(secp256k1::SECP256K1, &per_commitment_point.into_rust(), &broadcaster_delayed_payment_base.into_rust(), &broadcaster_htlc_base.into_rust(), &countersignatory_revocation_base.into_rust(), &countersignatory_htlc_base.into_rust()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; + local_ret +} + +/// Generate per-state keys from channel static keys. +/// Key set is asymmetric and can't be used as part of counter-signatory set of transactions. +#[must_use] +#[no_mangle] +pub extern "C" fn TxCreationKeys_from_channel_static_keys(mut per_commitment_point: crate::c_types::PublicKey, broadcaster_keys: &crate::lightning::ln::chan_utils::ChannelPublicKeys, countersignatory_keys: &crate::lightning::ln::chan_utils::ChannelPublicKeys) -> crate::c_types::derived::CResult_TxCreationKeysErrorZ { + let mut ret = lightning::ln::chan_utils::TxCreationKeys::from_channel_static_keys(&per_commitment_point.into_rust(), unsafe { &*broadcaster_keys.inner }, unsafe { &*countersignatory_keys.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; + local_ret +} + +/// The maximum length of a script returned by get_revokeable_redeemscript. + +#[no_mangle] +pub static REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH: usize = lightning::ln::chan_utils::REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; +/// A script either spendable by the revocation +/// key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. +/// Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. +#[no_mangle] +pub extern "C" fn get_revokeable_redeemscript(mut revocation_key: crate::c_types::PublicKey, mut contest_delay: u16, mut broadcaster_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(), contest_delay, &broadcaster_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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeHTLCOutputInCommitment, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for HTLCOutputInCommitment { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn HTLCOutputInCommitment_free(this_obj: 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_inner(mut self) -> *mut nativeHTLCOutputInCommitment { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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 counterparty 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 counterparty 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); +} +/// The position within the commitment transactions' outputs. This may be None if the value is +/// below the dust limit (in which case no output appears in the commitment transaction and the +/// value is spent to additional transaction fees). +#[no_mangle] +pub extern "C" fn HTLCOutputInCommitment_get_transaction_output_index(this_ptr: &HTLCOutputInCommitment) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.transaction_output_index; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { { crate::c_types::derived::COption_u32Z::Some(inner_val.unwrap()) } }; + local_inner_val +} +/// The position within the commitment transactions' outputs. This may be None if the value is +/// below the dust limit (in which case no output appears in the commitment transaction and the +/// value is spent to additional transaction fees). +#[no_mangle] +pub extern "C" fn HTLCOutputInCommitment_set_transaction_output_index(this_ptr: &mut HTLCOutputInCommitment, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *this_ptr.inner }.transaction_output_index = local_val; +} +/// Constructs a new HTLCOutputInCommitment given each field +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCOutputInCommitment_new(mut offered_arg: bool, mut amount_msat_arg: u64, mut cltv_expiry_arg: u32, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut transaction_output_index_arg: crate::c_types::derived::COption_u32Z) -> HTLCOutputInCommitment { + let mut local_transaction_output_index_arg = if transaction_output_index_arg.is_some() { Some( { transaction_output_index_arg.take() }) } else { None }; + HTLCOutputInCommitment { inner: Box::into_raw(Box::new(nativeHTLCOutputInCommitment { + offered: offered_arg, + amount_msat: amount_msat_arg, + cltv_expiry: cltv_expiry_arg, + payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash_arg.data), + transaction_output_index: local_transaction_output_index_arg, + })), is_owned: true } +} +impl Clone for HTLCOutputInCommitment { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the HTLCOutputInCommitment +pub extern "C" fn HTLCOutputInCommitment_clone(orig: &HTLCOutputInCommitment) -> HTLCOutputInCommitment { + orig.clone() +} +#[no_mangle] +/// Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read +pub extern "C" fn HTLCOutputInCommitment_write(obj: &HTLCOutputInCommitment) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn HTLCOutputInCommitment_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCOutputInCommitment) }) +} +#[no_mangle] +/// Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write +pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HTLCOutputInCommitmentDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +/// Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc +/// does not need to have its previous_output_index filled. +#[no_mangle] +pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, keys: &crate::lightning::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(mut broadcaster: crate::c_types::PublicKey, mut countersignatory: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { + let mut ret = lightning::ln::chan_utils::make_funding_redeemscript(&broadcaster.into_rust(), &countersignatory.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 contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { + let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, contest_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); + let mut local_ret = ::bitcoin::consensus::encode::serialize(&ret); + crate::c_types::Transaction::from_vec(local_ret) +} + + +use lightning::ln::chan_utils::ChannelTransactionParameters as nativeChannelTransactionParametersImport; +type nativeChannelTransactionParameters = nativeChannelTransactionParametersImport; + +/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction). +/// The fields are organized by holder/counterparty. +/// +/// Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters +/// before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions. +#[must_use] +#[repr(C)] +pub struct ChannelTransactionParameters { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelTransactionParameters, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelTransactionParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelTransactionParameters>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_free(this_obj: ChannelTransactionParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ChannelTransactionParameters_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelTransactionParameters); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ChannelTransactionParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelTransactionParameters { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Holder public keys +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_holder_pubkeys(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_pubkeys; + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Holder public keys +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_holder_pubkeys(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::ln::chan_utils::ChannelPublicKeys) { + unsafe { &mut *this_ptr.inner }.holder_pubkeys = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The contest delay selected by the holder, which applies to counterparty-broadcast transactions +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_holder_selected_contest_delay(this_ptr: &ChannelTransactionParameters) -> u16 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay; + (*inner_val) +} +/// The contest delay selected by the holder, which applies to counterparty-broadcast transactions +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_holder_selected_contest_delay(this_ptr: &mut ChannelTransactionParameters, mut val: u16) { + unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay = val; +} +/// Whether the holder is the initiator of this channel. +/// This is an input to the commitment number obscure factor computation. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_is_outbound_from_holder(this_ptr: &ChannelTransactionParameters) -> bool { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_outbound_from_holder; + (*inner_val) +} +/// Whether the holder is the initiator of this channel. +/// This is an input to the commitment number obscure factor computation. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_is_outbound_from_holder(this_ptr: &mut ChannelTransactionParameters, mut val: bool) { + unsafe { &mut *this_ptr.inner }.is_outbound_from_holder = val; +} +/// The late-bound counterparty channel transaction parameters. +/// These parameters are populated at the point in the protocol where the counterparty provides them. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_counterparty_parameters(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_parameters; + let mut local_inner_val = crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters { 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 +} +/// The late-bound counterparty channel transaction parameters. +/// These parameters are populated at the point in the protocol where the counterparty provides them. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_counterparty_parameters(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.counterparty_parameters = local_val; +} +/// The late-bound funding outpoint +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_funding_outpoint(this_ptr: &ChannelTransactionParameters) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_outpoint; + let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { 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 +} +/// The late-bound funding outpoint +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::chain::transaction::OutPoint) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.funding_outpoint = local_val; +} +/// Constructs a new ChannelTransactionParameters given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint) -> ChannelTransactionParameters { + let mut local_counterparty_parameters_arg = if counterparty_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(counterparty_parameters_arg.take_inner()) } }) }; + let mut local_funding_outpoint_arg = if funding_outpoint_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_outpoint_arg.take_inner()) } }) }; + ChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeChannelTransactionParameters { + holder_pubkeys: *unsafe { Box::from_raw(holder_pubkeys_arg.take_inner()) }, + holder_selected_contest_delay: holder_selected_contest_delay_arg, + is_outbound_from_holder: is_outbound_from_holder_arg, + counterparty_parameters: local_counterparty_parameters_arg, + funding_outpoint: local_funding_outpoint_arg, + })), is_owned: true } +} +impl Clone for ChannelTransactionParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelTransactionParameters>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 ChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelTransactionParameters)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelTransactionParameters +pub extern "C" fn ChannelTransactionParameters_clone(orig: &ChannelTransactionParameters) -> ChannelTransactionParameters { + orig.clone() +} + +use lightning::ln::chan_utils::CounterpartyChannelTransactionParameters as nativeCounterpartyChannelTransactionParametersImport; +type nativeCounterpartyChannelTransactionParameters = nativeCounterpartyChannelTransactionParametersImport; + +/// Late-bound per-channel counterparty data used to build transactions. +#[must_use] +#[repr(C)] +pub struct CounterpartyChannelTransactionParameters { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeCounterpartyChannelTransactionParameters, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for CounterpartyChannelTransactionParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_free(this_obj: CounterpartyChannelTransactionParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn CounterpartyChannelTransactionParameters_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCounterpartyChannelTransactionParameters); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl CounterpartyChannelTransactionParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyChannelTransactionParameters { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Counter-party public keys +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_get_pubkeys(this_ptr: &CounterpartyChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkeys; + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Counter-party public keys +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_set_pubkeys(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: crate::lightning::ln::chan_utils::ChannelPublicKeys) { + unsafe { &mut *this_ptr.inner }.pubkeys = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The contest delay selected by the counterparty, which applies to holder-broadcast transactions +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_get_selected_contest_delay(this_ptr: &CounterpartyChannelTransactionParameters) -> u16 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.selected_contest_delay; + (*inner_val) +} +/// The contest delay selected by the counterparty, which applies to holder-broadcast transactions +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_set_selected_contest_delay(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: u16) { + unsafe { &mut *this_ptr.inner }.selected_contest_delay = val; +} +/// Constructs a new CounterpartyChannelTransactionParameters given each field +#[must_use] +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_new(mut pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut selected_contest_delay_arg: u16) -> CounterpartyChannelTransactionParameters { + CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeCounterpartyChannelTransactionParameters { + pubkeys: *unsafe { Box::from_raw(pubkeys_arg.take_inner()) }, + selected_contest_delay: selected_contest_delay_arg, + })), is_owned: true } +} +impl Clone for CounterpartyChannelTransactionParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 CounterpartyChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCounterpartyChannelTransactionParameters)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the CounterpartyChannelTransactionParameters +pub extern "C" fn CounterpartyChannelTransactionParameters_clone(orig: &CounterpartyChannelTransactionParameters) -> CounterpartyChannelTransactionParameters { + orig.clone() +} +/// Whether the late bound parameters are populated. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_is_populated(this_arg: &ChannelTransactionParameters) -> bool { + let mut ret = unsafe { &*this_arg.inner }.is_populated(); + ret +} + +/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, +/// given that the holder is the broadcaster. +/// +/// self.is_populated() must be true before calling this function. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_as_holder_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters { + let mut ret = unsafe { &*this_arg.inner }.as_holder_broadcastable(); + crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, +/// given that the counterparty is the broadcaster. +/// +/// self.is_populated() must be true before calling this function. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_as_counterparty_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters { + let mut ret = unsafe { &*this_arg.inner }.as_counterparty_broadcastable(); + crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +#[no_mangle] +/// Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read +pub extern "C" fn CounterpartyChannelTransactionParameters_write(obj: &CounterpartyChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyChannelTransactionParameters) }) +} +#[no_mangle] +/// Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write +pub extern "C" fn CounterpartyChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read +pub extern "C" fn ChannelTransactionParameters_write(obj: &ChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTransactionParameters) }) +} +#[no_mangle] +/// Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write +pub extern "C" fn ChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelTransactionParametersDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +use lightning::ln::chan_utils::DirectedChannelTransactionParameters as nativeDirectedChannelTransactionParametersImport; +type nativeDirectedChannelTransactionParameters = nativeDirectedChannelTransactionParametersImport<'static>; + +/// Static channel fields used to build transactions given per-commitment fields, organized by +/// broadcaster/countersignatory. +/// +/// This is derived from the holder/counterparty-organized ChannelTransactionParameters via the +/// as_holder_broadcastable and as_counterparty_broadcastable functions. +#[must_use] +#[repr(C)] +pub struct DirectedChannelTransactionParameters { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeDirectedChannelTransactionParameters, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for DirectedChannelTransactionParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDirectedChannelTransactionParameters>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_free(this_obj: DirectedChannelTransactionParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn DirectedChannelTransactionParameters_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectedChannelTransactionParameters); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl DirectedChannelTransactionParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeDirectedChannelTransactionParameters { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Get the channel pubkeys for the broadcaster +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_broadcaster_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { + let mut ret = unsafe { &*this_arg.inner }.broadcaster_pubkeys(); + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// Get the channel pubkeys for the countersignatory +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_countersignatory_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { + let mut ret = unsafe { &*this_arg.inner }.countersignatory_pubkeys(); + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// Get the contest delay applicable to the transactions. +/// Note that the contest delay was selected by the countersignatory. +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_contest_delay(this_arg: &DirectedChannelTransactionParameters) -> u16 { + let mut ret = unsafe { &*this_arg.inner }.contest_delay(); + ret +} + +/// Whether the channel is outbound from the broadcaster. +/// +/// The boolean representing the side that initiated the channel is +/// an input to the commitment number obscure factor computation. +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_is_outbound(this_arg: &DirectedChannelTransactionParameters) -> bool { + let mut ret = unsafe { &*this_arg.inner }.is_outbound(); + ret +} + +/// The funding outpoint +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg: &DirectedChannelTransactionParameters) -> crate::lightning::chain::transaction::OutPoint { + let mut ret = unsafe { &*this_arg.inner }.funding_outpoint(); + crate::c_types::bitcoin_to_C_outpoint(ret) +} + + +use lightning::ln::chan_utils::HolderCommitmentTransaction as nativeHolderCommitmentTransactionImport; +type nativeHolderCommitmentTransaction = nativeHolderCommitmentTransactionImport; + +/// Information needed to build and sign a holder's commitment transaction. +/// +/// The transaction is only signed once we are ready to broadcast. +#[must_use] +#[repr(C)] +pub struct HolderCommitmentTransaction { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeHolderCommitmentTransaction, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for HolderCommitmentTransaction { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_free(this_obj: HolderCommitmentTransaction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn HolderCommitmentTransaction_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHolderCommitmentTransaction); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl HolderCommitmentTransaction { + pub(crate) fn take_inner(mut self) -> *mut nativeHolderCommitmentTransaction { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Our counterparty's signature for the transaction +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_get_counterparty_sig(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Signature { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_sig; + crate::c_types::Signature::from_rust(&(*inner_val)) +} +/// Our counterparty's signature for the transaction +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_set_counterparty_sig(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::Signature) { + unsafe { &mut *this_ptr.inner }.counterparty_sig = val.into_rust(); +} +/// All non-dust counterparty HTLC signatures, in the order they appear in the transaction +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_set_counterparty_htlc_sigs(this_ptr: &mut HolderCommitmentTransaction, 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 }.counterparty_htlc_sigs = local_val; +} +impl Clone for HolderCommitmentTransaction { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 HolderCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHolderCommitmentTransaction)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the HolderCommitmentTransaction +pub extern "C" fn HolderCommitmentTransaction_clone(orig: &HolderCommitmentTransaction) -> HolderCommitmentTransaction { + orig.clone() +} +#[no_mangle] +/// Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read +pub extern "C" fn HolderCommitmentTransaction_write(obj: &HolderCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn HolderCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHolderCommitmentTransaction) }) +} +#[no_mangle] +/// Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write +pub extern "C" fn HolderCommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HolderCommitmentTransactionDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +/// Create a new holder transaction with the given counterparty signatures. +/// The funding keys are used to figure out which signature should go first when building the transaction for broadcast. +#[must_use] +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_new(mut commitment_tx: crate::lightning::ln::chan_utils::CommitmentTransaction, mut counterparty_sig: crate::c_types::Signature, mut counterparty_htlc_sigs: crate::c_types::derived::CVec_SignatureZ, mut holder_funding_key: crate::c_types::PublicKey, mut counterparty_funding_key: crate::c_types::PublicKey) -> HolderCommitmentTransaction { + let mut local_counterparty_htlc_sigs = Vec::new(); for mut item in counterparty_htlc_sigs.into_rust().drain(..) { local_counterparty_htlc_sigs.push( { item.into_rust() }); }; + let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new(*unsafe { Box::from_raw(commitment_tx.take_inner()) }, counterparty_sig.into_rust(), local_counterparty_htlc_sigs, &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust()); + HolderCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + + +use lightning::ln::chan_utils::BuiltCommitmentTransaction as nativeBuiltCommitmentTransactionImport; +type nativeBuiltCommitmentTransaction = nativeBuiltCommitmentTransactionImport; + +/// A pre-built Bitcoin commitment transaction and its txid. +#[must_use] +#[repr(C)] +pub struct BuiltCommitmentTransaction { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeBuiltCommitmentTransaction, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for BuiltCommitmentTransaction { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_free(this_obj: BuiltCommitmentTransaction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn BuiltCommitmentTransaction_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBuiltCommitmentTransaction); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl BuiltCommitmentTransaction { + pub(crate) fn take_inner(mut self) -> *mut nativeBuiltCommitmentTransaction { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The commitment transaction +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_get_transaction(this_ptr: &BuiltCommitmentTransaction) -> crate::c_types::Transaction { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.transaction; + let mut local_inner_val = ::bitcoin::consensus::encode::serialize(inner_val); + crate::c_types::Transaction::from_vec(local_inner_val) +} +/// The commitment transaction +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_set_transaction(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::Transaction) { + unsafe { &mut *this_ptr.inner }.transaction = val.into_bitcoin(); +} +/// The txid for the commitment transaction. +/// +/// This is provided as a performance optimization, instead of calling transaction.txid() +/// multiple times. +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_get_txid(this_ptr: &BuiltCommitmentTransaction) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.txid; + (*inner_val).as_inner() +} +/// The txid for the commitment transaction. +/// +/// This is provided as a performance optimization, instead of calling transaction.txid() +/// multiple times. +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_set_txid(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); +} +/// Constructs a new BuiltCommitmentTransaction given each field +#[must_use] +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_new(mut transaction_arg: crate::c_types::Transaction, mut txid_arg: crate::c_types::ThirtyTwoBytes) -> BuiltCommitmentTransaction { + BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(nativeBuiltCommitmentTransaction { + transaction: transaction_arg.into_bitcoin(), + txid: ::bitcoin::hash_types::Txid::from_slice(&txid_arg.data[..]).unwrap(), + })), is_owned: true } +} +impl Clone for BuiltCommitmentTransaction { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 BuiltCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBuiltCommitmentTransaction)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BuiltCommitmentTransaction +pub extern "C" fn BuiltCommitmentTransaction_clone(orig: &BuiltCommitmentTransaction) -> BuiltCommitmentTransaction { + orig.clone() +} +#[no_mangle] +/// Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read +pub extern "C" fn BuiltCommitmentTransaction_write(obj: &BuiltCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn BuiltCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBuiltCommitmentTransaction) }) +} +#[no_mangle] +/// Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write +pub extern "C" fn BuiltCommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BuiltCommitmentTransactionDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +/// Get the SIGHASH_ALL sighash value of the transaction. +/// +/// This can be used to verify a signature. +#[must_use] +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &BuiltCommitmentTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*this_arg.inner }.get_sighash_all(&::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis); + crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() } +} + +/// Sign a transaction, either because we are counter-signing the counterparty's transaction or +/// because we are about to broadcast a holder transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_sign(this_arg: &BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature { + let mut ret = unsafe { &*this_arg.inner }.sign(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, secp256k1::SECP256K1); + crate::c_types::Signature::from_rust(&ret) +} + + +use lightning::ln::chan_utils::CommitmentTransaction as nativeCommitmentTransactionImport; +type nativeCommitmentTransaction = nativeCommitmentTransactionImport; + +/// This class tracks the per-transaction information needed to build a commitment transaction and to +/// actually build it and sign. It is used for holder transactions that we sign only when needed +/// and for transactions we sign for the counterparty. +/// +/// This class can be used inside a signer implementation to generate a signature given the relevant +/// secret key. +#[must_use] +#[repr(C)] +pub struct CommitmentTransaction { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeCommitmentTransaction, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for CommitmentTransaction { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCommitmentTransaction>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CommitmentTransaction_free(this_obj: CommitmentTransaction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn CommitmentTransaction_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentTransaction); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl CommitmentTransaction { + pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentTransaction { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for CommitmentTransaction { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 CommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentTransaction)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the CommitmentTransaction +pub extern "C" fn CommitmentTransaction_clone(orig: &CommitmentTransaction) -> CommitmentTransaction { + orig.clone() +} +#[no_mangle] +/// Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read +pub extern "C" fn CommitmentTransaction_write(obj: &CommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn CommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentTransaction) }) +} +#[no_mangle] +/// Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write +pub extern "C" fn CommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentTransactionDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::CommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +/// The backwards-counting commitment number +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_commitment_number(this_arg: &CommitmentTransaction) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.commitment_number(); + ret +} + +/// The value to be sent to the broadcaster +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_to_broadcaster_value_sat(this_arg: &CommitmentTransaction) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.to_broadcaster_value_sat(); + ret +} + +/// The value to be sent to the counterparty +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_to_countersignatory_value_sat(this_arg: &CommitmentTransaction) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.to_countersignatory_value_sat(); + ret +} + +/// The feerate paid per 1000-weight-unit in this commitment transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_feerate_per_kw(this_arg: &CommitmentTransaction) -> u32 { + let mut ret = unsafe { &*this_arg.inner }.feerate_per_kw(); + ret +} + +/// Trust our pre-built transaction and derived transaction creation public keys. +/// +/// Applies a wrapper which allows access to these fields. +/// +/// This should only be used if you fully trust the builder of this object. It should not +///\tbe used by an external signer - instead use the verify function. +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_trust(this_arg: &CommitmentTransaction) -> crate::lightning::ln::chan_utils::TrustedCommitmentTransaction { + let mut ret = unsafe { &*this_arg.inner }.trust(); + crate::lightning::ln::chan_utils::TrustedCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Verify our pre-built transaction and derived transaction creation public keys. +/// +/// Applies a wrapper which allows access to these fields. +/// +/// An external validating signer must call this method before signing +/// or using the built transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_verify(this_arg: &CommitmentTransaction, channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters, broadcaster_keys: &crate::lightning::ln::chan_utils::ChannelPublicKeys, countersignatory_keys: &crate::lightning::ln::chan_utils::ChannelPublicKeys) -> crate::c_types::derived::CResult_TrustedCommitmentTransactionNoneZ { + let mut ret = unsafe { &*this_arg.inner }.verify(unsafe { &*channel_parameters.inner }, unsafe { &*broadcaster_keys.inner }, unsafe { &*countersignatory_keys.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TrustedCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} + + +use lightning::ln::chan_utils::TrustedCommitmentTransaction as nativeTrustedCommitmentTransactionImport; +type nativeTrustedCommitmentTransaction = nativeTrustedCommitmentTransactionImport<'static>; + +/// A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin +/// transaction and the transaction creation keys) are trusted. +/// +/// See trust() and verify() functions on CommitmentTransaction. +/// +/// This structure implements Deref. +#[must_use] +#[repr(C)] +pub struct TrustedCommitmentTransaction { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeTrustedCommitmentTransaction, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TrustedCommitmentTransaction { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTrustedCommitmentTransaction>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TrustedCommitmentTransaction_free(this_obj: TrustedCommitmentTransaction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn TrustedCommitmentTransaction_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeTrustedCommitmentTransaction); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl TrustedCommitmentTransaction { + pub(crate) fn take_inner(mut self) -> *mut nativeTrustedCommitmentTransaction { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The transaction ID of the built Bitcoin transaction +#[must_use] +#[no_mangle] +pub extern "C" fn TrustedCommitmentTransaction_txid(this_arg: &TrustedCommitmentTransaction) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*this_arg.inner }.txid(); + crate::c_types::ThirtyTwoBytes { data: ret.into_inner() } +} + +/// The pre-built Bitcoin commitment transaction +#[must_use] +#[no_mangle] +pub extern "C" fn TrustedCommitmentTransaction_built_transaction(this_arg: &TrustedCommitmentTransaction) -> crate::lightning::ln::chan_utils::BuiltCommitmentTransaction { + let mut ret = unsafe { &*this_arg.inner }.built_transaction(); + crate::lightning::ln::chan_utils::BuiltCommitmentTransaction { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// The pre-calculated transaction creation public keys. +#[must_use] +#[no_mangle] +pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &TrustedCommitmentTransaction) -> crate::lightning::ln::chan_utils::TxCreationKeys { + let mut ret = unsafe { &*this_arg.inner }.keys(); + crate::lightning::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// 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. +#[must_use] +#[no_mangle] +pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> 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(), unsafe { &*channel_parameters.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + local_ret +} + +/// Get the transaction number obscure factor +#[no_mangle] +pub extern "C" fn get_commitment_transaction_number_obscure_factor(mut broadcaster_payment_basepoint: crate::c_types::PublicKey, mut countersignatory_payment_basepoint: crate::c_types::PublicKey, mut outbound_from_broadcaster: bool) -> u64 { + let mut ret = lightning::ln::chan_utils::get_commitment_transaction_number_obscure_factor(&broadcaster_payment_basepoint.into_rust(), &countersignatory_payment_basepoint.into_rust(), outbound_from_broadcaster); + ret +} + diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs new file mode 100644 index 0000000..9530c75 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -0,0 +1,1432 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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; + +/// 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 chain::Watch::watch_/update_channel, 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 (BlockHash, 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_tick_occurred 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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelManager, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelManager { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelManager_free(this_obj: 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_inner(mut self) -> *mut nativeChannelManager { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} + +use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport; +type nativeChainParameters = nativeChainParametersImport; + +/// Chain-related parameters used to construct a new `ChannelManager`. +/// +/// Typically, the block-specific parameters are derived from the best block hash for the network, +/// as a newly constructed `ChannelManager` will not have created any channels yet. These parameters +/// are not needed when deserializing a previously constructed `ChannelManager`. +#[must_use] +#[repr(C)] +pub struct ChainParameters { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChainParameters, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChainParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChainParameters_free(this_obj: ChainParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ChainParameters_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainParameters); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ChainParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The network for determining the `chain_hash` in Lightning messages. +#[no_mangle] +pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.network; + crate::bitcoin::network::Network::from_bitcoin((*inner_val)) +} +/// The network for determining the `chain_hash` in Lightning messages. +#[no_mangle] +pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) { + unsafe { &mut *this_ptr.inner }.network = val.into_bitcoin(); +} +/// The hash and height of the latest block successfully connected. +/// +/// Used to track on-chain channel funding outputs and send payments with reliable timelocks. +#[no_mangle] +pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::ln::channelmanager::BestBlock { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.best_block; + crate::lightning::ln::channelmanager::BestBlock { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// The hash and height of the latest block successfully connected. +/// +/// Used to track on-chain channel funding outputs and send payments with reliable timelocks. +#[no_mangle] +pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::lightning::ln::channelmanager::BestBlock) { + unsafe { &mut *this_ptr.inner }.best_block = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new ChainParameters given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::lightning::ln::channelmanager::BestBlock) -> ChainParameters { + ChainParameters { inner: Box::into_raw(Box::new(nativeChainParameters { + network: network_arg.into_bitcoin(), + best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) }, + })), is_owned: true } +} + +use lightning::ln::channelmanager::BestBlock as nativeBestBlockImport; +type nativeBestBlock = nativeBestBlockImport; + +/// The best known block as identified by its hash and height. +#[must_use] +#[repr(C)] +pub struct BestBlock { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeBestBlock, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for BestBlock { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBestBlock>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BestBlock_free(this_obj: BestBlock) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn BestBlock_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBestBlock); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl BestBlock { + pub(crate) fn take_inner(mut self) -> *mut nativeBestBlock { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for BestBlock { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBestBlock>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 BestBlock_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBestBlock)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BestBlock +pub extern "C" fn BestBlock_clone(orig: &BestBlock) -> BestBlock { + orig.clone() +} +/// Returns the best block from the genesis of the given network. +#[must_use] +#[no_mangle] +pub extern "C" fn BestBlock_from_genesis(mut network: crate::bitcoin::network::Network) -> BestBlock { + let mut ret = lightning::ln::channelmanager::BestBlock::from_genesis(network.into_bitcoin()); + BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Returns the best block as identified by the given block hash and height. +#[must_use] +#[no_mangle] +pub extern "C" fn BestBlock_new(mut block_hash: crate::c_types::ThirtyTwoBytes, mut height: u32) -> BestBlock { + let mut ret = lightning::ln::channelmanager::BestBlock::new(::bitcoin::hash_types::BlockHash::from_slice(&block_hash.data[..]).unwrap(), height); + BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Returns the best block hash. +#[must_use] +#[no_mangle] +pub extern "C" fn BestBlock_block_hash(this_arg: &BestBlock) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*this_arg.inner }.block_hash(); + crate::c_types::ThirtyTwoBytes { data: ret.into_inner() } +} + +/// Returns the best block height. +#[must_use] +#[no_mangle] +pub extern "C" fn BestBlock_height(this_arg: &BestBlock) -> u32 { + let mut ret = unsafe { &*this_arg.inner }.height(); + ret +} + +/// The amount of time in blocks we require our counterparty wait to claim their money (ie time +/// between when we, or our watchtower, must check for them having broadcast a theft transaction). +/// +/// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`] +/// +/// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay + +#[no_mangle] +pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT; +/// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound +/// HTLC's CLTV. The current default represents roughly six hours of blocks at six blocks/hour. +/// +/// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`] +/// +/// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta + +#[no_mangle] +pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA; + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelDetails, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelDetails { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelDetails_free(this_obj: 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_inner(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 position of the funding transaction in the chain. None if the funding transaction has +/// not yet been confirmed and the channel fully opened. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; + local_inner_val +} +/// The position of the funding transaction in the chain. None if the funding transaction has +/// not yet been confirmed and the channel fully opened. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *this_ptr.inner }.short_channel_id = local_val; +} +/// 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::lightning::ln::features::InitFeatures { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_features; + crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, 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::lightning::ln::features::InitFeatures) { + unsafe { &mut *this_ptr.inner }.counterparty_features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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; +} +impl Clone for ChannelDetails { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelDetails>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDetails)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelDetails +pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails { + orig.clone() +} +/// 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] +#[derive(Clone)] +#[repr(C)] +pub enum PaymentSendFailure { + /// A parameter which was passed to send_payment was invalid, preventing us from attempting to + /// send the payment at all. No channel state has been changed or messages sent to peers, and + /// once you've changed the parameter at error, you can freely retry the payment in full. + ParameterError(crate::lightning::util::errors::APIError), + /// A parameter in a single path which was passed to send_payment was invalid, preventing us + /// from attempting to send the payment at all. No channel state has been changed or messages + /// sent to peers, and once you've changed the parameter at error, you can freely retry the + /// payment in full. + /// + /// The results here are ordered the same as the paths in the route object which was passed to + /// send_payment. + PathParameterError(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ), + /// All paths which were attempted failed to send, with no channel state change taking place. + /// You can freely retry the payment in full (though you probably want to do so over different + /// paths than the ones selected). + AllFailedRetrySafe(crate::c_types::derived::CVec_APIErrorZ), + /// Some paths which were attempted failed to send, though possibly not all. At least some + /// paths have irrevocably committed to the HTLC and retrying the payment in full would result + /// in over-/re-payment. + /// + /// The results here are ordered the same as the paths in the route object which was passed to + /// send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely + /// retried (though there is currently no API with which to do so). + /// + /// Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried + /// as they will result in over-/re-payment. These HTLCs all either successfully sent (in the + /// case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel + /// with the latest update_id. + PartialFailure(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ), +} +use lightning::ln::channelmanager::PaymentSendFailure as nativePaymentSendFailure; +impl PaymentSendFailure { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativePaymentSendFailure { + match self { + PaymentSendFailure::ParameterError (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativePaymentSendFailure::ParameterError ( + a_nonref.into_native(), + ) + }, + PaymentSendFailure::PathParameterError (ref a, ) => { + let mut a_nonref = (*a).clone(); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_nonref_0 }); }; + nativePaymentSendFailure::PathParameterError ( + local_a_nonref, + ) + }, + PaymentSendFailure::AllFailedRetrySafe (ref a, ) => { + let mut a_nonref = (*a).clone(); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into_native() }); }; + nativePaymentSendFailure::AllFailedRetrySafe ( + local_a_nonref, + ) + }, + PaymentSendFailure::PartialFailure (ref a, ) => { + let mut a_nonref = (*a).clone(); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_nonref_0 }); }; + nativePaymentSendFailure::PartialFailure ( + local_a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativePaymentSendFailure { + match self { + PaymentSendFailure::ParameterError (mut a, ) => { + nativePaymentSendFailure::ParameterError ( + a.into_native(), + ) + }, + PaymentSendFailure::PathParameterError (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let mut local_a_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_0 }); }; + nativePaymentSendFailure::PathParameterError ( + local_a, + ) + }, + PaymentSendFailure::AllFailedRetrySafe (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into_native() }); }; + nativePaymentSendFailure::AllFailedRetrySafe ( + local_a, + ) + }, + PaymentSendFailure::PartialFailure (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let mut local_a_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_0 }); }; + nativePaymentSendFailure::PartialFailure ( + local_a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativePaymentSendFailure) -> Self { + match native { + nativePaymentSendFailure::ParameterError (ref a, ) => { + let mut a_nonref = (*a).clone(); + PaymentSendFailure::ParameterError ( + crate::lightning::util::errors::APIError::native_into(a_nonref), + ) + }, + nativePaymentSendFailure::PathParameterError (ref a, ) => { + let mut a_nonref = (*a).clone(); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); }; + PaymentSendFailure::PathParameterError ( + local_a_nonref.into(), + ) + }, + nativePaymentSendFailure::AllFailedRetrySafe (ref a, ) => { + let mut a_nonref = (*a).clone(); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { crate::lightning::util::errors::APIError::native_into(item) }); }; + PaymentSendFailure::AllFailedRetrySafe ( + local_a_nonref.into(), + ) + }, + nativePaymentSendFailure::PartialFailure (ref a, ) => { + let mut a_nonref = (*a).clone(); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); }; + PaymentSendFailure::PartialFailure ( + local_a_nonref.into(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativePaymentSendFailure) -> Self { + match native { + nativePaymentSendFailure::ParameterError (mut a, ) => { + PaymentSendFailure::ParameterError ( + crate::lightning::util::errors::APIError::native_into(a), + ) + }, + nativePaymentSendFailure::PathParameterError (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let mut local_a_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); }; + PaymentSendFailure::PathParameterError ( + local_a.into(), + ) + }, + nativePaymentSendFailure::AllFailedRetrySafe (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::lightning::util::errors::APIError::native_into(item) }); }; + PaymentSendFailure::AllFailedRetrySafe ( + local_a.into(), + ) + }, + nativePaymentSendFailure::PartialFailure (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let mut local_a_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); }; + PaymentSendFailure::PartialFailure ( + local_a.into(), + ) + }, + } + } +} +/// Frees any resources used by the PaymentSendFailure +#[no_mangle] +pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { } +/// Creates a copy of the PaymentSendFailure +#[no_mangle] +pub extern "C" fn PaymentSendFailure_clone(orig: &PaymentSendFailure) -> PaymentSendFailure { + orig.clone() +} +/// 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 need to notify the new ChannelManager when a new block is connected or +/// disconnected using its `block_connected` and `block_disconnected` methods, starting +/// from after `params.latest_hash`. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_new(mut fee_est: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut logger: crate::lightning::util::logger::Logger, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters) -> ChannelManager { + let mut ret = lightning::ln::channelmanager::ChannelManager::new(fee_est, chain_monitor, tx_broadcaster, logger, keys_manager, *unsafe { Box::from_raw(config.take_inner()) }, *unsafe { Box::from_raw(params.take_inner()) }); + ChannelManager { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Gets the current configuration applied to all new channels, as +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &ChannelManager) -> crate::lightning::util::config::UserConfig { + let mut ret = unsafe { &*this_arg.inner }.get_current_default_configuration(); + crate::lightning::util::config::UserConfig { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// 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 events to allow +/// tracking of which events correspond with which create_channel call. Note that the +/// user_channel_id defaults to 0 for inbound channels, so you may wish to avoid using 0 for +/// user_id here. user_id has no meaning inside of LDK, it is simply copied to events and +/// otherwise ignored. +/// +/// 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::lightning::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_inner()) } }) }; + 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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + 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 mut item in ret.drain(..) { local_ret.push( { crate::lightning::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 mut item in ret.drain(..) { local_ret.push( { crate::lightning::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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// Force closes a channel, immediately broadcasting the latest local commitment transaction to +/// the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_force_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*this_arg.inner }.force_close_channel(unsafe { &*channel_id}); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// 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::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut 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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() }; + local_ret +} + +/// Call this upon creation of a funding transaction for the given channel. +/// +/// Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs +/// or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. +/// +/// Panics if a funding transaction has already been provided for this channel. +/// +/// May panic if the output found in the funding transaction is duplicative with some other +/// channel (note that this should be trivially prevented by using unique funding transaction +/// keys per-channel). +/// +/// Do NOT broadcast the funding transaction yourself. When we have safely received our +/// counterparty's signature the funding transaction will automatically be broadcast via the +/// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. +/// +/// Note that this includes RBF or similar transaction replacement strategies - lightning does +/// not currently support replacing a funding transaction on an existing channel. Instead, +/// create a new channel with a conflicting funding transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32], mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*this_arg.inner }.funding_transaction_generated(unsafe { &*temporary_channel_id}, funding_transaction.into_bitcoin()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// 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. +/// +/// Note that in some rare cases this may generate a `chain::Watch::update_channel` call. +#[no_mangle] +pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &ChannelManager) { + unsafe { &*this_arg.inner }.timer_tick_occurred() +} + +/// 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], mut 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, mut 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 chain::Watch 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::lightning::chain::transaction::OutPoint, mut highest_applied_update_id: u64) { + unsafe { &*this_arg.inner }.channel_monitor_updated(unsafe { &*funding_txo.inner }, highest_applied_update_id) +} + +impl From for crate::lightning::util::events::MessageSendEventsProvider { + fn from(obj: nativeChannelManager) -> Self { + let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChannelManager_as_MessageSendEventsProvider(&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(ChannelManager_free_void); + ret + } +} +/// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::MessageSendEventsProvider { + crate::lightning::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, + } +} + +#[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 = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); }; + local_ret.into() +} + +impl From for crate::lightning::util::events::EventsProvider { + fn from(obj: nativeChannelManager) -> Self { + let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChannelManager_as_EventsProvider(&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(ChannelManager_free_void); + ret + } +} +/// Constructs a new EventsProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::EventsProvider { + crate::lightning::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, + } +} + +#[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 = >::get_and_clear_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::Event::native_into(item) }); }; + local_ret.into() +} + +impl From for crate::lightning::chain::Listen { + fn from(obj: nativeChannelManager) -> Self { + let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChannelManager_as_Listen(&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(ChannelManager_free_void); + ret + } +} +/// Constructs a new Listen which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChannelManager_as_Listen(this_arg: &ChannelManager) -> crate::lightning::chain::Listen { + crate::lightning::chain::Listen { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + block_connected: ChannelManager_Listen_block_connected, + block_disconnected: ChannelManager_Listen_block_disconnected, + } +} + +extern "C" fn ChannelManager_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) { + >::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height) +} +extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { + >::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +} + +/// Updates channel state to take note of transactions which were confirmed in the given block +/// at the given height. +/// +/// Note that you must still call (or have called) [`update_best_block`] with the block +/// information which is included here. +/// +/// This method may be called before or after [`update_best_block`] for a given block's +/// transaction data and may be called multiple times with additional transaction data for a +/// given block. +/// +/// This method may be called for a previous block after an [`update_best_block`] call has +/// been made for a later block, however it must *not* be called with transaction data from a +/// block which is no longer in the best chain (ie where [`update_best_block`] has already +/// been informed about a blockchain reorganization which no longer includes the block which +/// corresponds to `header`). +/// +/// [`update_best_block`]: `Self::update_best_block` +#[no_mangle] +pub extern "C" fn ChannelManager_transactions_confirmed(this_arg: &ChannelManager, header: *const [u8; 80], mut height: u32, mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ) { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + unsafe { &*this_arg.inner }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..]) +} + +/// Updates channel state with the current best blockchain tip. You should attempt to call this +/// quickly after a new block becomes available, however if multiple new blocks become +/// available at the same time, only a single `update_best_block()` call needs to be made. +/// +/// This method should also be called immediately after any block disconnections, once at the +/// reorganization fork point, and once with the new chain tip. Calling this method at the +/// blockchain reorganization fork point ensures we learn when a funding transaction which was +/// previously confirmed is reorganized out of the blockchain, ensuring we do not continue to +/// accept payments which cannot be enforced on-chain. +/// +/// In both the block-connection and block-disconnection case, this method may be called either +/// once per block connected or disconnected, or simply at the fork point and new tip(s), +/// skipping any intermediary blocks. +#[no_mangle] +pub extern "C" fn ChannelManager_update_best_block(this_arg: &ChannelManager, header: *const [u8; 80], mut height: u32) { + unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +} + +/// Gets the set of txids which should be monitored for their confirmation state. +/// +/// If you're providing information about reorganizations via [`transaction_unconfirmed`], this +/// is the set of transactions which you may need to call [`transaction_unconfirmed`] for. +/// +/// This may be useful to poll to determine the set of transactions which must be registered +/// with an Electrum server or for which an Electrum server needs to be polled to determine +/// transaction confirmation state. +/// +/// This may update after any [`transactions_confirmed`] or [`block_connected`] call. +/// +/// Note that this is NOT the set of transactions which must be included in calls to +/// [`transactions_confirmed`] if they are confirmed, but a small subset of it. +/// +/// [`transactions_confirmed`]: Self::transactions_confirmed +/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed +/// [`block_connected`]: chain::Listen::block_connected +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_get_relevant_txids(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_TxidZ { + let mut ret = unsafe { &*this_arg.inner }.get_relevant_txids(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; + local_ret.into() +} + +/// Marks a transaction as having been reorganized out of the blockchain. +/// +/// If a transaction is included in [`get_relevant_txids`], and is no longer in the main branch +/// of the blockchain, this function should be called to indicate that the transaction should +/// be considered reorganized out. +/// +/// Once this is called, the given transaction will no longer appear on [`get_relevant_txids`], +/// though this may be called repeatedly for a given transaction without issue. +/// +/// Note that if the transaction is confirmed on the main chain in a different block (indicated +/// via a call to [`transactions_confirmed`]), it may re-appear in [`get_relevant_txids`], thus +/// be very wary of race-conditions wherein the final state of a transaction indicated via +/// these APIs is not the same as its state on the blockchain. +/// +/// [`transactions_confirmed`]: Self::transactions_confirmed +/// [`get_relevant_txids`]: Self::get_relevant_txids +#[no_mangle] +pub extern "C" fn ChannelManager_transaction_unconfirmed(this_arg: &ChannelManager, txid: *const [u8; 32]) { + unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) +} + +/// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool +/// indicating whether persistence is necessary. Only one listener on +/// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken +/// up. +/// Note that the feature `allow_wallclock_use` must be enabled to use this function. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_await_persistable_update_timeout(this_arg: &ChannelManager, mut max_wait: u64) -> bool { + let mut ret = unsafe { &*this_arg.inner }.await_persistable_update_timeout(std::time::Duration::from_secs(max_wait)); + ret +} + +/// Blocks until ChannelManager needs to be persisted. Only one listener on +/// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken +/// up. +#[no_mangle] +pub extern "C" fn ChannelManager_await_persistable_update(this_arg: &ChannelManager) { + unsafe { &*this_arg.inner }.await_persistable_update() +} + +impl From for crate::lightning::ln::msgs::ChannelMessageHandler { + fn from(obj: nativeChannelManager) -> Self { + let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChannelManager_as_ChannelMessageHandler(&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(ChannelManager_free_void); + ret + } +} +/// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelManager) -> crate::lightning::ln::msgs::ChannelMessageHandler { + crate::lightning::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_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update, + handle_error: ChannelManager_ChannelMessageHandler_handle_error, + MessageSendEventsProvider: crate::lightning::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, + }, + } +} + +extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel) { + >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel) { + >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) { + >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned) { + >::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingLocked) { + >::handle_funding_locked(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown) { + >::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*their_features.inner }, unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { + >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) { + >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC) { + >::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC) { + >::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) { + >::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned) { + >::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK) { + >::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee) { + >::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) { + >::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate) { + >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) { + >::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) { + >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), no_connection_possible) +} +extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) { + >::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*init_msg.inner }) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage) { + >::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} + +#[no_mangle] +/// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read +pub extern "C" fn ChannelManager_write(obj: &ChannelManager) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) }) +} + +use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport; +type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::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: +/// <(BlockHash, 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) If you are not fetching full blocks, register all relevant ChannelMonitor outpoints the same +/// way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and +/// ChannelMonitor::get_funding_txo(). +/// 4) Reconnect blocks on your ChannelMonitors. +/// 5) Disconnect/connect blocks on the ChannelManager. +/// 6) Move the ChannelMonitors into your local chain::Watch. +/// +/// Note that the ordering of #4-6 is not of importance, however all three must occur before you +/// call any other methods on the newly-deserialized ChannelManager. +/// +/// Note that because some channels may be closed during deserialization, it is critical that you +/// always deserialize only the latest version of a ChannelManager and ChannelMonitors available to +/// you. If you deserialize an old ChannelManager (during which force-closure transactions may be +/// broadcast), and then later deserialize a newer version of the same ChannelManager (which will +/// not force-close the same channels but consider them live), you may end up revoking a state for +/// which you've already broadcasted the transaction. +#[must_use] +#[repr(C)] +pub struct ChannelManagerReadArgs { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelManagerReadArgs, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelManagerReadArgs { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelManagerReadArgs_free(this_obj: 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_inner(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 and KeysInterface::read_chan_signer will be used to read per-Channel +/// signing data. +#[no_mangle] +pub extern "C" fn ChannelManagerReadArgs_get_keys_manager(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::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 and KeysInterface::read_chan_signer will be used to read per-Channel +/// signing data. +#[no_mangle] +pub extern "C" fn ChannelManagerReadArgs_set_keys_manager(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::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::lightning::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::lightning::chain::chaininterface::FeeEstimator) { + unsafe { &mut *this_ptr.inner }.fee_estimator = val; +} +/// The chain::Watch for use in the ChannelManager in the future. +/// +/// No calls to the chain::Watch will be made during deserialization. It is assumed that +/// you have deserialized ChannelMonitors separately and will add them to your +/// chain::Watch after deserializing this ChannelManager. +#[no_mangle] +pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::Watch { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_monitor; + &(*inner_val) +} +/// The chain::Watch for use in the ChannelManager in the future. +/// +/// No calls to the chain::Watch will be made during deserialization. It is assumed that +/// you have deserialized ChannelMonitors separately and will add them to your +/// chain::Watch after deserializing this ChannelManager. +#[no_mangle] +pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::Watch) { + unsafe { &mut *this_ptr.inner }.chain_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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::util::config::UserConfig { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.default_config; + crate::lightning::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::lightning::util::config::UserConfig) { + unsafe { &mut *this_ptr.inner }.default_config = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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::lightning::chain::keysinterface::KeysInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut logger: crate::lightning::util::logger::Logger, mut default_config: crate::lightning::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, chain_monitor, tx_broadcaster, logger, *unsafe { Box::from_raw(default_config.take_inner()) }, local_channel_monitors); + ChannelManagerReadArgs { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +#[no_mangle] +/// Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write +pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_read(ser: crate::c_types::u8slice, arg: crate::lightning::ln::channelmanager::ChannelManagerReadArgs) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) }; + let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::lightning::ln::channelmanager::ChannelManager { inner: Box::into_raw(Box::new(orig_res_0_1)), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs new file mode 100644 index 0000000..e12ee03 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -0,0 +1,411 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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). +//! +//! 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]: crate::ln::msgs + +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +impl Clone for InitFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInitFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 InitFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInitFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InitFeatures +pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures { + orig.clone() +} +impl Clone for NodeFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 NodeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the NodeFeatures +pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures { + orig.clone() +} +impl Clone for ChannelFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 ChannelFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelFeatures +pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures { + orig.clone() +} +impl Clone for InvoiceFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InvoiceFeatures +pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatures { + orig.clone() +} + +use lightning::ln::features::InitFeatures as nativeInitFeaturesImport; +type nativeInitFeatures = nativeInitFeaturesImport; + +/// Features used within an `init` message. +#[must_use] +#[repr(C)] +pub struct InitFeatures { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeInitFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for InitFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InitFeatures_free(this_obj: 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_inner(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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeNodeFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for NodeFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn NodeFeatures_free(this_obj: 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_inner(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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelFeatures_free(this_obj: 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_inner(mut self) -> *mut nativeChannelFeatures { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} + +use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport; +type nativeInvoiceFeatures = nativeInvoiceFeaturesImport; + +/// Features used within an invoice. +#[must_use] +#[repr(C)] +pub struct InvoiceFeatures { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeInvoiceFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for InvoiceFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceFeatures); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl InvoiceFeatures { + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceFeatures { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_empty() -> InitFeatures { + let mut ret = lightning::ln::features::InitFeatures::empty(); + InitFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Creates a Features with the bits set which are known by the implementation +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_known() -> InitFeatures { + let mut ret = lightning::ln::features::InitFeatures::known(); + InitFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_empty() -> NodeFeatures { + let mut ret = lightning::ln::features::NodeFeatures::empty(); + NodeFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Creates a Features with the bits set which are known by the implementation +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_known() -> NodeFeatures { + let mut ret = lightning::ln::features::NodeFeatures::known(); + NodeFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_empty() -> ChannelFeatures { + let mut ret = lightning::ln::features::ChannelFeatures::empty(); + ChannelFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Creates a Features with the bits set which are known by the implementation +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures { + let mut ret = lightning::ln::features::ChannelFeatures::known(); + ChannelFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceFeatures_empty() -> InvoiceFeatures { + let mut ret = lightning::ln::features::InvoiceFeatures::empty(); + InvoiceFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Creates a Features with the bits set which are known by the implementation +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceFeatures_known() -> InvoiceFeatures { + let mut ret = lightning::ln::features::InvoiceFeatures::known(); + InvoiceFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +#[no_mangle] +/// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read +pub extern "C" fn InitFeatures_write(obj: &InitFeatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInitFeatures) }) +} +#[no_mangle] +/// Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read +pub extern "C" fn NodeFeatures_write(obj: &NodeFeatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeFeatures) }) +} +#[no_mangle] +/// Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read +pub extern "C" fn ChannelFeatures_write(obj: &ChannelFeatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelFeatures) }) +} +#[no_mangle] +/// Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read +pub extern "C" fn InvoiceFeatures_write(obj: &InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceFeatures) }) +} +#[no_mangle] +/// Read a InitFeatures from a byte array, created by InitFeatures_write +pub extern "C" fn InitFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitFeaturesDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InitFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Read a NodeFeatures from a byte array, created by NodeFeatures_write +pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeFeaturesDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::NodeFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Read a ChannelFeatures from a byte array, created by ChannelFeatures_write +pub extern "C" fn ChannelFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelFeaturesDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::ChannelFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write +pub extern "C" fn InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceFeaturesDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InvoiceFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/ln/mod.rs b/lightning-c-bindings/src/lightning/ln/mod.rs new file mode 100644 index 0000000..d6ca8b3 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/mod.rs @@ -0,0 +1,28 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 msgs; +pub mod peer_handler; +pub mod chan_utils; +pub mod features; diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs new file mode 100644 index 0000000..a005cf4 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -0,0 +1,5266 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeDecodeError, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for DecodeError { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDecodeError>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DecodeError_free(this_obj: 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_inner(mut self) -> *mut nativeDecodeError { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for DecodeError { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeDecodeError>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDecodeError)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the DecodeError +pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeInit, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Init { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInit>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the Init, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Init_free(this_obj: 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_inner(mut self) -> *mut nativeInit { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The relevant features which the sender supports +#[no_mangle] +pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; + crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// The relevant features which the sender supports +#[no_mangle] +pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) { + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new Init given each field +#[must_use] +#[no_mangle] +pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures) -> Init { + Init { inner: Box::into_raw(Box::new(nativeInit { + features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + })), is_owned: true } +} +impl Clone for Init { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInit>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 Init_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Init +pub extern "C" fn Init_clone(orig: &Init) -> Init { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeErrorMessage, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ErrorMessage { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ErrorMessage_free(this_obj: 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_inner(mut self) -> *mut nativeErrorMessage { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +/// Constructs a new ErrorMessage given each field +#[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 } +} +impl Clone for ErrorMessage { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeErrorMessage>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ErrorMessage +pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativePing, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Ping { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePing>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Ping_free(this_obj: 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_inner(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; +} +/// Constructs a new Ping given each field +#[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 } +} +impl Clone for Ping { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativePing>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 Ping_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Ping +pub extern "C" fn Ping_clone(orig: &Ping) -> Ping { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativePong, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Pong { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePong>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Pong_free(this_obj: 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_inner(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; +} +/// Constructs a new Pong given each field +#[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 } +} +impl Clone for Pong { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativePong>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 Pong_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Pong +pub extern "C" fn Pong_clone(orig: &Pong) -> Pong { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeOpenChannel, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for OpenChannel { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OpenChannel_free(this_obj: 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_inner(mut self) -> *mut nativeOpenChannel { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +impl Clone for OpenChannel { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the OpenChannel +pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeAcceptChannel, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for AcceptChannel { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn AcceptChannel_free(this_obj: 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_inner(mut self) -> *mut nativeAcceptChannel { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +impl Clone for AcceptChannel { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the AcceptChannel +pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeFundingCreated, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for FundingCreated { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn FundingCreated_free(this_obj: 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_inner(mut self) -> *mut nativeFundingCreated { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +/// Constructs a new FundingCreated given each field +#[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 } +} +impl Clone for FundingCreated { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the FundingCreated +pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeFundingSigned, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for FundingSigned { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn FundingSigned_free(this_obj: 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_inner(mut self) -> *mut nativeFundingSigned { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +/// Constructs a new FundingSigned given each field +#[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 } +} +impl Clone for FundingSigned { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the FundingSigned +pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeFundingLocked, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for FundingLocked { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeFundingLocked>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn FundingLocked_free(this_obj: 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_inner(mut self) -> *mut nativeFundingLocked { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +/// Constructs a new FundingLocked given each field +#[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 } +} +impl Clone for FundingLocked { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the FundingLocked +pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeShutdown, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Shutdown { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Shutdown_free(this_obj: 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_inner(mut self) -> *mut nativeShutdown { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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()); +} +/// Constructs a new Shutdown given each field +#[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 } +} +impl Clone for Shutdown { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the Shutdown +pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeClosingSigned, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ClosingSigned { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ClosingSigned_free(this_obj: 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_inner(mut self) -> *mut nativeClosingSigned { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +/// Constructs a new ClosingSigned given each field +#[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 } +} +impl Clone for ClosingSigned { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ClosingSigned +pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUpdateAddHTLC, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UpdateAddHTLC { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UpdateAddHTLC_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateAddHTLC { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +impl Clone for UpdateAddHTLC { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UpdateAddHTLC +pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUpdateFulfillHTLC, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UpdateFulfillHTLC { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UpdateFulfillHTLC_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateFulfillHTLC { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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); +} +/// Constructs a new UpdateFulfillHTLC given each field +#[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 } +} +impl Clone for UpdateFulfillHTLC { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UpdateFulfillHTLC +pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUpdateFailHTLC, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UpdateFailHTLC { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UpdateFailHTLC_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateFailHTLC { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +impl Clone for UpdateFailHTLC { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UpdateFailHTLC +pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUpdateFailMalformedHTLC, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UpdateFailMalformedHTLC { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +impl Clone for UpdateFailMalformedHTLC { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UpdateFailMalformedHTLC +pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeCommitmentSigned, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for CommitmentSigned { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CommitmentSigned_free(this_obj: 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_inner(mut self) -> *mut nativeCommitmentSigned { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +/// Constructs a new CommitmentSigned given each field +#[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 } +} +impl Clone for CommitmentSigned { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the CommitmentSigned +pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeRevokeAndACK, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for RevokeAndACK { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RevokeAndACK_free(this_obj: 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_inner(mut self) -> *mut nativeRevokeAndACK { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +/// Constructs a new RevokeAndACK given each field +#[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 } +} +impl Clone for RevokeAndACK { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the RevokeAndACK +pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUpdateFee, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UpdateFee { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UpdateFee_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateFee { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +/// Constructs a new UpdateFee given each field +#[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 } +} +impl Clone for UpdateFee { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UpdateFee +pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeDataLossProtect, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for DataLossProtect { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DataLossProtect_free(this_obj: 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_inner(mut self) -> *mut nativeDataLossProtect { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +/// Constructs a new DataLossProtect given each field +#[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 } +} +impl Clone for DataLossProtect { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the DataLossProtect +pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelReestablish, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelReestablish { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelReestablish_free(this_obj: 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_inner(mut self) -> *mut nativeChannelReestablish { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +impl Clone for ChannelReestablish { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ChannelReestablish +pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeAnnouncementSignatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for AnnouncementSignatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn AnnouncementSignatures_free(this_obj: 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_inner(mut self) -> *mut nativeAnnouncementSignatures { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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(); +} +/// Constructs a new AnnouncementSignatures given each field +#[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 } +} +impl Clone for AnnouncementSignatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the AnnouncementSignatures +pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures { + orig.clone() +} +/// 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 { + /// The 4-byte IPv4 address + addr: crate::c_types::FourBytes, + /// The port on which the node is listening + port: u16, + }, + /// An IPv6 address/port on which the peer is listening. + IPv6 { + /// The 16-byte IPv6 address + addr: crate::c_types::SixteenBytes, + /// The port on which the node is listening + port: u16, + }, + /// An old-style Tor onion address/port on which the peer is listening. + OnionV2 { + /// The bytes (usually encoded in base32 with \".onion\" appended) + addr: crate::c_types::TenBytes, + /// The port on which the node is listening + 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 { + /// The ed25519 long-term public key of the peer + ed25519_pubkey: crate::c_types::ThirtyTwoBytes, + /// The checksum of the pubkey and version, as included in the onion address + checksum: u16, + /// The version byte, as defined by the Tor Onion v3 spec. + version: u8, + /// The port on which the node is listening + 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, + } + }, + } + } +} +/// Frees any resources used by the NetAddress +#[no_mangle] +pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { } +/// Creates a copy of the NetAddress +#[no_mangle] +pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress { + orig.clone() +} +#[no_mangle] +/// Serialize the NetAddress object into a byte array which can be read by NetAddress_read +pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a Result from a byte array, created by Result_write +pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { e }).into() }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport; +type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport; + +/// The unsigned part of a node_announcement +#[must_use] +#[repr(C)] +pub struct UnsignedNodeAnnouncement { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUnsignedNodeAnnouncement, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UnsignedNodeAnnouncement { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: 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_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The advertised features +#[no_mangle] +pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; + crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// The advertised features +#[no_mangle] +pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) { + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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; +} +impl Clone for UnsignedNodeAnnouncement { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UnsignedNodeAnnouncement +pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeNodeAnnouncement, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for NodeAnnouncement { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn NodeAnnouncement_free(this_obj: 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_inner(mut self) -> *mut nativeNodeAnnouncement { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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::lightning::ln::msgs::UnsignedNodeAnnouncement { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; + crate::lightning::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::lightning::ln::msgs::UnsignedNodeAnnouncement) { + unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new NodeAnnouncement given each field +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::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_inner()) }, + })), is_owned: true } +} +impl Clone for NodeAnnouncement { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the NodeAnnouncement +pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement { + orig.clone() +} + +use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport; +type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport; + +/// The unsigned part of a channel_announcement +#[must_use] +#[repr(C)] +pub struct UnsignedChannelAnnouncement { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUnsignedChannelAnnouncement, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UnsignedChannelAnnouncement { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: 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_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The advertised channel features +#[no_mangle] +pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; + crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// The advertised channel features +#[no_mangle] +pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) { + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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(); +} +impl Clone for UnsignedChannelAnnouncement { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UnsignedChannelAnnouncement +pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelAnnouncement, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelAnnouncement { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelAnnouncement_free(this_obj: 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_inner(mut self) -> *mut nativeChannelAnnouncement { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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::lightning::ln::msgs::UnsignedChannelAnnouncement { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; + crate::lightning::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::lightning::ln::msgs::UnsignedChannelAnnouncement) { + unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new ChannelAnnouncement given each field +#[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::lightning::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_inner()) }, + })), is_owned: true } +} +impl Clone for ChannelAnnouncement { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ChannelAnnouncement +pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement { + orig.clone() +} + +use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport; +type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport; + +/// The unsigned part of a channel_update +#[must_use] +#[repr(C)] +pub struct UnsignedChannelUpdate { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUnsignedChannelUpdate, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UnsignedChannelUpdate { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UnsignedChannelUpdate_free(this_obj: 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_inner(mut self) -> *mut nativeUnsignedChannelUpdate { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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 such that if: +/// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` +/// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines +/// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a +/// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, +/// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before +/// forwarding. Note that the HTLC sender is the one who originally sets this value when +/// constructing the route. +#[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 such that if: +/// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` +/// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines +/// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a +/// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, +/// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before +/// forwarding. Note that the HTLC sender is the one who originally sets this value when +/// constructing the route. +#[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; +} +impl Clone for UnsignedChannelUpdate { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UnsignedChannelUpdate +pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelUpdate, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelUpdate { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelUpdate_free(this_obj: 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_inner(mut self) -> *mut nativeChannelUpdate { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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::lightning::ln::msgs::UnsignedChannelUpdate { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; + crate::lightning::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::lightning::ln::msgs::UnsignedChannelUpdate) { + unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new ChannelUpdate given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::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_inner()) }, + })), is_owned: true } +} +impl Clone for ChannelUpdate { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ChannelUpdate +pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate { + orig.clone() +} + +use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport; +type nativeQueryChannelRange = nativeQueryChannelRangeImport; + +/// A query_channel_range message is used to query a peer for channel +/// UTXOs in a range of blocks. The recipient of a query makes a best +/// effort to reply to the query using one or more reply_channel_range +/// messages. +#[must_use] +#[repr(C)] +pub struct QueryChannelRange { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeQueryChannelRange, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for QueryChannelRange { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl QueryChannelRange { + pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *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 being queried +#[no_mangle] +pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// The height of the first block for the channel UTXOs being queried +#[no_mangle] +pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; + (*inner_val) +} +/// The height of the first block for the channel UTXOs being queried +#[no_mangle] +pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) { + unsafe { &mut *this_ptr.inner }.first_blocknum = val; +} +/// The number of blocks to include in the query results +#[no_mangle] +pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; + (*inner_val) +} +/// The number of blocks to include in the query results +#[no_mangle] +pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) { + unsafe { &mut *this_ptr.inner }.number_of_blocks = val; +} +/// Constructs a new QueryChannelRange given each field +#[must_use] +#[no_mangle] +pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange { + QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + first_blocknum: first_blocknum_arg, + number_of_blocks: number_of_blocks_arg, + })), is_owned: true } +} +impl Clone for QueryChannelRange { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the QueryChannelRange +pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange { + orig.clone() +} + +use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport; +type nativeReplyChannelRange = nativeReplyChannelRangeImport; + +/// A reply_channel_range message is a reply to a query_channel_range +/// message. Multiple reply_channel_range messages can be sent in reply +/// to a single query_channel_range message. The query recipient makes a +/// best effort to respond based on their local network view which may +/// not be a perfect view of the network. The short_channel_ids in the +/// reply are encoded. We only support encoding_type=0 uncompressed +/// serialization and do not support encoding_type=1 zlib serialization. +#[must_use] +#[repr(C)] +pub struct ReplyChannelRange { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeReplyChannelRange, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ReplyChannelRange { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ReplyChannelRange { + pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *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 being queried +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// The height of the first block in the range of the reply +#[no_mangle] +pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; + (*inner_val) +} +/// The height of the first block in the range of the reply +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) { + unsafe { &mut *this_ptr.inner }.first_blocknum = val; +} +/// The number of blocks included in the range of the reply +#[no_mangle] +pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; + (*inner_val) +} +/// The number of blocks included in the range of the reply +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) { + unsafe { &mut *this_ptr.inner }.number_of_blocks = val; +} +/// True when this is the final reply for a query +#[no_mangle] +pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete; + (*inner_val) +} +/// True when this is the final reply for a query +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) { + unsafe { &mut *this_ptr.inner }.sync_complete = val; +} +/// The short_channel_ids in the channel range +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, 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 }.short_channel_ids = local_val; +} +/// Constructs a new ReplyChannelRange given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange { + let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; + ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + first_blocknum: first_blocknum_arg, + number_of_blocks: number_of_blocks_arg, + sync_complete: sync_complete_arg, + short_channel_ids: local_short_channel_ids_arg, + })), is_owned: true } +} +impl Clone for ReplyChannelRange { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ReplyChannelRange +pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange { + orig.clone() +} + +use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport; +type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport; + +/// A query_short_channel_ids message is used to query a peer for +/// routing gossip messages related to one or more short_channel_ids. +/// The query recipient will reply with the latest, if available, +/// channel_announcement, channel_update and node_announcement messages +/// it maintains for the requested short_channel_ids followed by a +/// reply_short_channel_ids_end message. The short_channel_ids sent in +/// this query are encoded. We only support encoding_type=0 uncompressed +/// serialization and do not support encoding_type=1 zlib serialization. +#[must_use] +#[repr(C)] +pub struct QueryShortChannelIds { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeQueryShortChannelIds, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for QueryShortChannelIds { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl QueryShortChannelIds { + pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *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 being queried +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, 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_ids that are being queried +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, 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 }.short_channel_ids = local_val; +} +/// Constructs a new QueryShortChannelIds given each field +#[must_use] +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds { + let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; + QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + short_channel_ids: local_short_channel_ids_arg, + })), is_owned: true } +} +impl Clone for QueryShortChannelIds { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the QueryShortChannelIds +pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds { + orig.clone() +} + +use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport; +type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport; + +/// A reply_short_channel_ids_end message is sent as a reply to a +/// query_short_channel_ids message. The query recipient makes a best +/// effort to respond based on their local network view which may not be +/// a perfect view of the network. +#[must_use] +#[repr(C)] +pub struct ReplyShortChannelIdsEnd { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeReplyShortChannelIdsEnd, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ReplyShortChannelIdsEnd { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ReplyShortChannelIdsEnd { + pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The genesis hash of the blockchain that was queried +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *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 that was queried +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// Indicates if the query recipient maintains up-to-date channel +/// information for the chain_hash +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information; + (*inner_val) +} +/// Indicates if the query recipient maintains up-to-date channel +/// information for the chain_hash +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) { + unsafe { &mut *this_ptr.inner }.full_information = val; +} +/// Constructs a new ReplyShortChannelIdsEnd given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd { + ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + full_information: full_information_arg, + })), is_owned: true } +} +impl Clone for ReplyShortChannelIdsEnd { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ReplyShortChannelIdsEnd +pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd { + orig.clone() +} + +use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport; +type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport; + +/// A gossip_timestamp_filter message is used by a node to request +/// gossip relay for messages in the requested time range when the +/// gossip_queries feature has been negotiated. +#[must_use] +#[repr(C)] +pub struct GossipTimestampFilter { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeGossipTimestampFilter, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for GossipTimestampFilter { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl GossipTimestampFilter { + pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The genesis hash of the blockchain for channel and node information +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *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 for channel and node information +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// The starting unix timestamp +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp; + (*inner_val) +} +/// The starting unix timestamp +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) { + unsafe { &mut *this_ptr.inner }.first_timestamp = val; +} +/// The range of information in seconds +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range; + (*inner_val) +} +/// The range of information in seconds +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) { + unsafe { &mut *this_ptr.inner }.timestamp_range = val; +} +/// Constructs a new GossipTimestampFilter given each field +#[must_use] +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter { + GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + first_timestamp: first_timestamp_arg, + timestamp_range: timestamp_range_arg, + })), is_owned: true } +} +impl Clone for GossipTimestampFilter { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the GossipTimestampFilter +pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter { + orig.clone() +} +/// 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 { + /// An error message which we should make an effort to send before we disconnect. + msg: crate::lightning::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 { + /// The message to send. + msg: crate::lightning::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_inner()) } }) }; + 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_inner()) }, + } + }, + } + } + #[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_inner()) } }) }; + nativeErrorAction::DisconnectPeer { + msg: local_msg, + } + }, + ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, + ErrorAction::SendErrorMessage {mut msg, } => { + nativeErrorAction::SendErrorMessage { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + } + } + #[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::lightning::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::lightning::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::lightning::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::lightning::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, + } + } +} +/// Frees any resources used by the ErrorAction +#[no_mangle] +pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { } +/// Creates a copy of the ErrorAction +#[no_mangle] +pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeLightningError, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for LightningError { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LightningError_free(this_obj: 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_inner(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::lightning::ln::msgs::ErrorAction { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action; + crate::lightning::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::lightning::ln::msgs::ErrorAction) { + unsafe { &mut *this_ptr.inner }.action = val.into_native(); +} +/// Constructs a new LightningError given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::lightning::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 } +} +impl Clone for LightningError { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LightningError +pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeCommitmentUpdate, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for CommitmentUpdate { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CommitmentUpdate_free(this_obj: 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_inner(mut self) -> *mut nativeCommitmentUpdate { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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_inner()) } }); }; + 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_inner()) } }); }; + 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_inner()) } }); }; + 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_inner()) } }); }; + 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::lightning::ln::msgs::UpdateFee { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee; + let mut local_inner_val = crate::lightning::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::lightning::ln::msgs::UpdateFee) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + 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::lightning::ln::msgs::CommitmentSigned { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed; + crate::lightning::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::lightning::ln::msgs::CommitmentSigned) { + unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new CommitmentUpdate given each field +#[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::lightning::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::lightning::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_inner()) } }); }; + 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_inner()) } }); }; + 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_inner()) } }); }; + 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_inner()) } }); }; + let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_inner()) } }) }; + 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_inner()) }, + })), is_owned: true } +} +impl Clone for CommitmentUpdate { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the CommitmentUpdate +pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate { + orig.clone() +} +/// 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 { + /// The unwrapped message we received + msg: crate::lightning::ln::msgs::ChannelUpdate, + }, + /// We received an error which indicated only that a channel has been closed + ChannelClosed { + /// The short_channel_id which has now closed. + short_channel_id: u64, + /// when this true, this channel should be permanently removed from the + /// consideration. Otherwise, this channel can be restored as new channel_update is received + is_permanent: bool, + }, + /// We received an error which indicated only that a node has failed + NodeFailure { + /// The node_id that has failed. + node_id: crate::c_types::PublicKey, + /// when this true, node should be permanently removed from the + /// consideration. Otherwise, the channels connected to this node can be + /// restored as new channel_update is received + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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::lightning::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::lightning::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, + } + }, + } + } +} +/// Frees any resources used by the HTLCFailChannelUpdate +#[no_mangle] +pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { } +/// Creates a copy of the HTLCFailChannelUpdate +#[no_mangle] +pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate { + orig.clone() +} +/// 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 { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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::lightning::ln::features::InitFeatures, msg: &crate::lightning::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::lightning::ln::features::InitFeatures, msg: &crate::lightning::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::lightning::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::lightning::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::lightning::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, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::ln::msgs::ChannelReestablish), + /// Handle an incoming channel update from the given peer. + pub handle_channel_update: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate), + /// 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::lightning::ln::msgs::ErrorMessage), + /// Implementation of MessageSendEventsProvider for this object. + pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.MessageSendEventsProvider.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 + } +} +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::lightning::ln::features::InitFeatures { inner: Box::into_raw(Box::new(their_features)), is_owned: true }, &crate::lightning::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::lightning::ln::features::InitFeatures { inner: Box::into_raw(Box::new(their_features)), is_owned: true }, &crate::lightning::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::lightning::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::lightning::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::lightning::ln::msgs::FundingLocked { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) + } + fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: &lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::Shutdown) { + (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::features::InitFeatures { inner: unsafe { (their_features as *const _) as *mut _ }, is_owned: false }, &crate::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::ln::msgs::ChannelReestablish { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) + } + fn handle_channel_update(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelUpdate) { + (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { 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::lightning::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. +/// +/// # Implementor DoS Warnings +/// +/// For `gossip_queries` messages there are potential DoS vectors when handling +/// inbound queries. Implementors using an on-disk network graph should be aware of +/// repeated disk I/O for queries accessing different parts of the network graph. +#[repr(C)] +pub struct RoutingMessageHandler { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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::lightning::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::lightning::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::lightning::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::lightning::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 ::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, + /// Called when a connection is established with a peer. This can be used to + /// perform routing table synchronization using a strategy defined by the + /// implementor. + pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init), + /// Handles the reply of a query we initiated to learn about channels + /// for a given range of blocks. We can expect to receive one or more + /// replies to a single query. + #[must_use] + pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, + /// Handles the reply of a query we initiated asking for routing gossip + /// messages for a list of channels. We should receive this message when + /// a node has completed its best effort to send us the pertaining routing + /// gossip messages. + #[must_use] + pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ, + /// Handles when a peer asks us to send a list of short_channel_ids + /// for the requested range of blocks. + #[must_use] + pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, + /// Handles when a peer asks us to send routing gossip messages for a + /// list of short_channel_ids. + #[must_use] + pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ, + /// Implementation of MessageSendEventsProvider for this object. + pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for RoutingMessageHandler {} +unsafe impl Sync for RoutingMessageHandler {} +impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.MessageSendEventsProvider.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 + } +} + +use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler; +impl rustRoutingMessageHandler for RoutingMessageHandler { + fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result { + let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::lightning::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(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result { + let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::lightning::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(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result { + let mut ret = (self.handle_channel_update)(self.this_arg, &crate::lightning::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(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) { + (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(&update)) + } + fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option, Option)> { + 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_inner()) } }) }; 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_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, 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 { + 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_inner()) } }); }; + local_ret + } + fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) { + (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { (init as *const _) as *mut _ }, is_owned: false }) + } + fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_reply_short_channel_ids_end(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(msg)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + 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 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] +/// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read +pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) }) +} +#[no_mangle] +/// Read a AcceptChannel from a byte array, created by AcceptChannel_write +pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read +pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) }) +} +#[no_mangle] +/// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write +pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read +pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) }) +} +#[no_mangle] +/// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write +pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read +pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) }) +} +#[no_mangle] +/// Read a ClosingSigned from a byte array, created by ClosingSigned_write +pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read +pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) }) +} +#[no_mangle] +/// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write +pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::CommitmentSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read +pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) }) +} +#[no_mangle] +/// Read a FundingCreated from a byte array, created by FundingCreated_write +pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read +pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) }) +} +#[no_mangle] +/// Read a FundingSigned from a byte array, created by FundingSigned_write +pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read +pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) }) +} +#[no_mangle] +/// Read a FundingLocked from a byte array, created by FundingLocked_write +pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the Init object into a byte array which can be read by Init_read +pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) }) +} +#[no_mangle] +/// Read a Init from a byte array, created by Init_write +pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Init { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read +pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) }) +} +#[no_mangle] +/// Read a OpenChannel from a byte array, created by OpenChannel_write +pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read +pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) }) +} +#[no_mangle] +/// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write +pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the Shutdown object into a byte array which can be read by Shutdown_read +pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) }) +} +#[no_mangle] +/// Read a Shutdown from a byte array, created by Shutdown_write +pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read +pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) }) +} +#[no_mangle] +/// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write +pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read +pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) }) +} +#[no_mangle] +/// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write +pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read +pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) }) +} +#[no_mangle] +/// Read a UpdateFee from a byte array, created by UpdateFee_write +pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFee { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read +pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) }) +} +#[no_mangle] +/// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write +pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read +pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) }) +} +#[no_mangle] +/// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write +pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the Ping object into a byte array which can be read by Ping_read +pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) }) +} +#[no_mangle] +/// Read a Ping from a byte array, created by Ping_write +pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Ping { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the Pong object into a byte array which can be read by Pong_read +pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) }) +} +#[no_mangle] +/// Read a Pong from a byte array, created by Pong_write +pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Pong { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read +pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) }) +} +#[no_mangle] +/// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write +pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read +pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) }) +} +#[no_mangle] +/// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write +pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read +pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) }) +} +#[no_mangle] +/// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write +pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read +pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) }) +} +#[no_mangle] +/// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write +pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read +pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) }) +} +#[no_mangle] +/// Read a ErrorMessage from a byte array, created by ErrorMessage_write +pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read +pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) }) +} +#[no_mangle] +/// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write +pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read +pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) }) +} +#[no_mangle] +/// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write +pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write +pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read +pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) }) +} +#[no_mangle] +/// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write +pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read +pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) }) +} +///\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t +#[must_use] +#[no_mangle] +pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 { + let mut ret = unsafe { &*this_arg.inner }.end_blocknum(); + ret +} + +#[no_mangle] +/// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write +pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read +pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) }) +} +#[no_mangle] +/// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write +pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read +pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) }) +} +#[no_mangle] +/// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write +pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read +pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) }) +} diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs new file mode 100644 index 0000000..d1c07e6 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -0,0 +1,848 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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::IgnoringMessageHandler as nativeIgnoringMessageHandlerImport; +type nativeIgnoringMessageHandler = nativeIgnoringMessageHandlerImport; + +/// A dummy struct which implements `RoutingMessageHandler` without storing any routing information +/// or doing any processing. You can provide one of these as the route_handler in a MessageHandler. +#[must_use] +#[repr(C)] +pub struct IgnoringMessageHandler { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeIgnoringMessageHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for IgnoringMessageHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeIgnoringMessageHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn IgnoringMessageHandler_free(this_obj: IgnoringMessageHandler) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn IgnoringMessageHandler_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeIgnoringMessageHandler); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl IgnoringMessageHandler { + pub(crate) fn take_inner(mut self) -> *mut nativeIgnoringMessageHandler { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Constructs a new IgnoringMessageHandler given each field +#[must_use] +#[no_mangle] +pub extern "C" fn IgnoringMessageHandler_new() -> IgnoringMessageHandler { + IgnoringMessageHandler { inner: Box::into_raw(Box::new(nativeIgnoringMessageHandler { + })), is_owned: true } +} +impl From for crate::lightning::util::events::MessageSendEventsProvider { + fn from(obj: nativeIgnoringMessageHandler) -> Self { + let mut rust_obj = IgnoringMessageHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&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(IgnoringMessageHandler_free_void); + ret + } +} +/// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn IgnoringMessageHandler_as_MessageSendEventsProvider(this_arg: &IgnoringMessageHandler) -> crate::lightning::util::events::MessageSendEventsProvider { + crate::lightning::util::events::MessageSendEventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_msg_events: IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, + } +} + +#[must_use] +extern "C" fn IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { + let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); }; + local_ret.into() +} + +impl From for crate::lightning::ln::msgs::RoutingMessageHandler { + fn from(obj: nativeIgnoringMessageHandler) -> Self { + let mut rust_obj = IgnoringMessageHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = IgnoringMessageHandler_as_RoutingMessageHandler(&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(IgnoringMessageHandler_free_void); + ret + } +} +/// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn IgnoringMessageHandler_as_RoutingMessageHandler(this_arg: &IgnoringMessageHandler) -> crate::lightning::ln::msgs::RoutingMessageHandler { + crate::lightning::ln::msgs::RoutingMessageHandler { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + handle_node_announcement: IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement, + handle_channel_announcement: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement, + handle_channel_update: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update, + handle_htlc_fail_channel_update: IgnoringMessageHandler_RoutingMessageHandler_handle_htlc_fail_channel_update, + get_next_channel_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcements, + get_next_node_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcements, + sync_routing_table: IgnoringMessageHandler_RoutingMessageHandler_sync_routing_table, + handle_reply_channel_range: IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range, + handle_reply_short_channel_ids_end: IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end, + handle_query_channel_range: IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range, + handle_query_short_channel_ids: IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_channel_ids, + MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_msg_events: IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, + }, + } +} + +#[must_use] +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, _msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { + let mut ret = >::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, unsafe { &*_msg.inner }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, _msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { + let mut ret = >::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, unsafe { &*_msg.inner }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, _msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ { + let mut ret = >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, unsafe { &*_msg.inner }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, _update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate) { + >::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_update.to_native()) +} +#[must_use] +extern "C" fn IgnoringMessageHandler_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 = >::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _starting_point, _batch_amount); + let mut local_ret = Vec::new(); for mut 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::lightning::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::lightning::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::lightning::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 IgnoringMessageHandler_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 = >::get_next_node_announcements(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, local__starting_point, _batch_amount); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); }; + local_ret.into() +} +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _init: &crate::lightning::ln::msgs::Init) { + >::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_init.inner }) +} +#[must_use] +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + + +use lightning::ln::peer_handler::ErroringMessageHandler as nativeErroringMessageHandlerImport; +type nativeErroringMessageHandler = nativeErroringMessageHandlerImport; + +/// A dummy struct which implements `ChannelMessageHandler` without having any channels. +/// You can provide one of these as the route_handler in a MessageHandler. +#[must_use] +#[repr(C)] +pub struct ErroringMessageHandler { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeErroringMessageHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ErroringMessageHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeErroringMessageHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ErroringMessageHandler_free(this_obj: ErroringMessageHandler) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ErroringMessageHandler_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErroringMessageHandler); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ErroringMessageHandler { + pub(crate) fn take_inner(mut self) -> *mut nativeErroringMessageHandler { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Constructs a new ErroringMessageHandler +#[must_use] +#[no_mangle] +pub extern "C" fn ErroringMessageHandler_new() -> ErroringMessageHandler { + let mut ret = lightning::ln::peer_handler::ErroringMessageHandler::new(); + ErroringMessageHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +impl From for crate::lightning::util::events::MessageSendEventsProvider { + fn from(obj: nativeErroringMessageHandler) -> Self { + let mut rust_obj = ErroringMessageHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ErroringMessageHandler_as_MessageSendEventsProvider(&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(ErroringMessageHandler_free_void); + ret + } +} +/// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ErroringMessageHandler_as_MessageSendEventsProvider(this_arg: &ErroringMessageHandler) -> crate::lightning::util::events::MessageSendEventsProvider { + crate::lightning::util::events::MessageSendEventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_msg_events: ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, + } +} + +#[must_use] +extern "C" fn ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { + let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); }; + local_ret.into() +} + +impl From for crate::lightning::ln::msgs::ChannelMessageHandler { + fn from(obj: nativeErroringMessageHandler) -> Self { + let mut rust_obj = ErroringMessageHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ErroringMessageHandler_as_ChannelMessageHandler(&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(ErroringMessageHandler_free_void); + ret + } +} +/// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &ErroringMessageHandler) -> crate::lightning::ln::msgs::ChannelMessageHandler { + crate::lightning::ln::msgs::ChannelMessageHandler { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + handle_open_channel: ErroringMessageHandler_ChannelMessageHandler_handle_open_channel, + handle_accept_channel: ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel, + handle_funding_created: ErroringMessageHandler_ChannelMessageHandler_handle_funding_created, + handle_funding_signed: ErroringMessageHandler_ChannelMessageHandler_handle_funding_signed, + handle_funding_locked: ErroringMessageHandler_ChannelMessageHandler_handle_funding_locked, + handle_shutdown: ErroringMessageHandler_ChannelMessageHandler_handle_shutdown, + handle_closing_signed: ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed, + handle_update_add_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc, + handle_update_fulfill_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fulfill_htlc, + handle_update_fail_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_htlc, + handle_update_fail_malformed_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_malformed_htlc, + handle_commitment_signed: ErroringMessageHandler_ChannelMessageHandler_handle_commitment_signed, + handle_revoke_and_ack: ErroringMessageHandler_ChannelMessageHandler_handle_revoke_and_ack, + handle_update_fee: ErroringMessageHandler_ChannelMessageHandler_handle_update_fee, + handle_announcement_signatures: ErroringMessageHandler_ChannelMessageHandler_handle_announcement_signatures, + peer_disconnected: ErroringMessageHandler_ChannelMessageHandler_peer_disconnected, + peer_connected: ErroringMessageHandler_ChannelMessageHandler_peer_connected, + handle_channel_reestablish: ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish, + handle_channel_update: ErroringMessageHandler_ChannelMessageHandler_handle_channel_update, + handle_error: ErroringMessageHandler_ChannelMessageHandler_handle_error, + MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_msg_events: ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, + }, + } +} + +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut _their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel) { + >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(_their_features.take_inner()) }, unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut _their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel) { + >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(_their_features.take_inner()) }, unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) { + >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned) { + >::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingLocked) { + >::handle_funding_locked(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, _their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown) { + >::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*_their_features.inner }, unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { + >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) { + >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC) { + >::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC) { + >::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) { + >::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned) { + >::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK) { + >::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee) { + >::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) { + >::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) { + >::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::lightning::ln::msgs::ChannelUpdate) { + >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _no_connection_possible: bool) { + >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), _no_connection_possible) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::lightning::ln::msgs::Init) { + >::peer_connected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_msg.inner }) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::lightning::ln::msgs::ErrorMessage) { + >::handle_error(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_msg.inner }) +} + + +use lightning::ln::peer_handler::MessageHandler as nativeMessageHandlerImport; +type nativeMessageHandler = nativeMessageHandlerImport; + +/// Provides references to trait impls which handle different types of messages. +#[must_use] +#[repr(C)] +pub struct MessageHandler { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeMessageHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for MessageHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeMessageHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn MessageHandler_free(this_obj: 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_inner(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 or a ErroringMessageHandler. +#[no_mangle] +pub extern "C" fn MessageHandler_get_chan_handler(this_ptr: &MessageHandler) -> *const crate::lightning::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 or a ErroringMessageHandler. +#[no_mangle] +pub extern "C" fn MessageHandler_set_chan_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::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 or an IgnoringMessageHandler. +#[no_mangle] +pub extern "C" fn MessageHandler_get_route_handler(this_ptr: &MessageHandler) -> *const crate::lightning::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 or an IgnoringMessageHandler. +#[no_mangle] +pub extern "C" fn MessageHandler_set_route_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::msgs::RoutingMessageHandler) { + unsafe { &mut *this_ptr.inner }.route_handler = val; +} +/// Constructs a new MessageHandler given each field +#[must_use] +#[no_mangle] +pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::lightning::ln::msgs::ChannelMessageHandler, mut route_handler_arg: crate::lightning::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 { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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), + /// Checks if two objects are equal given this object's this_arg pointer and another object. + pub eq: extern "C" fn (this_arg: *const c_void, other_arg: &SocketDescriptor) -> bool, + /// Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. + /// This is used, for example, for inclusion of this object in a hash map. + pub hash: extern "C" fn (this_arg: *const c_void) -> u64, + /// Creates a copy of the object pointed to by this_arg, for a copy of this SocketDescriptor. + /// Note that the ultimate copy of the SocketDescriptor will have all function pointers the same as the original. + /// May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new SocketDescriptor. + pub clone: Option *mut c_void>, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +impl std::cmp::Eq for SocketDescriptor {} +impl std::cmp::PartialEq for SocketDescriptor { + fn eq(&self, o: &Self) -> bool { (self.eq)(self.this_arg, o) } +} +impl std::hash::Hash for SocketDescriptor { + fn hash(&self, hasher: &mut H) { hasher.write_u64((self.hash)(self.this_arg)) } +} +#[no_mangle] +/// Creates a copy of a SocketDescriptor +pub extern "C" fn SocketDescriptor_clone(orig: &SocketDescriptor) -> SocketDescriptor { + SocketDescriptor { + this_arg: if let Some(f) = orig.clone { (f)(orig.this_arg) } else { orig.this_arg }, + send_data: Clone::clone(&orig.send_data), + disconnect_socket: Clone::clone(&orig.disconnect_socket), + eq: Clone::clone(&orig.eq), + hash: Clone::clone(&orig.hash), + clone: Clone::clone(&orig.clone), + free: Clone::clone(&orig.free), + } +} +impl Clone for SocketDescriptor { + fn clone(&self) -> Self { + SocketDescriptor_clone(self) + } +} + +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/socket_disconnected calls for the +/// descriptor. +#[must_use] +#[repr(C)] +pub struct PeerHandleError { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativePeerHandleError, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for PeerHandleError { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePeerHandleError>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PeerHandleError_free(this_obj: 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_inner(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; +} +/// Constructs a new PeerHandleError given each field +#[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 } +} +impl Clone for PeerHandleError { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativePeerHandleError>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 PeerHandleError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePeerHandleError)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the PeerHandleError +pub extern "C" fn PeerHandleError_clone(orig: &PeerHandleError) -> PeerHandleError { + orig.clone() +} + +use lightning::ln::peer_handler::PeerManager as nativePeerManagerImport; +type nativePeerManager = nativePeerManagerImport; + +/// 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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativePeerManager, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for PeerManager { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePeerManager>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PeerManager_free(this_obj: 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_inner(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::lightning::ln::peer_handler::MessageHandler, mut our_node_secret: crate::c_types::SecretKey, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger) -> PeerManager { + let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, 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 mut 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::lightning::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 mut item in o.drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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::lightning::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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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::lightning::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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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::lightning::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 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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::lightning::ln::peer_handler::SocketDescriptor) { + unsafe { &*this_arg.inner }.socket_disconnected(descriptor) +} + +/// Disconnect a peer given its node id. +/// +/// Set no_connection_possible to true to prevent any further connection with this peer, +/// force-closing any channels we have with it. +/// +/// If a peer is connected, this will call `disconnect_socket` on the descriptor for the peer, +/// so be careful about reentrancy issues. +#[no_mangle] +pub extern "C" fn PeerManager_disconnect_by_node_id(this_arg: &PeerManager, mut node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) { + unsafe { &*this_arg.inner }.disconnect_by_node_id(node_id.into_rust(), no_connection_possible) +} + +/// 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_occurred(this_arg: &PeerManager) { + unsafe { &*this_arg.inner }.timer_tick_occurred() +} + diff --git a/lightning-c-bindings/src/lightning/mod.rs b/lightning-c-bindings/src/lightning/mod.rs new file mode 100644 index 0000000..6244aff --- /dev/null +++ b/lightning-c-bindings/src/lightning/mod.rs @@ -0,0 +1,25 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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. + +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +pub mod util; +pub mod chain; +pub mod ln; +pub mod routing; diff --git a/lightning-c-bindings/src/lightning/routing/mod.rs b/lightning-c-bindings/src/lightning/routing/mod.rs new file mode 100644 index 0000000..a06e1d0 --- /dev/null +++ b/lightning-c-bindings/src/lightning/routing/mod.rs @@ -0,0 +1,16 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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; diff --git a/lightning-c-bindings/src/lightning/routing/network_graph.rs b/lightning-c-bindings/src/lightning/routing/network_graph.rs new file mode 100644 index 0000000..5f719e9 --- /dev/null +++ b/lightning-c-bindings/src/lightning/routing/network_graph.rs @@ -0,0 +1,1259 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeNetworkGraph, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for NetworkGraph { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn NetworkGraph_free(this_obj: 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_inner(mut self) -> *mut nativeNetworkGraph { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for NetworkGraph { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the NetworkGraph +pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph { + orig.clone() +} + +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 possible from +/// the C bindings, as it can be done directly in Rust code. +#[must_use] +#[repr(C)] +pub struct LockedNetworkGraph { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeLockedNetworkGraph, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for LockedNetworkGraph { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLockedNetworkGraph>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LockedNetworkGraph_free(this_obj: 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_inner(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; + +/// 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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeNetGraphMsgHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for NetGraphMsgHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNetGraphMsgHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn NetGraphMsgHandler_free(this_obj: 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_inner(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 genesis_hash: crate::c_types::ThirtyTwoBytes, chain_access: *mut crate::lightning::chain::Access, mut logger: crate::lightning::util::logger::Logger) -> NetGraphMsgHandler { + let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; + let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), local_chain_access, 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(chain_access: *mut crate::lightning::chain::Access, mut logger: crate::lightning::util::logger::Logger, mut network_graph: crate::lightning::routing::network_graph::NetworkGraph) -> NetGraphMsgHandler { + let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; + let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(local_chain_access, logger, *unsafe { Box::from_raw(network_graph.take_inner()) }); + NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Adds a provider used to check new announcements. Does not affect +/// existing announcements unless they are updated. +/// Add, update or remove the provider would replace the current one. +#[no_mangle] +pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, chain_access: *mut crate::lightning::chain::Access) { + let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; + unsafe { &mut (*(this_arg.inner as *mut nativeNetGraphMsgHandler)) }.add_chain_access(local_chain_access) +} + +/// 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::lightning::routing::network_graph::LockedNetworkGraph { + let mut ret = unsafe { &*this_arg.inner }.read_locked_graph(); + crate::lightning::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::lightning::routing::network_graph::NetworkGraph { + let mut ret = unsafe { &*this_arg.inner }.graph(); + crate::lightning::routing::network_graph::NetworkGraph { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +impl From for crate::lightning::ln::msgs::RoutingMessageHandler { + fn from(obj: nativeNetGraphMsgHandler) -> Self { + let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&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(NetGraphMsgHandler_free_void); + ret + } +} +/// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &NetGraphMsgHandler) -> crate::lightning::ln::msgs::RoutingMessageHandler { + crate::lightning::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, + sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table, + handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range, + handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end, + handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range, + handle_query_short_channel_ids: NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids, + MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, + }, + } +} + +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { + let mut ret = >::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { + let mut ret = >::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate) { + >::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &update.to_native()) +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ { + let mut ret = >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + 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 = >::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount); + let mut local_ret = Vec::new(); for mut 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::lightning::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::lightning::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::lightning::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 = >::get_next_node_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, local_starting_point, batch_amount); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); }; + local_ret.into() +} +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) { + >::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), unsafe { &*init_msg.inner }) +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + +impl From for crate::lightning::util::events::MessageSendEventsProvider { + fn from(obj: nativeNetGraphMsgHandler) -> Self { + let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&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(NetGraphMsgHandler_free_void); + ret + } +} +/// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn NetGraphMsgHandler_as_MessageSendEventsProvider(this_arg: &NetGraphMsgHandler) -> crate::lightning::util::events::MessageSendEventsProvider { + crate::lightning::util::events::MessageSendEventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, + } +} + +#[must_use] +extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { + let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); }; + local_ret.into() +} + + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeDirectionalChannelInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for DirectionalChannelInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDirectionalChannelInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DirectionalChannelInfo_free(this_obj: 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_inner(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; +} +/// The maximum value which may be relayed to the next hop via the channel. +#[no_mangle] +pub extern "C" fn DirectionalChannelInfo_get_htlc_maximum_msat(this_ptr: &DirectionalChannelInfo) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_maximum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; + local_inner_val +} +/// The maximum value which may be relayed to the next hop via the channel. +#[no_mangle] +pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *this_ptr.inner }.htlc_maximum_msat = local_val; +} +/// Fees charged when the channel is used for routing +#[no_mangle] +pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::lightning::routing::network_graph::RoutingFees { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees; + crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Fees charged when the channel is used for routing +#[no_mangle] +pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) { + unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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::lightning::ln::msgs::ChannelUpdate { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update_message; + let mut local_inner_val = crate::lightning::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::lightning::ln::msgs::ChannelUpdate) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.last_update_message = local_val; +} +/// Constructs a new DirectionalChannelInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn DirectionalChannelInfo_new(mut last_update_arg: u32, mut enabled_arg: bool, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut fees_arg: crate::lightning::routing::network_graph::RoutingFees, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> DirectionalChannelInfo { + let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; + let mut local_last_update_message_arg = if last_update_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(last_update_message_arg.take_inner()) } }) }; + DirectionalChannelInfo { inner: Box::into_raw(Box::new(nativeDirectionalChannelInfo { + last_update: last_update_arg, + enabled: enabled_arg, + cltv_expiry_delta: cltv_expiry_delta_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + htlc_maximum_msat: local_htlc_maximum_msat_arg, + fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, + last_update_message: local_last_update_message_arg, + })), is_owned: true } +} +impl Clone for DirectionalChannelInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 DirectionalChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectionalChannelInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the DirectionalChannelInfo +pub extern "C" fn DirectionalChannelInfo_clone(orig: &DirectionalChannelInfo) -> DirectionalChannelInfo { + orig.clone() +} +#[no_mangle] +/// Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read +pub extern "C" fn DirectionalChannelInfo_write(obj: &DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) }) +} +#[no_mangle] +/// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write +pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelInfo_free(this_obj: 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_inner(mut self) -> *mut nativeChannelInfo { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Protocol features of a channel communicated during its announcement +#[no_mangle] +pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; + crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Protocol features of a channel communicated during its announcement +#[no_mangle] +pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::features::ChannelFeatures) { + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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::lightning::routing::network_graph::DirectionalChannelInfo { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.one_to_two; + let mut local_inner_val = crate::lightning::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::lightning::routing::network_graph::DirectionalChannelInfo) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + 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::lightning::routing::network_graph::DirectionalChannelInfo { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.two_to_one; + let mut local_inner_val = crate::lightning::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::lightning::routing::network_graph::DirectionalChannelInfo) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.two_to_one = local_val; +} +/// The channel capacity as seen on-chain, if chain lookup is available. +#[no_mangle] +pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.capacity_sats; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; + local_inner_val +} +/// The channel capacity as seen on-chain, if chain lookup is available. +#[no_mangle] +pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *this_ptr.inner }.capacity_sats = 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::lightning::ln::msgs::ChannelAnnouncement { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message; + let mut local_inner_val = crate::lightning::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::lightning::ln::msgs::ChannelAnnouncement) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.announcement_message = local_val; +} +/// Constructs a new ChannelInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelInfo_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut node_one_arg: crate::c_types::PublicKey, mut one_to_two_arg: crate::lightning::routing::network_graph::DirectionalChannelInfo, mut node_two_arg: crate::c_types::PublicKey, mut two_to_one_arg: crate::lightning::routing::network_graph::DirectionalChannelInfo, mut capacity_sats_arg: crate::c_types::derived::COption_u64Z, mut announcement_message_arg: crate::lightning::ln::msgs::ChannelAnnouncement) -> ChannelInfo { + let mut local_one_to_two_arg = if one_to_two_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(one_to_two_arg.take_inner()) } }) }; + let mut local_two_to_one_arg = if two_to_one_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(two_to_one_arg.take_inner()) } }) }; + let mut local_capacity_sats_arg = if capacity_sats_arg.is_some() { Some( { capacity_sats_arg.take() }) } else { None }; + let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) }; + ChannelInfo { inner: Box::into_raw(Box::new(nativeChannelInfo { + features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + node_one: node_one_arg.into_rust(), + one_to_two: local_one_to_two_arg, + node_two: node_two_arg.into_rust(), + two_to_one: local_two_to_one_arg, + capacity_sats: local_capacity_sats_arg, + announcement_message: local_announcement_message_arg, + })), is_owned: true } +} +impl Clone for ChannelInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelInfo +pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo { + orig.clone() +} +#[no_mangle] +/// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read +pub extern "C" fn ChannelInfo_write(obj: &ChannelInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) }) +} +#[no_mangle] +/// Read a ChannelInfo from a byte array, created by ChannelInfo_write +pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::ChannelInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeRoutingFees, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for RoutingFees { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RoutingFees_free(this_obj: 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_inner(mut self) -> *mut nativeRoutingFees { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +/// Constructs a new RoutingFees given each field +#[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 } +} +impl Clone for RoutingFees { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRoutingFees>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the RoutingFees +pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees { + orig.clone() +} +#[no_mangle] +/// Read a RoutingFees from a byte array, created by RoutingFees_write +pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::RoutingFees { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read +pub extern "C" fn RoutingFees_write(obj: &RoutingFees) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) }) +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeNodeAnnouncementInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for NodeAnnouncementInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_free(this_obj: 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_inner(mut self) -> *mut nativeNodeAnnouncementInfo { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Protocol features the node announced support for +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; + crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Protocol features the node announced support for +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::features::NodeFeatures) { + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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::lightning::ln::msgs::NodeAnnouncement { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message; + let mut local_inner_val = crate::lightning::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::lightning::ln::msgs::NodeAnnouncement) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.announcement_message = local_val; +} +/// Constructs a new NodeAnnouncementInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::c_types::ThirtyTwoBytes, mut addresses_arg: crate::c_types::derived::CVec_NetAddressZ, mut announcement_message_arg: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo { + let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); }; + let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) }; + NodeAnnouncementInfo { inner: Box::into_raw(Box::new(nativeNodeAnnouncementInfo { + features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + last_update: last_update_arg, + rgb: rgb_arg.data, + alias: alias_arg.data, + addresses: local_addresses_arg, + announcement_message: local_announcement_message_arg, + })), is_owned: true } +} +impl Clone for NodeAnnouncementInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncementInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the NodeAnnouncementInfo +pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo { + orig.clone() +} +#[no_mangle] +/// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read +pub extern "C" fn NodeAnnouncementInfo_write(obj: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) }) +} +#[no_mangle] +/// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write +pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeNodeInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for NodeInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn NodeInfo_free(this_obj: 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_inner(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::lightning::routing::network_graph::RoutingFees { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees; + let mut local_inner_val = crate::lightning::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::lightning::routing::network_graph::RoutingFees) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + 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::lightning::routing::network_graph::NodeAnnouncementInfo { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_info; + let mut local_inner_val = crate::lightning::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::lightning::routing::network_graph::NodeAnnouncementInfo) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.announcement_info = local_val; +} +/// Constructs a new NodeInfo given each field +#[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::lightning::routing::network_graph::RoutingFees, mut announcement_info_arg: crate::lightning::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_inner()) } }) }; + let mut local_announcement_info_arg = if announcement_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_info_arg.take_inner()) } }) }; + 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 } +} +impl Clone for NodeInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNodeInfo>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the NodeInfo +pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo { + orig.clone() +} +#[no_mangle] +/// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read +pub extern "C" fn NodeInfo_write(obj: &NodeInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) }) +} +#[no_mangle] +/// Read a NodeInfo from a byte array, created by NodeInfo_write +pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read +pub extern "C" fn NetworkGraph_write(obj: &NetworkGraph) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) }) +} +#[no_mangle] +/// Read a NetworkGraph from a byte array, created by NetworkGraph_write +pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} +/// Creates a new, empty, network graph. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes) -> crate::lightning::routing::network_graph::NetworkGraph { + let mut ret = lightning::routing::network_graph::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap()); + crate::lightning::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// For an already known node (from channel announcements), update its stored properties from a +/// given node announcement. +/// +/// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's +/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept +/// routing messages from a source using a protocol other than the lightning P2P protocol. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_announcement(unsafe { &*msg.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + +/// For an already known node (from channel announcements), update its stored properties from a +/// given node announcement without verifying the associated signatures. Because we aren't +/// given the associated signatures here we cannot relay the node announcement to any of our +/// peers. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_unsigned_announcement(unsafe { &*msg.inner }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + +/// Store or update channel info from a channel announcement. +/// +/// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's +/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept +/// routing messages from a source using a protocol other than the lightning P2P protocol. +/// +/// If a `chain::Access` object is provided via `chain_access`, it will be called to verify +/// the corresponding UTXO exists on chain and is correctly-formatted. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement, chain_access: *mut crate::lightning::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; + let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_announcement(unsafe { &*msg.inner }, &local_chain_access, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + +/// Store or update channel info from a channel announcement without verifying the associated +/// signatures. Because we aren't given the associated signatures here we cannot relay the +/// channel announcement to any of our peers. +/// +/// If a `chain::Access` object is provided via `chain_access`, it will be called to verify +/// the corresponding UTXO exists on chain and is correctly-formatted. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement, chain_access: *mut crate::lightning::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; + let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_unsigned_announcement(unsafe { &*msg.inner }, &local_chain_access); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + +/// 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) +} + +/// For an already known (from announcement) channel, update info about one of the directions +/// of the channel. +/// +/// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's +/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept +/// routing messages from a source using a protocol other than the lightning P2P protocol. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_update_channel(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel(unsafe { &*msg.inner }, secp256k1::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + +/// For an already known (from announcement) channel, update info about one of the directions +/// of the channel without verifying the associated signatures. Because we aren't given the +/// associated signatures here we cannot relay the channel update to any of our peers. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_unsigned(unsafe { &*msg.inner }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs new file mode 100644 index 0000000..211b44f --- /dev/null +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -0,0 +1,449 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeRouteHop, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for RouteHop { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRouteHop>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RouteHop_free(this_obj: 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_inner(mut self) -> *mut nativeRouteHop { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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 node_announcement features of the node at this hop. For the last hop, these may be +/// amended to match the features present in the invoice this node generated. +#[no_mangle] +pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::NodeFeatures { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_features; + crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// The node_announcement features of the node at this hop. For the last hop, these may be +/// amended to match the features present in the invoice this node generated. +#[no_mangle] +pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::NodeFeatures) { + unsafe { &mut *this_ptr.inner }.node_features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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 channel_announcement features of the channel that should be used from the previous hop +/// to reach this node. +#[no_mangle] +pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::ChannelFeatures { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_features; + crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// The channel_announcement features of the channel that should be used from the previous hop +/// to reach this node. +#[no_mangle] +pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::ChannelFeatures) { + unsafe { &mut *this_ptr.inner }.channel_features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The fee taken on this hop (for paying for the use of the *next* channel in the path). +/// For the last hop, this should be the full value of the payment (might be more than +/// requested if we had to match htlc_minimum_msat). +#[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 paying for the use of the *next* channel in the path). +/// For the last hop, this should be the full value of the payment (might be more than +/// requested if we had to match htlc_minimum_msat). +#[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; +} +/// Constructs a new RouteHop given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::lightning::ln::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::lightning::ln::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32) -> RouteHop { + RouteHop { inner: Box::into_raw(Box::new(nativeRouteHop { + pubkey: pubkey_arg.into_rust(), + node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) }, + short_channel_id: short_channel_id_arg, + channel_features: *unsafe { Box::from_raw(channel_features_arg.take_inner()) }, + fee_msat: fee_msat_arg, + cltv_expiry_delta: cltv_expiry_delta_arg, + })), is_owned: true } +} +impl Clone for RouteHop { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRouteHop>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the RouteHop +pub extern "C" fn RouteHop_clone(orig: &RouteHop) -> RouteHop { + orig.clone() +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeRoute, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Route { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRoute>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the Route, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Route_free(this_obj: 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_inner(mut self) -> *mut nativeRoute { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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_inner()) } }); }; local_val_0 }); }; + unsafe { &mut *this_ptr.inner }.paths = local_val; +} +/// Constructs a new Route given each field +#[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_inner()) } }); }; local_paths_arg_0 }); }; + Route { inner: Box::into_raw(Box::new(nativeRoute { + paths: local_paths_arg, + })), is_owned: true } +} +impl Clone for Route { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRoute>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the Route +pub extern "C" fn Route_clone(orig: &Route) -> Route { + orig.clone() +} +#[no_mangle] +/// Serialize the Route object into a byte array which can be read by Route_read +pub extern "C" fn Route_write(obj: &Route) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) }) +} +#[no_mangle] +/// Read a Route from a byte array, created by Route_write +pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeRouteHint, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for RouteHint { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RouteHint_free(this_obj: 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_inner(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::lightning::routing::network_graph::RoutingFees { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees; + crate::lightning::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::lightning::routing::network_graph::RoutingFees) { + unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; + local_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: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = local_val; +} +/// The maximum value in msat available for routing with a single HTLC. +#[no_mangle] +pub extern "C" fn RouteHint_get_htlc_maximum_msat(this_ptr: &RouteHint) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_maximum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; + local_inner_val +} +/// The maximum value in msat available for routing with a single HTLC. +#[no_mangle] +pub extern "C" fn RouteHint_set_htlc_maximum_msat(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *this_ptr.inner }.htlc_maximum_msat = local_val; +} +/// Constructs a new RouteHint given each field +#[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::lightning::routing::network_graph::RoutingFees, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteHint { + let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None }; + let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; + 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_inner()) }, + cltv_expiry_delta: cltv_expiry_delta_arg, + htlc_minimum_msat: local_htlc_minimum_msat_arg, + htlc_maximum_msat: local_htlc_maximum_msat_arg, + })), is_owned: true } +} +impl Clone for RouteHint { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRouteHint>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHint)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RouteHint +pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { + orig.clone() +} +/// Gets a route from us (payer) to the given target node (payee). +/// +/// If the payee provided features in their invoice, they should be provided via payee_features. +/// Without this, MPP will only be used if the payee's features are available in the network graph. +/// +/// 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/htlc_maximum_msat *are* checked as they may change based on the receiving node. +#[no_mangle] +pub extern "C" fn get_route(mut our_node_id: crate::c_types::PublicKey, network: &crate::lightning::routing::network_graph::NetworkGraph, mut payee: crate::c_types::PublicKey, mut payee_features: crate::lightning::ln::features::InvoiceFeatures, 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::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_RouteLightningErrorZ { + let mut local_payee_features = if payee_features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payee_features.take_inner()) } }) }; + let mut local_first_hops_base = if first_hops == std::ptr::null_mut() { 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 }, &payee.into_rust(), local_payee_features, 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::lightning::routing::router::Route { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs new file mode 100644 index 0000000..8ee8561 --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -0,0 +1,813 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelHandshakeConfig, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelHandshakeConfig { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelHandshakeConfig_free(this_obj: 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_inner(mut self) -> *mut nativeChannelHandshakeConfig { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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 number of blocks we require our counterparty to wait to claim their money (ie +/// the number of blocks we have to punish our counterparty if they broadcast a revoked +/// transaction). +/// +/// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST +/// be online to check for revoked transactions on-chain at least once every our_to_self_delay +/// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, +/// possibly with time in between to RBF the spending transaction). +/// +/// 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`], 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 number of blocks we require our counterparty to wait to claim their money (ie +/// the number of blocks we have to punish our counterparty if they broadcast a revoked +/// transaction). +/// +/// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST +/// be online to check for revoked transactions on-chain at least once every our_to_self_delay +/// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, +/// possibly with time in between to RBF the spending transaction). +/// +/// 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`], 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; +} +/// Constructs a new ChannelHandshakeConfig given each field +#[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 } +} +impl Clone for ChannelHandshakeConfig { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ChannelHandshakeConfig +pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig { + orig.clone() +} +/// Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. +#[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/::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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelHandshakeLimits, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelHandshakeLimits { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelHandshakeLimits_free(this_obj: 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_inner(mut self) -> *mut nativeChannelHandshakeLimits { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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: 2016, 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: 2016, 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; +} +/// Constructs a new ChannelHandshakeLimits given each field +#[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 } +} +impl Clone for ChannelHandshakeLimits { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ChannelHandshakeLimits +pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits { + orig.clone() +} +/// Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. +#[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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeChannelConfig, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelConfig { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelConfig_free(this_obj: 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_inner(mut self) -> *mut nativeChannelConfig { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// 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; +} +/// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over +/// the channel this config applies to. +/// +/// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight +/// HTLC balance when a channel appears on-chain whereas +/// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining +/// (non-HTLC-encumbered) balance. +/// +/// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, +/// we (or one of our watchtowers) MUST be online to check for broadcast of the current +/// commitment transaction at least once per this many blocks (minus some margin to allow us +/// enough time to broadcast and confirm a transaction, possibly with time in between to RBF +/// the spending transaction). +/// +/// Default value: 72 (12 hours at an average of 6 blocks/hour). +/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as +/// [`MIN_CLTV_EXPIRY_DELTA`] instead. +/// +/// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA +#[no_mangle] +pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; + (*inner_val) +} +/// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over +/// the channel this config applies to. +/// +/// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight +/// HTLC balance when a channel appears on-chain whereas +/// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining +/// (non-HTLC-encumbered) balance. +/// +/// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, +/// we (or one of our watchtowers) MUST be online to check for broadcast of the current +/// commitment transaction at least once per this many blocks (minus some margin to allow us +/// enough time to broadcast and confirm a transaction, possibly with time in between to RBF +/// the spending transaction). +/// +/// Default value: 72 (12 hours at an average of 6 blocks/hour). +/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as +/// [`MIN_CLTV_EXPIRY_DELTA`] instead. +/// +/// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA +#[no_mangle] +pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) { + unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = 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; +} +/// Constructs a new ChannelConfig given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelConfig_new(mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, 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, + cltv_expiry_delta: cltv_expiry_delta_arg, + announced_channel: announced_channel_arg, + commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg, + })), is_owned: true } +} +impl Clone for ChannelConfig { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelConfig>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the ChannelConfig +pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig { + orig.clone() +} +/// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. +#[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] +/// Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read +pub extern "C" fn ChannelConfig_write(obj: &ChannelConfig) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) }) +} +#[no_mangle] +/// Read a ChannelConfig from a byte array, created by ChannelConfig_write +pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::config::ChannelConfig { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} + +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 { + /// A pointer to the opaque Rust object. + + /// 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. + pub inner: *mut nativeUserConfig, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for UserConfig { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UserConfig_free(this_obj: 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_inner(mut self) -> *mut nativeUserConfig { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Channel config that we propose to our counterparty. +#[no_mangle] +pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeConfig { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.own_channel_config; + crate::lightning::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::lightning::util::config::ChannelHandshakeConfig) { + unsafe { &mut *this_ptr.inner }.own_channel_config = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// 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::lightning::util::config::ChannelHandshakeLimits { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.peer_channel_config_limits; + crate::lightning::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::lightning::util::config::ChannelHandshakeLimits) { + unsafe { &mut *this_ptr.inner }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Channel config which affects behavior during channel lifetime. +#[no_mangle] +pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelConfig { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_options; + crate::lightning::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::lightning::util::config::ChannelConfig) { + unsafe { &mut *this_ptr.inner }.channel_options = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new UserConfig given each field +#[must_use] +#[no_mangle] +pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_options_arg: crate::lightning::util::config::ChannelConfig) -> UserConfig { + UserConfig { inner: Box::into_raw(Box::new(nativeUserConfig { + own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) }, + peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) }, + channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) }, + })), is_owned: true } +} +impl Clone for UserConfig { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUserConfig>::is_null(self.inner) { std::ptr::null_mut() } else { + 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 +} +#[no_mangle] +/// Creates a copy of the UserConfig +pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig { + orig.clone() +} +/// Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. +#[must_use] +#[no_mangle] +pub extern "C" fn UserConfig_default() -> UserConfig { + UserConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true } +} diff --git a/lightning-c-bindings/src/lightning/util/errors.rs b/lightning-c-bindings/src/lightning/util/errors.rs new file mode 100644 index 0000000..5261382 --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/errors.rs @@ -0,0 +1,181 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 { + /// A human-readable error message + 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 { + /// A human-readable error message + err: crate::c_types::derived::CVec_u8Z, + /// The feerate which was too high. + feerate: u32, + }, + /// A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, + /// too-many-hops, etc). + RouteError { + /// A human-readable error message + 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 { + /// A human-readable error message + err: crate::c_types::derived::CVec_u8Z, + }, + /// An attempt to call watch/update_channel 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, + } + } +} +/// Frees any resources used by the APIError +#[no_mangle] +pub extern "C" fn APIError_free(this_ptr: APIError) { } +/// Creates a copy of the APIError +#[no_mangle] +pub extern "C" fn APIError_clone(orig: &APIError) -> APIError { + orig.clone() +} diff --git a/lightning-c-bindings/src/lightning/util/events.rs b/lightning-c-bindings/src/lightning/util/events.rs new file mode 100644 index 0000000..4e4e385 --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/events.rs @@ -0,0 +1,1101 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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 { + /// The random channel_id we picked which you'll need to pass into + /// ChannelManager::funding_transaction_generated. + temporary_channel_id: crate::c_types::ThirtyTwoBytes, + /// The value, in satoshis, that the output should have. + channel_value_satoshis: u64, + /// The script which should be used in the transaction output. + output_script: crate::c_types::derived::CVec_u8Z, + /// The value passed in to ChannelManager::create_channel + 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 { + /// The hash for which the preimage should be handed to the ChannelManager. + payment_hash: crate::c_types::ThirtyTwoBytes, + /// The \"payment secret\". This authenticates the sender to the recipient, preventing a + /// number of deanonymization attacks during the routing process. + /// As nodes upgrade, the invoices you provide should likely migrate to setting the + /// payment_secret feature to required, at which point you should fail_backwards any HTLCs + /// which have a None here. + /// Until then, however, values of None should be ignored, and only incorrect Some values + /// should result in an HTLC fail_backwards. + /// Note that, in any case, this value must be passed as-is to any fail or claim calls as + /// the HTLC index includes this value. + payment_secret: crate::c_types::ThirtyTwoBytes, + /// The value, in thousandths of a satoshi, that this payment is for. Note that you must + /// compare this to the expected value before accepting the payment (as otherwise you are + /// providing proof-of-payment for less than the value you expected!). + 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 { + /// The preimage to the hash given to ChannelManager::send_payment. + /// Note that this serves as a payment receipt, if you wish to have such a thing, you must + /// store it somehow! + 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 { + /// The hash which was given to ChannelManager::send_payment. + payment_hash: crate::c_types::ThirtyTwoBytes, + /// Indicates the payment was rejected for some reason by the recipient. This implies that + /// the payment has failed, not just the route in question. If this is not set, you may + /// retry the payment via a different route. + rejected_by_dest: bool, + }, + /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a + /// time in the future. + PendingHTLCsForwardable { + /// The minimum amount of time that should be waited prior to calling + /// process_pending_htlc_forwards. To increase the effort required to correlate payments, + /// you should wait a random amount of time in roughly the range (now + time_forwardable, + /// now + 5*time_forwardable). + 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 { + /// The outputs which you should store as spendable by you. + 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::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::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::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 mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::lightning::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::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 mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); }; + Event::SpendableOutputs { + outputs: local_outputs.into(), + } + }, + } + } +} +/// Frees any resources used by the Event +#[no_mangle] +pub extern "C" fn Event_free(this_ptr: Event) { } +/// Creates a copy of the Event +#[no_mangle] +pub extern "C" fn Event_clone(orig: &Event) -> Event { + orig.clone() +} +#[no_mangle] +/// Serialize the Event object into a byte array which can be read by Event_read +pub extern "C" fn Event_write(obj: &Event) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +/// 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 { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::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 { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::OpenChannel, + }, + /// Used to indicate that a funding_created message should be sent to the peer with the given node_id. + SendFundingCreated { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::FundingCreated, + }, + /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id. + SendFundingSigned { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::FundingSigned, + }, + /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id. + SendFundingLocked { + /// The node_id of the node which should receive these message(s) + node_id: crate::c_types::PublicKey, + /// The funding_locked message which should be sent. + msg: crate::lightning::ln::msgs::FundingLocked, + }, + /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. + SendAnnouncementSignatures { + /// The node_id of the node which should receive these message(s) + node_id: crate::c_types::PublicKey, + /// The announcement_signatures message which should be sent. + msg: crate::lightning::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 { + /// The node_id of the node which should receive these message(s) + node_id: crate::c_types::PublicKey, + /// The update messages which should be sent. ALL messages in the struct should be sent! + updates: crate::lightning::ln::msgs::CommitmentUpdate, + }, + /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. + SendRevokeAndACK { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::RevokeAndACK, + }, + /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id. + SendClosingSigned { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::ClosingSigned, + }, + /// Used to indicate that a shutdown message should be sent to the peer with the given node_id. + SendShutdown { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::Shutdown, + }, + /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. + SendChannelReestablish { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::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 { + /// The channel_announcement which should be sent. + msg: crate::lightning::ln::msgs::ChannelAnnouncement, + /// The followup channel_update which should be sent. + update_msg: crate::lightning::ln::msgs::ChannelUpdate, + }, + /// Used to indicate that a node_announcement should be broadcast to all peers. + BroadcastNodeAnnouncement { + /// The node_announcement which should be sent. + msg: crate::lightning::ln::msgs::NodeAnnouncement, + }, + /// Used to indicate that a channel_update should be broadcast to all peers. + BroadcastChannelUpdate { + /// The channel_update which should be sent. + msg: crate::lightning::ln::msgs::ChannelUpdate, + }, + /// Broadcast an error downstream to be handled + HandleError { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The action which should be taken. + action: crate::lightning::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 { + /// The channel/node update which should be sent to NetGraphMsgHandler + update: crate::lightning::ln::msgs::HTLCFailChannelUpdate, + }, + /// Query a peer for channels with funding transaction UTXOs in a block range. + SendChannelRangeQuery { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The query_channel_range which should be sent. + msg: crate::lightning::ln::msgs::QueryChannelRange, + }, + /// Request routing gossip messages from a peer for a list of channels identified by + /// their short_channel_ids. + SendShortIdsQuery { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The query_short_channel_ids which should be sent. + msg: crate::lightning::ln::msgs::QueryShortChannelIds, + }, + /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + /// emitted during processing of the query. + SendReplyChannelRange { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The reply_channel_range which should be sent. + msg: crate::lightning::ln::msgs::ReplyChannelRange, + }, +} +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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + } + }, + 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_inner()) }, + update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::BroadcastNodeAnnouncement { + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::BroadcastChannelUpdate {ref msg, } => { + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::BroadcastChannelUpdate { + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + 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(), + } + }, + MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::SendChannelRangeQuery { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::SendShortIdsQuery { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::SendReplyChannelRange { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + } + } + #[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_inner()) }, + } + }, + MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendOpenChannel { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendFundingCreated { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendFundingSigned { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendFundingLocked { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendAnnouncementSignatures { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { + nativeMessageSendEvent::UpdateHTLCs { + node_id: node_id.into_rust(), + updates: *unsafe { Box::from_raw(updates.take_inner()) }, + } + }, + MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendRevokeAndACK { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendClosingSigned { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendShutdown {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendShutdown { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendChannelReestablish { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { + nativeMessageSendEvent::BroadcastChannelAnnouncement { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) }, + } + }, + MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { + nativeMessageSendEvent::BroadcastNodeAnnouncement { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::BroadcastChannelUpdate {mut msg, } => { + nativeMessageSendEvent::BroadcastChannelUpdate { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + 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(), + } + }, + MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendChannelRangeQuery { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendShortIdsQuery { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendReplyChannelRange { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + } + } + #[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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + update_msg: crate::lightning::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::lightning::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::lightning::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::lightning::ln::msgs::ErrorAction::native_into(action_nonref), + } + }, + nativeMessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => { + let mut update_nonref = (*update).clone(); + MessageSendEvent::PaymentFailureNetworkUpdate { + update: crate::lightning::ln::msgs::HTLCFailChannelUpdate::native_into(update_nonref), + } + }, + nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + MessageSendEvent::SendChannelRangeQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + } + }, + nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + MessageSendEvent::SendShortIdsQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + } + }, + nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + MessageSendEvent::SendReplyChannelRange { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + } + }, + } + } + #[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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::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::lightning::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, + nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { + MessageSendEvent::BroadcastChannelAnnouncement { + msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg)), is_owned: true }, + } + }, + nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { + MessageSendEvent::BroadcastNodeAnnouncement { + msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, + nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => { + MessageSendEvent::BroadcastChannelUpdate { + msg: crate::lightning::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::lightning::ln::msgs::ErrorAction::native_into(action), + } + }, + nativeMessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => { + MessageSendEvent::PaymentFailureNetworkUpdate { + update: crate::lightning::ln::msgs::HTLCFailChannelUpdate::native_into(update), + } + }, + nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { + MessageSendEvent::SendChannelRangeQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, + nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { + MessageSendEvent::SendShortIdsQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, + nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { + MessageSendEvent::SendReplyChannelRange { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, + } + } +} +/// Frees any resources used by the MessageSendEvent +#[no_mangle] +pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { } +/// Creates a copy of the MessageSendEvent +#[no_mangle] +pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent { + orig.clone() +} +/// A trait indicating an object may generate message send events +#[repr(C)] +pub struct MessageSendEventsProvider { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} + +use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider; +impl rustMessageSendEventsProvider for MessageSendEventsProvider { + fn get_and_clear_pending_msg_events(&self) -> Vec { + 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 { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} + +use lightning::util::events::EventsProvider as rustEventsProvider; +impl rustEventsProvider for EventsProvider { + fn get_and_clear_pending_events(&self) -> Vec { + 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); + } + } +} diff --git a/lightning-c-bindings/src/lightning/util/logger.rs b/lightning-c-bindings/src/lightning/util/logger.rs new file mode 100644 index 0000000..3cfcf6d --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/logger.rs @@ -0,0 +1,138 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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, + } + } +} +/// Creates a copy of the Level +#[no_mangle] +pub extern "C" fn Level_clone(orig: &Level) -> Level { + orig.clone() +} +/// Returns the most verbose logging level. +#[must_use] +#[no_mangle] +pub extern "C" fn Level_max() -> crate::lightning::util::logger::Level { + let mut ret = lightning::util::logger::Level::max(); + crate::lightning::util::logger::Level::native_into(ret) +} + +/// A trait encapsulating the operations required of a logger +#[repr(C)] +pub struct Logger { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + 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), + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +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); + } + } +} diff --git a/lightning-c-bindings/src/lightning/util/mod.rs b/lightning-c-bindings/src/lightning/util/mod.rs new file mode 100644 index 0000000..49003dc --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/mod.rs @@ -0,0 +1,19 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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; diff --git a/lightning-c-bindings/src/lightning/util/ser.rs b/lightning-c-bindings/src/lightning/util/ser.rs new file mode 100644 index 0000000..e0c561f --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/ser.rs @@ -0,0 +1,19 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! 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::*; + +/// serialization buffer size + +#[no_mangle] +pub static MAX_BUF_SIZE: usize = lightning::util::ser::MAX_BUF_SIZE; diff --git a/lightning-c-bindings/src/ln/chan_utils.rs b/lightning-c-bindings/src/ln/chan_utils.rs deleted file mode 100644 index 69cf18c..0000000 --- a/lightning-c-bindings/src/ln/chan_utils.rs +++ /dev/null @@ -1,1504 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Various utilities for building scripts and deriving keys related to channels. These are -//! largely of interest for those implementing chain::keysinterface::Sign 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(mut per_commitment_point: crate::c_types::PublicKey, base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeyErrorZ { - let mut ret = lightning::ln::chan_utils::derive_private_key(secp256k1::SECP256K1, &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) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; - 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(mut per_commitment_point: crate::c_types::PublicKey, mut base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeyErrorZ { - let mut ret = lightning::ln::chan_utils::derive_public_key(secp256k1::SECP256K1, &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) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; - local_ret -} - -/// Derives a per-commitment-transaction revocation key from its constituent parts. -/// -/// Only the cheating participant owns a valid witness to propagate a revoked -/// commitment transaction, thus per_commitment_secret always come from cheater -/// and revocation_base_secret always come from punisher, which is the broadcaster -/// of the transaction spending with this key knowledge. -/// -/// 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], countersignatory_revocation_base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeyErrorZ { - let mut ret = lightning::ln::chan_utils::derive_private_revocation_key(secp256k1::SECP256K1, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_secret}[..]).unwrap(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *countersignatory_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) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; - 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. -/// -/// Only the cheating participant owns a valid witness to propagate a revoked -/// commitment transaction, thus per_commitment_point always come from cheater -/// and revocation_base_point always come from punisher, which is the broadcaster -/// of the transaction spending with this key knowledge. -/// -/// 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(mut per_commitment_point: crate::c_types::PublicKey, mut countersignatory_revocation_base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeyErrorZ { - let mut ret = lightning::ln::chan_utils::derive_public_revocation_key(secp256k1::SECP256K1, &per_commitment_point.into_rust(), &countersignatory_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) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; - 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. -/// -/// A broadcaster key is provided from potential broadcaster of the computed transaction. -/// A countersignatory key is coming from a protocol participant unable to broadcast the -/// transaction. -/// -/// 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 -/// CommitmentTransaction.trust().keys() because we trusted the source of the -/// pre-calculated keys. -#[must_use] -#[repr(C)] -pub struct TxCreationKeys { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeTxCreationKeys, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for TxCreationKeys { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeTxCreationKeys>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn TxCreationKeys_free(this_obj: 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_inner(mut self) -> *mut nativeTxCreationKeys { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The broadcaster's 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 broadcaster's 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 broadcaster 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 broadcaster 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(); -} -/// Broadcaster's HTLC Key -#[no_mangle] -pub extern "C" fn TxCreationKeys_get_broadcaster_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_htlc_key; - crate::c_types::PublicKey::from_rust(&(*inner_val)) -} -/// Broadcaster's HTLC Key -#[no_mangle] -pub extern "C" fn TxCreationKeys_set_broadcaster_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { - unsafe { &mut *this_ptr.inner }.broadcaster_htlc_key = val.into_rust(); -} -/// Countersignatory's HTLC Key -#[no_mangle] -pub extern "C" fn TxCreationKeys_get_countersignatory_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.countersignatory_htlc_key; - crate::c_types::PublicKey::from_rust(&(*inner_val)) -} -/// Countersignatory's HTLC Key -#[no_mangle] -pub extern "C" fn TxCreationKeys_set_countersignatory_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { - unsafe { &mut *this_ptr.inner }.countersignatory_htlc_key = val.into_rust(); -} -/// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) -#[no_mangle] -pub extern "C" fn TxCreationKeys_get_broadcaster_delayed_payment_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key; - crate::c_types::PublicKey::from_rust(&(*inner_val)) -} -/// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) -#[no_mangle] -pub extern "C" fn TxCreationKeys_set_broadcaster_delayed_payment_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { - unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key = val.into_rust(); -} -/// Constructs a new TxCreationKeys given each field -#[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 broadcaster_htlc_key_arg: crate::c_types::PublicKey, mut countersignatory_htlc_key_arg: crate::c_types::PublicKey, mut broadcaster_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(), - broadcaster_htlc_key: broadcaster_htlc_key_arg.into_rust(), - countersignatory_htlc_key: countersignatory_htlc_key_arg.into_rust(), - broadcaster_delayed_payment_key: broadcaster_delayed_payment_key_arg.into_rust(), - })), is_owned: true } -} -impl Clone for TxCreationKeys { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeTxCreationKeys>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the TxCreationKeys -pub extern "C" fn TxCreationKeys_clone(orig: &TxCreationKeys) -> TxCreationKeys { - orig.clone() -} -#[no_mangle] -/// Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read -pub extern "C" fn TxCreationKeys_write(obj: &TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn TxCreationKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxCreationKeys) }) -} -#[no_mangle] -/// Read a TxCreationKeys from a byte array, created by TxCreationKeys_write -pub extern "C" fn TxCreationKeys_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCreationKeysDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelPublicKeys, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelPublicKeys { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelPublicKeys>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelPublicKeys_free(this_obj: 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_inner(mut self) -> *mut nativeChannelPublicKeys { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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 on which the non-broadcaster (ie the countersignatory) receives an immediately -/// spendable primary channel balance on the broadcaster's commitment transaction. 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 on which the non-broadcaster (ie the countersignatory) receives an immediately -/// spendable primary channel balance on the broadcaster's commitment transaction. 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(); -} -/// Constructs a new ChannelPublicKeys given each field -#[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 } -} -impl Clone for ChannelPublicKeys { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelPublicKeys>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ChannelPublicKeys -pub extern "C" fn ChannelPublicKeys_clone(orig: &ChannelPublicKeys) -> ChannelPublicKeys { - orig.clone() -} -#[no_mangle] -/// Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read -pub extern "C" fn ChannelPublicKeys_write(obj: &ChannelPublicKeys) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelPublicKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelPublicKeys) }) -} -#[no_mangle] -/// Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write -pub extern "C" fn ChannelPublicKeys_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelPublicKeysDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::ChannelPublicKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -/// Create per-state keys from channel base points and the per-commitment point. -/// Key set is asymmetric and can't be used as part of counter-signatory set of transactions. -#[must_use] -#[no_mangle] -pub extern "C" fn TxCreationKeys_derive_new(mut per_commitment_point: crate::c_types::PublicKey, mut broadcaster_delayed_payment_base: crate::c_types::PublicKey, mut broadcaster_htlc_base: crate::c_types::PublicKey, mut countersignatory_revocation_base: crate::c_types::PublicKey, mut countersignatory_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysErrorZ { - let mut ret = lightning::ln::chan_utils::TxCreationKeys::derive_new(secp256k1::SECP256K1, &per_commitment_point.into_rust(), &broadcaster_delayed_payment_base.into_rust(), &broadcaster_htlc_base.into_rust(), &countersignatory_revocation_base.into_rust(), &countersignatory_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 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; - local_ret -} - -/// Generate per-state keys from channel static keys. -/// Key set is asymmetric and can't be used as part of counter-signatory set of transactions. -#[must_use] -#[no_mangle] -pub extern "C" fn TxCreationKeys_from_channel_static_keys(mut per_commitment_point: crate::c_types::PublicKey, broadcaster_keys: &crate::ln::chan_utils::ChannelPublicKeys, countersignatory_keys: &crate::ln::chan_utils::ChannelPublicKeys) -> crate::c_types::derived::CResult_TxCreationKeysErrorZ { - let mut ret = lightning::ln::chan_utils::TxCreationKeys::from_channel_static_keys(&per_commitment_point.into_rust(), unsafe { &*broadcaster_keys.inner }, unsafe { &*countersignatory_keys.inner }, secp256k1::SECP256K1); - 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 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; - local_ret -} - -/// The maximum length of a script returned by get_revokeable_redeemscript. - -#[no_mangle] -pub static REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH: usize = lightning::ln::chan_utils::REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; -/// A script either spendable by the revocation -/// key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. -/// Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. -#[no_mangle] -pub extern "C" fn get_revokeable_redeemscript(mut revocation_key: crate::c_types::PublicKey, mut contest_delay: u16, mut broadcaster_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(), contest_delay, &broadcaster_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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeHTLCOutputInCommitment, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for HTLCOutputInCommitment { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn HTLCOutputInCommitment_free(this_obj: 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_inner(mut self) -> *mut nativeHTLCOutputInCommitment { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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 counterparty 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 counterparty 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); -} -/// The position within the commitment transactions' outputs. This may be None if the value is -/// below the dust limit (in which case no output appears in the commitment transaction and the -/// value is spent to additional transaction fees). -#[no_mangle] -pub extern "C" fn HTLCOutputInCommitment_get_transaction_output_index(this_ptr: &HTLCOutputInCommitment) -> crate::c_types::derived::COption_u32Z { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.transaction_output_index; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { { crate::c_types::derived::COption_u32Z::Some(inner_val.unwrap()) } }; - local_inner_val -} -/// The position within the commitment transactions' outputs. This may be None if the value is -/// below the dust limit (in which case no output appears in the commitment transaction and the -/// value is spent to additional transaction fees). -#[no_mangle] -pub extern "C" fn HTLCOutputInCommitment_set_transaction_output_index(this_ptr: &mut HTLCOutputInCommitment, mut val: crate::c_types::derived::COption_u32Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *this_ptr.inner }.transaction_output_index = local_val; -} -/// Constructs a new HTLCOutputInCommitment given each field -#[must_use] -#[no_mangle] -pub extern "C" fn HTLCOutputInCommitment_new(mut offered_arg: bool, mut amount_msat_arg: u64, mut cltv_expiry_arg: u32, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut transaction_output_index_arg: crate::c_types::derived::COption_u32Z) -> HTLCOutputInCommitment { - let mut local_transaction_output_index_arg = if transaction_output_index_arg.is_some() { Some( { transaction_output_index_arg.take() }) } else { None }; - HTLCOutputInCommitment { inner: Box::into_raw(Box::new(nativeHTLCOutputInCommitment { - offered: offered_arg, - amount_msat: amount_msat_arg, - cltv_expiry: cltv_expiry_arg, - payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash_arg.data), - transaction_output_index: local_transaction_output_index_arg, - })), is_owned: true } -} -impl Clone for HTLCOutputInCommitment { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the HTLCOutputInCommitment -pub extern "C" fn HTLCOutputInCommitment_clone(orig: &HTLCOutputInCommitment) -> HTLCOutputInCommitment { - orig.clone() -} -#[no_mangle] -/// Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read -pub extern "C" fn HTLCOutputInCommitment_write(obj: &HTLCOutputInCommitment) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn HTLCOutputInCommitment_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCOutputInCommitment) }) -} -#[no_mangle] -/// Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write -pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HTLCOutputInCommitmentDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::HTLCOutputInCommitment { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -/// Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that 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(mut broadcaster: crate::c_types::PublicKey, mut countersignatory: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { - let mut ret = lightning::ln::chan_utils::make_funding_redeemscript(&broadcaster.into_rust(), &countersignatory.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 contest_delay: u16, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { - let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, contest_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); - let mut local_ret = ::bitcoin::consensus::encode::serialize(&ret); - crate::c_types::Transaction::from_vec(local_ret) -} - - -use lightning::ln::chan_utils::ChannelTransactionParameters as nativeChannelTransactionParametersImport; -type nativeChannelTransactionParameters = nativeChannelTransactionParametersImport; - -/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction). -/// The fields are organized by holder/counterparty. -/// -/// Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters -/// before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions. -#[must_use] -#[repr(C)] -pub struct ChannelTransactionParameters { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelTransactionParameters, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelTransactionParameters { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelTransactionParameters>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_free(this_obj: ChannelTransactionParameters) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ChannelTransactionParameters_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelTransactionParameters); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl ChannelTransactionParameters { - pub(crate) fn take_inner(mut self) -> *mut nativeChannelTransactionParameters { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Holder public keys -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_holder_pubkeys(this_ptr: &ChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_pubkeys; - crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// Holder public keys -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_holder_pubkeys(this_ptr: &mut ChannelTransactionParameters, mut val: crate::ln::chan_utils::ChannelPublicKeys) { - unsafe { &mut *this_ptr.inner }.holder_pubkeys = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The contest delay selected by the holder, which applies to counterparty-broadcast transactions -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_holder_selected_contest_delay(this_ptr: &ChannelTransactionParameters) -> u16 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay; - (*inner_val) -} -/// The contest delay selected by the holder, which applies to counterparty-broadcast transactions -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_holder_selected_contest_delay(this_ptr: &mut ChannelTransactionParameters, mut val: u16) { - unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay = val; -} -/// Whether the holder is the initiator of this channel. -/// This is an input to the commitment number obscure factor computation. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_is_outbound_from_holder(this_ptr: &ChannelTransactionParameters) -> bool { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_outbound_from_holder; - (*inner_val) -} -/// Whether the holder is the initiator of this channel. -/// This is an input to the commitment number obscure factor computation. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_is_outbound_from_holder(this_ptr: &mut ChannelTransactionParameters, mut val: bool) { - unsafe { &mut *this_ptr.inner }.is_outbound_from_holder = val; -} -/// The late-bound counterparty channel transaction parameters. -/// These parameters are populated at the point in the protocol where the counterparty provides them. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_counterparty_parameters(this_ptr: &ChannelTransactionParameters) -> crate::ln::chan_utils::CounterpartyChannelTransactionParameters { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_parameters; - let mut local_inner_val = crate::ln::chan_utils::CounterpartyChannelTransactionParameters { 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 -} -/// The late-bound counterparty channel transaction parameters. -/// These parameters are populated at the point in the protocol where the counterparty provides them. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_counterparty_parameters(this_ptr: &mut ChannelTransactionParameters, mut val: crate::ln::chan_utils::CounterpartyChannelTransactionParameters) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *this_ptr.inner }.counterparty_parameters = local_val; -} -/// The late-bound funding outpoint -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_funding_outpoint(this_ptr: &ChannelTransactionParameters) -> crate::chain::transaction::OutPoint { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_outpoint; - let mut local_inner_val = crate::chain::transaction::OutPoint { 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 -} -/// The late-bound funding outpoint -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &mut ChannelTransactionParameters, mut val: crate::chain::transaction::OutPoint) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *this_ptr.inner }.funding_outpoint = local_val; -} -/// Constructs a new ChannelTransactionParameters given each field -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::chain::transaction::OutPoint) -> ChannelTransactionParameters { - let mut local_counterparty_parameters_arg = if counterparty_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(counterparty_parameters_arg.take_inner()) } }) }; - let mut local_funding_outpoint_arg = if funding_outpoint_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_outpoint_arg.take_inner()) } }) }; - ChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeChannelTransactionParameters { - holder_pubkeys: *unsafe { Box::from_raw(holder_pubkeys_arg.take_inner()) }, - holder_selected_contest_delay: holder_selected_contest_delay_arg, - is_outbound_from_holder: is_outbound_from_holder_arg, - counterparty_parameters: local_counterparty_parameters_arg, - funding_outpoint: local_funding_outpoint_arg, - })), is_owned: true } -} -impl Clone for ChannelTransactionParameters { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelTransactionParameters>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 ChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelTransactionParameters)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelTransactionParameters -pub extern "C" fn ChannelTransactionParameters_clone(orig: &ChannelTransactionParameters) -> ChannelTransactionParameters { - orig.clone() -} - -use lightning::ln::chan_utils::CounterpartyChannelTransactionParameters as nativeCounterpartyChannelTransactionParametersImport; -type nativeCounterpartyChannelTransactionParameters = nativeCounterpartyChannelTransactionParametersImport; - -/// Late-bound per-channel counterparty data used to build transactions. -#[must_use] -#[repr(C)] -pub struct CounterpartyChannelTransactionParameters { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeCounterpartyChannelTransactionParameters, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for CounterpartyChannelTransactionParameters { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn CounterpartyChannelTransactionParameters_free(this_obj: CounterpartyChannelTransactionParameters) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn CounterpartyChannelTransactionParameters_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCounterpartyChannelTransactionParameters); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl CounterpartyChannelTransactionParameters { - pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyChannelTransactionParameters { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Counter-party public keys -#[no_mangle] -pub extern "C" fn CounterpartyChannelTransactionParameters_get_pubkeys(this_ptr: &CounterpartyChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkeys; - crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// Counter-party public keys -#[no_mangle] -pub extern "C" fn CounterpartyChannelTransactionParameters_set_pubkeys(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: crate::ln::chan_utils::ChannelPublicKeys) { - unsafe { &mut *this_ptr.inner }.pubkeys = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The contest delay selected by the counterparty, which applies to holder-broadcast transactions -#[no_mangle] -pub extern "C" fn CounterpartyChannelTransactionParameters_get_selected_contest_delay(this_ptr: &CounterpartyChannelTransactionParameters) -> u16 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.selected_contest_delay; - (*inner_val) -} -/// The contest delay selected by the counterparty, which applies to holder-broadcast transactions -#[no_mangle] -pub extern "C" fn CounterpartyChannelTransactionParameters_set_selected_contest_delay(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: u16) { - unsafe { &mut *this_ptr.inner }.selected_contest_delay = val; -} -/// Constructs a new CounterpartyChannelTransactionParameters given each field -#[must_use] -#[no_mangle] -pub extern "C" fn CounterpartyChannelTransactionParameters_new(mut pubkeys_arg: crate::ln::chan_utils::ChannelPublicKeys, mut selected_contest_delay_arg: u16) -> CounterpartyChannelTransactionParameters { - CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeCounterpartyChannelTransactionParameters { - pubkeys: *unsafe { Box::from_raw(pubkeys_arg.take_inner()) }, - selected_contest_delay: selected_contest_delay_arg, - })), is_owned: true } -} -impl Clone for CounterpartyChannelTransactionParameters { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 CounterpartyChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCounterpartyChannelTransactionParameters)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the CounterpartyChannelTransactionParameters -pub extern "C" fn CounterpartyChannelTransactionParameters_clone(orig: &CounterpartyChannelTransactionParameters) -> CounterpartyChannelTransactionParameters { - orig.clone() -} -/// Whether the late bound parameters are populated. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_is_populated(this_arg: &ChannelTransactionParameters) -> bool { - let mut ret = unsafe { &*this_arg.inner }.is_populated(); - ret -} - -/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, -/// given that the holder is the broadcaster. -/// -/// self.is_populated() must be true before calling this function. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_as_holder_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::ln::chan_utils::DirectedChannelTransactionParameters { - let mut ret = unsafe { &*this_arg.inner }.as_holder_broadcastable(); - crate::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, -/// given that the counterparty is the broadcaster. -/// -/// self.is_populated() must be true before calling this function. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_as_counterparty_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::ln::chan_utils::DirectedChannelTransactionParameters { - let mut ret = unsafe { &*this_arg.inner }.as_counterparty_broadcastable(); - crate::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -#[no_mangle] -/// Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read -pub extern "C" fn CounterpartyChannelTransactionParameters_write(obj: &CounterpartyChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyChannelTransactionParameters) }) -} -#[no_mangle] -/// Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write -pub extern "C" fn CounterpartyChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read -pub extern "C" fn ChannelTransactionParameters_write(obj: &ChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTransactionParameters) }) -} -#[no_mangle] -/// Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write -pub extern "C" fn ChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelTransactionParametersDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::ChannelTransactionParameters { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -use lightning::ln::chan_utils::DirectedChannelTransactionParameters as nativeDirectedChannelTransactionParametersImport; -type nativeDirectedChannelTransactionParameters = nativeDirectedChannelTransactionParametersImport<'static>; - -/// Static channel fields used to build transactions given per-commitment fields, organized by -/// broadcaster/countersignatory. -/// -/// This is derived from the holder/counterparty-organized ChannelTransactionParameters via the -/// as_holder_broadcastable and as_counterparty_broadcastable functions. -#[must_use] -#[repr(C)] -pub struct DirectedChannelTransactionParameters { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeDirectedChannelTransactionParameters, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DirectedChannelTransactionParameters { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDirectedChannelTransactionParameters>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_free(this_obj: DirectedChannelTransactionParameters) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn DirectedChannelTransactionParameters_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectedChannelTransactionParameters); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl DirectedChannelTransactionParameters { - pub(crate) fn take_inner(mut self) -> *mut nativeDirectedChannelTransactionParameters { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Get the channel pubkeys for the broadcaster -#[must_use] -#[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_broadcaster_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys { - let mut ret = unsafe { &*this_arg.inner }.broadcaster_pubkeys(); - crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// Get the channel pubkeys for the countersignatory -#[must_use] -#[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_countersignatory_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys { - let mut ret = unsafe { &*this_arg.inner }.countersignatory_pubkeys(); - crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// Get the contest delay applicable to the transactions. -/// Note that the contest delay was selected by the countersignatory. -#[must_use] -#[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_contest_delay(this_arg: &DirectedChannelTransactionParameters) -> u16 { - let mut ret = unsafe { &*this_arg.inner }.contest_delay(); - ret -} - -/// Whether the channel is outbound from the broadcaster. -/// -/// The boolean representing the side that initiated the channel is -/// an input to the commitment number obscure factor computation. -#[must_use] -#[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_is_outbound(this_arg: &DirectedChannelTransactionParameters) -> bool { - let mut ret = unsafe { &*this_arg.inner }.is_outbound(); - ret -} - -/// The funding outpoint -#[must_use] -#[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg: &DirectedChannelTransactionParameters) -> crate::chain::transaction::OutPoint { - let mut ret = unsafe { &*this_arg.inner }.funding_outpoint(); - crate::c_types::bitcoin_to_C_outpoint(ret) -} - - -use lightning::ln::chan_utils::HolderCommitmentTransaction as nativeHolderCommitmentTransactionImport; -type nativeHolderCommitmentTransaction = nativeHolderCommitmentTransactionImport; - -/// Information needed to build and sign a holder's commitment transaction. -/// -/// The transaction is only signed once we are ready to broadcast. -#[must_use] -#[repr(C)] -pub struct HolderCommitmentTransaction { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeHolderCommitmentTransaction, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for HolderCommitmentTransaction { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_free(this_obj: HolderCommitmentTransaction) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn HolderCommitmentTransaction_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHolderCommitmentTransaction); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl HolderCommitmentTransaction { - pub(crate) fn take_inner(mut self) -> *mut nativeHolderCommitmentTransaction { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Our counterparty's signature for the transaction -#[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_get_counterparty_sig(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Signature { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_sig; - crate::c_types::Signature::from_rust(&(*inner_val)) -} -/// Our counterparty's signature for the transaction -#[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_set_counterparty_sig(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::Signature) { - unsafe { &mut *this_ptr.inner }.counterparty_sig = val.into_rust(); -} -/// All non-dust counterparty HTLC signatures, in the order they appear in the transaction -#[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_set_counterparty_htlc_sigs(this_ptr: &mut HolderCommitmentTransaction, 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 }.counterparty_htlc_sigs = local_val; -} -impl Clone for HolderCommitmentTransaction { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 HolderCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHolderCommitmentTransaction)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the HolderCommitmentTransaction -pub extern "C" fn HolderCommitmentTransaction_clone(orig: &HolderCommitmentTransaction) -> HolderCommitmentTransaction { - orig.clone() -} -#[no_mangle] -/// Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read -pub extern "C" fn HolderCommitmentTransaction_write(obj: &HolderCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn HolderCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHolderCommitmentTransaction) }) -} -#[no_mangle] -/// Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write -pub extern "C" fn HolderCommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HolderCommitmentTransactionDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::HolderCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -/// Create a new holder transaction with the given counterparty signatures. -/// The funding keys are used to figure out which signature should go first when building the transaction for broadcast. -#[must_use] -#[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_new(mut commitment_tx: crate::ln::chan_utils::CommitmentTransaction, mut counterparty_sig: crate::c_types::Signature, mut counterparty_htlc_sigs: crate::c_types::derived::CVec_SignatureZ, mut holder_funding_key: crate::c_types::PublicKey, mut counterparty_funding_key: crate::c_types::PublicKey) -> HolderCommitmentTransaction { - let mut local_counterparty_htlc_sigs = Vec::new(); for mut item in counterparty_htlc_sigs.into_rust().drain(..) { local_counterparty_htlc_sigs.push( { item.into_rust() }); }; - let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new(*unsafe { Box::from_raw(commitment_tx.take_inner()) }, counterparty_sig.into_rust(), local_counterparty_htlc_sigs, &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust()); - HolderCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - - -use lightning::ln::chan_utils::BuiltCommitmentTransaction as nativeBuiltCommitmentTransactionImport; -type nativeBuiltCommitmentTransaction = nativeBuiltCommitmentTransactionImport; - -/// A pre-built Bitcoin commitment transaction and its txid. -#[must_use] -#[repr(C)] -pub struct BuiltCommitmentTransaction { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeBuiltCommitmentTransaction, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for BuiltCommitmentTransaction { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_free(this_obj: BuiltCommitmentTransaction) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn BuiltCommitmentTransaction_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBuiltCommitmentTransaction); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl BuiltCommitmentTransaction { - pub(crate) fn take_inner(mut self) -> *mut nativeBuiltCommitmentTransaction { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The commitment transaction -#[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_get_transaction(this_ptr: &BuiltCommitmentTransaction) -> crate::c_types::Transaction { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.transaction; - let mut local_inner_val = ::bitcoin::consensus::encode::serialize(inner_val); - crate::c_types::Transaction::from_vec(local_inner_val) -} -/// The commitment transaction -#[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_set_transaction(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::Transaction) { - unsafe { &mut *this_ptr.inner }.transaction = val.into_bitcoin(); -} -/// The txid for the commitment transaction. -/// -/// This is provided as a performance optimization, instead of calling transaction.txid() -/// multiple times. -#[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_get_txid(this_ptr: &BuiltCommitmentTransaction) -> *const [u8; 32] { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.txid; - (*inner_val).as_inner() -} -/// The txid for the commitment transaction. -/// -/// This is provided as a performance optimization, instead of calling transaction.txid() -/// multiple times. -#[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_set_txid(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); -} -/// Constructs a new BuiltCommitmentTransaction given each field -#[must_use] -#[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_new(mut transaction_arg: crate::c_types::Transaction, mut txid_arg: crate::c_types::ThirtyTwoBytes) -> BuiltCommitmentTransaction { - BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(nativeBuiltCommitmentTransaction { - transaction: transaction_arg.into_bitcoin(), - txid: ::bitcoin::hash_types::Txid::from_slice(&txid_arg.data[..]).unwrap(), - })), is_owned: true } -} -impl Clone for BuiltCommitmentTransaction { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 BuiltCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBuiltCommitmentTransaction)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the BuiltCommitmentTransaction -pub extern "C" fn BuiltCommitmentTransaction_clone(orig: &BuiltCommitmentTransaction) -> BuiltCommitmentTransaction { - orig.clone() -} -#[no_mangle] -/// Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read -pub extern "C" fn BuiltCommitmentTransaction_write(obj: &BuiltCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn BuiltCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBuiltCommitmentTransaction) }) -} -#[no_mangle] -/// Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write -pub extern "C" fn BuiltCommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BuiltCommitmentTransactionDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -/// Get the SIGHASH_ALL sighash value of the transaction. -/// -/// This can be used to verify a signature. -#[must_use] -#[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &BuiltCommitmentTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*this_arg.inner }.get_sighash_all(&::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis); - crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() } -} - -/// Sign a transaction, either because we are counter-signing the counterparty's transaction or -/// because we are about to broadcast a holder transaction. -#[must_use] -#[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_sign(this_arg: &BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature { - let mut ret = unsafe { &*this_arg.inner }.sign(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, secp256k1::SECP256K1); - crate::c_types::Signature::from_rust(&ret) -} - - -use lightning::ln::chan_utils::CommitmentTransaction as nativeCommitmentTransactionImport; -type nativeCommitmentTransaction = nativeCommitmentTransactionImport; - -/// This class tracks the per-transaction information needed to build a commitment transaction and to -/// actually build it and sign. It is used for holder transactions that we sign only when needed -/// and for transactions we sign for the counterparty. -/// -/// This class can be used inside a signer implementation to generate a signature given the relevant -/// secret key. -#[must_use] -#[repr(C)] -pub struct CommitmentTransaction { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeCommitmentTransaction, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for CommitmentTransaction { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeCommitmentTransaction>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn CommitmentTransaction_free(this_obj: CommitmentTransaction) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn CommitmentTransaction_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentTransaction); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl CommitmentTransaction { - pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentTransaction { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -impl Clone for CommitmentTransaction { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 CommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentTransaction)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the CommitmentTransaction -pub extern "C" fn CommitmentTransaction_clone(orig: &CommitmentTransaction) -> CommitmentTransaction { - orig.clone() -} -#[no_mangle] -/// Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read -pub extern "C" fn CommitmentTransaction_write(obj: &CommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn CommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentTransaction) }) -} -#[no_mangle] -/// Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write -pub extern "C" fn CommitmentTransaction_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentTransactionDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::CommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -/// The backwards-counting commitment number -#[must_use] -#[no_mangle] -pub extern "C" fn CommitmentTransaction_commitment_number(this_arg: &CommitmentTransaction) -> u64 { - let mut ret = unsafe { &*this_arg.inner }.commitment_number(); - ret -} - -/// The value to be sent to the broadcaster -#[must_use] -#[no_mangle] -pub extern "C" fn CommitmentTransaction_to_broadcaster_value_sat(this_arg: &CommitmentTransaction) -> u64 { - let mut ret = unsafe { &*this_arg.inner }.to_broadcaster_value_sat(); - ret -} - -/// The value to be sent to the counterparty -#[must_use] -#[no_mangle] -pub extern "C" fn CommitmentTransaction_to_countersignatory_value_sat(this_arg: &CommitmentTransaction) -> u64 { - let mut ret = unsafe { &*this_arg.inner }.to_countersignatory_value_sat(); - ret -} - -/// The feerate paid per 1000-weight-unit in this commitment transaction. -#[must_use] -#[no_mangle] -pub extern "C" fn CommitmentTransaction_feerate_per_kw(this_arg: &CommitmentTransaction) -> u32 { - let mut ret = unsafe { &*this_arg.inner }.feerate_per_kw(); - ret -} - -/// Trust our pre-built transaction and derived transaction creation public keys. -/// -/// Applies a wrapper which allows access to these fields. -/// -/// This should only be used if you fully trust the builder of this object. It should not -///\tbe used by an external signer - instead use the verify function. -#[must_use] -#[no_mangle] -pub extern "C" fn CommitmentTransaction_trust(this_arg: &CommitmentTransaction) -> crate::ln::chan_utils::TrustedCommitmentTransaction { - let mut ret = unsafe { &*this_arg.inner }.trust(); - crate::ln::chan_utils::TrustedCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Verify our pre-built transaction and derived transaction creation public keys. -/// -/// Applies a wrapper which allows access to these fields. -/// -/// An external validating signer must call this method before signing -/// or using the built transaction. -#[must_use] -#[no_mangle] -pub extern "C" fn CommitmentTransaction_verify(this_arg: &CommitmentTransaction, channel_parameters: &crate::ln::chan_utils::DirectedChannelTransactionParameters, broadcaster_keys: &crate::ln::chan_utils::ChannelPublicKeys, countersignatory_keys: &crate::ln::chan_utils::ChannelPublicKeys) -> crate::c_types::derived::CResult_TrustedCommitmentTransactionNoneZ { - let mut ret = unsafe { &*this_arg.inner }.verify(unsafe { &*channel_parameters.inner }, unsafe { &*broadcaster_keys.inner }, unsafe { &*countersignatory_keys.inner }, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::TrustedCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} - - -use lightning::ln::chan_utils::TrustedCommitmentTransaction as nativeTrustedCommitmentTransactionImport; -type nativeTrustedCommitmentTransaction = nativeTrustedCommitmentTransactionImport<'static>; - -/// A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin -/// transaction and the transaction creation keys) are trusted. -/// -/// See trust() and verify() functions on CommitmentTransaction. -/// -/// This structure implements Deref. -#[must_use] -#[repr(C)] -pub struct TrustedCommitmentTransaction { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeTrustedCommitmentTransaction, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for TrustedCommitmentTransaction { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeTrustedCommitmentTransaction>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_free(this_obj: TrustedCommitmentTransaction) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn TrustedCommitmentTransaction_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeTrustedCommitmentTransaction); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl TrustedCommitmentTransaction { - pub(crate) fn take_inner(mut self) -> *mut nativeTrustedCommitmentTransaction { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The transaction ID of the built Bitcoin transaction -#[must_use] -#[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_txid(this_arg: &TrustedCommitmentTransaction) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*this_arg.inner }.txid(); - crate::c_types::ThirtyTwoBytes { data: ret.into_inner() } -} - -/// The pre-built Bitcoin commitment transaction -#[must_use] -#[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_built_transaction(this_arg: &TrustedCommitmentTransaction) -> crate::ln::chan_utils::BuiltCommitmentTransaction { - let mut ret = unsafe { &*this_arg.inner }.built_transaction(); - crate::ln::chan_utils::BuiltCommitmentTransaction { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// The pre-calculated transaction creation public keys. -#[must_use] -#[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &TrustedCommitmentTransaction) -> crate::ln::chan_utils::TxCreationKeys { - let mut ret = unsafe { &*this_arg.inner }.keys(); - crate::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// 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. -#[must_use] -#[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::ln::chan_utils::DirectedChannelTransactionParameters) -> 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(), unsafe { &*channel_parameters.inner }, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; - local_ret -} - -/// Get the transaction number obscure factor -#[no_mangle] -pub extern "C" fn get_commitment_transaction_number_obscure_factor(mut broadcaster_payment_basepoint: crate::c_types::PublicKey, mut countersignatory_payment_basepoint: crate::c_types::PublicKey, mut outbound_from_broadcaster: bool) -> u64 { - let mut ret = lightning::ln::chan_utils::get_commitment_transaction_number_obscure_factor(&broadcaster_payment_basepoint.into_rust(), &countersignatory_payment_basepoint.into_rust(), outbound_from_broadcaster); - ret -} - diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs deleted file mode 100644 index 3b2ca23..0000000 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ /dev/null @@ -1,1432 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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; - -/// 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 chain::Watch::watch_/update_channel, 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 (BlockHash, 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_tick_occurred 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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelManager, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelManager { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelManager_free(this_obj: 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_inner(mut self) -> *mut nativeChannelManager { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} - -use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport; -type nativeChainParameters = nativeChainParametersImport; - -/// Chain-related parameters used to construct a new `ChannelManager`. -/// -/// Typically, the block-specific parameters are derived from the best block hash for the network, -/// as a newly constructed `ChannelManager` will not have created any channels yet. These parameters -/// are not needed when deserializing a previously constructed `ChannelManager`. -#[must_use] -#[repr(C)] -pub struct ChainParameters { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChainParameters, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChainParameters { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChainParameters_free(this_obj: ChainParameters) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ChainParameters_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainParameters); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl ChainParameters { - pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The network for determining the `chain_hash` in Lightning messages. -#[no_mangle] -pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.network; - crate::bitcoin::network::Network::from_bitcoin((*inner_val)) -} -/// The network for determining the `chain_hash` in Lightning messages. -#[no_mangle] -pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) { - unsafe { &mut *this_ptr.inner }.network = val.into_bitcoin(); -} -/// The hash and height of the latest block successfully connected. -/// -/// Used to track on-chain channel funding outputs and send payments with reliable timelocks. -#[no_mangle] -pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::ln::channelmanager::BestBlock { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.best_block; - crate::ln::channelmanager::BestBlock { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// The hash and height of the latest block successfully connected. -/// -/// Used to track on-chain channel funding outputs and send payments with reliable timelocks. -#[no_mangle] -pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::ln::channelmanager::BestBlock) { - unsafe { &mut *this_ptr.inner }.best_block = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Constructs a new ChainParameters given each field -#[must_use] -#[no_mangle] -pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::ln::channelmanager::BestBlock) -> ChainParameters { - ChainParameters { inner: Box::into_raw(Box::new(nativeChainParameters { - network: network_arg.into_bitcoin(), - best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) }, - })), is_owned: true } -} - -use lightning::ln::channelmanager::BestBlock as nativeBestBlockImport; -type nativeBestBlock = nativeBestBlockImport; - -/// The best known block as identified by its hash and height. -#[must_use] -#[repr(C)] -pub struct BestBlock { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeBestBlock, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for BestBlock { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBestBlock>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn BestBlock_free(this_obj: BestBlock) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn BestBlock_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBestBlock); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl BestBlock { - pub(crate) fn take_inner(mut self) -> *mut nativeBestBlock { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -impl Clone for BestBlock { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBestBlock>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 BestBlock_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBestBlock)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the BestBlock -pub extern "C" fn BestBlock_clone(orig: &BestBlock) -> BestBlock { - orig.clone() -} -/// Returns the best block from the genesis of the given network. -#[must_use] -#[no_mangle] -pub extern "C" fn BestBlock_from_genesis(mut network: crate::bitcoin::network::Network) -> BestBlock { - let mut ret = lightning::ln::channelmanager::BestBlock::from_genesis(network.into_bitcoin()); - BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Returns the best block as identified by the given block hash and height. -#[must_use] -#[no_mangle] -pub extern "C" fn BestBlock_new(mut block_hash: crate::c_types::ThirtyTwoBytes, mut height: u32) -> BestBlock { - let mut ret = lightning::ln::channelmanager::BestBlock::new(::bitcoin::hash_types::BlockHash::from_slice(&block_hash.data[..]).unwrap(), height); - BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Returns the best block hash. -#[must_use] -#[no_mangle] -pub extern "C" fn BestBlock_block_hash(this_arg: &BestBlock) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*this_arg.inner }.block_hash(); - crate::c_types::ThirtyTwoBytes { data: ret.into_inner() } -} - -/// Returns the best block height. -#[must_use] -#[no_mangle] -pub extern "C" fn BestBlock_height(this_arg: &BestBlock) -> u32 { - let mut ret = unsafe { &*this_arg.inner }.height(); - ret -} - -/// The amount of time in blocks we require our counterparty wait to claim their money (ie time -/// between when we, or our watchtower, must check for them having broadcast a theft transaction). -/// -/// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`] -/// -/// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay - -#[no_mangle] -pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT; -/// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound -/// HTLC's CLTV. The current default represents roughly six hours of blocks at six blocks/hour. -/// -/// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`] -/// -/// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta - -#[no_mangle] -pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA; - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelDetails, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelDetails { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelDetails_free(this_obj: 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_inner(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 position of the funding transaction in the chain. None if the funding transaction has -/// not yet been confirmed and the channel fully opened. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; - local_inner_val -} -/// The position of the funding transaction in the chain. None if the funding transaction has -/// not yet been confirmed and the channel fully opened. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *this_ptr.inner }.short_channel_id = local_val; -} -/// 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: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, 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_inner()) }; -} -/// 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; -} -impl Clone for ChannelDetails { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelDetails>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDetails)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelDetails -pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails { - orig.clone() -} -/// 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] -#[derive(Clone)] -#[repr(C)] -pub enum PaymentSendFailure { - /// A parameter which was passed to send_payment was invalid, preventing us from attempting to - /// send the payment at all. No channel state has been changed or messages sent to peers, and - /// once you've changed the parameter at error, you can freely retry the payment in full. - ParameterError(crate::util::errors::APIError), - /// A parameter in a single path which was passed to send_payment was invalid, preventing us - /// from attempting to send the payment at all. No channel state has been changed or messages - /// sent to peers, and once you've changed the parameter at error, you can freely retry the - /// payment in full. - /// - /// The results here are ordered the same as the paths in the route object which was passed to - /// send_payment. - PathParameterError(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ), - /// All paths which were attempted failed to send, with no channel state change taking place. - /// You can freely retry the payment in full (though you probably want to do so over different - /// paths than the ones selected). - AllFailedRetrySafe(crate::c_types::derived::CVec_APIErrorZ), - /// Some paths which were attempted failed to send, though possibly not all. At least some - /// paths have irrevocably committed to the HTLC and retrying the payment in full would result - /// in over-/re-payment. - /// - /// The results here are ordered the same as the paths in the route object which was passed to - /// send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely - /// retried (though there is currently no API with which to do so). - /// - /// Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried - /// as they will result in over-/re-payment. These HTLCs all either successfully sent (in the - /// case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel - /// with the latest update_id. - PartialFailure(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ), -} -use lightning::ln::channelmanager::PaymentSendFailure as nativePaymentSendFailure; -impl PaymentSendFailure { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativePaymentSendFailure { - match self { - PaymentSendFailure::ParameterError (ref a, ) => { - let mut a_nonref = (*a).clone(); - nativePaymentSendFailure::ParameterError ( - a_nonref.into_native(), - ) - }, - PaymentSendFailure::PathParameterError (ref a, ) => { - let mut a_nonref = (*a).clone(); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_nonref_0 }); }; - nativePaymentSendFailure::PathParameterError ( - local_a_nonref, - ) - }, - PaymentSendFailure::AllFailedRetrySafe (ref a, ) => { - let mut a_nonref = (*a).clone(); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into_native() }); }; - nativePaymentSendFailure::AllFailedRetrySafe ( - local_a_nonref, - ) - }, - PaymentSendFailure::PartialFailure (ref a, ) => { - let mut a_nonref = (*a).clone(); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_nonref_0 }); }; - nativePaymentSendFailure::PartialFailure ( - local_a_nonref, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativePaymentSendFailure { - match self { - PaymentSendFailure::ParameterError (mut a, ) => { - nativePaymentSendFailure::ParameterError ( - a.into_native(), - ) - }, - PaymentSendFailure::PathParameterError (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let mut local_a_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_0 }); }; - nativePaymentSendFailure::PathParameterError ( - local_a, - ) - }, - PaymentSendFailure::AllFailedRetrySafe (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into_native() }); }; - nativePaymentSendFailure::AllFailedRetrySafe ( - local_a, - ) - }, - PaymentSendFailure::PartialFailure (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let mut local_a_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_0 }); }; - nativePaymentSendFailure::PartialFailure ( - local_a, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativePaymentSendFailure) -> Self { - match native { - nativePaymentSendFailure::ParameterError (ref a, ) => { - let mut a_nonref = (*a).clone(); - PaymentSendFailure::ParameterError ( - crate::util::errors::APIError::native_into(a_nonref), - ) - }, - nativePaymentSendFailure::PathParameterError (ref a, ) => { - let mut a_nonref = (*a).clone(); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); }; - PaymentSendFailure::PathParameterError ( - local_a_nonref.into(), - ) - }, - nativePaymentSendFailure::AllFailedRetrySafe (ref a, ) => { - let mut a_nonref = (*a).clone(); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { crate::util::errors::APIError::native_into(item) }); }; - PaymentSendFailure::AllFailedRetrySafe ( - local_a_nonref.into(), - ) - }, - nativePaymentSendFailure::PartialFailure (ref a, ) => { - let mut a_nonref = (*a).clone(); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); }; - PaymentSendFailure::PartialFailure ( - local_a_nonref.into(), - ) - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativePaymentSendFailure) -> Self { - match native { - nativePaymentSendFailure::ParameterError (mut a, ) => { - PaymentSendFailure::ParameterError ( - crate::util::errors::APIError::native_into(a), - ) - }, - nativePaymentSendFailure::PathParameterError (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let mut local_a_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); }; - PaymentSendFailure::PathParameterError ( - local_a.into(), - ) - }, - nativePaymentSendFailure::AllFailedRetrySafe (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::util::errors::APIError::native_into(item) }); }; - PaymentSendFailure::AllFailedRetrySafe ( - local_a.into(), - ) - }, - nativePaymentSendFailure::PartialFailure (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let mut local_a_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); }; - PaymentSendFailure::PartialFailure ( - local_a.into(), - ) - }, - } - } -} -/// Frees any resources used by the PaymentSendFailure -#[no_mangle] -pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { } -/// Creates a copy of the PaymentSendFailure -#[no_mangle] -pub extern "C" fn PaymentSendFailure_clone(orig: &PaymentSendFailure) -> PaymentSendFailure { - orig.clone() -} -/// 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 need to notify the new ChannelManager when a new block is connected or -/// disconnected using its `block_connected` and `block_disconnected` methods, starting -/// from after `params.latest_hash`. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_new(mut fee_est: crate::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::chain::Watch, 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 params: crate::ln::channelmanager::ChainParameters) -> ChannelManager { - let mut ret = lightning::ln::channelmanager::ChannelManager::new(fee_est, chain_monitor, tx_broadcaster, logger, keys_manager, *unsafe { Box::from_raw(config.take_inner()) }, *unsafe { Box::from_raw(params.take_inner()) }); - ChannelManager { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Gets the current configuration applied to all new channels, as -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &ChannelManager) -> crate::util::config::UserConfig { - let mut ret = unsafe { &*this_arg.inner }.get_current_default_configuration(); - crate::util::config::UserConfig { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// 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 events to allow -/// tracking of which events correspond with which create_channel call. Note that the -/// user_channel_id defaults to 0 for inbound channels, so you may wish to avoid using 0 for -/// user_id here. user_id has no meaning inside of LDK, it is simply copied to events and -/// otherwise ignored. -/// -/// 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_inner()) } }) }; - 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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; - 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 mut 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 mut 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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; - local_ret -} - -/// Force closes a channel, immediately broadcasting the latest local commitment transaction to -/// the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_force_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*this_arg.inner }.force_close_channel(unsafe { &*channel_id}); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; - local_ret -} - -/// 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, mut 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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() }; - local_ret -} - -/// Call this upon creation of a funding transaction for the given channel. -/// -/// Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs -/// or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. -/// -/// Panics if a funding transaction has already been provided for this channel. -/// -/// May panic if the output found in the funding transaction is duplicative with some other -/// channel (note that this should be trivially prevented by using unique funding transaction -/// keys per-channel). -/// -/// Do NOT broadcast the funding transaction yourself. When we have safely received our -/// counterparty's signature the funding transaction will automatically be broadcast via the -/// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. -/// -/// Note that this includes RBF or similar transaction replacement strategies - lightning does -/// not currently support replacing a funding transaction on an existing channel. Instead, -/// create a new channel with a conflicting funding transaction. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32], mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*this_arg.inner }.funding_transaction_generated(unsafe { &*temporary_channel_id}, funding_transaction.into_bitcoin()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; - local_ret -} - -/// 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. -/// -/// Note that in some rare cases this may generate a `chain::Watch::update_channel` call. -#[no_mangle] -pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &ChannelManager) { - unsafe { &*this_arg.inner }.timer_tick_occurred() -} - -/// 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], mut 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, mut 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 chain::Watch 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) -} - -impl From for crate::util::events::MessageSendEventsProvider { - fn from(obj: nativeChannelManager) -> Self { - let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = ChannelManager_as_MessageSendEventsProvider(&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(ChannelManager_free_void); - ret - } -} -/// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &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, - } -} - -#[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 = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); }; - local_ret.into() -} - -impl From for crate::util::events::EventsProvider { - fn from(obj: nativeChannelManager) -> Self { - let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = ChannelManager_as_EventsProvider(&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(ChannelManager_free_void); - ret - } -} -/// Constructs a new EventsProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &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, - } -} - -#[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 = >::get_and_clear_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); }; - local_ret.into() -} - -impl From for crate::chain::Listen { - fn from(obj: nativeChannelManager) -> Self { - let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = ChannelManager_as_Listen(&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(ChannelManager_free_void); - ret - } -} -/// Constructs a new Listen which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is -#[no_mangle] -pub extern "C" fn ChannelManager_as_Listen(this_arg: &ChannelManager) -> crate::chain::Listen { - crate::chain::Listen { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - block_connected: ChannelManager_Listen_block_connected, - block_disconnected: ChannelManager_Listen_block_disconnected, - } -} - -extern "C" fn ChannelManager_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) { - >::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height) -} -extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { - >::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) -} - -/// Updates channel state to take note of transactions which were confirmed in the given block -/// at the given height. -/// -/// Note that you must still call (or have called) [`update_best_block`] with the block -/// information which is included here. -/// -/// This method may be called before or after [`update_best_block`] for a given block's -/// transaction data and may be called multiple times with additional transaction data for a -/// given block. -/// -/// This method may be called for a previous block after an [`update_best_block`] call has -/// been made for a later block, however it must *not* be called with transaction data from a -/// block which is no longer in the best chain (ie where [`update_best_block`] has already -/// been informed about a blockchain reorganization which no longer includes the block which -/// corresponds to `header`). -/// -/// [`update_best_block`]: `Self::update_best_block` -#[no_mangle] -pub extern "C" fn ChannelManager_transactions_confirmed(this_arg: &ChannelManager, header: *const [u8; 80], mut height: u32, mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ) { - let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - unsafe { &*this_arg.inner }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..]) -} - -/// Updates channel state with the current best blockchain tip. You should attempt to call this -/// quickly after a new block becomes available, however if multiple new blocks become -/// available at the same time, only a single `update_best_block()` call needs to be made. -/// -/// This method should also be called immediately after any block disconnections, once at the -/// reorganization fork point, and once with the new chain tip. Calling this method at the -/// blockchain reorganization fork point ensures we learn when a funding transaction which was -/// previously confirmed is reorganized out of the blockchain, ensuring we do not continue to -/// accept payments which cannot be enforced on-chain. -/// -/// In both the block-connection and block-disconnection case, this method may be called either -/// once per block connected or disconnected, or simply at the fork point and new tip(s), -/// skipping any intermediary blocks. -#[no_mangle] -pub extern "C" fn ChannelManager_update_best_block(this_arg: &ChannelManager, header: *const [u8; 80], mut height: u32) { - unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) -} - -/// Gets the set of txids which should be monitored for their confirmation state. -/// -/// If you're providing information about reorganizations via [`transaction_unconfirmed`], this -/// is the set of transactions which you may need to call [`transaction_unconfirmed`] for. -/// -/// This may be useful to poll to determine the set of transactions which must be registered -/// with an Electrum server or for which an Electrum server needs to be polled to determine -/// transaction confirmation state. -/// -/// This may update after any [`transactions_confirmed`] or [`block_connected`] call. -/// -/// Note that this is NOT the set of transactions which must be included in calls to -/// [`transactions_confirmed`] if they are confirmed, but a small subset of it. -/// -/// [`transactions_confirmed`]: Self::transactions_confirmed -/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed -/// [`block_connected`]: chain::Listen::block_connected -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_get_relevant_txids(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_TxidZ { - let mut ret = unsafe { &*this_arg.inner }.get_relevant_txids(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; - local_ret.into() -} - -/// Marks a transaction as having been reorganized out of the blockchain. -/// -/// If a transaction is included in [`get_relevant_txids`], and is no longer in the main branch -/// of the blockchain, this function should be called to indicate that the transaction should -/// be considered reorganized out. -/// -/// Once this is called, the given transaction will no longer appear on [`get_relevant_txids`], -/// though this may be called repeatedly for a given transaction without issue. -/// -/// Note that if the transaction is confirmed on the main chain in a different block (indicated -/// via a call to [`transactions_confirmed`]), it may re-appear in [`get_relevant_txids`], thus -/// be very wary of race-conditions wherein the final state of a transaction indicated via -/// these APIs is not the same as its state on the blockchain. -/// -/// [`transactions_confirmed`]: Self::transactions_confirmed -/// [`get_relevant_txids`]: Self::get_relevant_txids -#[no_mangle] -pub extern "C" fn ChannelManager_transaction_unconfirmed(this_arg: &ChannelManager, txid: *const [u8; 32]) { - unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) -} - -/// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool -/// indicating whether persistence is necessary. Only one listener on -/// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken -/// up. -/// Note that the feature `allow_wallclock_use` must be enabled to use this function. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_await_persistable_update_timeout(this_arg: &ChannelManager, mut max_wait: u64) -> bool { - let mut ret = unsafe { &*this_arg.inner }.await_persistable_update_timeout(std::time::Duration::from_secs(max_wait)); - ret -} - -/// Blocks until ChannelManager needs to be persisted. Only one listener on -/// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken -/// up. -#[no_mangle] -pub extern "C" fn ChannelManager_await_persistable_update(this_arg: &ChannelManager) { - unsafe { &*this_arg.inner }.await_persistable_update() -} - -impl From for crate::ln::msgs::ChannelMessageHandler { - fn from(obj: nativeChannelManager) -> Self { - let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = ChannelManager_as_ChannelMessageHandler(&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(ChannelManager_free_void); - ret - } -} -/// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is -#[no_mangle] -pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &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_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update, - 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_MessageSendEventsProvider_get_and_clear_pending_msg_events, - }, - } -} - -extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel) { - >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel) { - >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated) { - >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned) { - >::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked) { - >::handle_funding_locked(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, their_features: &crate::ln::features::InitFeatures, msg: &crate::ln::msgs::Shutdown) { - >::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*their_features.inner }, unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned) { - >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC) { - >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC) { - >::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC) { - >::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC) { - >::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned) { - >::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK) { - >::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee) { - >::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures) { - >::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelUpdate) { - >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) { - >::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) { - >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), no_connection_possible) -} -extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) { - >::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*init_msg.inner }) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage) { - >::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) -} - -#[no_mangle] -/// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read -pub extern "C" fn ChannelManager_write(obj: &ChannelManager) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) }) -} - -use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport; -type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::chain::keysinterface::Sign, crate::chain::Watch, 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: -/// <(BlockHash, 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) If you are not fetching full blocks, register all relevant ChannelMonitor outpoints the same -/// way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and -/// ChannelMonitor::get_funding_txo(). -/// 4) Reconnect blocks on your ChannelMonitors. -/// 5) Disconnect/connect blocks on the ChannelManager. -/// 6) Move the ChannelMonitors into your local chain::Watch. -/// -/// Note that the ordering of #4-6 is not of importance, however all three must occur before you -/// call any other methods on the newly-deserialized ChannelManager. -/// -/// Note that because some channels may be closed during deserialization, it is critical that you -/// always deserialize only the latest version of a ChannelManager and ChannelMonitors available to -/// you. If you deserialize an old ChannelManager (during which force-closure transactions may be -/// broadcast), and then later deserialize a newer version of the same ChannelManager (which will -/// not force-close the same channels but consider them live), you may end up revoking a state for -/// which you've already broadcasted the transaction. -#[must_use] -#[repr(C)] -pub struct ChannelManagerReadArgs { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelManagerReadArgs, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelManagerReadArgs { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_free(this_obj: 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_inner(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 and KeysInterface::read_chan_signer will be used to read per-Channel -/// signing data. -#[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 and KeysInterface::read_chan_signer will be used to read per-Channel -/// signing data. -#[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 chain::Watch for use in the ChannelManager in the future. -/// -/// No calls to the chain::Watch will be made during deserialization. It is assumed that -/// you have deserialized ChannelMonitors separately and will add them to your -/// chain::Watch after deserializing this ChannelManager. -#[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::chain::Watch { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_monitor; - &(*inner_val) -} -/// The chain::Watch for use in the ChannelManager in the future. -/// -/// No calls to the chain::Watch will be made during deserialization. It is assumed that -/// you have deserialized ChannelMonitors separately and will add them to your -/// chain::Watch after deserializing this ChannelManager. -#[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::chain::Watch) { - unsafe { &mut *this_ptr.inner }.chain_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_inner()) }; -} -/// 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 chain_monitor: crate::chain::Watch, 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, chain_monitor, tx_broadcaster, logger, *unsafe { Box::from_raw(default_config.take_inner()) }, local_channel_monitors); - ChannelManagerReadArgs { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -#[no_mangle] -/// Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write -pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_read(ser: crate::c_types::u8slice, arg: crate::ln::channelmanager::ChannelManagerReadArgs) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) }; - let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::ln::channelmanager::ChannelManager { inner: Box::into_raw(Box::new(orig_res_0_1)), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} diff --git a/lightning-c-bindings/src/ln/features.rs b/lightning-c-bindings/src/ln/features.rs deleted file mode 100644 index a58ae7a..0000000 --- a/lightning-c-bindings/src/ln/features.rs +++ /dev/null @@ -1,411 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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). -//! -//! 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]: crate::ln::msgs - -use std::ffi::c_void; -use bitcoin::hashes::Hash; -use crate::c_types::*; - -impl Clone for InitFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInitFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 InitFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInitFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InitFeatures -pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures { - orig.clone() -} -impl Clone for NodeFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 NodeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the NodeFeatures -pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures { - orig.clone() -} -impl Clone for ChannelFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 ChannelFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelFeatures -pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures { - orig.clone() -} -impl Clone for InvoiceFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InvoiceFeatures -pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatures { - orig.clone() -} - -use lightning::ln::features::InitFeatures as nativeInitFeaturesImport; -type nativeInitFeatures = nativeInitFeaturesImport; - -/// Features used within an `init` message. -#[must_use] -#[repr(C)] -pub struct InitFeatures { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeInitFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for InitFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InitFeatures_free(this_obj: 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_inner(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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeNodeFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for NodeFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn NodeFeatures_free(this_obj: 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_inner(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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelFeatures_free(this_obj: 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_inner(mut self) -> *mut nativeChannelFeatures { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport; -type nativeInvoiceFeatures = nativeInvoiceFeaturesImport; - -/// Features used within an invoice. -#[must_use] -#[repr(C)] -pub struct InvoiceFeatures { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeInvoiceFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for InvoiceFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceFeatures); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl InvoiceFeatures { - pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceFeatures { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_empty() -> InitFeatures { - let mut ret = lightning::ln::features::InitFeatures::empty(); - InitFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Creates a Features with the bits set which are known by the implementation -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_known() -> InitFeatures { - let mut ret = lightning::ln::features::InitFeatures::known(); - InitFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_empty() -> NodeFeatures { - let mut ret = lightning::ln::features::NodeFeatures::empty(); - NodeFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Creates a Features with the bits set which are known by the implementation -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_known() -> NodeFeatures { - let mut ret = lightning::ln::features::NodeFeatures::known(); - NodeFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_empty() -> ChannelFeatures { - let mut ret = lightning::ln::features::ChannelFeatures::empty(); - ChannelFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Creates a Features with the bits set which are known by the implementation -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures { - let mut ret = lightning::ln::features::ChannelFeatures::known(); - ChannelFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceFeatures_empty() -> InvoiceFeatures { - let mut ret = lightning::ln::features::InvoiceFeatures::empty(); - InvoiceFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Creates a Features with the bits set which are known by the implementation -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceFeatures_known() -> InvoiceFeatures { - let mut ret = lightning::ln::features::InvoiceFeatures::known(); - InvoiceFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -#[no_mangle] -/// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read -pub extern "C" fn InitFeatures_write(obj: &InitFeatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInitFeatures) }) -} -#[no_mangle] -/// Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read -pub extern "C" fn NodeFeatures_write(obj: &NodeFeatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeFeatures) }) -} -#[no_mangle] -/// Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read -pub extern "C" fn ChannelFeatures_write(obj: &ChannelFeatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelFeatures) }) -} -#[no_mangle] -/// Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read -pub extern "C" fn InvoiceFeatures_write(obj: &InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceFeatures) }) -} -#[no_mangle] -/// Read a InitFeatures from a byte array, created by InitFeatures_write -pub extern "C" fn InitFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitFeaturesDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::features::InitFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Read a NodeFeatures from a byte array, created by NodeFeatures_write -pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeFeaturesDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::features::NodeFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Read a ChannelFeatures from a byte array, created by ChannelFeatures_write -pub extern "C" fn ChannelFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelFeaturesDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::features::ChannelFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write -pub extern "C" fn InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceFeaturesDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::features::InvoiceFeatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} diff --git a/lightning-c-bindings/src/ln/mod.rs b/lightning-c-bindings/src/ln/mod.rs deleted file mode 100644 index d6ca8b3..0000000 --- a/lightning-c-bindings/src/ln/mod.rs +++ /dev/null @@ -1,28 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 msgs; -pub mod peer_handler; -pub mod chan_utils; -pub mod features; diff --git a/lightning-c-bindings/src/ln/msgs.rs b/lightning-c-bindings/src/ln/msgs.rs deleted file mode 100644 index 67d2f0b..0000000 --- a/lightning-c-bindings/src/ln/msgs.rs +++ /dev/null @@ -1,5266 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeDecodeError, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DecodeError { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDecodeError>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DecodeError_free(this_obj: 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_inner(mut self) -> *mut nativeDecodeError { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -impl Clone for DecodeError { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeDecodeError>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDecodeError)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the DecodeError -pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeInit, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for Init { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInit>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the Init, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Init_free(this_obj: 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_inner(mut self) -> *mut nativeInit { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The relevant features which the sender supports -#[no_mangle] -pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::ln::features::InitFeatures { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::ln::features::InitFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// The relevant features which the sender supports -#[no_mangle] -pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::ln::features::InitFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Constructs a new Init given each field -#[must_use] -#[no_mangle] -pub extern "C" fn Init_new(mut features_arg: crate::ln::features::InitFeatures) -> Init { - Init { inner: Box::into_raw(Box::new(nativeInit { - features: *unsafe { Box::from_raw(features_arg.take_inner()) }, - })), is_owned: true } -} -impl Clone for Init { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInit>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 Init_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the Init -pub extern "C" fn Init_clone(orig: &Init) -> Init { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeErrorMessage, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ErrorMessage { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ErrorMessage_free(this_obj: 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_inner(mut self) -> *mut nativeErrorMessage { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -/// Constructs a new ErrorMessage given each field -#[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 } -} -impl Clone for ErrorMessage { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeErrorMessage>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ErrorMessage -pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativePing, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for Ping { - fn drop(&mut self) { - if self.is_owned && !<*mut nativePing>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Ping_free(this_obj: 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_inner(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; -} -/// Constructs a new Ping given each field -#[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 } -} -impl Clone for Ping { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativePing>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 Ping_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the Ping -pub extern "C" fn Ping_clone(orig: &Ping) -> Ping { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativePong, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for Pong { - fn drop(&mut self) { - if self.is_owned && !<*mut nativePong>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Pong_free(this_obj: 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_inner(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; -} -/// Constructs a new Pong given each field -#[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 } -} -impl Clone for Pong { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativePong>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 Pong_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the Pong -pub extern "C" fn Pong_clone(orig: &Pong) -> Pong { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeOpenChannel, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for OpenChannel { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn OpenChannel_free(this_obj: 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_inner(mut self) -> *mut nativeOpenChannel { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -impl Clone for OpenChannel { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the OpenChannel -pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeAcceptChannel, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for AcceptChannel { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn AcceptChannel_free(this_obj: 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_inner(mut self) -> *mut nativeAcceptChannel { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -impl Clone for AcceptChannel { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the AcceptChannel -pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeFundingCreated, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for FundingCreated { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn FundingCreated_free(this_obj: 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_inner(mut self) -> *mut nativeFundingCreated { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -/// Constructs a new FundingCreated given each field -#[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 } -} -impl Clone for FundingCreated { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the FundingCreated -pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeFundingSigned, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for FundingSigned { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn FundingSigned_free(this_obj: 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_inner(mut self) -> *mut nativeFundingSigned { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -/// Constructs a new FundingSigned given each field -#[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 } -} -impl Clone for FundingSigned { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the FundingSigned -pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeFundingLocked, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for FundingLocked { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeFundingLocked>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn FundingLocked_free(this_obj: 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_inner(mut self) -> *mut nativeFundingLocked { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -/// Constructs a new FundingLocked given each field -#[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 } -} -impl Clone for FundingLocked { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the FundingLocked -pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeShutdown, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for Shutdown { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Shutdown_free(this_obj: 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_inner(mut self) -> *mut nativeShutdown { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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()); -} -/// Constructs a new Shutdown given each field -#[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 } -} -impl Clone for Shutdown { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the Shutdown -pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeClosingSigned, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ClosingSigned { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ClosingSigned_free(this_obj: 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_inner(mut self) -> *mut nativeClosingSigned { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -/// Constructs a new ClosingSigned given each field -#[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 } -} -impl Clone for ClosingSigned { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ClosingSigned -pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUpdateAddHTLC, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UpdateAddHTLC { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UpdateAddHTLC_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateAddHTLC { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -impl Clone for UpdateAddHTLC { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UpdateAddHTLC -pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUpdateFulfillHTLC, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UpdateFulfillHTLC { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UpdateFulfillHTLC_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateFulfillHTLC { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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); -} -/// Constructs a new UpdateFulfillHTLC given each field -#[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 } -} -impl Clone for UpdateFulfillHTLC { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UpdateFulfillHTLC -pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUpdateFailHTLC, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UpdateFailHTLC { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UpdateFailHTLC_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateFailHTLC { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -impl Clone for UpdateFailHTLC { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UpdateFailHTLC -pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUpdateFailMalformedHTLC, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UpdateFailMalformedHTLC { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -impl Clone for UpdateFailMalformedHTLC { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UpdateFailMalformedHTLC -pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeCommitmentSigned, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for CommitmentSigned { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn CommitmentSigned_free(this_obj: 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_inner(mut self) -> *mut nativeCommitmentSigned { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -/// Constructs a new CommitmentSigned given each field -#[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 } -} -impl Clone for CommitmentSigned { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the CommitmentSigned -pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeRevokeAndACK, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for RevokeAndACK { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RevokeAndACK_free(this_obj: 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_inner(mut self) -> *mut nativeRevokeAndACK { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -/// Constructs a new RevokeAndACK given each field -#[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 } -} -impl Clone for RevokeAndACK { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the RevokeAndACK -pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUpdateFee, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UpdateFee { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UpdateFee_free(this_obj: 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_inner(mut self) -> *mut nativeUpdateFee { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -/// Constructs a new UpdateFee given each field -#[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 } -} -impl Clone for UpdateFee { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UpdateFee -pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeDataLossProtect, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DataLossProtect { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DataLossProtect_free(this_obj: 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_inner(mut self) -> *mut nativeDataLossProtect { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -/// Constructs a new DataLossProtect given each field -#[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 } -} -impl Clone for DataLossProtect { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the DataLossProtect -pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelReestablish, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelReestablish { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelReestablish_free(this_obj: 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_inner(mut self) -> *mut nativeChannelReestablish { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -impl Clone for ChannelReestablish { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ChannelReestablish -pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeAnnouncementSignatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for AnnouncementSignatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn AnnouncementSignatures_free(this_obj: 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_inner(mut self) -> *mut nativeAnnouncementSignatures { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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(); -} -/// Constructs a new AnnouncementSignatures given each field -#[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 } -} -impl Clone for AnnouncementSignatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the AnnouncementSignatures -pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures { - orig.clone() -} -/// 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 { - /// The 4-byte IPv4 address - addr: crate::c_types::FourBytes, - /// The port on which the node is listening - port: u16, - }, - /// An IPv6 address/port on which the peer is listening. - IPv6 { - /// The 16-byte IPv6 address - addr: crate::c_types::SixteenBytes, - /// The port on which the node is listening - port: u16, - }, - /// An old-style Tor onion address/port on which the peer is listening. - OnionV2 { - /// The bytes (usually encoded in base32 with \".onion\" appended) - addr: crate::c_types::TenBytes, - /// The port on which the node is listening - 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 { - /// The ed25519 long-term public key of the peer - ed25519_pubkey: crate::c_types::ThirtyTwoBytes, - /// The checksum of the pubkey and version, as included in the onion address - checksum: u16, - /// The version byte, as defined by the Tor Onion v3 spec. - version: u8, - /// The port on which the node is listening - 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, - } - }, - } - } -} -/// Frees any resources used by the NetAddress -#[no_mangle] -pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { } -/// Creates a copy of the NetAddress -#[no_mangle] -pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress { - orig.clone() -} -#[no_mangle] -/// Serialize the NetAddress object into a byte array which can be read by NetAddress_read -pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a Result from a byte array, created by Result_write -pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { e }).into() }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport; -type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport; - -/// The unsigned part of a node_announcement -#[must_use] -#[repr(C)] -pub struct UnsignedNodeAnnouncement { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUnsignedNodeAnnouncement, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UnsignedNodeAnnouncement { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: 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_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The advertised features -#[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::ln::features::NodeFeatures { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// The advertised features -#[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// 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; -} -impl Clone for UnsignedNodeAnnouncement { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UnsignedNodeAnnouncement -pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeNodeAnnouncement, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for NodeAnnouncement { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn NodeAnnouncement_free(this_obj: 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_inner(mut self) -> *mut nativeNodeAnnouncement { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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_inner()) }; -} -/// Constructs a new NodeAnnouncement given each field -#[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_inner()) }, - })), is_owned: true } -} -impl Clone for NodeAnnouncement { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the NodeAnnouncement -pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement { - orig.clone() -} - -use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport; -type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport; - -/// The unsigned part of a channel_announcement -#[must_use] -#[repr(C)] -pub struct UnsignedChannelAnnouncement { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUnsignedChannelAnnouncement, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UnsignedChannelAnnouncement { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: 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_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The advertised channel features -#[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::ln::features::ChannelFeatures { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// The advertised channel features -#[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// 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(); -} -impl Clone for UnsignedChannelAnnouncement { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UnsignedChannelAnnouncement -pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelAnnouncement, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelAnnouncement { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelAnnouncement_free(this_obj: 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_inner(mut self) -> *mut nativeChannelAnnouncement { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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_inner()) }; -} -/// Constructs a new ChannelAnnouncement given each field -#[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_inner()) }, - })), is_owned: true } -} -impl Clone for ChannelAnnouncement { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ChannelAnnouncement -pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement { - orig.clone() -} - -use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport; -type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport; - -/// The unsigned part of a channel_update -#[must_use] -#[repr(C)] -pub struct UnsignedChannelUpdate { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUnsignedChannelUpdate, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UnsignedChannelUpdate { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UnsignedChannelUpdate_free(this_obj: 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_inner(mut self) -> *mut nativeUnsignedChannelUpdate { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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 such that if: -/// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` -/// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines -/// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a -/// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, -/// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before -/// forwarding. Note that the HTLC sender is the one who originally sets this value when -/// constructing the route. -#[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 such that if: -/// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` -/// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines -/// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a -/// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, -/// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before -/// forwarding. Note that the HTLC sender is the one who originally sets this value when -/// constructing the route. -#[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; -} -impl Clone for UnsignedChannelUpdate { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UnsignedChannelUpdate -pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelUpdate, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelUpdate { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelUpdate_free(this_obj: 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_inner(mut self) -> *mut nativeChannelUpdate { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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_inner()) }; -} -/// Constructs a new ChannelUpdate given each field -#[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_inner()) }, - })), is_owned: true } -} -impl Clone for ChannelUpdate { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ChannelUpdate -pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate { - orig.clone() -} - -use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport; -type nativeQueryChannelRange = nativeQueryChannelRangeImport; - -/// A query_channel_range message is used to query a peer for channel -/// UTXOs in a range of blocks. The recipient of a query makes a best -/// effort to reply to the query using one or more reply_channel_range -/// messages. -#[must_use] -#[repr(C)] -pub struct QueryChannelRange { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeQueryChannelRange, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for QueryChannelRange { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl QueryChannelRange { - pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The genesis hash of the blockchain being queried -#[no_mangle] -pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *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 being queried -#[no_mangle] -pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); -} -/// The height of the first block for the channel UTXOs being queried -#[no_mangle] -pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; - (*inner_val) -} -/// The height of the first block for the channel UTXOs being queried -#[no_mangle] -pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) { - unsafe { &mut *this_ptr.inner }.first_blocknum = val; -} -/// The number of blocks to include in the query results -#[no_mangle] -pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; - (*inner_val) -} -/// The number of blocks to include in the query results -#[no_mangle] -pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) { - unsafe { &mut *this_ptr.inner }.number_of_blocks = val; -} -/// Constructs a new QueryChannelRange given each field -#[must_use] -#[no_mangle] -pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange { - QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange { - chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), - first_blocknum: first_blocknum_arg, - number_of_blocks: number_of_blocks_arg, - })), is_owned: true } -} -impl Clone for QueryChannelRange { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the QueryChannelRange -pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange { - orig.clone() -} - -use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport; -type nativeReplyChannelRange = nativeReplyChannelRangeImport; - -/// A reply_channel_range message is a reply to a query_channel_range -/// message. Multiple reply_channel_range messages can be sent in reply -/// to a single query_channel_range message. The query recipient makes a -/// best effort to respond based on their local network view which may -/// not be a perfect view of the network. The short_channel_ids in the -/// reply are encoded. We only support encoding_type=0 uncompressed -/// serialization and do not support encoding_type=1 zlib serialization. -#[must_use] -#[repr(C)] -pub struct ReplyChannelRange { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeReplyChannelRange, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ReplyChannelRange { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl ReplyChannelRange { - pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The genesis hash of the blockchain being queried -#[no_mangle] -pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *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 being queried -#[no_mangle] -pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); -} -/// The height of the first block in the range of the reply -#[no_mangle] -pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; - (*inner_val) -} -/// The height of the first block in the range of the reply -#[no_mangle] -pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) { - unsafe { &mut *this_ptr.inner }.first_blocknum = val; -} -/// The number of blocks included in the range of the reply -#[no_mangle] -pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; - (*inner_val) -} -/// The number of blocks included in the range of the reply -#[no_mangle] -pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) { - unsafe { &mut *this_ptr.inner }.number_of_blocks = val; -} -/// True when this is the final reply for a query -#[no_mangle] -pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete; - (*inner_val) -} -/// True when this is the final reply for a query -#[no_mangle] -pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) { - unsafe { &mut *this_ptr.inner }.sync_complete = val; -} -/// The short_channel_ids in the channel range -#[no_mangle] -pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, 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 }.short_channel_ids = local_val; -} -/// Constructs a new ReplyChannelRange given each field -#[must_use] -#[no_mangle] -pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange { - let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; - ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange { - chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), - first_blocknum: first_blocknum_arg, - number_of_blocks: number_of_blocks_arg, - sync_complete: sync_complete_arg, - short_channel_ids: local_short_channel_ids_arg, - })), is_owned: true } -} -impl Clone for ReplyChannelRange { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ReplyChannelRange -pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange { - orig.clone() -} - -use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport; -type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport; - -/// A query_short_channel_ids message is used to query a peer for -/// routing gossip messages related to one or more short_channel_ids. -/// The query recipient will reply with the latest, if available, -/// channel_announcement, channel_update and node_announcement messages -/// it maintains for the requested short_channel_ids followed by a -/// reply_short_channel_ids_end message. The short_channel_ids sent in -/// this query are encoded. We only support encoding_type=0 uncompressed -/// serialization and do not support encoding_type=1 zlib serialization. -#[must_use] -#[repr(C)] -pub struct QueryShortChannelIds { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeQueryShortChannelIds, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for QueryShortChannelIds { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl QueryShortChannelIds { - pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The genesis hash of the blockchain being queried -#[no_mangle] -pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *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 being queried -#[no_mangle] -pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, 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_ids that are being queried -#[no_mangle] -pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, 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 }.short_channel_ids = local_val; -} -/// Constructs a new QueryShortChannelIds given each field -#[must_use] -#[no_mangle] -pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds { - let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; - QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds { - chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), - short_channel_ids: local_short_channel_ids_arg, - })), is_owned: true } -} -impl Clone for QueryShortChannelIds { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the QueryShortChannelIds -pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds { - orig.clone() -} - -use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport; -type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport; - -/// A reply_short_channel_ids_end message is sent as a reply to a -/// query_short_channel_ids message. The query recipient makes a best -/// effort to respond based on their local network view which may not be -/// a perfect view of the network. -#[must_use] -#[repr(C)] -pub struct ReplyShortChannelIdsEnd { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeReplyShortChannelIdsEnd, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ReplyShortChannelIdsEnd { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl ReplyShortChannelIdsEnd { - pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The genesis hash of the blockchain that was queried -#[no_mangle] -pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *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 that was queried -#[no_mangle] -pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); -} -/// Indicates if the query recipient maintains up-to-date channel -/// information for the chain_hash -#[no_mangle] -pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information; - (*inner_val) -} -/// Indicates if the query recipient maintains up-to-date channel -/// information for the chain_hash -#[no_mangle] -pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) { - unsafe { &mut *this_ptr.inner }.full_information = val; -} -/// Constructs a new ReplyShortChannelIdsEnd given each field -#[must_use] -#[no_mangle] -pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd { - ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd { - chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), - full_information: full_information_arg, - })), is_owned: true } -} -impl Clone for ReplyShortChannelIdsEnd { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ReplyShortChannelIdsEnd -pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd { - orig.clone() -} - -use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport; -type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport; - -/// A gossip_timestamp_filter message is used by a node to request -/// gossip relay for messages in the requested time range when the -/// gossip_queries feature has been negotiated. -#[must_use] -#[repr(C)] -pub struct GossipTimestampFilter { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeGossipTimestampFilter, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for GossipTimestampFilter { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl GossipTimestampFilter { - pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// The genesis hash of the blockchain for channel and node information -#[no_mangle] -pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *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 for channel and node information -#[no_mangle] -pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); -} -/// The starting unix timestamp -#[no_mangle] -pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp; - (*inner_val) -} -/// The starting unix timestamp -#[no_mangle] -pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) { - unsafe { &mut *this_ptr.inner }.first_timestamp = val; -} -/// The range of information in seconds -#[no_mangle] -pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range; - (*inner_val) -} -/// The range of information in seconds -#[no_mangle] -pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) { - unsafe { &mut *this_ptr.inner }.timestamp_range = val; -} -/// Constructs a new GossipTimestampFilter given each field -#[must_use] -#[no_mangle] -pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter { - GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter { - chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), - first_timestamp: first_timestamp_arg, - timestamp_range: timestamp_range_arg, - })), is_owned: true } -} -impl Clone for GossipTimestampFilter { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the GossipTimestampFilter -pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter { - orig.clone() -} -/// 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 { - /// An error message which we should make an effort to send before we disconnect. - 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 { - /// The message to send. - 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_inner()) } }) }; - 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_inner()) }, - } - }, - } - } - #[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_inner()) } }) }; - nativeErrorAction::DisconnectPeer { - msg: local_msg, - } - }, - ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, - ErrorAction::SendErrorMessage {mut msg, } => { - nativeErrorAction::SendErrorMessage { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - } - } - #[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 }, - } - }, - } - } -} -/// Frees any resources used by the ErrorAction -#[no_mangle] -pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { } -/// Creates a copy of the ErrorAction -#[no_mangle] -pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeLightningError, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for LightningError { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn LightningError_free(this_obj: 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_inner(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(); -} -/// Constructs a new LightningError given each field -#[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 } -} -impl Clone for LightningError { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the LightningError -pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeCommitmentUpdate, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for CommitmentUpdate { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn CommitmentUpdate_free(this_obj: 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_inner(mut self) -> *mut nativeCommitmentUpdate { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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_inner()) } }); }; - 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_inner()) } }); }; - 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_inner()) } }); }; - 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_inner()) } }); }; - 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_inner()) } }) }; - 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_inner()) }; -} -/// Constructs a new CommitmentUpdate given each field -#[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_inner()) } }); }; - 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_inner()) } }); }; - 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_inner()) } }); }; - 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_inner()) } }); }; - let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_inner()) } }) }; - 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_inner()) }, - })), is_owned: true } -} -impl Clone for CommitmentUpdate { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the CommitmentUpdate -pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate { - orig.clone() -} -/// 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 { - /// The unwrapped message we received - msg: crate::ln::msgs::ChannelUpdate, - }, - /// We received an error which indicated only that a channel has been closed - ChannelClosed { - /// The short_channel_id which has now closed. - short_channel_id: u64, - /// when this true, this channel should be permanently removed from the - /// consideration. Otherwise, this channel can be restored as new channel_update is received - is_permanent: bool, - }, - /// We received an error which indicated only that a node has failed - NodeFailure { - /// The node_id that has failed. - node_id: crate::c_types::PublicKey, - /// when this true, node should be permanently removed from the - /// consideration. Otherwise, the channels connected to this node can be - /// restored as new channel_update is received - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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, - } - }, - } - } -} -/// Frees any resources used by the HTLCFailChannelUpdate -#[no_mangle] -pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { } -/// Creates a copy of the HTLCFailChannelUpdate -#[no_mangle] -pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate { - orig.clone() -} -/// 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 { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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, their_features: &crate::ln::features::InitFeatures, 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 channel update from the given peer. - pub handle_channel_update: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelUpdate), - /// 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), - /// Implementation of MessageSendEventsProvider for this object. - pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler { - fn get_and_clear_pending_msg_events(&self) -> Vec { - let mut ret = (self.MessageSendEventsProvider.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 - } -} -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, their_features: &lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::Shutdown) { - (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::features::InitFeatures { inner: unsafe { (their_features as *const _) as *mut _ }, is_owned: false }, &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_channel_update(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelUpdate) { - (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ChannelUpdate { 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. -/// -/// # Implementor DoS Warnings -/// -/// For `gossip_queries` messages there are potential DoS vectors when handling -/// inbound queries. Implementors using an on-disk network graph should be aware of -/// repeated disk I/O for queries accessing different parts of the network graph. -#[repr(C)] -pub struct RoutingMessageHandler { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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 ::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, - /// Called when a connection is established with a peer. This can be used to - /// perform routing table synchronization using a strategy defined by the - /// implementor. - pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::ln::msgs::Init), - /// Handles the reply of a query we initiated to learn about channels - /// for a given range of blocks. We can expect to receive one or more - /// replies to a single query. - #[must_use] - pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, - /// Handles the reply of a query we initiated asking for routing gossip - /// messages for a list of channels. We should receive this message when - /// a node has completed its best effort to send us the pertaining routing - /// gossip messages. - #[must_use] - pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ, - /// Handles when a peer asks us to send a list of short_channel_ids - /// for the requested range of blocks. - #[must_use] - pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, - /// Handles when a peer asks us to send routing gossip messages for a - /// list of short_channel_ids. - #[must_use] - pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ, - /// Implementation of MessageSendEventsProvider for this object. - pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for RoutingMessageHandler {} -unsafe impl Sync for RoutingMessageHandler {} -impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler { - fn get_and_clear_pending_msg_events(&self) -> Vec { - let mut ret = (self.MessageSendEventsProvider.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 - } -} - -use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler; -impl rustRoutingMessageHandler for RoutingMessageHandler { - fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result { - 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(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; - local_ret - } - fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result { - 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(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; - local_ret - } - fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result { - 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(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; - 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, Option)> { - 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_inner()) } }) }; 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_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, 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 { - 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_inner()) } }); }; - local_ret - } - fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) { - (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Init { inner: unsafe { (init as *const _) as *mut _ }, is_owned: false }) - } - fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { - let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; - local_ret - } - fn handle_reply_short_channel_ids_end(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> { - let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(msg)), is_owned: true }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; - local_ret - } - fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { - let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; - local_ret - } - fn handle_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> { - let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; - 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 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] -/// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read -pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) }) -} -#[no_mangle] -/// Read a AcceptChannel from a byte array, created by AcceptChannel_write -pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read -pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) }) -} -#[no_mangle] -/// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write -pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read -pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) }) -} -#[no_mangle] -/// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write -pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read -pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) }) -} -#[no_mangle] -/// Read a ClosingSigned from a byte array, created by ClosingSigned_write -pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read -pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) }) -} -#[no_mangle] -/// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write -pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::CommitmentSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read -pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) }) -} -#[no_mangle] -/// Read a FundingCreated from a byte array, created by FundingCreated_write -pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read -pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) }) -} -#[no_mangle] -/// Read a FundingSigned from a byte array, created by FundingSigned_write -pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read -pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) }) -} -#[no_mangle] -/// Read a FundingLocked from a byte array, created by FundingLocked_write -pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the Init object into a byte array which can be read by Init_read -pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) }) -} -#[no_mangle] -/// Read a Init from a byte array, created by Init_write -pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Init { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read -pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) }) -} -#[no_mangle] -/// Read a OpenChannel from a byte array, created by OpenChannel_write -pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read -pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) }) -} -#[no_mangle] -/// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write -pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the Shutdown object into a byte array which can be read by Shutdown_read -pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) }) -} -#[no_mangle] -/// Read a Shutdown from a byte array, created by Shutdown_write -pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read -pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) }) -} -#[no_mangle] -/// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write -pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFailHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read -pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) }) -} -#[no_mangle] -/// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write -pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read -pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) }) -} -#[no_mangle] -/// Read a UpdateFee from a byte array, created by UpdateFee_write -pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFee { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read -pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) }) -} -#[no_mangle] -/// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write -pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFulfillHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read -pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) }) -} -#[no_mangle] -/// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write -pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateAddHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the Ping object into a byte array which can be read by Ping_read -pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) }) -} -#[no_mangle] -/// Read a Ping from a byte array, created by Ping_write -pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Ping { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the Pong object into a byte array which can be read by Pong_read -pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) }) -} -#[no_mangle] -/// Read a Pong from a byte array, created by Pong_write -pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Pong { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read -pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) }) -} -#[no_mangle] -/// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write -pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read -pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) }) -} -#[no_mangle] -/// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write -pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read -pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) }) -} -#[no_mangle] -/// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write -pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedChannelUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read -pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) }) -} -#[no_mangle] -/// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write -pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read -pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) }) -} -#[no_mangle] -/// Read a ErrorMessage from a byte array, created by ErrorMessage_write -pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read -pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) }) -} -#[no_mangle] -/// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write -pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read -pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) }) -} -#[no_mangle] -/// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write -pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write -pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read -pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) }) -} -#[no_mangle] -/// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write -pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read -pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) }) -} -///\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t -#[must_use] -#[no_mangle] -pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 { - let mut ret = unsafe { &*this_arg.inner }.end_blocknum(); - ret -} - -#[no_mangle] -/// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write -pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read -pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) }) -} -#[no_mangle] -/// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write -pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read -pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) }) -} -#[no_mangle] -/// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write -pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::GossipTimestampFilter { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read -pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) }) -} diff --git a/lightning-c-bindings/src/ln/peer_handler.rs b/lightning-c-bindings/src/ln/peer_handler.rs deleted file mode 100644 index 07368ae..0000000 --- a/lightning-c-bindings/src/ln/peer_handler.rs +++ /dev/null @@ -1,848 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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::IgnoringMessageHandler as nativeIgnoringMessageHandlerImport; -type nativeIgnoringMessageHandler = nativeIgnoringMessageHandlerImport; - -/// A dummy struct which implements `RoutingMessageHandler` without storing any routing information -/// or doing any processing. You can provide one of these as the route_handler in a MessageHandler. -#[must_use] -#[repr(C)] -pub struct IgnoringMessageHandler { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeIgnoringMessageHandler, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for IgnoringMessageHandler { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeIgnoringMessageHandler>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn IgnoringMessageHandler_free(this_obj: IgnoringMessageHandler) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn IgnoringMessageHandler_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeIgnoringMessageHandler); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl IgnoringMessageHandler { - pub(crate) fn take_inner(mut self) -> *mut nativeIgnoringMessageHandler { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Constructs a new IgnoringMessageHandler given each field -#[must_use] -#[no_mangle] -pub extern "C" fn IgnoringMessageHandler_new() -> IgnoringMessageHandler { - IgnoringMessageHandler { inner: Box::into_raw(Box::new(nativeIgnoringMessageHandler { - })), is_owned: true } -} -impl From for crate::util::events::MessageSendEventsProvider { - fn from(obj: nativeIgnoringMessageHandler) -> Self { - let mut rust_obj = IgnoringMessageHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&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(IgnoringMessageHandler_free_void); - ret - } -} -/// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn IgnoringMessageHandler_as_MessageSendEventsProvider(this_arg: &IgnoringMessageHandler) -> 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: IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, - } -} - -#[must_use] -extern "C" fn IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); }; - local_ret.into() -} - -impl From for crate::ln::msgs::RoutingMessageHandler { - fn from(obj: nativeIgnoringMessageHandler) -> Self { - let mut rust_obj = IgnoringMessageHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = IgnoringMessageHandler_as_RoutingMessageHandler(&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(IgnoringMessageHandler_free_void); - ret - } -} -/// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is -#[no_mangle] -pub extern "C" fn IgnoringMessageHandler_as_RoutingMessageHandler(this_arg: &IgnoringMessageHandler) -> crate::ln::msgs::RoutingMessageHandler { - crate::ln::msgs::RoutingMessageHandler { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - handle_node_announcement: IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement, - handle_channel_announcement: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement, - handle_channel_update: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update, - handle_htlc_fail_channel_update: IgnoringMessageHandler_RoutingMessageHandler_handle_htlc_fail_channel_update, - get_next_channel_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcements, - get_next_node_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcements, - sync_routing_table: IgnoringMessageHandler_RoutingMessageHandler_sync_routing_table, - handle_reply_channel_range: IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range, - handle_reply_short_channel_ids_end: IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end, - handle_query_channel_range: IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range, - handle_query_short_channel_ids: IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_channel_ids, - MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - get_and_clear_pending_msg_events: IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, - }, - } -} - -#[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, _msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, unsafe { &*_msg.inner }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -#[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, _msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, unsafe { &*_msg.inner }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -#[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, _msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, unsafe { &*_msg.inner }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, _update: &crate::ln::msgs::HTLCFailChannelUpdate) { - >::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_update.to_native()) -} -#[must_use] -extern "C" fn IgnoringMessageHandler_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 = >::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _starting_point, _batch_amount); - let mut local_ret = Vec::new(); for mut 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 IgnoringMessageHandler_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 = >::get_next_node_announcements(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, local__starting_point, _batch_amount); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); }; - local_ret.into() -} -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _init: &crate::ln::msgs::Init) { - >::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_init.inner }) -} -#[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -#[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -#[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -#[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - - -use lightning::ln::peer_handler::ErroringMessageHandler as nativeErroringMessageHandlerImport; -type nativeErroringMessageHandler = nativeErroringMessageHandlerImport; - -/// A dummy struct which implements `ChannelMessageHandler` without having any channels. -/// You can provide one of these as the route_handler in a MessageHandler. -#[must_use] -#[repr(C)] -pub struct ErroringMessageHandler { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeErroringMessageHandler, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ErroringMessageHandler { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeErroringMessageHandler>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ErroringMessageHandler_free(this_obj: ErroringMessageHandler) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ErroringMessageHandler_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErroringMessageHandler); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl ErroringMessageHandler { - pub(crate) fn take_inner(mut self) -> *mut nativeErroringMessageHandler { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Constructs a new ErroringMessageHandler -#[must_use] -#[no_mangle] -pub extern "C" fn ErroringMessageHandler_new() -> ErroringMessageHandler { - let mut ret = lightning::ln::peer_handler::ErroringMessageHandler::new(); - ErroringMessageHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -impl From for crate::util::events::MessageSendEventsProvider { - fn from(obj: nativeErroringMessageHandler) -> Self { - let mut rust_obj = ErroringMessageHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = ErroringMessageHandler_as_MessageSendEventsProvider(&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(ErroringMessageHandler_free_void); - ret - } -} -/// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn ErroringMessageHandler_as_MessageSendEventsProvider(this_arg: &ErroringMessageHandler) -> 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: ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, - } -} - -#[must_use] -extern "C" fn ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); }; - local_ret.into() -} - -impl From for crate::ln::msgs::ChannelMessageHandler { - fn from(obj: nativeErroringMessageHandler) -> Self { - let mut rust_obj = ErroringMessageHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = ErroringMessageHandler_as_ChannelMessageHandler(&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(ErroringMessageHandler_free_void); - ret - } -} -/// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is -#[no_mangle] -pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &ErroringMessageHandler) -> crate::ln::msgs::ChannelMessageHandler { - crate::ln::msgs::ChannelMessageHandler { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - handle_open_channel: ErroringMessageHandler_ChannelMessageHandler_handle_open_channel, - handle_accept_channel: ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel, - handle_funding_created: ErroringMessageHandler_ChannelMessageHandler_handle_funding_created, - handle_funding_signed: ErroringMessageHandler_ChannelMessageHandler_handle_funding_signed, - handle_funding_locked: ErroringMessageHandler_ChannelMessageHandler_handle_funding_locked, - handle_shutdown: ErroringMessageHandler_ChannelMessageHandler_handle_shutdown, - handle_closing_signed: ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed, - handle_update_add_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc, - handle_update_fulfill_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fulfill_htlc, - handle_update_fail_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_htlc, - handle_update_fail_malformed_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_malformed_htlc, - handle_commitment_signed: ErroringMessageHandler_ChannelMessageHandler_handle_commitment_signed, - handle_revoke_and_ack: ErroringMessageHandler_ChannelMessageHandler_handle_revoke_and_ack, - handle_update_fee: ErroringMessageHandler_ChannelMessageHandler_handle_update_fee, - handle_announcement_signatures: ErroringMessageHandler_ChannelMessageHandler_handle_announcement_signatures, - peer_disconnected: ErroringMessageHandler_ChannelMessageHandler_peer_disconnected, - peer_connected: ErroringMessageHandler_ChannelMessageHandler_peer_connected, - handle_channel_reestablish: ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish, - handle_channel_update: ErroringMessageHandler_ChannelMessageHandler_handle_channel_update, - handle_error: ErroringMessageHandler_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: ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, - }, - } -} - -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut _their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel) { - >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(_their_features.take_inner()) }, unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut _their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel) { - >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(_their_features.take_inner()) }, unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated) { - >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned) { - >::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked) { - >::handle_funding_locked(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, _their_features: &crate::ln::features::InitFeatures, msg: &crate::ln::msgs::Shutdown) { - >::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*_their_features.inner }, unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned) { - >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC) { - >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC) { - >::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC) { - >::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC) { - >::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned) { - >::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK) { - >::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee) { - >::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures) { - >::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) { - >::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::ln::msgs::ChannelUpdate) { - >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _no_connection_possible: bool) { - >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), _no_connection_possible) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::ln::msgs::Init) { - >::peer_connected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_msg.inner }) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::ln::msgs::ErrorMessage) { - >::handle_error(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_msg.inner }) -} - - -use lightning::ln::peer_handler::MessageHandler as nativeMessageHandlerImport; -type nativeMessageHandler = nativeMessageHandlerImport; - -/// Provides references to trait impls which handle different types of messages. -#[must_use] -#[repr(C)] -pub struct MessageHandler { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeMessageHandler, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for MessageHandler { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeMessageHandler>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn MessageHandler_free(this_obj: 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_inner(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 or a ErroringMessageHandler. -#[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 or a ErroringMessageHandler. -#[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 or an IgnoringMessageHandler. -#[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 or an IgnoringMessageHandler. -#[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; -} -/// Constructs a new MessageHandler given each field -#[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 { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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), - /// Checks if two objects are equal given this object's this_arg pointer and another object. - pub eq: extern "C" fn (this_arg: *const c_void, other_arg: &SocketDescriptor) -> bool, - /// Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. - /// This is used, for example, for inclusion of this object in a hash map. - pub hash: extern "C" fn (this_arg: *const c_void) -> u64, - /// Creates a copy of the object pointed to by this_arg, for a copy of this SocketDescriptor. - /// Note that the ultimate copy of the SocketDescriptor will have all function pointers the same as the original. - /// May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new SocketDescriptor. - pub clone: Option *mut c_void>, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -impl std::cmp::Eq for SocketDescriptor {} -impl std::cmp::PartialEq for SocketDescriptor { - fn eq(&self, o: &Self) -> bool { (self.eq)(self.this_arg, o) } -} -impl std::hash::Hash for SocketDescriptor { - fn hash(&self, hasher: &mut H) { hasher.write_u64((self.hash)(self.this_arg)) } -} -#[no_mangle] -/// Creates a copy of a SocketDescriptor -pub extern "C" fn SocketDescriptor_clone(orig: &SocketDescriptor) -> SocketDescriptor { - SocketDescriptor { - this_arg: if let Some(f) = orig.clone { (f)(orig.this_arg) } else { orig.this_arg }, - send_data: Clone::clone(&orig.send_data), - disconnect_socket: Clone::clone(&orig.disconnect_socket), - eq: Clone::clone(&orig.eq), - hash: Clone::clone(&orig.hash), - clone: Clone::clone(&orig.clone), - free: Clone::clone(&orig.free), - } -} -impl Clone for SocketDescriptor { - fn clone(&self) -> Self { - SocketDescriptor_clone(self) - } -} - -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/socket_disconnected calls for the -/// descriptor. -#[must_use] -#[repr(C)] -pub struct PeerHandleError { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativePeerHandleError, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for PeerHandleError { - fn drop(&mut self) { - if self.is_owned && !<*mut nativePeerHandleError>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn PeerHandleError_free(this_obj: 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_inner(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; -} -/// Constructs a new PeerHandleError given each field -#[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 } -} -impl Clone for PeerHandleError { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativePeerHandleError>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 PeerHandleError_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePeerHandleError)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the PeerHandleError -pub extern "C" fn PeerHandleError_clone(orig: &PeerHandleError) -> PeerHandleError { - orig.clone() -} - -use lightning::ln::peer_handler::PeerManager as nativePeerManagerImport; -type nativePeerManager = nativePeerManagerImport; - -/// 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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativePeerManager, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for PeerManager { - fn drop(&mut self) { - if self.is_owned && !<*mut nativePeerManager>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn PeerManager_free(this_obj: 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_inner(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_inner()) }, 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 mut 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 mut item in o.drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - 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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - 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*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - 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 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - 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) -} - -/// Disconnect a peer given its node id. -/// -/// Set no_connection_possible to true to prevent any further connection with this peer, -/// force-closing any channels we have with it. -/// -/// If a peer is connected, this will call `disconnect_socket` on the descriptor for the peer, -/// so be careful about reentrancy issues. -#[no_mangle] -pub extern "C" fn PeerManager_disconnect_by_node_id(this_arg: &PeerManager, mut node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) { - unsafe { &*this_arg.inner }.disconnect_by_node_id(node_id.into_rust(), no_connection_possible) -} - -/// 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_occurred(this_arg: &PeerManager) { - unsafe { &*this_arg.inner }.timer_tick_occurred() -} - diff --git a/lightning-c-bindings/src/routing/mod.rs b/lightning-c-bindings/src/routing/mod.rs deleted file mode 100644 index a06e1d0..0000000 --- a/lightning-c-bindings/src/routing/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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; diff --git a/lightning-c-bindings/src/routing/network_graph.rs b/lightning-c-bindings/src/routing/network_graph.rs deleted file mode 100644 index b1421b8..0000000 --- a/lightning-c-bindings/src/routing/network_graph.rs +++ /dev/null @@ -1,1259 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeNetworkGraph, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for NetworkGraph { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn NetworkGraph_free(this_obj: 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_inner(mut self) -> *mut nativeNetworkGraph { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -impl Clone for NetworkGraph { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the NetworkGraph -pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph { - orig.clone() -} - -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 possible from -/// the C bindings, as it can be done directly in Rust code. -#[must_use] -#[repr(C)] -pub struct LockedNetworkGraph { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeLockedNetworkGraph, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for LockedNetworkGraph { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeLockedNetworkGraph>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn LockedNetworkGraph_free(this_obj: 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_inner(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; - -/// 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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeNetGraphMsgHandler, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for NetGraphMsgHandler { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeNetGraphMsgHandler>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn NetGraphMsgHandler_free(this_obj: 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_inner(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 genesis_hash: crate::c_types::ThirtyTwoBytes, chain_access: *mut crate::chain::Access, mut logger: crate::util::logger::Logger) -> NetGraphMsgHandler { - let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; - let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), local_chain_access, 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(chain_access: *mut crate::chain::Access, mut logger: crate::util::logger::Logger, mut network_graph: crate::routing::network_graph::NetworkGraph) -> NetGraphMsgHandler { - let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; - let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(local_chain_access, logger, *unsafe { Box::from_raw(network_graph.take_inner()) }); - NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// Adds a provider used to check new announcements. Does not affect -/// existing announcements unless they are updated. -/// Add, update or remove the provider would replace the current one. -#[no_mangle] -pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, chain_access: *mut crate::chain::Access) { - let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; - unsafe { &mut (*(this_arg.inner as *mut nativeNetGraphMsgHandler)) }.add_chain_access(local_chain_access) -} - -/// 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 } -} - -impl From for crate::ln::msgs::RoutingMessageHandler { - fn from(obj: nativeNetGraphMsgHandler) -> Self { - let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&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(NetGraphMsgHandler_free_void); - ret - } -} -/// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is -#[no_mangle] -pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &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, - sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table, - handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range, - handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end, - handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range, - handle_query_short_channel_ids: NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids, - MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider { - this_arg: unsafe { (*this_arg).inner as *mut c_void }, - free: None, - get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, - }, - } -} - -#[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 = >::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - 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 = >::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate) { - >::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &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 = >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - 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 = >::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount); - let mut local_ret = Vec::new(); for mut 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 = >::get_next_node_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, local_starting_point, batch_amount); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); }; - local_ret.into() -} -extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) { - >::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), unsafe { &*init_msg.inner }) -} -#[must_use] -extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -#[must_use] -extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -#[must_use] -extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} -#[must_use] -extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - -impl From for crate::util::events::MessageSendEventsProvider { - fn from(obj: nativeNetGraphMsgHandler) -> Self { - let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&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(NetGraphMsgHandler_free_void); - ret - } -} -/// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn NetGraphMsgHandler_as_MessageSendEventsProvider(this_arg: &NetGraphMsgHandler) -> 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: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, - } -} - -#[must_use] -extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); }; - local_ret.into() -} - - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeDirectionalChannelInfo, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DirectionalChannelInfo { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDirectionalChannelInfo>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DirectionalChannelInfo_free(this_obj: 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_inner(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; -} -/// The maximum value which may be relayed to the next hop via the channel. -#[no_mangle] -pub extern "C" fn DirectionalChannelInfo_get_htlc_maximum_msat(this_ptr: &DirectionalChannelInfo) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_maximum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; - local_inner_val -} -/// The maximum value which may be relayed to the next hop via the channel. -#[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *this_ptr.inner }.htlc_maximum_msat = local_val; -} -/// Fees charged when the channel is used for routing -#[no_mangle] -pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> 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 } -} -/// Fees charged when the channel is used for routing -#[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::routing::network_graph::RoutingFees) { - unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// 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_inner()) } }) }; - unsafe { &mut *this_ptr.inner }.last_update_message = local_val; -} -/// Constructs a new DirectionalChannelInfo given each field -#[must_use] -#[no_mangle] -pub extern "C" fn DirectionalChannelInfo_new(mut last_update_arg: u32, mut enabled_arg: bool, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut fees_arg: crate::routing::network_graph::RoutingFees, mut last_update_message_arg: crate::ln::msgs::ChannelUpdate) -> DirectionalChannelInfo { - let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; - let mut local_last_update_message_arg = if last_update_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(last_update_message_arg.take_inner()) } }) }; - DirectionalChannelInfo { inner: Box::into_raw(Box::new(nativeDirectionalChannelInfo { - last_update: last_update_arg, - enabled: enabled_arg, - cltv_expiry_delta: cltv_expiry_delta_arg, - htlc_minimum_msat: htlc_minimum_msat_arg, - htlc_maximum_msat: local_htlc_maximum_msat_arg, - fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, - last_update_message: local_last_update_message_arg, - })), is_owned: true } -} -impl Clone for DirectionalChannelInfo { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 DirectionalChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectionalChannelInfo)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the DirectionalChannelInfo -pub extern "C" fn DirectionalChannelInfo_clone(orig: &DirectionalChannelInfo) -> DirectionalChannelInfo { - orig.clone() -} -#[no_mangle] -/// Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read -pub extern "C" fn DirectionalChannelInfo_write(obj: &DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) }) -} -#[no_mangle] -/// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write -pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::DirectionalChannelInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelInfo, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelInfo { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelInfo_free(this_obj: 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_inner(mut self) -> *mut nativeChannelInfo { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Protocol features of a channel communicated during its announcement -#[no_mangle] -pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::ln::features::ChannelFeatures { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// Protocol features of a channel communicated during its announcement -#[no_mangle] -pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::ln::features::ChannelFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// 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_inner()) } }) }; - 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_inner()) } }) }; - unsafe { &mut *this_ptr.inner }.two_to_one = local_val; -} -/// The channel capacity as seen on-chain, if chain lookup is available. -#[no_mangle] -pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.capacity_sats; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; - local_inner_val -} -/// The channel capacity as seen on-chain, if chain lookup is available. -#[no_mangle] -pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *this_ptr.inner }.capacity_sats = 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_inner()) } }) }; - unsafe { &mut *this_ptr.inner }.announcement_message = local_val; -} -/// Constructs a new ChannelInfo given each field -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelInfo_new(mut features_arg: crate::ln::features::ChannelFeatures, mut node_one_arg: crate::c_types::PublicKey, mut one_to_two_arg: crate::routing::network_graph::DirectionalChannelInfo, mut node_two_arg: crate::c_types::PublicKey, mut two_to_one_arg: crate::routing::network_graph::DirectionalChannelInfo, mut capacity_sats_arg: crate::c_types::derived::COption_u64Z, mut announcement_message_arg: crate::ln::msgs::ChannelAnnouncement) -> ChannelInfo { - let mut local_one_to_two_arg = if one_to_two_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(one_to_two_arg.take_inner()) } }) }; - let mut local_two_to_one_arg = if two_to_one_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(two_to_one_arg.take_inner()) } }) }; - let mut local_capacity_sats_arg = if capacity_sats_arg.is_some() { Some( { capacity_sats_arg.take() }) } else { None }; - let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) }; - ChannelInfo { inner: Box::into_raw(Box::new(nativeChannelInfo { - features: *unsafe { Box::from_raw(features_arg.take_inner()) }, - node_one: node_one_arg.into_rust(), - one_to_two: local_one_to_two_arg, - node_two: node_two_arg.into_rust(), - two_to_one: local_two_to_one_arg, - capacity_sats: local_capacity_sats_arg, - announcement_message: local_announcement_message_arg, - })), is_owned: true } -} -impl Clone for ChannelInfo { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelInfo -pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo { - orig.clone() -} -#[no_mangle] -/// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read -pub extern "C" fn ChannelInfo_write(obj: &ChannelInfo) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) }) -} -#[no_mangle] -/// Read a ChannelInfo from a byte array, created by ChannelInfo_write -pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::ChannelInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeRoutingFees, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for RoutingFees { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RoutingFees_free(this_obj: 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_inner(mut self) -> *mut nativeRoutingFees { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -/// Constructs a new RoutingFees given each field -#[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 } -} -impl Clone for RoutingFees { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRoutingFees>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the RoutingFees -pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees { - orig.clone() -} -#[no_mangle] -/// Read a RoutingFees from a byte array, created by RoutingFees_write -pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::RoutingFees { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read -pub extern "C" fn RoutingFees_write(obj: &RoutingFees) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) }) -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeNodeAnnouncementInfo, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for NodeAnnouncementInfo { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_free(this_obj: 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_inner(mut self) -> *mut nativeNodeAnnouncementInfo { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// Protocol features the node announced support for -#[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::ln::features::NodeFeatures { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// Protocol features the node announced support for -#[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::ln::features::NodeFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// 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_inner()) } }) }; - unsafe { &mut *this_ptr.inner }.announcement_message = local_val; -} -/// Constructs a new NodeAnnouncementInfo given each field -#[must_use] -#[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::ln::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::c_types::ThirtyTwoBytes, mut addresses_arg: crate::c_types::derived::CVec_NetAddressZ, mut announcement_message_arg: crate::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo { - let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); }; - let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) }; - NodeAnnouncementInfo { inner: Box::into_raw(Box::new(nativeNodeAnnouncementInfo { - features: *unsafe { Box::from_raw(features_arg.take_inner()) }, - last_update: last_update_arg, - rgb: rgb_arg.data, - alias: alias_arg.data, - addresses: local_addresses_arg, - announcement_message: local_announcement_message_arg, - })), is_owned: true } -} -impl Clone for NodeAnnouncementInfo { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncementInfo)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the NodeAnnouncementInfo -pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo { - orig.clone() -} -#[no_mangle] -/// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read -pub extern "C" fn NodeAnnouncementInfo_write(obj: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) }) -} -#[no_mangle] -/// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write -pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::NodeAnnouncementInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeNodeInfo, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for NodeInfo { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn NodeInfo_free(this_obj: 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_inner(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_inner()) } }) }; - 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_inner()) } }) }; - unsafe { &mut *this_ptr.inner }.announcement_info = local_val; -} -/// Constructs a new NodeInfo given each field -#[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_inner()) } }) }; - let mut local_announcement_info_arg = if announcement_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_info_arg.take_inner()) } }) }; - 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 } -} -impl Clone for NodeInfo { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeNodeInfo>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeInfo)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the NodeInfo -pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo { - orig.clone() -} -#[no_mangle] -/// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read -pub extern "C" fn NodeInfo_write(obj: &NodeInfo) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) }) -} -#[no_mangle] -/// Read a NodeInfo from a byte array, created by NodeInfo_write -pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::NodeInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -#[no_mangle] -/// Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read -pub extern "C" fn NetworkGraph_write(obj: &NetworkGraph) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) }) -} -#[no_mangle] -/// Read a NetworkGraph from a byte array, created by NetworkGraph_write -pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} -/// Creates a new, empty, network graph. -#[must_use] -#[no_mangle] -pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes) -> crate::routing::network_graph::NetworkGraph { - let mut ret = lightning::routing::network_graph::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap()); - crate::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// For an already known node (from channel announcements), update its stored properties from a -/// given node announcement. -/// -/// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's -/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept -/// routing messages from a source using a protocol other than the lightning P2P protocol. -#[must_use] -#[no_mangle] -pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_announcement(unsafe { &*msg.inner }, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - -/// For an already known node (from channel announcements), update its stored properties from a -/// given node announcement without verifying the associated signatures. Because we aren't -/// given the associated signatures here we cannot relay the node announcement to any of our -/// peers. -#[must_use] -#[no_mangle] -pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_unsigned_announcement(unsafe { &*msg.inner }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - -/// Store or update channel info from a channel announcement. -/// -/// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's -/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept -/// routing messages from a source using a protocol other than the lightning P2P protocol. -/// -/// If a `chain::Access` object is provided via `chain_access`, it will be called to verify -/// the corresponding UTXO exists on chain and is correctly-formatted. -#[must_use] -#[no_mangle] -pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::ChannelAnnouncement, chain_access: *mut crate::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_announcement(unsafe { &*msg.inner }, &local_chain_access, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - -/// Store or update channel info from a channel announcement without verifying the associated -/// signatures. Because we aren't given the associated signatures here we cannot relay the -/// channel announcement to any of our peers. -/// -/// If a `chain::Access` object is provided via `chain_access`, it will be called to verify -/// the corresponding UTXO exists on chain and is correctly-formatted. -#[must_use] -#[no_mangle] -pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedChannelAnnouncement, chain_access: *mut crate::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_unsigned_announcement(unsafe { &*msg.inner }, &local_chain_access); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - -/// 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) -} - -/// For an already known (from announcement) channel, update info about one of the directions -/// of the channel. -/// -/// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's -/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept -/// routing messages from a source using a protocol other than the lightning P2P protocol. -#[must_use] -#[no_mangle] -pub extern "C" fn NetworkGraph_update_channel(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel(unsafe { &*msg.inner }, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - -/// For an already known (from announcement) channel, update info about one of the directions -/// of the channel without verifying the associated signatures. Because we aren't given the -/// associated signatures here we cannot relay the channel update to any of our peers. -#[must_use] -#[no_mangle] -pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_unsigned(unsafe { &*msg.inner }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - diff --git a/lightning-c-bindings/src/routing/router.rs b/lightning-c-bindings/src/routing/router.rs deleted file mode 100644 index 4289511..0000000 --- a/lightning-c-bindings/src/routing/router.rs +++ /dev/null @@ -1,449 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeRouteHop, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for RouteHop { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRouteHop>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RouteHop_free(this_obj: 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_inner(mut self) -> *mut nativeRouteHop { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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 node_announcement features of the node at this hop. For the last hop, these may be -/// amended to match the features present in the invoice this node generated. -#[no_mangle] -pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::ln::features::NodeFeatures { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_features; - crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// The node_announcement features of the node at this hop. For the last hop, these may be -/// amended to match the features present in the invoice this node generated. -#[no_mangle] -pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::ln::features::NodeFeatures) { - unsafe { &mut *this_ptr.inner }.node_features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// 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 channel_announcement features of the channel that should be used from the previous hop -/// to reach this node. -#[no_mangle] -pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::ln::features::ChannelFeatures { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_features; - crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } -} -/// The channel_announcement features of the channel that should be used from the previous hop -/// to reach this node. -#[no_mangle] -pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::ln::features::ChannelFeatures) { - unsafe { &mut *this_ptr.inner }.channel_features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The fee taken on this hop (for paying for the use of the *next* channel in the path). -/// For the last hop, this should be the full value of the payment (might be more than -/// requested if we had to match htlc_minimum_msat). -#[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 paying for the use of the *next* channel in the path). -/// For the last hop, this should be the full value of the payment (might be more than -/// requested if we had to match htlc_minimum_msat). -#[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; -} -/// Constructs a new RouteHop given each field -#[must_use] -#[no_mangle] -pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::ln::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::ln::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32) -> RouteHop { - RouteHop { inner: Box::into_raw(Box::new(nativeRouteHop { - pubkey: pubkey_arg.into_rust(), - node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) }, - short_channel_id: short_channel_id_arg, - channel_features: *unsafe { Box::from_raw(channel_features_arg.take_inner()) }, - fee_msat: fee_msat_arg, - cltv_expiry_delta: cltv_expiry_delta_arg, - })), is_owned: true } -} -impl Clone for RouteHop { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRouteHop>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the RouteHop -pub extern "C" fn RouteHop_clone(orig: &RouteHop) -> RouteHop { - orig.clone() -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeRoute, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for Route { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRoute>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the Route, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Route_free(this_obj: 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_inner(mut self) -> *mut nativeRoute { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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_inner()) } }); }; local_val_0 }); }; - unsafe { &mut *this_ptr.inner }.paths = local_val; -} -/// Constructs a new Route given each field -#[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_inner()) } }); }; local_paths_arg_0 }); }; - Route { inner: Box::into_raw(Box::new(nativeRoute { - paths: local_paths_arg, - })), is_owned: true } -} -impl Clone for Route { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRoute>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the Route -pub extern "C" fn Route_clone(orig: &Route) -> Route { - orig.clone() -} -#[no_mangle] -/// Serialize the Route object into a byte array which can be read by Route_read -pub extern "C" fn Route_write(obj: &Route) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) }) -} -#[no_mangle] -/// Read a Route from a byte array, created by Route_write -pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::router::Route { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeRouteHint, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for RouteHint { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RouteHint_free(this_obj: 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_inner(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_inner()) }; -} -/// 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) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; - local_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: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = local_val; -} -/// The maximum value in msat available for routing with a single HTLC. -#[no_mangle] -pub extern "C" fn RouteHint_get_htlc_maximum_msat(this_ptr: &RouteHint) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_maximum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } }; - local_inner_val -} -/// The maximum value in msat available for routing with a single HTLC. -#[no_mangle] -pub extern "C" fn RouteHint_set_htlc_maximum_msat(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *this_ptr.inner }.htlc_maximum_msat = local_val; -} -/// Constructs a new RouteHint given each field -#[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: crate::c_types::derived::COption_u64Z, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteHint { - let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None }; - let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; - 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_inner()) }, - cltv_expiry_delta: cltv_expiry_delta_arg, - htlc_minimum_msat: local_htlc_minimum_msat_arg, - htlc_maximum_msat: local_htlc_maximum_msat_arg, - })), is_owned: true } -} -impl Clone for RouteHint { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRouteHint>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHint)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the RouteHint -pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { - orig.clone() -} -/// Gets a route from us (payer) to the given target node (payee). -/// -/// If the payee provided features in their invoice, they should be provided via payee_features. -/// Without this, MPP will only be used if the payee's features are available in the network graph. -/// -/// 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/htlc_maximum_msat *are* checked as they may change based on the receiving node. -#[no_mangle] -pub extern "C" fn get_route(mut our_node_id: crate::c_types::PublicKey, network: &crate::routing::network_graph::NetworkGraph, mut payee: crate::c_types::PublicKey, mut payee_features: crate::ln::features::InvoiceFeatures, 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_payee_features = if payee_features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payee_features.take_inner()) } }) }; - let mut local_first_hops_base = if first_hops == std::ptr::null_mut() { 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 }, &payee.into_rust(), local_payee_features, 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 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_ret -} - diff --git a/lightning-c-bindings/src/util/config.rs b/lightning-c-bindings/src/util/config.rs deleted file mode 100644 index 1d1cb15..0000000 --- a/lightning-c-bindings/src/util/config.rs +++ /dev/null @@ -1,813 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelHandshakeConfig, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelHandshakeConfig { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelHandshakeConfig_free(this_obj: 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_inner(mut self) -> *mut nativeChannelHandshakeConfig { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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 number of blocks we require our counterparty to wait to claim their money (ie -/// the number of blocks we have to punish our counterparty if they broadcast a revoked -/// transaction). -/// -/// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST -/// be online to check for revoked transactions on-chain at least once every our_to_self_delay -/// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, -/// possibly with time in between to RBF the spending transaction). -/// -/// 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`], 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 number of blocks we require our counterparty to wait to claim their money (ie -/// the number of blocks we have to punish our counterparty if they broadcast a revoked -/// transaction). -/// -/// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST -/// be online to check for revoked transactions on-chain at least once every our_to_self_delay -/// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, -/// possibly with time in between to RBF the spending transaction). -/// -/// 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`], 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; -} -/// Constructs a new ChannelHandshakeConfig given each field -#[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 } -} -impl Clone for ChannelHandshakeConfig { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ChannelHandshakeConfig -pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig { - orig.clone() -} -/// Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. -#[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/::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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelHandshakeLimits, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelHandshakeLimits { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelHandshakeLimits_free(this_obj: 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_inner(mut self) -> *mut nativeChannelHandshakeLimits { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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: 2016, 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: 2016, 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; -} -/// Constructs a new ChannelHandshakeLimits given each field -#[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 } -} -impl Clone for ChannelHandshakeLimits { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ChannelHandshakeLimits -pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits { - orig.clone() -} -/// Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. -#[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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeChannelConfig, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelConfig { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelConfig_free(this_obj: 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_inner(mut self) -> *mut nativeChannelConfig { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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; -} -/// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over -/// the channel this config applies to. -/// -/// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight -/// HTLC balance when a channel appears on-chain whereas -/// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining -/// (non-HTLC-encumbered) balance. -/// -/// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, -/// we (or one of our watchtowers) MUST be online to check for broadcast of the current -/// commitment transaction at least once per this many blocks (minus some margin to allow us -/// enough time to broadcast and confirm a transaction, possibly with time in between to RBF -/// the spending transaction). -/// -/// Default value: 72 (12 hours at an average of 6 blocks/hour). -/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as -/// [`MIN_CLTV_EXPIRY_DELTA`] instead. -/// -/// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA -#[no_mangle] -pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; - (*inner_val) -} -/// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over -/// the channel this config applies to. -/// -/// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight -/// HTLC balance when a channel appears on-chain whereas -/// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining -/// (non-HTLC-encumbered) balance. -/// -/// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, -/// we (or one of our watchtowers) MUST be online to check for broadcast of the current -/// commitment transaction at least once per this many blocks (minus some margin to allow us -/// enough time to broadcast and confirm a transaction, possibly with time in between to RBF -/// the spending transaction). -/// -/// Default value: 72 (12 hours at an average of 6 blocks/hour). -/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as -/// [`MIN_CLTV_EXPIRY_DELTA`] instead. -/// -/// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA -#[no_mangle] -pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) { - unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = 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; -} -/// Constructs a new ChannelConfig given each field -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelConfig_new(mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, 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, - cltv_expiry_delta: cltv_expiry_delta_arg, - announced_channel: announced_channel_arg, - commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg, - })), is_owned: true } -} -impl Clone for ChannelConfig { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelConfig>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the ChannelConfig -pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig { - orig.clone() -} -/// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. -#[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] -/// Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read -pub extern "C" fn ChannelConfig_write(obj: &ChannelConfig) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) -} -#[no_mangle] -pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) }) -} -#[no_mangle] -/// Read a ChannelConfig from a byte array, created by ChannelConfig_write -pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::util::config::ChannelConfig { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; - local_res -} - -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 { - /// A pointer to the opaque Rust object. - - /// 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. - pub inner: *mut nativeUserConfig, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UserConfig { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(self.inner) }; - } - } -} -/// Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UserConfig_free(this_obj: 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_inner(mut self) -> *mut nativeUserConfig { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -/// 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_inner()) }; -} -/// 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_inner()) }; -} -/// 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_inner()) }; -} -/// Constructs a new UserConfig given each field -#[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_inner()) }, - peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) }, - channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) }, - })), is_owned: true } -} -impl Clone for UserConfig { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUserConfig>::is_null(self.inner) { std::ptr::null_mut() } else { - 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 -} -#[no_mangle] -/// Creates a copy of the UserConfig -pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig { - orig.clone() -} -/// Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. -#[must_use] -#[no_mangle] -pub extern "C" fn UserConfig_default() -> UserConfig { - UserConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true } -} diff --git a/lightning-c-bindings/src/util/errors.rs b/lightning-c-bindings/src/util/errors.rs deleted file mode 100644 index 5261382..0000000 --- a/lightning-c-bindings/src/util/errors.rs +++ /dev/null @@ -1,181 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 { - /// A human-readable error message - 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 { - /// A human-readable error message - err: crate::c_types::derived::CVec_u8Z, - /// The feerate which was too high. - feerate: u32, - }, - /// A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, - /// too-many-hops, etc). - RouteError { - /// A human-readable error message - 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 { - /// A human-readable error message - err: crate::c_types::derived::CVec_u8Z, - }, - /// An attempt to call watch/update_channel 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, - } - } -} -/// Frees any resources used by the APIError -#[no_mangle] -pub extern "C" fn APIError_free(this_ptr: APIError) { } -/// Creates a copy of the APIError -#[no_mangle] -pub extern "C" fn APIError_clone(orig: &APIError) -> APIError { - orig.clone() -} diff --git a/lightning-c-bindings/src/util/events.rs b/lightning-c-bindings/src/util/events.rs deleted file mode 100644 index 295878e..0000000 --- a/lightning-c-bindings/src/util/events.rs +++ /dev/null @@ -1,1101 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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 { - /// The random channel_id we picked which you'll need to pass into - /// ChannelManager::funding_transaction_generated. - temporary_channel_id: crate::c_types::ThirtyTwoBytes, - /// The value, in satoshis, that the output should have. - channel_value_satoshis: u64, - /// The script which should be used in the transaction output. - output_script: crate::c_types::derived::CVec_u8Z, - /// The value passed in to ChannelManager::create_channel - 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 { - /// The hash for which the preimage should be handed to the ChannelManager. - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The \"payment secret\". This authenticates the sender to the recipient, preventing a - /// number of deanonymization attacks during the routing process. - /// As nodes upgrade, the invoices you provide should likely migrate to setting the - /// payment_secret feature to required, at which point you should fail_backwards any HTLCs - /// which have a None here. - /// Until then, however, values of None should be ignored, and only incorrect Some values - /// should result in an HTLC fail_backwards. - /// Note that, in any case, this value must be passed as-is to any fail or claim calls as - /// the HTLC index includes this value. - payment_secret: crate::c_types::ThirtyTwoBytes, - /// The value, in thousandths of a satoshi, that this payment is for. Note that you must - /// compare this to the expected value before accepting the payment (as otherwise you are - /// providing proof-of-payment for less than the value you expected!). - 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 { - /// The preimage to the hash given to ChannelManager::send_payment. - /// Note that this serves as a payment receipt, if you wish to have such a thing, you must - /// store it somehow! - 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 { - /// The hash which was given to ChannelManager::send_payment. - payment_hash: crate::c_types::ThirtyTwoBytes, - /// Indicates the payment was rejected for some reason by the recipient. This implies that - /// the payment has failed, not just the route in question. If this is not set, you may - /// retry the payment via a different route. - rejected_by_dest: bool, - }, - /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a - /// time in the future. - PendingHTLCsForwardable { - /// The minimum amount of time that should be waited prior to calling - /// process_pending_htlc_forwards. To increase the effort required to correlate payments, - /// you should wait a random amount of time in roughly the range (now + time_forwardable, - /// now + 5*time_forwardable). - 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 { - /// The outputs which you should store as spendable by you. - 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::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::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::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 mut 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::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 mut item in outputs.drain(..) { local_outputs.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); }; - Event::SpendableOutputs { - outputs: local_outputs.into(), - } - }, - } - } -} -/// Frees any resources used by the Event -#[no_mangle] -pub extern "C" fn Event_free(this_ptr: Event) { } -/// Creates a copy of the Event -#[no_mangle] -pub extern "C" fn Event_clone(orig: &Event) -> Event { - orig.clone() -} -#[no_mangle] -/// Serialize the Event object into a byte array which can be read by Event_read -pub extern "C" fn Event_write(obj: &Event) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -/// 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 { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - 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 { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - 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 { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - 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 { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - 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 { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The funding_locked message which should be sent. - 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 { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The announcement_signatures message which should be sent. - 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 { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The update messages which should be sent. ALL messages in the struct should be sent! - 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 { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - 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 { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::ln::msgs::ClosingSigned, - }, - /// Used to indicate that a shutdown message should be sent to the peer with the given node_id. - SendShutdown { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - 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 { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - 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 { - /// The channel_announcement which should be sent. - msg: crate::ln::msgs::ChannelAnnouncement, - /// The followup channel_update which should be sent. - update_msg: crate::ln::msgs::ChannelUpdate, - }, - /// Used to indicate that a node_announcement should be broadcast to all peers. - BroadcastNodeAnnouncement { - /// The node_announcement which should be sent. - msg: crate::ln::msgs::NodeAnnouncement, - }, - /// Used to indicate that a channel_update should be broadcast to all peers. - BroadcastChannelUpdate { - /// The channel_update which should be sent. - msg: crate::ln::msgs::ChannelUpdate, - }, - /// Broadcast an error downstream to be handled - HandleError { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The action which should be taken. - 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 { - /// The channel/node update which should be sent to NetGraphMsgHandler - update: crate::ln::msgs::HTLCFailChannelUpdate, - }, - /// Query a peer for channels with funding transaction UTXOs in a block range. - SendChannelRangeQuery { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The query_channel_range which should be sent. - msg: crate::ln::msgs::QueryChannelRange, - }, - /// Request routing gossip messages from a peer for a list of channels identified by - /// their short_channel_ids. - SendShortIdsQuery { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The query_short_channel_ids which should be sent. - msg: crate::ln::msgs::QueryShortChannelIds, - }, - /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events - /// emitted during processing of the query. - SendReplyChannelRange { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The reply_channel_range which should be sent. - msg: crate::ln::msgs::ReplyChannelRange, - }, -} -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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - } - }, - 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_inner()) }, - update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { - let mut msg_nonref = (*msg).clone(); - nativeMessageSendEvent::BroadcastNodeAnnouncement { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::BroadcastChannelUpdate {ref msg, } => { - let mut msg_nonref = (*msg).clone(); - nativeMessageSendEvent::BroadcastChannelUpdate { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - 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(), - } - }, - MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = (*node_id).clone(); - let mut msg_nonref = (*msg).clone(); - nativeMessageSendEvent::SendChannelRangeQuery { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = (*node_id).clone(); - let mut msg_nonref = (*msg).clone(); - nativeMessageSendEvent::SendShortIdsQuery { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { - let mut node_id_nonref = (*node_id).clone(); - let mut msg_nonref = (*msg).clone(); - nativeMessageSendEvent::SendReplyChannelRange { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - } - } - #[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_inner()) }, - } - }, - MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendOpenChannel { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendFundingCreated { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendFundingSigned { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendFundingLocked { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendAnnouncementSignatures { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { - nativeMessageSendEvent::UpdateHTLCs { - node_id: node_id.into_rust(), - updates: *unsafe { Box::from_raw(updates.take_inner()) }, - } - }, - MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendRevokeAndACK { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendClosingSigned { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendShutdown {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendShutdown { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelReestablish { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { - nativeMessageSendEvent::BroadcastChannelAnnouncement { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) }, - } - }, - MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { - nativeMessageSendEvent::BroadcastNodeAnnouncement { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::BroadcastChannelUpdate {mut msg, } => { - nativeMessageSendEvent::BroadcastChannelUpdate { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - 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(), - } - }, - MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelRangeQuery { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendShortIdsQuery { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendReplyChannelRange { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - } - } - #[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), - } - }, - nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = (*node_id).clone(); - let mut msg_nonref = (*msg).clone(); - MessageSendEvent::SendChannelRangeQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = (*node_id).clone(); - let mut msg_nonref = (*msg).clone(); - MessageSendEvent::SendShortIdsQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, - } - }, - nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { - let mut node_id_nonref = (*node_id).clone(); - let mut msg_nonref = (*msg).clone(); - MessageSendEvent::SendReplyChannelRange { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, - } - }, - } - } - #[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), - } - }, - nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelRangeQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { - MessageSendEvent::SendShortIdsQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }, - } - }, - nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { - MessageSendEvent::SendReplyChannelRange { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }, - } - }, - } - } -} -/// Frees any resources used by the MessageSendEvent -#[no_mangle] -pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { } -/// Creates a copy of the MessageSendEvent -#[no_mangle] -pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent { - orig.clone() -} -/// A trait indicating an object may generate message send events -#[repr(C)] -pub struct MessageSendEventsProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} - -use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider; -impl rustMessageSendEventsProvider for MessageSendEventsProvider { - fn get_and_clear_pending_msg_events(&self) -> Vec { - 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 { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} - -use lightning::util::events::EventsProvider as rustEventsProvider; -impl rustEventsProvider for EventsProvider { - fn get_and_clear_pending_events(&self) -> Vec { - 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); - } - } -} diff --git a/lightning-c-bindings/src/util/logger.rs b/lightning-c-bindings/src/util/logger.rs deleted file mode 100644 index e6b98de..0000000 --- a/lightning-c-bindings/src/util/logger.rs +++ /dev/null @@ -1,138 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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, - } - } -} -/// Creates a copy of the Level -#[no_mangle] -pub extern "C" fn Level_clone(orig: &Level) -> Level { - orig.clone() -} -/// 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 { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - 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), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -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); - } - } -} diff --git a/lightning-c-bindings/src/util/mod.rs b/lightning-c-bindings/src/util/mod.rs deleted file mode 100644 index 49003dc..0000000 --- a/lightning-c-bindings/src/util/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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; diff --git a/lightning-c-bindings/src/util/ser.rs b/lightning-c-bindings/src/util/ser.rs deleted file mode 100644 index e0c561f..0000000 --- a/lightning-c-bindings/src/util/ser.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! 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::*; - -/// serialization buffer size - -#[no_mangle] -pub static MAX_BUF_SIZE: usize = lightning::util::ser::MAX_BUF_SIZE;